org.texi: Improve ODT section
[org-mode.git] / doc / org.texi
blobefb3f40568525f052f3ec2075d8a8b0d5ed51227
2 \input texinfo
3 @c %**start of header
4 @setfilename ../../info/org
5 @settitle The Org Manual
7 @set VERSION 7.7
8 @set DATE July 2011
10 @c Use proper quote and backtick for code sections in PDF output
11 @c Cf. Texinfo manual 14.2
12 @set txicodequoteundirected
13 @set txicodequotebacktick
15 @c Version and Contact Info
16 @set MAINTAINERSITE @uref{http://orgmode.org,maintainers webpage}
17 @set AUTHOR Carsten Dominik
18 @set MAINTAINER Carsten Dominik
19 @set MAINTAINEREMAIL @email{carsten at orgmode dot org}
20 @set MAINTAINERCONTACT @uref{mailto:carsten at orgmode dot org,contact the maintainer}
21 @c %**end of header
22 @finalout
25 @c -----------------------------------------------------------------------------
27 @c Macro definitions for commands and keys
28 @c =======================================
30 @c The behavior of the key/command macros will depend on the flag cmdnames
31 @c When set, commands names are shown.  When clear, they are not shown.
33 @set cmdnames
35 @c Below we define the following macros for Org key tables:
37 @c orgkey{key}                        A key item
38 @c orgcmd{key,cmd}                    Key with command name
39 @c xorgcmd{key,cmmand}                Key with command name as @itemx
40 @c orgcmdnki{key,cmd}                 Like orgcmd, but do not index the key
41 @c orgcmdtkc{text,key,cmd}            Like orgcmd,special text instead of key
42 @c orgcmdkkc{key1,key2,cmd}           Two keys with one command name, use "or"
43 @c orgcmdkxkc{key1,key2,cmd}          Two keys with one command name, but
44 @c                                    different functions, so format as @itemx
45 @c orgcmdkskc{key1,key2,cmd}          Same as orgcmdkkc, but use "or short"
46 @c xorgcmdkskc{key1,key2,cmd}         Same as previous, but use @itemx
47 @c orgcmdkkcc{key1,key2,cmd1,cmd2}    Two keys and two commands
49 @c a key but no command
50 @c    Inserts:    @item key
51 @macro orgkey{key}
52 @kindex \key\
53 @item @kbd{\key\}
54 @end macro
56 @macro xorgkey{key}
57 @kindex \key\
58 @itemx @kbd{\key\}
59 @end macro
61 @c one key with a command
62 @c   Inserts:    @item KEY               COMMAND
63 @macro orgcmd{key,command}
64 @ifset cmdnames
65 @kindex \key\
66 @findex \command\
67 @iftex
68 @item @kbd{\key\} @hskip 0pt plus 1filll @code{\command\}
69 @end iftex
70 @ifnottex
71 @item @kbd{\key\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
72 @end ifnottex
73 @end ifset
74 @ifclear cmdnames
75 @kindex \key\
76 @item @kbd{\key\}
77 @end ifclear
78 @end macro
80 @c One key with one command, formatted using @itemx
81 @c   Inserts:    @itemx KEY               COMMAND
82 @macro xorgcmd{key,command}
83 @ifset cmdnames
84 @kindex \key\
85 @findex \command\
86 @iftex
87 @itemx @kbd{\key\} @hskip 0pt plus 1filll @code{\command\}
88 @end iftex
89 @ifnottex
90 @itemx @kbd{\key\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
91 @end ifnottex
92 @end ifset
93 @ifclear cmdnames
94 @kindex \key\
95 @itemx @kbd{\key\}
96 @end ifclear
97 @end macro
99 @c one key with a command, bit do not index the key
100 @c   Inserts:    @item KEY               COMMAND
101 @macro orgcmdnki{key,command}
102 @ifset cmdnames
103 @findex \command\
104 @iftex
105 @item @kbd{\key\} @hskip 0pt plus 1filll @code{\command\}
106 @end iftex
107 @ifnottex
108 @item @kbd{\key\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
109 @end ifnottex
110 @end ifset
111 @ifclear cmdnames
112 @item @kbd{\key\}
113 @end ifclear
114 @end macro
116 @c one key with a command, and special text to replace key in item
117 @c   Inserts:    @item TEXT                    COMMAND
118 @macro orgcmdtkc{text,key,command}
119 @ifset cmdnames
120 @kindex \key\
121 @findex \command\
122 @iftex
123 @item @kbd{\text\} @hskip 0pt plus 1filll @code{\command\}
124 @end iftex
125 @ifnottex
126 @item @kbd{\text\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
127 @end ifnottex
128 @end ifset
129 @ifclear cmdnames
130 @kindex \key\
131 @item @kbd{\text\}
132 @end ifclear
133 @end macro
135 @c two keys with one command
136 @c   Inserts:    @item KEY1 or KEY2            COMMAND
137 @macro orgcmdkkc{key1,key2,command}
138 @ifset cmdnames
139 @kindex \key1\
140 @kindex \key2\
141 @findex \command\
142 @iftex
143 @item @kbd{\key1\} @ @r{or} @ @kbd{\key2\} @hskip 0pt plus 1filll @code{\command\}
144 @end iftex
145 @ifnottex
146 @item @kbd{\key1\} @ @r{or} @ @kbd{\key2\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
147 @end ifnottex
148 @end ifset
149 @ifclear cmdnames
150 @kindex \key1\
151 @kindex \key2\
152 @item @kbd{\key1\} @ @r{or} @ @kbd{\key2\}
153 @end ifclear
154 @end macro
156 @c Two keys with one command name, but different functions, so format as
157 @c @itemx
158 @c   Inserts:    @item KEY1
159 @c               @itemx KEY2                COMMAND
160 @macro orgcmdkxkc{key1,key2,command}
161 @ifset cmdnames
162 @kindex \key1\
163 @kindex \key2\
164 @findex \command\
165 @iftex
166 @item @kbd{\key1\}
167 @itemx @kbd{\key2\} @hskip 0pt plus 1filll @code{\command\}
168 @end iftex
169 @ifnottex
170 @item @kbd{\key1\}
171 @itemx @kbd{\key2\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
172 @end ifnottex
173 @end ifset
174 @ifclear cmdnames
175 @kindex \key1\
176 @kindex \key2\
177 @item @kbd{\key1\}
178 @itemx @kbd{\key2\}
179 @end ifclear
180 @end macro
182 @c Same as previous, but use "or short"
183 @c   Inserts:    @item KEY1 or short KEY2            COMMAND
184 @macro orgcmdkskc{key1,key2,command}
185 @ifset cmdnames
186 @kindex \key1\
187 @kindex \key2\
188 @findex \command\
189 @iftex
190 @item @kbd{\key1\} @ @r{or short} @ @kbd{\key2\} @hskip 0pt plus 1filll @code{\command\}
191 @end iftex
192 @ifnottex
193 @item @kbd{\key1\} @ @r{or short} @ @kbd{\key2\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
194 @end ifnottex
195 @end ifset
196 @ifclear cmdnames
197 @kindex \key1\
198 @kindex \key2\
199 @item @kbd{\key1\} @ @r{or short} @ @kbd{\key2\}
200 @end ifclear
201 @end macro
203 @c Same as previous, but use @itemx
204 @c   Inserts:    @itemx KEY1 or short KEY2            COMMAND
205 @macro xorgcmdkskc{key1,key2,command}
206 @ifset cmdnames
207 @kindex \key1\
208 @kindex \key2\
209 @findex \command\
210 @iftex
211 @itemx @kbd{\key1\} @ @r{or short} @ @kbd{\key2\} @hskip 0pt plus 1filll @code{\command\}
212 @end iftex
213 @ifnottex
214 @itemx @kbd{\key1\} @ @r{or short} @ @kbd{\key2\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
215 @end ifnottex
216 @end ifset
217 @ifclear cmdnames
218 @kindex \key1\
219 @kindex \key2\
220 @itemx @kbd{\key1\} @ @r{or short} @ @kbd{\key2\}
221 @end ifclear
222 @end macro
224 @c two keys with two commands
225 @c   Inserts:    @item KEY1                        COMMAND1
226 @c               @itemx KEY2                       COMMAND2
227 @macro orgcmdkkcc{key1,key2,command1,command2}
228 @ifset cmdnames
229 @kindex \key1\
230 @kindex \key2\
231 @findex \command1\
232 @findex \command2\
233 @iftex
234 @item @kbd{\key1\} @hskip 0pt plus 1filll @code{\command1\}
235 @itemx @kbd{\key2\} @hskip 0pt plus 1filll @code{\command2\}
236 @end iftex
237 @ifnottex
238 @item @kbd{\key1\} @tie{}@tie{}@tie{}@tie{}(@code{\command1\})
239 @itemx @kbd{\key2\} @tie{}@tie{}@tie{}@tie{}(@code{\command2\})
240 @end ifnottex
241 @end ifset
242 @ifclear cmdnames
243 @kindex \key1\
244 @kindex \key2\
245 @item @kbd{\key1\}
246 @itemx @kbd{\key2\}
247 @end ifclear
248 @end macro
249 @c -----------------------------------------------------------------------------
251 @iftex
252 @c @hyphenation{time-stamp time-stamps time-stamp-ing time-stamp-ed}
253 @end iftex
255 @c Subheadings inside a table.
256 @macro tsubheading{text}
257 @ifinfo
258 @subsubheading \text\
259 @end ifinfo
260 @ifnotinfo
261 @item @b{\text\}
262 @end ifnotinfo
263 @end macro
265 @copying
266 This manual is for Org version @value{VERSION}.
268 Copyright @copyright{} 2004-2011  Free Software Foundation, Inc.
270 @quotation
271 Permission is granted to copy, distribute and/or modify this document
272 under the terms of the GNU Free Documentation License, Version 1.3 or
273 any later version published by the Free Software Foundation; with no
274 Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
275 and with the Back-Cover Texts as in (a) below.  A copy of the license
276 is included in the section entitled ``GNU Free Documentation License.''
278 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
279 modify this GNU manual.  Buying copies from the FSF supports it in
280 developing GNU and promoting software freedom.''
282 This document is part of a collection distributed under the GNU Free
283 Documentation License.  If you want to distribute this document
284 separately from the collection, you can do so by adding a copy of the
285 license to the document, as described in section 6 of the license.
286 @end quotation
287 @end copying
289 @dircategory Emacs
290 @direntry
291 * Org Mode: (org).      Outline-based notes management and organizer
292 @end direntry
294 @titlepage
295 @title The Org Manual
297 @subtitle Release @value{VERSION}
298 @author by Carsten Dominik
299 with contributions by David O'Toole, Bastien Guerry, Philip Rooke, Dan Davison, Eric Schulte, Thomas Dye and Jambunathan K.
301 @c The following two commands start the copyright page.
302 @page
303 @vskip 0pt plus 1filll
304 @insertcopying
305 @end titlepage
307 @c Output the table of contents at the beginning.
308 @contents
310 @ifnottex
311 @node Top, Introduction, (dir), (dir)
312 @top Org Mode Manual
314 @insertcopying
315 @end ifnottex
317 @menu
318 * Introduction::                Getting started
319 * Document Structure::          A tree works like your brain
320 * Tables::                      Pure magic for quick formatting
321 * Hyperlinks::                  Notes in context
322 * TODO Items::                  Every tree branch can be a TODO item
323 * Tags::                        Tagging headlines and matching sets of tags
324 * Properties and Columns::      Storing information about an entry
325 * Dates and Times::             Making items useful for planning
326 * Capture - Refile - Archive::  The ins and outs for projects
327 * Agenda Views::                Collecting information into views
328 * Markup::                      Prepare text for rich export
329 * Exporting::                   Sharing and publishing of notes
330 * Publishing::                  Create a web site of linked Org files
331 * Working With Source Code::    Export, evaluate, and tangle code blocks
332 * Miscellaneous::               All the rest which did not fit elsewhere
333 * Hacking::                     How to hack your way around
334 * MobileOrg::                   Viewing and capture on a mobile device
335 * History and Acknowledgments::  How Org came into being
336 * Main Index::                  An index of Org's concepts and features
337 * Key Index::                   Key bindings and where they are described
338 * Command and Function Index::  Command names and some internal functions
339 * Variable Index::              Variables mentioned in the manual
341 @detailmenu
342  --- The Detailed Node Listing ---
344 Introduction
346 * Summary::                     Brief summary of what Org does
347 * Installation::                How to install a downloaded version of Org
348 * Activation::                  How to activate Org for certain buffers
349 * Feedback::                    Bug reports, ideas, patches etc.
350 * Conventions::                 Type-setting conventions in the manual
352 Document structure
354 * Outlines::                    Org is based on Outline mode
355 * Headlines::                   How to typeset Org tree headlines
356 * Visibility cycling::          Show and hide, much simplified
357 * Motion::                      Jumping to other headlines
358 * Structure editing::           Changing sequence and level of headlines
359 * Sparse trees::                Matches embedded in context
360 * Plain lists::                 Additional structure within an entry
361 * Drawers::                     Tucking stuff away
362 * Blocks::                      Folding blocks
363 * Footnotes::                   How footnotes are defined in Org's syntax
364 * Orgstruct mode::              Structure editing outside Org
366 Tables
368 * Built-in table editor::       Simple tables
369 * Column width and alignment::  Overrule the automatic settings
370 * Column groups::               Grouping to trigger vertical lines
371 * Orgtbl mode::                 The table editor as minor mode
372 * The spreadsheet::             The table editor has spreadsheet capabilities
373 * Org-Plot::                    Plotting from org tables
375 The spreadsheet
377 * References::                  How to refer to another field or range
378 * Formula syntax for Calc::     Using Calc to compute stuff
379 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
380 * Durations and time values::   How to compute durations and time values
381 * Field and range formulas::    Formula for specific (ranges of) fields
382 * Column formulas::             Formulas valid for an entire column
383 * Editing and debugging formulas::  Fixing formulas
384 * Updating the table::          Recomputing all dependent fields
385 * Advanced features::           Field and column names, parameters and automatic recalc
387 Hyperlinks
389 * Link format::                 How links in Org are formatted
390 * Internal links::              Links to other places in the current file
391 * External links::              URL-like links to the world
392 * Handling links::              Creating, inserting and following
393 * Using links outside Org::     Linking from my C source code?
394 * Link abbreviations::          Shortcuts for writing complex links
395 * Search options::              Linking to a specific location
396 * Custom searches::             When the default search is not enough
398 Internal links
400 * Radio targets::               Make targets trigger links in plain text
402 TODO items
404 * TODO basics::                 Marking and displaying TODO entries
405 * TODO extensions::             Workflow and assignments
406 * Progress logging::            Dates and notes for progress
407 * Priorities::                  Some things are more important than others
408 * Breaking down tasks::         Splitting a task into manageable pieces
409 * Checkboxes::                  Tick-off lists
411 Extended use of TODO keywords
413 * Workflow states::             From TODO to DONE in steps
414 * TODO types::                  I do this, Fred does the rest
415 * Multiple sets in one file::   Mixing it all, and still finding your way
416 * Fast access to TODO states::  Single letter selection of a state
417 * Per-file keywords::           Different files, different requirements
418 * Faces for TODO keywords::     Highlighting states
419 * TODO dependencies::           When one task needs to wait for others
421 Progress logging
423 * Closing items::               When was this entry marked DONE?
424 * Tracking TODO state changes::  When did the status change?
425 * Tracking your habits::        How consistent have you been?
427 Tags
429 * Tag inheritance::             Tags use the tree structure of the outline
430 * Setting tags::                How to assign tags to a headline
431 * Tag searches::                Searching for combinations of tags
433 Properties and columns
435 * Property syntax::             How properties are spelled out
436 * Special properties::          Access to other Org-mode features
437 * Property searches::           Matching property values
438 * Property inheritance::        Passing values down the tree
439 * Column view::                 Tabular viewing and editing
440 * Property API::                Properties for Lisp programmers
442 Column view
444 * Defining columns::            The COLUMNS format property
445 * Using column view::           How to create and use column view
446 * Capturing column view::       A dynamic block for column view
448 Defining columns
450 * Scope of column definitions::  Where defined, where valid?
451 * Column attributes::           Appearance and content of a column
453 Dates and times
455 * Timestamps::                  Assigning a time to a tree entry
456 * Creating timestamps::         Commands which insert timestamps
457 * Deadlines and scheduling::    Planning your work
458 * Clocking work time::          Tracking how long you spend on a task
459 * Effort estimates::            Planning work effort in advance
460 * Relative timer::              Notes with a running timer
461 * Countdown timer::             Starting a countdown timer for a task
463 Creating timestamps
465 * The date/time prompt::        How Org-mode helps you entering date and time
466 * Custom time format::          Making dates look different
468 Deadlines and scheduling
470 * Inserting deadline/schedule::  Planning items
471 * Repeated tasks::              Items that show up again and again
473 Clocking work time
475 * Clocking commands::           Starting and stopping a clock
476 * The clock table::             Detailed reports
477 * Resolving idle time::         Resolving time when you've been idle
479 Capture - Refile - Archive
481 * Capture::                     Capturing new stuff
482 * Attachments::                 Add files to tasks
483 * RSS Feeds::                   Getting input from RSS feeds
484 * Protocols::                   External (e.g.@: Browser) access to Emacs and Org
485 * Refiling notes::              Moving a tree from one place to another
486 * Archiving::                   What to do with finished projects
488 Capture
490 * Setting up capture::          Where notes will be stored
491 * Using capture::               Commands to invoke and terminate capture
492 * Capture templates::           Define the outline of different note types
494 Capture templates
496 * Template elements::           What is needed for a complete template entry
497 * Template expansion::          Filling in information about time and context
499 Archiving
501 * Moving subtrees::             Moving a tree to an archive file
502 * Internal archiving::          Switch off a tree but keep it in the file
504 Agenda views
506 * Agenda files::                Files being searched for agenda information
507 * Agenda dispatcher::           Keyboard access to agenda views
508 * Built-in agenda views::       What is available out of the box?
509 * Presentation and sorting::    How agenda items are prepared for display
510 * Agenda commands::             Remote editing of Org trees
511 * Custom agenda views::         Defining special searches and views
512 * Exporting Agenda Views::      Writing a view to a file
513 * Agenda column view::          Using column view for collected entries
515 The built-in agenda views
517 * Weekly/daily agenda::         The calendar page with current tasks
518 * Global TODO list::            All unfinished action items
519 * Matching tags and properties::  Structured information with fine-tuned search
520 * Timeline::                    Time-sorted view for single file
521 * Search view::                 Find entries by searching for text
522 * Stuck projects::              Find projects you need to review
524 Presentation and sorting
526 * Categories::                  Not all tasks are equal
527 * Time-of-day specifications::  How the agenda knows the time
528 * Sorting of agenda items::     The order of things
530 Custom agenda views
532 * Storing searches::            Type once, use often
533 * Block agenda::                All the stuff you need in a single buffer
534 * Setting Options::             Changing the rules
536 Markup for rich export
538 * Structural markup elements::  The basic structure as seen by the exporter
539 * Images and tables::           Tables and Images will be included
540 * Literal examples::            Source code examples with special formatting
541 * Include files::               Include additional files into a document
542 * Index entries::               Making an index
543 * Macro replacement::           Use macros to create complex output
544 * Embedded LaTeX::              LaTeX can be freely used inside Org documents
546 Structural markup elements
548 * Document title::              Where the title is taken from
549 * Headings and sections::       The document structure as seen by the exporter
550 * Table of contents::           The if and where of the table of contents
551 * Initial text::                Text before the first heading?
552 * Lists::                       Lists
553 * Paragraphs::                  Paragraphs
554 * Footnote markup::             Footnotes
555 * Emphasis and monospace::      Bold, italic, etc.
556 * Horizontal rules::            Make a line
557 * Comment lines::               What will *not* be exported
559 Embedded @LaTeX{}
561 * Special symbols::             Greek letters and other symbols
562 * Subscripts and superscripts::  Simple syntax for raising/lowering text
563 * LaTeX fragments::             Complex formulas made easy
564 * Previewing LaTeX fragments::  What will this snippet look like?
565 * CDLaTeX mode::                Speed up entering of formulas
567 Exporting
569 * Selective export::            Using tags to select and exclude trees
570 * Export options::              Per-file export settings
571 * The export dispatcher::       How to access exporter commands
572 * ASCII/Latin-1/UTF-8 export::  Exporting to flat files with encoding
573 * HTML export::                 Exporting to HTML
574 * LaTeX and PDF export::        Exporting to @LaTeX{}, and processing to PDF
575 * DocBook export::              Exporting to DocBook
576 * OpenDocument Text export::    Exporting to OpenDocument Text
577 * TaskJuggler export::          Exporting to TaskJuggler
578 * Freemind export::             Exporting to Freemind mind maps
579 * XOXO export::                 Exporting to XOXO
580 * iCalendar export::            Exporting in iCalendar format
582 HTML export
584 * HTML Export commands::        How to invoke HTML export
585 * HTML preamble and postamble::  How to insert a preamble and a postamble
586 * Quoting HTML tags::           Using direct HTML in Org-mode
587 * Links in HTML export::        How links will be interpreted and formatted
588 * Tables in HTML export::       How to modify the formatting of tables
589 * Images in HTML export::       How to insert figures into HTML output
590 * Math formatting in HTML export::  Beautiful math also on the web
591 * Text areas in HTML export::   An alternative way to show an example
592 * CSS support::                 Changing the appearance of the output
593 * JavaScript support::          Info and Folding in a web browser
595 @LaTeX{} and PDF export
597 * LaTeX/PDF export commands::   Which key invokes which commands
598 * Header and sectioning::       Setting up the export file structure
599 * Quoting LaTeX code::          Incorporating literal @LaTeX{} code
600 * Tables in LaTeX export::      Options for exporting tables to @LaTeX{}
601 * Images in LaTeX export::      How to insert figures into @LaTeX{} output
602 * Beamer class export::         Turning the file into a presentation
604 DocBook export
606 * DocBook export commands::     How to invoke DocBook export
607 * Quoting DocBook code::        Incorporating DocBook code in Org files
608 * Recursive sections::          Recursive sections in DocBook
609 * Tables in DocBook export::    Tables are exported as HTML tables
610 * Images in DocBook export::    How to insert figures into DocBook output
611 * Special characters::          How to handle special characters
613 OpenDocument Text export
615 * Pre-requisites for @acronym{ODT} export::
616 * @acronym{ODT} export commands::  How to invoke @acronym{ODT} export
617 * Applying Custom Styles::      How to apply custom styles to the output
618 * Links in @acronym{ODT} export::  How links will be interpreted and formatted
619 * Tables in @acronym{ODT} export::  How Tables are exported
620 * Images in @acronym{ODT} export::  How to insert images
621 * Math formatting in @acronym{ODT} export::  How @LaTeX{} fragments are formatted
622 * Literal Examples in @acronym{ODT} export::  How source and example blocks are formatted
623 * Working with raw OpenDocument XML::
624 * Advanced topics in @acronym{ODT} export::
626 Advanced topics in @acronym{ODT} export
628 * Exporting and Converting to Other formats::
629 * Configuring a converter::
630 * Using the converter::
631 * Customizing Tables in @acronym{ODT} export::
632 * A note on the internals of @acronym{ODT} exporter::
634 Exporting and Converting to Other formats
636 * Configuring a converter::     How to install a converter
637 * Using the converter::         How to use the converter
639 Publishing
641 * Configuration::               Defining projects
642 * Uploading files::             How to get files up on the server
643 * Sample configuration::        Example projects
644 * Triggering publication::      Publication commands
646 Configuration
648 * Project alist::               The central configuration variable
649 * Sources and destinations::    From here to there
650 * Selecting files::             What files are part of the project?
651 * Publishing action::           Setting the function doing the publishing
652 * Publishing options::          Tweaking HTML/@LaTeX{} export
653 * Publishing links::            Which links keep working after publishing?
654 * Sitemap::                     Generating a list of all pages
655 * Generating an index::         An index that reaches across pages
657 Sample configuration
659 * Simple example::              One-component publishing
660 * Complex example::             A multi-component publishing example
662 Working with source code
664 * Structure of code blocks::    Code block syntax described
665 * Editing source code::         Language major-mode editing
666 * Exporting code blocks::       Export contents and/or results
667 * Extracting source code::      Create pure source code files
668 * Evaluating code blocks::      Place results of evaluation in the Org-mode buffer
669 * Library of Babel::            Use and contribute to a library of useful code blocks
670 * Languages::                   List of supported code block languages
671 * Header arguments::            Configure code block functionality
672 * Results of evaluation::       How evaluation results are handled
673 * Noweb reference syntax::      Literate programming in Org-mode
674 * Key bindings and useful functions::  Work quickly with code blocks
675 * Batch execution::             Call functions from the command line
677 Header arguments
679 * Using header arguments::      Different ways to set header arguments
680 * Specific header arguments::   List of header arguments
682 Using header arguments
684 * System-wide header arguments::  Set global default values
685 * Language-specific header arguments::  Set default values by language
686 * Buffer-wide header arguments::  Set default values for a specific buffer
687 * Header arguments in Org-mode properties::  Set default values for a buffer or heading
688 * Code block specific header arguments::  The most common way to set values
689 * Header arguments in function calls::  The most specific level
691 Specific header arguments
693 * var::                         Pass arguments to code blocks
694 * results::                     Specify the type of results and how they will
695                                 be collected and handled
696 * file::                        Specify a path for file output
697 * dir::                         Specify the default (possibly remote)
698                                 directory for code block execution
699 * exports::                     Export code and/or results
700 * tangle::                      Toggle tangling and specify file name
701 * mkdirp::                      Toggle creation of parent directories of target
702                                 files during tangling
703 * comments::                    Toggle insertion of comments in tangled
704                                 code files
705 * padline::                     Control insertion of padding lines in tangled
706                                 code files
707 * no-expand::                   Turn off variable assignment and noweb
708                                 expansion during tangling
709 * session::                     Preserve the state of code evaluation
710 * noweb::                       Toggle expansion of noweb references
711 * noweb-ref::                   Specify block's noweb reference resolution target
712 * cache::                       Avoid re-evaluating unchanged code blocks
713 * sep::                         Delimiter for writing tabular results outside Org
714 * hlines::                      Handle horizontal lines in tables
715 * colnames::                    Handle column names in tables
716 * rownames::                    Handle row names in tables
717 * shebang::                     Make tangled files executable
718 * eval::                        Limit evaluation of specific code blocks
720 Miscellaneous
722 * Completion::                  M-TAB knows what you need
723 * Easy Templates::              Quick insertion of structural elements
724 * Speed keys::                  Electric commands at the beginning of a headline
725 * Code evaluation security::    Org mode files evaluate inline code
726 * Customization::               Adapting Org to your taste
727 * In-buffer settings::          Overview of the #+KEYWORDS
728 * The very busy C-c C-c key::   When in doubt, press C-c C-c
729 * Clean view::                  Getting rid of leading stars in the outline
730 * TTY keys::                    Using Org on a tty
731 * Interaction::                 Other Emacs packages
732 * org-crypt.el::                Encrypting Org files
734 Interaction with other packages
736 * Cooperation::                 Packages Org cooperates with
737 * Conflicts::                   Packages that lead to conflicts
739 Hacking
741 * Hooks::                       Who to reach into Org's internals
742 * Add-on packages::             Available extensions
743 * Adding hyperlink types::      New custom link types
744 * Context-sensitive commands::  How to add functionality to such commands
745 * Tables in arbitrary syntax::  Orgtbl for @LaTeX{} and other programs
746 * Dynamic blocks::              Automatically filled blocks
747 * Special agenda views::        Customized views
748 * Extracting agenda information::  Postprocessing of agenda information
749 * Using the property API::      Writing programs that use entry properties
750 * Using the mapping API::       Mapping over all or selected entries
752 Tables and lists in arbitrary syntax
754 * Radio tables::                Sending and receiving radio tables
755 * A LaTeX example::             Step by step, almost a tutorial
756 * Translator functions::        Copy and modify
757 * Radio lists::                 Doing the same for lists
759 MobileOrg
761 * Setting up the staging area::  Where to interact with the mobile device
762 * Pushing to MobileOrg::        Uploading Org files and agendas
763 * Pulling from MobileOrg::      Integrating captured and flagged items
765 @end detailmenu
766 @end menu
768 @node Introduction, Document Structure, Top, Top
769 @chapter Introduction
770 @cindex introduction
772 @menu
773 * Summary::                     Brief summary of what Org does
774 * Installation::                How to install a downloaded version of Org
775 * Activation::                  How to activate Org for certain buffers
776 * Feedback::                    Bug reports, ideas, patches etc.
777 * Conventions::                 Type-setting conventions in the manual
778 @end menu
780 @node Summary, Installation, Introduction, Introduction
781 @section Summary
782 @cindex summary
784 Org is a mode for keeping notes, maintaining TODO lists, and doing
785 project planning with a fast and effective plain-text system.
787 Org develops organizational tasks around NOTES files that contain
788 lists or information about projects as plain text.  Org is
789 implemented on top of Outline mode, which makes it possible to keep the
790 content of large files well structured.  Visibility cycling and
791 structure editing help to work with the tree.  Tables are easily created
792 with a built-in table editor.  Org supports TODO items, deadlines,
793 timestamps, and scheduling.  It dynamically compiles entries into an
794 agenda that utilizes and smoothly integrates much of the Emacs calendar
795 and diary.  Plain text URL-like links connect to websites, emails,
796 Usenet messages, BBDB entries, and any files related to the projects.
797 For printing and sharing of notes, an Org file can be exported as a
798 structured ASCII file, as HTML, or (TODO and agenda items only) as an
799 iCalendar file.  It can also serve as a publishing tool for a set of
800 linked web pages.
802 As a project planning environment, Org works by adding metadata to outline
803 nodes.  Based on this data, specific entries can be extracted in queries and
804 create dynamic @i{agenda views}.
806 Org mode contains the Org Babel environment which allows you to work with
807 embedded source code blocks in a file, to facilitate code evaluation,
808 documentation, and literate programming techniques.
810 Org's automatic, context-sensitive table editor with spreadsheet
811 capabilities can be integrated into any major mode by activating the
812 minor Orgtbl mode.  Using a translation step, it can be used to maintain
813 tables in arbitrary file types, for example in @LaTeX{}.  The structure
814 editing and list creation capabilities can be used outside Org with
815 the minor Orgstruct mode.
817 Org keeps simple things simple.  When first fired up, it should
818 feel like a straightforward, easy to use outliner.  Complexity is not
819 imposed, but a large amount of functionality is available when you need
820 it.  Org is a toolbox and can be used in different ways and for different
821 ends, for example:
823 @example
824 @r{@bullet{} an outline extension with visibility cycling and structure editing}
825 @r{@bullet{} an ASCII system and table editor for taking structured notes}
826 @r{@bullet{} a TODO list editor}
827 @r{@bullet{} a full agenda and planner with deadlines and work scheduling}
828 @pindex GTD, Getting Things Done
829 @r{@bullet{} an environment in which to implement David Allen's GTD system}
830 @r{@bullet{} a simple hypertext system, with HTML and @LaTeX{} export}
831 @r{@bullet{} a publishing tool to create a set of interlinked webpages}
832 @r{@bullet{} an environment for literate programming}
833 @end example
836 @cindex FAQ
837 There is a website for Org which provides links to the newest
838 version of Org, as well as additional information, frequently asked
839 questions (FAQ), links to tutorials, etc@.  This page is located at
840 @uref{http://orgmode.org}.
842 @cindex print edition
843 The version 7.3 of this manual is available as a
844 @uref{http://www.network-theory.co.uk/org/manual/, paperback book from Network
845 Theory Ltd.}
847 @page
850 @node Installation, Activation, Summary, Introduction
851 @section Installation
852 @cindex installation
853 @cindex XEmacs
855 @b{Important:} @i{If you are using a version of Org that is part of the Emacs
856 distribution or an XEmacs package, please skip this section and go directly
857 to @ref{Activation}.  To see what version of Org (if any) is part of your
858 Emacs distribution, type @kbd{M-x load-library RET org} and then @kbd{M-x
859 org-version}.}
861 If you have downloaded Org from the Web, either as a distribution @file{.zip}
862 or @file{.tar} file, or as a Git archive, you must take the following steps
863 to install it: go into the unpacked Org distribution directory and edit the
864 top section of the file @file{Makefile}.  You must set the name of the Emacs
865 binary (likely either @file{emacs} or @file{xemacs}), and the paths to the
866 directories where local Lisp and Info files are kept.  If you don't have
867 access to the system-wide directories, you can simply run Org directly from
868 the distribution directory by adding the @file{lisp} subdirectory to the
869 Emacs load path.  To do this, add the following line to @file{.emacs}:
871 @example
872 (setq load-path (cons "~/path/to/orgdir/lisp" load-path))
873 @end example
875 @noindent
876 If you plan to use code from the @file{contrib} subdirectory, do a similar
877 step for this directory:
879 @example
880 (setq load-path (cons "~/path/to/orgdir/contrib/lisp" load-path))
881 @end example
883 @noindent Now byte-compile the Lisp files with the shell command:
885 @example
886 make
887 @end example
889 @noindent If you are running Org from the distribution directory, this is
890 all.  If you want to install Org into the system directories, use (as
891 administrator)
893 @example
894 make install
895 @end example
897 Installing Info files is system dependent, because of differences in the
898 @file{install-info} program.  The following should correctly install the Info
899 files on most systems, please send a bug report if not@footnote{The output
900 from install-info (if any) is also system dependent.  In particular Debian
901 and its derivatives use two different versions of install-info and you may
902 see the message:
904 @example
905 This is not dpkg install-info anymore, but GNU install-info
906 See the man page for ginstall-info for command line arguments
907 @end example
909 @noindent which can be safely ignored.}.
911 @example
912 make install-info
913 @end example
915 Then add the following line to @file{.emacs}.  It is needed so that
916 Emacs can autoload functions that are located in files not immediately loaded
917 when Org-mode starts.
918 @lisp
919 (require 'org-install)
920 @end lisp
922 Do not forget to activate Org as described in the following section.
923 @page
925 @node Activation, Feedback, Installation, Introduction
926 @section Activation
927 @cindex activation
928 @cindex autoload
929 @cindex global key bindings
930 @cindex key bindings, global
932 To make sure files with extension @file{.org} use Org mode, add the following
933 line to your @file{.emacs} file.
934 @lisp
935 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
936 @end lisp
937 @noindent Org mode buffers need font-lock to be turned on - this is the
938 default in Emacs@footnote{If you don't use font-lock globally, turn it on in
939 Org buffer with @code{(add-hook 'org-mode-hook 'turn-on-font-lock)}}.
941 The four Org commands @command{org-store-link}, @command{org-capture},
942 @command{org-agenda}, and @command{org-iswitchb} should be accessible through
943 global keys (i.e.@: anywhere in Emacs, not just in Org buffers).  Here are
944 suggested bindings for these keys, please modify the keys to your own
945 liking.
946 @lisp
947 (global-set-key "\C-cl" 'org-store-link)
948 (global-set-key "\C-cc" 'org-capture)
949 (global-set-key "\C-ca" 'org-agenda)
950 (global-set-key "\C-cb" 'org-iswitchb)
951 @end lisp
953 @cindex Org-mode, turning on
954 With this setup, all files with extension @samp{.org} will be put
955 into Org-mode.  As an alternative, make the first line of a file look
956 like this:
958 @example
959 MY PROJECTS    -*- mode: org; -*-
960 @end example
962 @vindex org-insert-mode-line-in-empty-file
963 @noindent which will select Org-mode for this buffer no matter what
964 the file's name is.  See also the variable
965 @code{org-insert-mode-line-in-empty-file}.
967 Many commands in Org work on the region if the region is @i{active}.  To make
968 use of this, you need to have @code{transient-mark-mode}
969 (@code{zmacs-regions} in XEmacs) turned on.  In Emacs 23 this is the default,
970 in Emacs 22 you need to do this yourself with
971 @lisp
972 (transient-mark-mode 1)
973 @end lisp
974 @noindent If you do not like @code{transient-mark-mode}, you can create an
975 active region by using the mouse to select a region, or pressing
976 @kbd{C-@key{SPC}} twice before moving the cursor.
978 @node Feedback, Conventions, Activation, Introduction
979 @section Feedback
980 @cindex feedback
981 @cindex bug reports
982 @cindex maintainer
983 @cindex author
985 If you find problems with Org, or if you have questions, remarks, or ideas
986 about it, please mail to the Org mailing list @email{emacs-orgmode@@gnu.org}.
987 If you are not a member of the mailing list, your mail will be passed to the
988 list after a moderator has approved it@footnote{Please consider subscribing
989 to the mailing list, in order to minimize the work the mailing list
990 moderators have to do.}.
992 For bug reports, please first try to reproduce the bug with the latest
993 version of Org available---if you are running an outdated version, it is
994 quite possible that the bug has been fixed already.  If the bug persists,
995 prepare a report and provide as much information as possible, including the
996 version information of Emacs (@kbd{M-x emacs-version @key{RET}}) and Org
997 (@kbd{M-x org-version @key{RET}}), as well as the Org related setup in
998 @file{.emacs}.  The easiest way to do this is to use the command
999 @example
1000 @kbd{M-x org-submit-bug-report}
1001 @end example
1002 @noindent which will put all this information into an Emacs mail buffer so
1003 that you only need to add your description.  If you re not sending the Email
1004 from within Emacs, please copy and paste the content into your Email program.
1006 If an error occurs, a backtrace can be very useful (see below on how to
1007 create one).  Often a small example file helps, along with clear information
1008 about:
1010 @enumerate
1011 @item What exactly did you do?
1012 @item What did you expect to happen?
1013 @item What happened instead?
1014 @end enumerate
1015 @noindent Thank you for helping to improve this program.
1017 @subsubheading How to create a useful backtrace
1019 @cindex backtrace of an error
1020 If working with Org produces an error with a message you don't
1021 understand, you may have hit a bug.  The best way to report this is by
1022 providing, in addition to what was mentioned above, a @emph{backtrace}.
1023 This is information from the built-in debugger about where and how the
1024 error occurred.  Here is how to produce a useful backtrace:
1026 @enumerate
1027 @item
1028 Reload uncompiled versions of all Org-mode Lisp files.  The backtrace
1029 contains much more information if it is produced with uncompiled code.
1030 To do this, use
1031 @example
1032 C-u M-x org-reload RET
1033 @end example
1034 @noindent
1035 or select @code{Org -> Refresh/Reload -> Reload Org uncompiled} from the
1036 menu.
1037 @item
1038 Go to the @code{Options} menu and select @code{Enter Debugger on Error}
1039 (XEmacs has this option in the @code{Troubleshooting} sub-menu).
1040 @item
1041 Do whatever you have to do to hit the error.  Don't forget to
1042 document the steps you take.
1043 @item
1044 When you hit the error, a @file{*Backtrace*} buffer will appear on the
1045 screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
1046 attach it to your bug report.
1047 @end enumerate
1049 @node Conventions,  , Feedback, Introduction
1050 @section Typesetting conventions used in this manual
1052 Org uses three types of keywords: TODO keywords, tags, and property
1053 names.  In this manual we use the following conventions:
1055 @table @code
1056 @item TODO
1057 @itemx WAITING
1058 TODO keywords are written with all capitals, even if they are
1059 user-defined.
1060 @item boss
1061 @itemx ARCHIVE
1062 User-defined tags are written in lowercase; built-in tags with special
1063 meaning are written with all capitals.
1064 @item Release
1065 @itemx PRIORITY
1066 User-defined properties are capitalized; built-in properties with
1067 special meaning are written with all capitals.
1068 @end table
1070 The manual lists both the keys and the corresponding commands for accessing
1071 functionality.  Org mode often uses the same key for different functions,
1072 depending on context.  The command that is bound to such keys has a generic
1073 name, like @code{org-metaright}.  In the manual we will, wherever possible,
1074 give the function that is internally called by the generic command.  For
1075 example, in the chapter on document structure, @kbd{M-@key{right}} will be
1076 listed to call @code{org-do-demote}, while in the chapter on tables, it will
1077 be listed to call org-table-move-column-right.
1079 If you prefer, you can compile the manual without the command names by
1080 unsetting the flag @code{cmdnames} in @file{org.texi}.
1082 @node Document Structure, Tables, Introduction, Top
1083 @chapter Document structure
1084 @cindex document structure
1085 @cindex structure of document
1087 Org is based on Outline mode and provides flexible commands to
1088 edit the structure of the document.
1090 @menu
1091 * Outlines::                    Org is based on Outline mode
1092 * Headlines::                   How to typeset Org tree headlines
1093 * Visibility cycling::          Show and hide, much simplified
1094 * Motion::                      Jumping to other headlines
1095 * Structure editing::           Changing sequence and level of headlines
1096 * Sparse trees::                Matches embedded in context
1097 * Plain lists::                 Additional structure within an entry
1098 * Drawers::                     Tucking stuff away
1099 * Blocks::                      Folding blocks
1100 * Footnotes::                   How footnotes are defined in Org's syntax
1101 * Orgstruct mode::              Structure editing outside Org
1102 @end menu
1104 @node Outlines, Headlines, Document Structure, Document Structure
1105 @section Outlines
1106 @cindex outlines
1107 @cindex Outline mode
1109 Org is implemented on top of Outline mode.  Outlines allow a
1110 document to be organized in a hierarchical structure, which (at least
1111 for me) is the best representation of notes and thoughts.  An overview
1112 of this structure is achieved by folding (hiding) large parts of the
1113 document to show only the general document structure and the parts
1114 currently being worked on.  Org greatly simplifies the use of
1115 outlines by compressing the entire show/hide functionality into a single
1116 command, @command{org-cycle}, which is bound to the @key{TAB} key.
1118 @node Headlines, Visibility cycling, Outlines, Document Structure
1119 @section Headlines
1120 @cindex headlines
1121 @cindex outline tree
1122 @vindex org-special-ctrl-a/e
1123 @vindex org-special-ctrl-k
1124 @vindex org-ctrl-k-protect-subtree
1126 Headlines define the structure of an outline tree.  The headlines in Org
1127 start with one or more stars, on the left margin@footnote{See the variables
1128 @code{org-special-ctrl-a/e}, @code{org-special-ctrl-k}, and
1129 @code{org-ctrl-k-protect-subtree} to configure special behavior of @kbd{C-a},
1130 @kbd{C-e}, and @kbd{C-k} in headlines.}.  For example:
1132 @example
1133 * Top level headline
1134 ** Second level
1135 *** 3rd level
1136     some text
1137 *** 3rd level
1138     more text
1140 * Another top level headline
1141 @end example
1143 @noindent Some people find the many stars too noisy and would prefer an
1144 outline that has whitespace followed by a single star as headline
1145 starters.  @ref{Clean view}, describes a setup to realize this.
1147 @vindex org-cycle-separator-lines
1148 An empty line after the end of a subtree is considered part of it and
1149 will be hidden when the subtree is folded.  However, if you leave at
1150 least two empty lines, one empty line will remain visible after folding
1151 the subtree, in order to structure the collapsed view.  See the
1152 variable @code{org-cycle-separator-lines} to modify this behavior.
1154 @node Visibility cycling, Motion, Headlines, Document Structure
1155 @section Visibility cycling
1156 @cindex cycling, visibility
1157 @cindex visibility cycling
1158 @cindex trees, visibility
1159 @cindex show hidden text
1160 @cindex hide text
1162 Outlines make it possible to hide parts of the text in the buffer.
1163 Org uses just two commands, bound to @key{TAB} and
1164 @kbd{S-@key{TAB}} to change the visibility in the buffer.
1166 @cindex subtree visibility states
1167 @cindex subtree cycling
1168 @cindex folded, subtree visibility state
1169 @cindex children, subtree visibility state
1170 @cindex subtree, subtree visibility state
1171 @table @asis
1172 @orgcmd{@key{TAB},org-cycle}
1173 @emph{Subtree cycling}: Rotate current subtree among the states
1175 @example
1176 ,-> FOLDED -> CHILDREN -> SUBTREE --.
1177 '-----------------------------------'
1178 @end example
1180 @vindex org-cycle-emulate-tab
1181 @vindex org-cycle-global-at-bob
1182 The cursor must be on a headline for this to work@footnote{see, however,
1183 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
1184 beginning of the buffer and the first line is not a headline, then
1185 @key{TAB} actually runs global cycling (see below)@footnote{see the
1186 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
1187 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
1189 @cindex global visibility states
1190 @cindex global cycling
1191 @cindex overview, global visibility state
1192 @cindex contents, global visibility state
1193 @cindex show all, global visibility state
1194 @orgcmd{S-@key{TAB},org-global-cycle}
1195 @itemx C-u @key{TAB}
1196 @emph{Global cycling}: Rotate the entire buffer among the states
1198 @example
1199 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
1200 '--------------------------------------'
1201 @end example
1203 When @kbd{S-@key{TAB}} is called with a numeric prefix argument N, the
1204 CONTENTS view up to headlines of level N will be shown.  Note that inside
1205 tables, @kbd{S-@key{TAB}} jumps to the previous field.
1207 @cindex show all, command
1208 @orgcmd{C-u C-u C-u @key{TAB},show-all}
1209 Show all, including drawers.
1210 @orgcmd{C-c C-r,org-reveal}
1211 Reveal context around point, showing the current entry, the following heading
1212 and the hierarchy above.  Useful for working near a location that has been
1213 exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda command
1214 (@pxref{Agenda commands}).  With a prefix argument show, on each
1215 level, all sibling headings.  With double prefix arg, also show the entire
1216 subtree of the parent.
1217 @orgcmd{C-c C-k,show-branches}
1218 Expose all the headings of the subtree, CONTENT view for just one subtree.
1219 @orgcmd{C-c C-x b,org-tree-to-indirect-buffer}
1220 Show the current subtree in an indirect buffer@footnote{The indirect
1221 buffer
1222 @ifinfo
1223 (@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
1224 @end ifinfo
1225 @ifnotinfo
1226 (see the Emacs manual for more information about indirect buffers)
1227 @end ifnotinfo
1228 will contain the entire buffer, but will be narrowed to the current
1229 tree.  Editing the indirect buffer will also change the original buffer,
1230 but without affecting visibility in that buffer.}.  With a numeric
1231 prefix argument N, go up to level N and then take that tree.  If N is
1232 negative then go up that many levels.  With a @kbd{C-u} prefix, do not remove
1233 the previously used indirect buffer.
1234 @orgcmd{C-c C-x v,org-copy-visible}
1235 Copy the @i{visible} text in the region into the kill ring.
1236 @end table
1238 @vindex org-startup-folded
1239 @cindex @code{overview}, STARTUP keyword
1240 @cindex @code{content}, STARTUP keyword
1241 @cindex @code{showall}, STARTUP keyword
1242 @cindex @code{showeverything}, STARTUP keyword
1244 When Emacs first visits an Org file, the global state is set to
1245 OVERVIEW, i.e.@: only the top level headlines are visible.  This can be
1246 configured through the variable @code{org-startup-folded}, or on a
1247 per-file basis by adding one of the following lines anywhere in the
1248 buffer:
1250 @example
1251 #+STARTUP: overview
1252 #+STARTUP: content
1253 #+STARTUP: showall
1254 #+STARTUP: showeverything
1255 @end example
1257 @cindex property, VISIBILITY
1258 @noindent
1259 Furthermore, any entries with a @samp{VISIBILITY} property (@pxref{Properties
1260 and Columns}) will get their visibility adapted accordingly.  Allowed values
1261 for this property are @code{folded}, @code{children}, @code{content}, and
1262 @code{all}.
1263 @table @asis
1264 @orgcmd{C-u C-u @key{TAB},org-set-startup-visibility}
1265 Switch back to the startup visibility of the buffer, i.e.@: whatever is
1266 requested by startup options and @samp{VISIBILITY} properties in individual
1267 entries.
1268 @end table
1270 @node Motion, Structure editing, Visibility cycling, Document Structure
1271 @section Motion
1272 @cindex motion, between headlines
1273 @cindex jumping, to headlines
1274 @cindex headline navigation
1275 The following commands jump to other headlines in the buffer.
1277 @table @asis
1278 @orgcmd{C-c C-n,outline-next-visible-heading}
1279 Next heading.
1280 @orgcmd{C-c C-p,outline-previous-visible-heading}
1281 Previous heading.
1282 @orgcmd{C-c C-f,org-forward-same-level}
1283 Next heading same level.
1284 @orgcmd{C-c C-b,org-backward-same-level}
1285 Previous heading same level.
1286 @orgcmd{C-c C-u,outline-up-heading}
1287 Backward to higher level heading.
1288 @orgcmd{C-c C-j,org-goto}
1289 Jump to a different place without changing the current outline
1290 visibility.  Shows the document structure in a temporary buffer, where
1291 you can use the following keys to find your destination:
1292 @vindex org-goto-auto-isearch
1293 @example
1294 @key{TAB}         @r{Cycle visibility.}
1295 @key{down} / @key{up}   @r{Next/previous visible headline.}
1296 @key{RET}         @r{Select this location.}
1297 @kbd{/}           @r{Do a Sparse-tree search}
1298 @r{The following keys work if you turn off @code{org-goto-auto-isearch}}
1299 n / p        @r{Next/previous visible headline.}
1300 f / b        @r{Next/previous headline same level.}
1301 u            @r{One level up.}
1302 0-9          @r{Digit argument.}
1303 q            @r{Quit}
1304 @end example
1305 @vindex org-goto-interface
1306 @noindent
1307 See also the variable @code{org-goto-interface}.
1308 @end table
1310 @node Structure editing, Sparse trees, Motion, Document Structure
1311 @section Structure editing
1312 @cindex structure editing
1313 @cindex headline, promotion and demotion
1314 @cindex promotion, of subtrees
1315 @cindex demotion, of subtrees
1316 @cindex subtree, cut and paste
1317 @cindex pasting, of subtrees
1318 @cindex cutting, of subtrees
1319 @cindex copying, of subtrees
1320 @cindex sorting, of subtrees
1321 @cindex subtrees, cut and paste
1323 @table @asis
1324 @orgcmd{M-@key{RET},org-insert-heading}
1325 @vindex org-M-RET-may-split-line
1326 Insert new heading with same level as current.  If the cursor is in a plain
1327 list item, a new item is created (@pxref{Plain lists}).  To force creation of
1328 a new headline, use a prefix argument.  When this command is used in the
1329 middle of a line, the line is split and the rest of the line becomes the new
1330 headline@footnote{If you do not want the line to be split, customize the
1331 variable @code{org-M-RET-may-split-line}.}.  If the command is used at the
1332 beginning of a headline, the new headline is created before the current line.
1333 If at the beginning of any other line, the content of that line is made the
1334 new heading.  If the command is used at the end of a folded subtree (i.e.@:
1335 behind the ellipses at the end of a headline), then a headline like the
1336 current one will be inserted after the end of the subtree.
1337 @orgcmd{C-@key{RET},org-insert-heading-respect-content}
1338 Just like @kbd{M-@key{RET}}, except when adding a new heading below the
1339 current heading, the new heading is placed after the body instead of before
1340 it.  This command works from anywhere in the entry.
1341 @orgcmd{M-S-@key{RET},org-insert-todo-heading}
1342 @vindex org-treat-insert-todo-heading-as-state-change
1343 Insert new TODO entry with same level as current heading.  See also the
1344 variable @code{org-treat-insert-todo-heading-as-state-change}.
1345 @orgcmd{C-S-@key{RET},org-insert-todo-heading-respect-content}
1346 Insert new TODO entry with same level as current heading.  Like
1347 @kbd{C-@key{RET}}, the new headline will be inserted after the current
1348 subtree.
1349 @orgcmd{@key{TAB},org-cycle}
1350 In a new entry with no text yet, the first @key{TAB} demotes the entry to
1351 become a child of the previous one.  The next @key{TAB} makes it a parent,
1352 and so on, all the way to top level.  Yet another @key{TAB}, and you are back
1353 to the initial level.
1354 @orgcmd{M-@key{left},org-do-promote}
1355 Promote current heading by one level.
1356 @orgcmd{M-@key{right},org-do-demote}
1357 Demote current heading by one level.
1358 @orgcmd{M-S-@key{left},org-promote-subtree}
1359 Promote the current subtree by one level.
1360 @orgcmd{M-S-@key{right},org-demote-subtree}
1361 Demote the current subtree by one level.
1362 @orgcmd{M-S-@key{up},org-move-subtree-up}
1363 Move subtree up (swap with previous subtree of same
1364 level).
1365 @orgcmd{M-S-@key{down},org-move-subtree-down}
1366 Move subtree down (swap with next subtree of same level).
1367 @orgcmd{C-c C-x C-w,org-cut-subtree}
1368 Kill subtree, i.e.@: remove it from buffer but save in kill ring.
1369 With a numeric prefix argument N, kill N sequential subtrees.
1370 @orgcmd{C-c C-x M-w,org-copy-subtree}
1371 Copy subtree to kill ring.  With a numeric prefix argument N, copy the N
1372 sequential subtrees.
1373 @orgcmd{C-c C-x C-y,org-paste-subtree}
1374 Yank subtree from kill ring.  This does modify the level of the subtree to
1375 make sure the tree fits in nicely at the yank position.  The yank level can
1376 also be specified with a numeric prefix argument, or by yanking after a
1377 headline marker like @samp{****}.
1378 @orgcmd{C-y,org-yank}
1379 @vindex org-yank-adjusted-subtrees
1380 @vindex org-yank-folded-subtrees
1381 Depending on the variables @code{org-yank-adjusted-subtrees} and
1382 @code{org-yank-folded-subtrees}, Org's internal @code{yank} command will
1383 paste subtrees folded and in a clever way, using the same command as @kbd{C-c
1384 C-x C-y}.  With the default settings, no level adjustment will take place,
1385 but the yanked tree will be folded unless doing so would swallow text
1386 previously visible.  Any prefix argument to this command will force a normal
1387 @code{yank} to be executed, with the prefix passed along.  A good way to
1388 force a normal yank is @kbd{C-u C-y}.  If you use @code{yank-pop} after a
1389 yank, it will yank previous kill items plainly, without adjustment and
1390 folding.
1391 @orgcmd{C-c C-x c,org-clone-subtree-with-time-shift}
1392 Clone a subtree by making a number of sibling copies of it.  You will be
1393 prompted for the number of copies to make, and you can also specify if any
1394 timestamps in the entry should be shifted.  This can be useful, for example,
1395 to create a number of tasks related to a series of lectures to prepare.  For
1396 more details, see the docstring of the command
1397 @code{org-clone-subtree-with-time-shift}.
1398 @orgcmd{C-c C-w,org-refile}
1399 Refile entry or region to a different location.  @xref{Refiling notes}.
1400 @orgcmd{C-c ^,org-sort-entries-or-items}
1401 Sort same-level entries.  When there is an active region, all entries in the
1402 region will be sorted.  Otherwise the children of the current headline are
1403 sorted.  The command prompts for the sorting method, which can be
1404 alphabetically, numerically, by time (first timestamp with active preferred,
1405 creation time, scheduled time, deadline time), by priority, by TODO keyword
1406 (in the sequence the keywords have been defined in the setup) or by the value
1407 of a property.  Reverse sorting is possible as well.  You can also supply
1408 your own function to extract the sorting key.  With a @kbd{C-u} prefix,
1409 sorting will be case-sensitive.  With two @kbd{C-u C-u} prefixes, duplicate
1410 entries will also be removed.
1411 @orgcmd{C-x n s,org-narrow-to-subtree}
1412 Narrow buffer to current subtree.
1413 @orgcmd{C-x n b,org-narrow-to-block}
1414 Narrow buffer to current block.
1415 @orgcmd{C-x n w,widen}
1416 Widen buffer to remove narrowing.
1417 @orgcmd{C-c *,org-toggle-heading}
1418 Turn a normal line or plain list item into a headline (so that it becomes a
1419 subheading at its location).  Also turn a headline into a normal line by
1420 removing the stars.  If there is an active region, turn all lines in the
1421 region into headlines.  If the first line in the region was an item, turn
1422 only the item lines into headlines.  Finally, if the first line is a
1423 headline, remove the stars from all headlines in the region.
1424 @end table
1426 @cindex region, active
1427 @cindex active region
1428 @cindex transient mark mode
1429 When there is an active region (Transient Mark mode), promotion and
1430 demotion work on all headlines in the region.  To select a region of
1431 headlines, it is best to place both point and mark at the beginning of a
1432 line, mark at the beginning of the first headline, and point at the line
1433 just after the last headline to change.  Note that when the cursor is
1434 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
1435 functionality.
1438 @node Sparse trees, Plain lists, Structure editing, Document Structure
1439 @section Sparse trees
1440 @cindex sparse trees
1441 @cindex trees, sparse
1442 @cindex folding, sparse trees
1443 @cindex occur, command
1445 @vindex org-show-hierarchy-above
1446 @vindex org-show-following-heading
1447 @vindex org-show-siblings
1448 @vindex org-show-entry-below
1449 An important feature of Org-mode is the ability to construct @emph{sparse
1450 trees} for selected information in an outline tree, so that the entire
1451 document is folded as much as possible, but the selected information is made
1452 visible along with the headline structure above it@footnote{See also the
1453 variables @code{org-show-hierarchy-above}, @code{org-show-following-heading},
1454 @code{org-show-siblings}, and @code{org-show-entry-below} for detailed
1455 control on how much context is shown around each match.}.  Just try it out
1456 and you will see immediately how it works.
1458 Org-mode contains several commands creating such trees, all these
1459 commands can be accessed through a dispatcher:
1461 @table @asis
1462 @orgcmd{C-c /,org-sparse-tree}
1463 This prompts for an extra key to select a sparse-tree creating command.
1464 @orgcmd{C-c / r,org-occur}
1465 @vindex org-remove-highlights-with-change
1466 Prompts for a regexp and shows a sparse tree with all matches.  If
1467 the match is in a headline, the headline is made visible.  If the match is in
1468 the body of an entry, headline and body are made visible.  In order to
1469 provide minimal context, also the full hierarchy of headlines above the match
1470 is shown, as well as the headline following the match.  Each match is also
1471 highlighted; the highlights disappear when the buffer is changed by an
1472 editing command@footnote{This depends on the option
1473 @code{org-remove-highlights-with-change}}, or by pressing @kbd{C-c C-c}.
1474 When called with a @kbd{C-u} prefix argument, previous highlights are kept,
1475 so several calls to this command can be stacked.
1476 @orgcmdkkc{M-g n,M-g M-n,next-error}
1477 Jump to the next sparse tree match in this buffer.
1478 @orgcmdkkc{M-g p,M-g M-p,previous-error}
1479 Jump to the previous sparse tree match in this buffer.
1480 @end table
1483 @noindent
1484 @vindex org-agenda-custom-commands
1485 For frequently used sparse trees of specific search strings, you can
1486 use the variable @code{org-agenda-custom-commands} to define fast
1487 keyboard access to specific sparse trees.  These commands will then be
1488 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
1489 For example:
1491 @lisp
1492 (setq org-agenda-custom-commands
1493       '(("f" occur-tree "FIXME")))
1494 @end lisp
1496 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
1497 a sparse tree matching the string @samp{FIXME}.
1499 The other sparse tree commands select headings based on TODO keywords,
1500 tags, or properties and will be discussed later in this manual.
1502 @kindex C-c C-e v
1503 @cindex printing sparse trees
1504 @cindex visible text, printing
1505 To print a sparse tree, you can use the Emacs command
1506 @code{ps-print-buffer-with-faces} which does not print invisible parts
1507 of the document @footnote{This does not work under XEmacs, because
1508 XEmacs uses selective display for outlining, not text properties.}.
1509 Or you can use the command @kbd{C-c C-e v} to export only the visible
1510 part of the document and print the resulting file.
1512 @node Plain lists, Drawers, Sparse trees, Document Structure
1513 @section Plain lists
1514 @cindex plain lists
1515 @cindex lists, plain
1516 @cindex lists, ordered
1517 @cindex ordered lists
1519 Within an entry of the outline tree, hand-formatted lists can provide
1520 additional structure.  They also provide a way to create lists of checkboxes
1521 (@pxref{Checkboxes}).  Org supports editing such lists, and every exporter
1522 (@pxref{Exporting}) can parse and format them.
1524 Org knows ordered lists, unordered lists, and description lists.
1525 @itemize @bullet
1526 @item
1527 @emph{Unordered} list items start with @samp{-}, @samp{+}, or
1528 @samp{*}@footnote{When using @samp{*} as a bullet, lines must be indented or
1529 they will be seen as top-level headlines.  Also, when you are hiding leading
1530 stars to get a clean outline view, plain list items starting with a star may
1531 be hard to distinguish from true headlines.  In short: even though @samp{*}
1532 is supported, it may be better to not use it for plain list items.}  as
1533 bullets.
1534 @item
1535 @vindex org-plain-list-ordered-item-terminator
1536 @vindex org-alphabetical-lists
1537 @emph{Ordered} list items start with a numeral followed by either a period or
1538 a right parenthesis@footnote{You can filter out any of them by configuring
1539 @code{org-plain-list-ordered-item-terminator}.}, such as @samp{1.} or
1540 @samp{1)}@footnote{You can also get @samp{a.}, @samp{A.}, @samp{a)} and
1541 @samp{A)} by configuring @code{org-alphabetical-lists}.  To minimize
1542 confusion with normal text, those are limited to one character only.  Beyond
1543 that limit, bullets will automatically fallback to numbers.}.  If you want a
1544 list to start with a different value (e.g.@: 20), start the text of the item
1545 with @code{[@@20]}@footnote{If there's a checkbox in the item, the cookie
1546 must be put @emph{before} the checkbox.  If you have activated alphabetical
1547 lists, you can also use counters like @code{[@@b]}.}.  Those constructs can
1548 be used in any item of the list in order to enforce a particular numbering.
1549 @item
1550 @emph{Description} list items are unordered list items, and contain the
1551 separator @samp{ :: } to distinguish the description @emph{term} from the
1552 description.
1553 @end itemize
1555 Items belonging to the same list must have the same indentation on the first
1556 line.  In particular, if an ordered list reaches number @samp{10.}, then the
1557 2--digit numbers must be written left-aligned with the other numbers in the
1558 list.  An item ends before the next line that is less or equally indented
1559 than its bullet/number.
1561 @vindex org-list-ending-method
1562 @vindex org-list-end-regexp
1563 @vindex org-empty-line-terminates-plain-lists
1564 Two methods@footnote{To disable either of them, configure
1565 @code{org-list-ending-method}.} are provided to terminate lists.  A list ends
1566 whenever every item has ended, which means before any line less or equally
1567 indented than items at top level.  It also ends before two blank
1568 lines@footnote{See also @code{org-empty-line-terminates-plain-lists}.}.  In
1569 that case, all items are closed.  For finer control, you can end lists with
1570 any pattern set in @code{org-list-end-regexp}.  Here is an example:
1572 @example
1573 @group
1574 ** Lord of the Rings
1575    My favorite scenes are (in this order)
1576    1. The attack of the Rohirrim
1577    2. Eowyn's fight with the witch king
1578       + this was already my favorite scene in the book
1579       + I really like Miranda Otto.
1580    3. Peter Jackson being shot by Legolas
1581       - on DVD only
1582       He makes a really funny face when it happens.
1583    But in the end, no individual scenes matter but the film as a whole.
1584    Important actors in this film are:
1585    - @b{Elijah Wood} :: He plays Frodo
1586    - @b{Sean Austin} :: He plays Sam, Frodo's friend.  I still remember
1587      him very well from his role as Mikey Walsh in @i{The Goonies}.
1588 @end group
1589 @end example
1591 Org supports these lists by tuning filling and wrapping commands to deal with
1592 them correctly@footnote{Org only changes the filling settings for Emacs.  For
1593 XEmacs, you should use Kyle E. Jones' @file{filladapt.el}.  To turn this on,
1594 put into @file{.emacs}: @code{(require 'filladapt)}}, and by exporting them
1595 properly (@pxref{Exporting}).  Since indentation is what governs the
1596 structure of these lists, many structural constructs like @code{#+BEGIN_...}
1597 blocks can be indented to signal that they belong to a particular item.
1599 @vindex org-list-demote-modify-bullet
1600 @vindex org-list-indent-offset
1601 If you find that using a different bullet for a sub-list (than that used for
1602 the current list-level) improves readability, customize the variable
1603 @code{org-list-demote-modify-bullet}.  To get a greater difference of
1604 indentation between items and theirs sub-items, customize
1605 @code{org-list-indent-offset}.
1607 @vindex org-list-automatic-rules
1608 The following commands act on items when the cursor is in the first line of
1609 an item (the line with the bullet or number).  Some of them imply the
1610 application of automatic rules to keep list structure intact.  If some of
1611 these actions get in your way, configure @code{org-list-automatic-rules}
1612 to disable them individually.
1614 @table @asis
1615 @orgcmd{@key{TAB},org-cycle}
1616 @vindex org-cycle-include-plain-lists
1617 Items can be folded just like headline levels.  Normally this works only if
1618 the cursor is on a plain list item.  For more details, see the variable
1619 @code{org-cycle-include-plain-lists}.  If this variable is set to
1620 @code{integrate}, plain list items will be treated like low-level
1621 headlines.  The level of an item is then given by the
1622 indentation of the bullet/number.  Items are always subordinate to real
1623 headlines, however; the hierarchies remain completely separated.
1624 @orgcmd{M-@key{RET},org-insert-heading}
1625 @vindex org-M-RET-may-split-line
1626 @vindex org-list-automatic-rules
1627 Insert new item at current level.  With a prefix argument, force a new
1628 heading (@pxref{Structure editing}).  If this command is used in the middle
1629 of an item, that item is @emph{split} in two, and the second part becomes the
1630 new item@footnote{If you do not want the item to be split, customize the
1631 variable @code{org-M-RET-may-split-line}.}.  If this command is executed
1632 @emph{before item's body}, the new item is created @emph{before} the current
1633 one.
1634 @kindex M-S-@key{RET}
1635 @item M-S-@key{RET}
1636 Insert a new item with a checkbox (@pxref{Checkboxes}).
1637 @orgcmd{@key{TAB},org-cycle}
1638 In a new item with no text yet, the first @key{TAB} demotes the item to
1639 become a child of the previous one.  Subsequent @key{TAB}s move the item to
1640 meaningful levels in the list and eventually get it back to its initial
1641 position.
1642 @kindex S-@key{down}
1643 @item S-@key{up}
1644 @itemx S-@key{down}
1645 @cindex shift-selection-mode
1646 @vindex org-support-shift-select
1647 @vindex org-list-use-circular-motion
1648 Jump to the previous/next item in the current list@footnote{If you want to
1649 cycle around items that way, you may customize
1650 @code{org-list-use-circular-motion}.}, but only if
1651 @code{org-support-shift-select} is off.  If not, you can still use paragraph
1652 jumping commands like @kbd{C-@key{up}} and @kbd{C-@key{down}} to quite
1653 similar effect.
1654 @kindex M-@key{up}
1655 @kindex M-@key{down}
1656 @item M-@key{up}
1657 @itemx M-@key{down}
1658 Move the item including subitems up/down@footnote{See
1659 @code{org-liste-use-circular-motion} for a cyclic behavior.} (swap with
1660 previous/next item of same indentation).  If the list is ordered, renumbering
1661 is automatic.
1662 @kindex M-@key{left}
1663 @kindex M-@key{right}
1664 @item M-@key{left}
1665 @itemx M-@key{right}
1666 Decrease/increase the indentation of an item, leaving children alone.
1667 @kindex M-S-@key{left}
1668 @kindex M-S-@key{right}
1669 @item M-S-@key{left}
1670 @itemx M-S-@key{right}
1671 Decrease/increase the indentation of the item, including subitems.
1672 Initially, the item tree is selected based on current indentation.  When
1673 these commands are executed several times in direct succession, the initially
1674 selected region is used, even if the new indentation would imply a different
1675 hierarchy.  To use the new hierarchy, break the command chain with a cursor
1676 motion or so.
1678 As a special case, using this command on the very first item of a list will
1679 move the whole list.  This behavior can be disabled by configuring
1680 @code{org-list-automatic-rules}.  The global indentation of a list has no
1681 influence on the text @emph{after} the list.
1682 @kindex C-c C-c
1683 @item C-c C-c
1684 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1685 state of the checkbox.  In any case, verify bullets and indentation
1686 consistency in the whole list.
1687 @kindex C-c -
1688 @vindex org-plain-list-ordered-item-terminator
1689 @vindex org-list-automatic-rules
1690 @item C-c -
1691 Cycle the entire list level through the different itemize/enumerate bullets
1692 (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}) or a subset of them,
1693 depending on @code{org-plain-list-ordered-item-terminator}, the type of list,
1694 and its position@footnote{See @code{bullet} rule in
1695 @code{org-list-automatic-rules} for more information.}.  With a numeric
1696 prefix argument N, select the Nth bullet from this list.  If there is an
1697 active region when calling this, selected text will be changed into an item.
1698 With a prefix argument, all lines will be converted to list items.  If the
1699 first line already was a list item, any item marker will be removed from the
1700 list.  Finally, even without an active region, a normal line will be
1701 converted into a list item.
1702 @kindex C-c *
1703 @item C-c *
1704 Turn a plain list item into a headline (so that it becomes a subheading at
1705 its location).  @xref{Structure editing}, for a detailed explanation.
1706 @kindex C-c C-*
1707 @item C-c C-*
1708 Turn the whole plain list into a subtree of the current heading.  Checkboxes
1709 (@pxref{Checkboxes}) will become TODO (resp. DONE) keywords when unchecked
1710 (resp. checked).
1711 @kindex S-@key{left}
1712 @kindex S-@key{right}
1713 @item S-@key{left}/@key{right}
1714 @vindex org-support-shift-select
1715 This command also cycles bullet styles when the cursor in on the bullet or
1716 anywhere in an item line, details depending on
1717 @code{org-support-shift-select}.
1718 @kindex C-c ^
1719 @item C-c ^
1720 Sort the plain list.  You will be prompted for the sorting method:
1721 numerically, alphabetically, by time, or by custom function.
1722 @end table
1724 @node Drawers, Blocks, Plain lists, Document Structure
1725 @section Drawers
1726 @cindex drawers
1727 @cindex #+DRAWERS
1728 @cindex visibility cycling, drawers
1730 @vindex org-drawers
1731 Sometimes you want to keep information associated with an entry, but you
1732 normally don't want to see it.  For this, Org-mode has @emph{drawers}.
1733 Drawers need to be configured with the variable
1734 @code{org-drawers}@footnote{You can define drawers on a per-file basis
1735 with a line like @code{#+DRAWERS: HIDDEN PROPERTIES STATE}}.  Drawers
1736 look like this:
1738 @example
1739 ** This is a headline
1740    Still outside the drawer
1741    :DRAWERNAME:
1742    This is inside the drawer.
1743    :END:
1744    After the drawer.
1745 @end example
1747 Visibility cycling (@pxref{Visibility cycling}) on the headline will hide and
1748 show the entry, but keep the drawer collapsed to a single line.  In order to
1749 look inside the drawer, you need to move the cursor to the drawer line and
1750 press @key{TAB} there.  Org-mode uses the @code{PROPERTIES} drawer for
1751 storing properties (@pxref{Properties and Columns}), and you can also arrange
1752 for state change notes (@pxref{Tracking TODO state changes}) and clock times
1753 (@pxref{Clocking work time}) to be stored in a drawer @code{LOGBOOK}.  If you
1754 want to store a quick note in the LOGBOOK drawer, in a similar way to state changes, use
1756 @table @kbd
1757 @kindex C-c C-z
1758 @item C-c C-z
1759 Add a time-stamped note to the LOGBOOK drawer.
1760 @end table
1762 @node Blocks, Footnotes, Drawers, Document Structure
1763 @section Blocks
1765 @vindex org-hide-block-startup
1766 @cindex blocks, folding
1767 Org-mode uses begin...end blocks for various purposes from including source
1768 code examples (@pxref{Literal examples}) to capturing time logging
1769 information (@pxref{Clocking work time}).  These blocks can be folded and
1770 unfolded by pressing TAB in the begin line.  You can also get all blocks
1771 folded at startup by configuring the variable @code{org-hide-block-startup}
1772 or on a per-file basis by using
1774 @cindex @code{hideblocks}, STARTUP keyword
1775 @cindex @code{nohideblocks}, STARTUP keyword
1776 @example
1777 #+STARTUP: hideblocks
1778 #+STARTUP: nohideblocks
1779 @end example
1781 @node Footnotes, Orgstruct mode, Blocks, Document Structure
1782 @section Footnotes
1783 @cindex footnotes
1785 Org-mode supports the creation of footnotes.  In contrast to the
1786 @file{footnote.el} package, Org-mode's footnotes are designed for work on a
1787 larger document, not only for one-off documents like emails.  The basic
1788 syntax is similar to the one used by @file{footnote.el}, i.e.@: a footnote is
1789 defined in a paragraph that is started by a footnote marker in square
1790 brackets in column 0, no indentation allowed.  If you need a paragraph break
1791 inside a footnote, use the @LaTeX{} idiom @samp{\par}.  The footnote reference
1792 is simply the marker in square brackets, inside text.  For example:
1794 @example
1795 The Org homepage[fn:1] now looks a lot better than it used to.
1797 [fn:1] The link is: http://orgmode.org
1798 @end example
1800 Org-mode extends the number-based syntax to @emph{named} footnotes and
1801 optional inline definition.  Using plain numbers as markers (as
1802 @file{footnote.el} does) is supported for backward compatibility, but not
1803 encouraged because of possible conflicts with @LaTeX{} snippets (@pxref{Embedded
1804 LaTeX}).  Here are the valid references:
1806 @table @code
1807 @item [1]
1808 A plain numeric footnote marker.  Compatible with @file{footnote.el}, but not
1809 recommended because something like @samp{[1]} could easily be part of a code
1810 snippet.
1811 @item [fn:name]
1812 A named footnote reference, where @code{name} is a unique label word, or, for
1813 simplicity of automatic creation, a number.
1814 @item [fn:: This is the inline definition of this footnote]
1815 A @LaTeX{}-like anonymous footnote where the definition is given directly at the
1816 reference point.
1817 @item [fn:name: a definition]
1818 An inline definition of a footnote, which also specifies a name for the note.
1819 Since Org allows multiple references to the same note, you can then use
1820 @code{[fn:name]} to create additional references.
1821 @end table
1823 @vindex org-footnote-auto-label
1824 Footnote labels can be created automatically, or you can create names yourself.
1825 This is handled by the variable @code{org-footnote-auto-label} and its
1826 corresponding @code{#+STARTUP} keywords.  See the docstring of that variable
1827 for details.
1829 @noindent The following command handles footnotes:
1831 @table @kbd
1832 @kindex C-c C-x f
1833 @item C-c C-x f
1834 The footnote action command.
1836 When the cursor is on a footnote reference, jump to the definition.  When it
1837 is at a definition, jump to the (first) reference.
1839 @vindex org-footnote-define-inline
1840 @vindex org-footnote-section
1841 @vindex org-footnote-auto-adjust
1842 Otherwise, create a new footnote.  Depending on the variable
1843 @code{org-footnote-define-inline}@footnote{The corresponding in-buffer
1844 setting is: @code{#+STARTUP: fninline} or @code{#+STARTUP: nofninline}}, the
1845 definition will be placed right into the text as part of the reference, or
1846 separately into the location determined by the variable
1847 @code{org-footnote-section}.
1849 When this command is called with a prefix argument, a menu of additional
1850 options is offered:
1851 @example
1852 s   @r{Sort the footnote definitions by reference sequence.  During editing,}
1853     @r{Org makes no effort to sort footnote definitions into a particular}
1854     @r{sequence.  If you want them sorted, use this command, which will}
1855     @r{also move entries according to @code{org-footnote-section}.  Automatic}
1856     @r{sorting after each insertion/deletion can be configured using the}
1857     @r{variable @code{org-footnote-auto-adjust}.}
1858 r   @r{Renumber the simple @code{fn:N} footnotes.  Automatic renumbering}
1859     @r{after each insertion/deletion can be configured using the variable}
1860     @r{@code{org-footnote-auto-adjust}.}
1861 S   @r{Short for first @code{r}, then @code{s} action.}
1862 n   @r{Normalize the footnotes by collecting all definitions (including}
1863     @r{inline definitions) into a special section, and then numbering them}
1864     @r{in sequence.  The references will then also be numbers.  This is}
1865     @r{meant to be the final step before finishing a document (e.g.@: sending}
1866     @r{off an email).  The exporters do this automatically, and so could}
1867     @r{something like @code{message-send-hook}.}
1868 d   @r{Delete the footnote at point, and all definitions of and references}
1869     @r{to it.}
1870 @end example
1871 Depending on the variable @code{org-footnote-auto-adjust}@footnote{the
1872 corresponding in-buffer options are @code{fnadjust} and @code{nofnadjust}.},
1873 renumbering and sorting footnotes can be automatic after each insertion or
1874 deletion.
1876 @kindex C-c C-c
1877 @item C-c C-c
1878 If the cursor is on a footnote reference, jump to the definition.  If it is a
1879 the definition, jump back to the reference.  When called at a footnote
1880 location with a prefix argument, offer the same menu as @kbd{C-c C-x f}.
1881 @kindex C-c C-o
1882 @kindex mouse-1
1883 @kindex mouse-2
1884 @item C-c C-o  @r{or} mouse-1/2
1885 Footnote labels are also links to the corresponding definition/reference, and
1886 you can use the usual commands to follow these links.
1887 @end table
1889 @node Orgstruct mode,  , Footnotes, Document Structure
1890 @section The Orgstruct minor mode
1891 @cindex Orgstruct mode
1892 @cindex minor mode for structure editing
1894 If you like the intuitive way the Org-mode structure editing and list
1895 formatting works, you might want to use these commands in other modes like
1896 Text mode or Mail mode as well.  The minor mode @code{orgstruct-mode} makes
1897 this possible.   Toggle the mode with @kbd{M-x orgstruct-mode}, or
1898 turn it on by default, for example in Message mode, with one of:
1900 @lisp
1901 (add-hook 'message-mode-hook 'turn-on-orgstruct)
1902 (add-hook 'message-mode-hook 'turn-on-orgstruct++)
1903 @end lisp
1905 When this mode is active and the cursor is on a line that looks to Org like a
1906 headline or the first line of a list item, most structure editing commands
1907 will work, even if the same keys normally have different functionality in the
1908 major mode you are using.  If the cursor is not in one of those special
1909 lines, Orgstruct mode lurks silently in the shadows.  When you use
1910 @code{orgstruct++-mode}, Org will also export indentation and autofill
1911 settings into that mode, and detect item context after the first line of an
1912 item.
1914 @node Tables, Hyperlinks, Document Structure, Top
1915 @chapter Tables
1916 @cindex tables
1917 @cindex editing tables
1919 Org comes with a fast and intuitive table editor.  Spreadsheet-like
1920 calculations are supported using the Emacs @file{calc} package
1921 @ifinfo
1922 (@pxref{Top,Calc,,Calc,Gnu Emacs Calculator Manual}).
1923 @end ifinfo
1924 @ifnotinfo
1925 (see the Emacs Calculator manual for more information about the Emacs
1926 calculator).
1927 @end ifnotinfo
1929 @menu
1930 * Built-in table editor::       Simple tables
1931 * Column width and alignment::  Overrule the automatic settings
1932 * Column groups::               Grouping to trigger vertical lines
1933 * Orgtbl mode::                 The table editor as minor mode
1934 * The spreadsheet::             The table editor has spreadsheet capabilities
1935 * Org-Plot::                    Plotting from org tables
1936 @end menu
1938 @node Built-in table editor, Column width and alignment, Tables, Tables
1939 @section The built-in table editor
1940 @cindex table editor, built-in
1942 Org makes it easy to format tables in plain ASCII.  Any line with @samp{|} as
1943 the first non-whitespace character is considered part of a table.  @samp{|}
1944 is also the column separator@footnote{To insert a vertical bar into a table
1945 field, use @code{\vert} or, inside a word @code{abc\vert@{@}def}.}.  A table
1946 might look like this:
1948 @example
1949 | Name  | Phone | Age |
1950 |-------+-------+-----|
1951 | Peter |  1234 |  17 |
1952 | Anna  |  4321 |  25 |
1953 @end example
1955 A table is re-aligned automatically each time you press @key{TAB} or
1956 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
1957 the next field (@key{RET} to the next row) and creates new table rows
1958 at the end of the table or before horizontal lines.  The indentation
1959 of the table is set by the first line.  Any line starting with
1960 @samp{|-} is considered as a horizontal separator line and will be
1961 expanded on the next re-align to span the whole table width.  So, to
1962 create the above table, you would only type
1964 @example
1965 |Name|Phone|Age|
1967 @end example
1969 @noindent and then press @key{TAB} to align the table and start filling in
1970 fields.  Even faster would be to type @code{|Name|Phone|Age} followed by
1971 @kbd{C-c @key{RET}}.
1973 @vindex org-enable-table-editor
1974 @vindex org-table-auto-blank-field
1975 When typing text into a field, Org treats @key{DEL},
1976 @key{Backspace}, and all character keys in a special way, so that
1977 inserting and deleting avoids shifting other fields.  Also, when
1978 typing @emph{immediately after the cursor was moved into a new field
1979 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
1980 field is automatically made blank.  If this behavior is too
1981 unpredictable for you, configure the variables
1982 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
1984 @table @kbd
1985 @tsubheading{Creation and conversion}
1986 @orgcmd{C-c |,org-table-create-or-convert-from-region}
1987 Convert the active region to table.  If every line contains at least one
1988 TAB character, the function assumes that the material is tab separated.
1989 If every line contains a comma, comma-separated values (CSV) are assumed.
1990 If not, lines are split at whitespace into fields.  You can use a prefix
1991 argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
1992 C-u} forces TAB, and a numeric argument N indicates that at least N
1993 consecutive spaces, or alternatively a TAB will be the separator.
1995 If there is no active region, this command creates an empty Org
1996 table.  But it is easier just to start typing, like
1997 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
1999 @tsubheading{Re-aligning and field motion}
2000 @orgcmd{C-c C-c,org-table-align}
2001 Re-align the table without moving the cursor.
2003 @orgcmd{<TAB>,org-table-next-field}
2004 Re-align the table, move to the next field.  Creates a new row if
2005 necessary.
2007 @orgcmd{S-@key{TAB},org-table-previous-field}
2008 Re-align, move to previous field.
2010 @orgcmd{@key{RET},org-table-next-row}
2011 Re-align the table and move down to next row.  Creates a new row if
2012 necessary.  At the beginning or end of a line, @key{RET} still does
2013 NEWLINE, so it can be used to split a table.
2015 @orgcmd{M-a,org-table-beginning-of-field}
2016 Move to beginning of the current table field, or on to the previous field.
2017 @orgcmd{M-e,org-table-end-of-field}
2018 Move to end of the current table field, or on to the next field.
2020 @tsubheading{Column and row editing}
2021 @orgcmdkkcc{M-@key{left},M-@key{right},org-table-move-column-left,org-table-move-column-right}
2022 Move the current column left/right.
2024 @orgcmd{M-S-@key{left},org-table-delete-column}
2025 Kill the current column.
2027 @orgcmd{M-S-@key{right},org-table-insert-column}
2028 Insert a new column to the left of the cursor position.
2030 @orgcmdkkcc{M-@key{up},M-@key{down},org-table-move-row-up,org-table-move-row-down}
2031 Move the current row up/down.
2033 @orgcmd{M-S-@key{up},org-table-kill-row}
2034 Kill the current row or horizontal line.
2036 @orgcmd{M-S-@key{down},org-table-insert-row}
2037 Insert a new row above the current row.  With a prefix argument, the line is
2038 created below the current one.
2040 @orgcmd{C-c -,org-table-insert-hline}
2041 Insert a horizontal line below current row.  With a prefix argument, the line
2042 is created above the current line.
2044 @orgcmd{C-c @key{RET},org-table-hline-and-move}
2045 Insert a horizontal line below current row, and move the cursor into the row
2046 below that line.
2048 @orgcmd{C-c ^,org-table-sort-lines}
2049 Sort the table lines in the region.  The position of point indicates the
2050 column to be used for sorting, and the range of lines is the range
2051 between the nearest horizontal separator lines, or the entire table.  If
2052 point is before the first column, you will be prompted for the sorting
2053 column.  If there is an active region, the mark specifies the first line
2054 and the sorting column, while point should be in the last line to be
2055 included into the sorting.  The command prompts for the sorting type
2056 (alphabetically, numerically, or by time).  When called with a prefix
2057 argument, alphabetic sorting will be case-sensitive.
2059 @tsubheading{Regions}
2060 @orgcmd{C-c C-x M-w,org-table-copy-region}
2061 Copy a rectangular region from a table to a special clipboard.  Point and
2062 mark determine edge fields of the rectangle.  If there is no active region,
2063 copy just the current field.  The process ignores horizontal separator lines.
2065 @orgcmd{C-c C-x C-w,org-table-cut-region}
2066 Copy a rectangular region from a table to a special clipboard, and
2067 blank all fields in the rectangle.  So this is the ``cut'' operation.
2069 @orgcmd{C-c C-x C-y,org-table-paste-rectangle}
2070 Paste a rectangular region into a table.
2071 The upper left corner ends up in the current field.  All involved fields
2072 will be overwritten.  If the rectangle does not fit into the present table,
2073 the table is enlarged as needed.  The process ignores horizontal separator
2074 lines.
2076 @orgcmd{M-@key{RET},org-table-wrap-region}
2077 Split the current field at the cursor position and move the rest to the line
2078 below.  If there is an active region, and both point and mark are in the same
2079 column, the text in the column is wrapped to minimum width for the given
2080 number of lines.  A numeric prefix argument may be used to change the number
2081 of desired lines.  If there is no region, but you specify a prefix argument,
2082 the current field is made blank, and the content is appended to the field
2083 above.
2085 @tsubheading{Calculations}
2086 @cindex formula, in tables
2087 @cindex calculations, in tables
2088 @cindex region, active
2089 @cindex active region
2090 @cindex transient mark mode
2091 @orgcmd{C-c +,org-table-sum}
2092 Sum the numbers in the current column, or in the rectangle defined by
2093 the active region.  The result is shown in the echo area and can
2094 be inserted with @kbd{C-y}.
2096 @orgcmd{S-@key{RET},org-table-copy-down}
2097 @vindex org-table-copy-increment
2098 When current field is empty, copy from first non-empty field above.  When not
2099 empty, copy current field down to next row and move cursor along with it.
2100 Depending on the variable @code{org-table-copy-increment}, integer field
2101 values will be incremented during copy.  Integers that are too large will not
2102 be incremented.  Also, a @code{0} prefix argument temporarily disables the
2103 increment.  This key is also used by shift-selection and related modes
2104 (@pxref{Conflicts}).
2106 @tsubheading{Miscellaneous}
2107 @orgcmd{C-c `,org-table-edit-field}
2108 Edit the current field in a separate window.  This is useful for fields that
2109 are not fully visible (@pxref{Column width and alignment}).  When called with
2110 a @kbd{C-u} prefix, just make the full field visible, so that it can be
2111 edited in place.  When called with two @kbd{C-u} prefixes, make the editor
2112 window follow the cursor through the table and always show the current
2113 field.  The follow mode exits automatically when the cursor leaves the table,
2114 or when you repeat this command with @kbd{C-u C-u C-c `}.
2116 @item M-x org-table-import
2117 Import a file as a table.  The table should be TAB or whitespace
2118 separated.  Use, for example, to import a spreadsheet table or data
2119 from a database, because these programs generally can write
2120 TAB-separated text files.  This command works by inserting the file into
2121 the buffer and then converting the region to a table.  Any prefix
2122 argument is passed on to the converter, which uses it to determine the
2123 separator.
2124 @orgcmd{C-c |,org-table-create-or-convert-from-region}
2125 Tables can also be imported by pasting tabular text into the Org
2126 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
2127 @kbd{C-c |} command (see above under @i{Creation and conversion}).
2129 @item M-x org-table-export
2130 @findex org-table-export
2131 @vindex org-table-export-default-format
2132 Export the table, by default as a TAB-separated file.  Use for data
2133 exchange with, for example, spreadsheet or database programs.  The format
2134 used to export the file can be configured in the variable
2135 @code{org-table-export-default-format}.  You may also use properties
2136 @code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
2137 name and the format for table export in a subtree.  Org supports quite
2138 general formats for exported tables.  The exporter format is the same as the
2139 format used by Orgtbl radio tables, see @ref{Translator functions}, for a
2140 detailed description.
2141 @end table
2143 If you don't like the automatic table editor because it gets in your
2144 way on lines which you would like to start with @samp{|}, you can turn
2145 it off with
2147 @lisp
2148 (setq org-enable-table-editor nil)
2149 @end lisp
2151 @noindent Then the only table command that still works is
2152 @kbd{C-c C-c} to do a manual re-align.
2154 @node Column width and alignment, Column groups, Built-in table editor, Tables
2155 @section Column width and alignment
2156 @cindex narrow columns in tables
2157 @cindex alignment in tables
2159 The width of columns is automatically determined by the table editor.  And
2160 also the alignment of a column is determined automatically from the fraction
2161 of number-like versus non-number fields in the column.
2163 Sometimes a single field or a few fields need to carry more text, leading to
2164 inconveniently wide columns.  Or maybe you want to make a table with several
2165 columns having a fixed width, regardless of content.  To set@footnote{This
2166 feature does not work on XEmacs.} the width of a column, one field anywhere
2167 in the column may contain just the string @samp{<N>} where @samp{N} is an
2168 integer specifying the width of the column in characters.  The next re-align
2169 will then set the width of this column to this value.
2171 @example
2172 @group
2173 |---+------------------------------|               |---+--------|
2174 |   |                              |               |   | <6>    |
2175 | 1 | one                          |               | 1 | one    |
2176 | 2 | two                          |     ----\     | 2 | two    |
2177 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
2178 | 4 | four                         |               | 4 | four   |
2179 |---+------------------------------|               |---+--------|
2180 @end group
2181 @end example
2183 @noindent
2184 Fields that are wider become clipped and end in the string @samp{=>}.
2185 Note that the full text is still in the buffer but is hidden.
2186 To see the full text, hold the mouse over the field---a tool-tip window
2187 will show the full content.  To edit such a field, use the command
2188 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
2189 open a new window with the full field.  Edit it and finish with @kbd{C-c
2190 C-c}.
2192 @vindex org-startup-align-all-tables
2193 When visiting a file containing a table with narrowed columns, the
2194 necessary character hiding has not yet happened, and the table needs to
2195 be aligned before it looks nice.  Setting the option
2196 @code{org-startup-align-all-tables} will realign all tables in a file
2197 upon visiting, but also slow down startup.  You can also set this option
2198 on a per-file basis with:
2200 @example
2201 #+STARTUP: align
2202 #+STARTUP: noalign
2203 @end example
2205 If you would like to overrule the automatic alignment of number-rich columns
2206 to the right and of string-rich column to the left, you can use @samp{<r>},
2207 @samp{c}@footnote{Centering does not work inside Emacs, but it does have an
2208 effect when exporting to HTML.} or @samp{<l>} in a similar fashion.  You may
2209 also combine alignment and field width like this: @samp{<l10>}.
2211 Lines which only contain these formatting cookies will be removed
2212 automatically when exporting the document.
2214 @node Column groups, Orgtbl mode, Column width and alignment, Tables
2215 @section Column groups
2216 @cindex grouping columns in tables
2218 When Org exports tables, it does so by default without vertical
2219 lines because that is visually more satisfying in general.  Occasionally
2220 however, vertical lines can be useful to structure a table into groups
2221 of columns, much like horizontal lines can do for groups of rows.  In
2222 order to specify column groups, you can use a special row where the
2223 first field contains only @samp{/}.  The further fields can either
2224 contain @samp{<} to indicate that this column should start a group,
2225 @samp{>} to indicate the end of a column, or @samp{<>} to make a column
2226 a group of its own.  Boundaries between column groups will upon export be
2227 marked with vertical lines.  Here is an example:
2229 @example
2230 | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
2231 |---+-----+-----+-----+---------+------------|
2232 | / |   < |     |   > |       < |          > |
2233 | 1 |   1 |   1 |   1 |       1 |          1 |
2234 | 2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
2235 | 3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
2236 |---+-----+-----+-----+---------+------------|
2237 #+TBLFM: $2=$1^2::$3=$1^3::$4=$1^4::$5=sqrt($1)::$6=sqrt(sqrt(($1)))
2238 @end example
2240 It is also sufficient to just insert the column group starters after
2241 every vertical line you would like to have:
2243 @example
2244 |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
2245 |----+-----+-----+-----+---------+------------|
2246 | /  | <   |     |     | <       |            |
2247 @end example
2249 @node Orgtbl mode, The spreadsheet, Column groups, Tables
2250 @section The Orgtbl minor mode
2251 @cindex Orgtbl mode
2252 @cindex minor mode for tables
2254 If you like the intuitive way the Org table editor works, you
2255 might also want to use it in other modes like Text mode or Mail mode.
2256 The minor mode Orgtbl mode makes this possible.  You can always toggle
2257 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
2258 example in Message mode, use
2260 @lisp
2261 (add-hook 'message-mode-hook 'turn-on-orgtbl)
2262 @end lisp
2264 Furthermore, with some special setup, it is possible to maintain tables
2265 in arbitrary syntax with Orgtbl mode.  For example, it is possible to
2266 construct @LaTeX{} tables with the underlying ease and power of
2267 Orgtbl mode, including spreadsheet capabilities.  For details, see
2268 @ref{Tables in arbitrary syntax}.
2270 @node The spreadsheet, Org-Plot, Orgtbl mode, Tables
2271 @section The spreadsheet
2272 @cindex calculations, in tables
2273 @cindex spreadsheet capabilities
2274 @cindex @file{calc} package
2276 The table editor makes use of the Emacs @file{calc} package to implement
2277 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
2278 derive fields from other fields.  While fully featured, Org's implementation
2279 is not identical to other spreadsheets.  For example, Org knows the concept
2280 of a @emph{column formula} that will be applied to all non-header fields in a
2281 column without having to copy the formula to each relevant field.  There is
2282 also a formula debugger, and a formula editor with features for highlighting
2283 fields in the table corresponding to the references at the point in the
2284 formula, moving these references by arrow keys
2286 @menu
2287 * References::                  How to refer to another field or range
2288 * Formula syntax for Calc::     Using Calc to compute stuff
2289 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
2290 * Durations and time values::   How to compute durations and time values
2291 * Field and range formulas::    Formula for specific (ranges of) fields
2292 * Column formulas::             Formulas valid for an entire column
2293 * Editing and debugging formulas::  Fixing formulas
2294 * Updating the table::          Recomputing all dependent fields
2295 * Advanced features::           Field and column names, parameters and automatic recalc
2296 @end menu
2298 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
2299 @subsection References
2300 @cindex references
2302 To compute fields in the table from other fields, formulas must
2303 reference other fields or ranges.  In Org, fields can be referenced
2304 by name, by absolute coordinates, and by relative coordinates.  To find
2305 out what the coordinates of a field are, press @kbd{C-c ?} in that
2306 field, or press @kbd{C-c @}} to toggle the display of a grid.
2308 @subsubheading Field references
2309 @cindex field references
2310 @cindex references, to fields
2312 Formulas can reference the value of another field in two ways.  Like in
2313 any other spreadsheet, you may reference fields with a letter/number
2314 combination like @code{B3}, meaning the 2nd field in the 3rd row.
2315 @vindex org-table-use-standard-references
2316 However, Org prefers@footnote{Org will understand references typed by the
2317 user as @samp{B4}, but it will not use this syntax when offering a formula
2318 for editing.  You can customize this behavior using the variable
2319 @code{org-table-use-standard-references}.}  to use another, more general
2320 representation that looks like this:
2321 @example
2322 @@@var{row}$@var{column}
2323 @end example
2325 Column specifications can be absolute like @code{$1},
2326 @code{$2},...@code{$@var{N}}, or relative to the current column (i.e.@: the
2327 column of the field which is being computed) like @code{$+1} or @code{$-2}.
2328 @code{$<} and @code{$>} are immutable references to the first and last
2329 column, respectively, and you can use @code{$>>>} to indicate the third
2330 column from the right.
2332 The row specification only counts data lines and ignores horizontal separator
2333 lines (hlines).  Like with columns, you can use absolute row numbers
2334 @code{@@1}, @code{@@2},...@code{@@@var{N}}, and row numbers relative to the
2335 current row like @code{@@+3} or @code{@@-1}.  @code{@@<} and @code{@@>} are
2336 immutable references the first and last@footnote{For backward compatibility
2337 you can also use special names like @code{$LR5} and @code{$LR12} to refer in
2338 a stable way to the 5th and 12th field in the last row of the table.
2339 However, this syntax is deprecated, it should not be used for new documents.
2340 Use @code{@@>$} instead.} row in the table, respectively.  You may also
2341 specify the row relative to one of the hlines: @code{@@I} refers to the first
2342 hline, @code{@@II} to the second, etc@.  @code{@@-I} refers to the first such
2343 line above the current line, @code{@@+I} to the first such line below the
2344 current line.  You can also write @code{@@III+2} which is the second data line
2345 after the third hline in the table.
2347 @code{@@0} and @code{$0} refer to the current row and column, respectively,
2348 i.e. to the row/column for the field being computed.  Also, if you omit
2349 either the column or the row part of the reference, the current row/column is
2350 implied.
2352 Org's references with @emph{unsigned} numbers are fixed references
2353 in the sense that if you use the same reference in the formula for two
2354 different fields, the same field will be referenced each time.
2355 Org's references with @emph{signed} numbers are floating
2356 references because the same reference operator can reference different
2357 fields depending on the field being calculated by the formula.
2359 Here are a few examples:
2361 @example
2362 @@2$3      @r{2nd row, 3rd column (same as @code{C2})}
2363 $5        @r{column 5 in the current row (same as @code{E&})}
2364 @@2        @r{current column, row 2}
2365 @@-1$-3    @r{the field one row up, three columns to the left}
2366 @@-I$2     @r{field just under hline above current row, column 2}
2367 @@>$5      @r{field in the last row, in column 5}
2368 @end example
2370 @subsubheading Range references
2371 @cindex range references
2372 @cindex references, to ranges
2374 You may reference a rectangular range of fields by specifying two field
2375 references connected by two dots @samp{..}.  If both fields are in the
2376 current row, you may simply use @samp{$2..$7}, but if at least one field
2377 is in a different row, you need to use the general @code{@@row$column}
2378 format at least for the first field (i.e the reference must start with
2379 @samp{@@} in order to be interpreted correctly).  Examples:
2381 @example
2382 $1..$3        @r{first three fields in the current row}
2383 $P..$Q        @r{range, using column names (see under Advanced)}
2384 $<<<..$>>     @r{start in third column, continue to the one but last}
2385 @@2$1..@@4$3    @r{6 fields between these two fields (same as @code{A2..C4})}
2386 @@-1$-2..@@-1   @r{3 numbers from the column to the left, 2 up to current row}
2387 @@I..II        @r{between first and second hline, short for @code{@@I..@@II}}
2388 @end example
2390 @noindent Range references return a vector of values that can be fed
2391 into Calc vector functions.  Empty fields in ranges are normally
2392 suppressed, so that the vector contains only the non-empty fields (but
2393 see the @samp{E} mode switch below).  If there are no non-empty fields,
2394 @samp{[0]} is returned to avoid syntax errors in formulas.
2396 @subsubheading Field coordinates in formulas
2397 @cindex field coordinates
2398 @cindex coordinates, of field
2399 @cindex row, of field coordinates
2400 @cindex column, of field coordinates
2402 For Calc formulas and Lisp formulas @code{@@#} and @code{$#} can be used to
2403 get the row or column number of the field where the formula result goes.
2404 The traditional Lisp formula equivalents are @code{org-table-current-dline}
2405 and @code{org-table-current-column}.  Examples:
2407 @example
2408 if(@@# % 2, $#, string(""))   @r{column number on odd lines only}
2409 $3 = remote(FOO, @@@@#$2)      @r{copy column 2 from table FOO into}
2410                              @r{column 3 of the current table}
2411 @end example
2413 @noindent For the second example, table FOO must have at least as many rows
2414 as the current table.  Note that this is inefficient@footnote{The computation time scales as
2415 O(N^2) because table FOO is parsed for each field to be copied.} for large
2416 number of rows.
2418 @subsubheading Named references
2419 @cindex named references
2420 @cindex references, named
2421 @cindex name, of column or field
2422 @cindex constants, in calculations
2423 @cindex #+CONSTANTS
2425 @vindex org-table-formula-constants
2426 @samp{$name} is interpreted as the name of a column, parameter or
2427 constant.  Constants are defined globally through the variable
2428 @code{org-table-formula-constants}, and locally (for the file) through a
2429 line like
2431 @example
2432 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
2433 @end example
2435 @noindent
2436 @vindex constants-unit-system
2437 @pindex constants.el
2438 Also properties (@pxref{Properties and Columns}) can be used as
2439 constants in table formulas: for a property @samp{:Xyz:} use the name
2440 @samp{$PROP_Xyz}, and the property will be searched in the current
2441 outline entry and in the hierarchy above it.  If you have the
2442 @file{constants.el} package, it will also be used to resolve constants,
2443 including natural constants like @samp{$h} for Planck's constant, and
2444 units like @samp{$km} for kilometers@footnote{@file{constants.el} can
2445 supply the values of constants in two different unit systems, @code{SI}
2446 and @code{cgs}.  Which one is used depends on the value of the variable
2447 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
2448 @code{constSI} and @code{constcgs} to set this value for the current
2449 buffer.}.  Column names and parameters can be specified in special table
2450 lines.  These are described below, see @ref{Advanced features}.  All
2451 names must start with a letter, and further consist of letters and
2452 numbers.
2454 @subsubheading Remote references
2455 @cindex remote references
2456 @cindex references, remote
2457 @cindex references, to a different table
2458 @cindex name, of column or field
2459 @cindex constants, in calculations
2460 @cindex #+TBLNAME
2462 You may also reference constants, fields and ranges from a different table,
2463 either in the current file or even in a different file.  The syntax is
2465 @example
2466 remote(NAME-OR-ID,REF)
2467 @end example
2469 @noindent
2470 where NAME can be the name of a table in the current file as set by a
2471 @code{#+TBLNAME: NAME} line before the table.  It can also be the ID of an
2472 entry, even in a different file, and the reference then refers to the first
2473 table in that entry.  REF is an absolute field or range reference as
2474 described above for example @code{@@3$3} or @code{$somename}, valid in the
2475 referenced table.
2477 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
2478 @subsection Formula syntax for Calc
2479 @cindex formula syntax, Calc
2480 @cindex syntax, of formulas
2482 A formula can be any algebraic expression understood by the Emacs
2483 @file{Calc} package.  @b{Note that @file{calc} has the
2484 non-standard convention that @samp{/} has lower precedence than
2485 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
2486 evaluation by @code{calc-eval} (@pxref{Calling Calc from
2487 Your Programs,calc-eval,Calling Calc from Your Lisp Programs,Calc,GNU
2488 Emacs Calc Manual}),
2489 @c FIXME:  The link to the Calc manual in HTML does not work.
2490 variable substitution takes place according to the rules described above.
2491 @cindex vectors, in table calculations
2492 The range vectors can be directly fed into the Calc vector functions
2493 like @samp{vmean} and @samp{vsum}.
2495 @cindex format specifier
2496 @cindex mode, for @file{calc}
2497 @vindex org-calc-default-modes
2498 A formula can contain an optional mode string after a semicolon.  This
2499 string consists of flags to influence Calc and other modes during
2500 execution.  By default, Org uses the standard Calc modes (precision
2501 12, angular units degrees, fraction and symbolic modes off).  The display
2502 format, however, has been changed to @code{(float 8)} to keep tables
2503 compact.  The default settings can be configured using the variable
2504 @code{org-calc-default-modes}.
2506 @example
2507 p20           @r{set the internal Calc calculation precision to 20 digits}
2508 n3 s3 e2 f4   @r{Normal, scientific, engineering, or fixed}
2509               @r{format of the result of Calc passed back to Org.}
2510               @r{Calc formatting is unlimited in precision as}
2511               @r{long as the Calc calculation precision is greater.}
2512 D R           @r{angle modes: degrees, radians}
2513 F S           @r{fraction and symbolic modes}
2514 N             @r{interpret all fields as numbers, use 0 for non-numbers}
2515 E             @r{keep empty fields in ranges}
2516 L             @r{literal}
2517 @end example
2519 @noindent
2520 Unless you use large integer numbers or high-precision-calculation
2521 and -display for floating point numbers you may alternatively provide a
2522 @code{printf} format specifier to reformat the Calc result after it has been
2523 passed back to Org instead of letting Calc already do the
2524 formatting@footnote{The @code{printf} reformatting is limited in precision
2525 because the value passed to it is converted into an @code{integer} or
2526 @code{double}.  The @code{integer} is limited in size by truncating the
2527 signed value to 32 bits.  The @code{double} is limited in precision to 64
2528 bits overall which leaves approximately 16 significant decimal digits.}.
2529 A few examples:
2531 @example
2532 $1+$2                @r{Sum of first and second field}
2533 $1+$2;%.2f           @r{Same, format result to two decimals}
2534 exp($2)+exp($1)      @r{Math functions can be used}
2535 $0;%.1f              @r{Reformat current cell to 1 decimal}
2536 ($3-32)*5/9          @r{Degrees F -> C conversion}
2537 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
2538 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
2539 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
2540 vmean($2..$7)        @r{Compute column range mean, using vector function}
2541 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
2542 taylor($3,x=7,2)     @r{Taylor series of $3, at x=7, second degree}
2543 @end example
2545 Calc also contains a complete set of logical operations.  For example
2547 @example
2548 if($1<20,teen,string(""))  @r{"teen" if age $1 less than 20, else empty}
2549 @end example
2551 Note that you can also use two org-specific flags @code{T} and @code{t} for
2552 durations computations @ref{Durations and time values}.
2554 @node Formula syntax for Lisp, Durations and time values, Formula syntax for Calc, The spreadsheet
2555 @subsection Emacs Lisp forms as formulas
2556 @cindex Lisp forms, as table formulas
2558 It is also possible to write a formula in Emacs Lisp; this can be useful for
2559 string manipulation and control structures, if Calc's functionality is not
2560 enough.  If a formula starts with a single-quote followed by an opening
2561 parenthesis, then it is evaluated as a Lisp form.  The evaluation should
2562 return either a string or a number.  Just as with @file{calc} formulas, you
2563 can specify modes and a printf format after a semicolon.  With Emacs Lisp
2564 forms, you need to be conscious about the way field references are
2565 interpolated into the form.  By default, a reference will be interpolated as
2566 a Lisp string (in double-quotes) containing the field.  If you provide the
2567 @samp{N} mode switch, all referenced elements will be numbers (non-number
2568 fields will be zero) and interpolated as Lisp numbers, without quotes.  If
2569 you provide the @samp{L} flag, all fields will be interpolated literally,
2570 without quotes.  I.e., if you want a reference to be interpreted as a string
2571 by the Lisp form, enclose the reference operator itself in double-quotes,
2572 like @code{"$3"}.  Ranges are inserted as space-separated fields, so you can
2573 embed them in list or vector syntax.  Here are a few examples---note how the
2574 @samp{N} mode is used when we do computations in Lisp:
2576 @example
2577 @r{Swap the first two characters of the content of column 1}
2578   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
2579 @r{Add columns 1 and 2, equivalent to Calc's @code{$1+$2}}
2580   '(+ $1 $2);N
2581 @r{Compute the sum of columns 1-4, like Calc's @code{vsum($1..$4)}}
2582   '(apply '+ '($1..$4));N
2583 @end example
2585 @node Durations and time values, Field and range formulas, Formula syntax for Lisp, The spreadsheet
2586 @subsection Durations and time values
2587 @cindex Duration, computing
2588 @cindex Time, computing
2589 @vindex org-table-duration-custom-format
2591 If you want to compute time values use the @code{T} flag, either in Calc
2592 formulas or Elisp formulas:
2594 @example
2595 @group
2596   |  Task 1 |   Task 2 |    Total |
2597   |---------+----------+----------|
2598   |    2:12 |     1:47 | 03:59:00 |
2599   | 3:02:20 | -2:07:00 |     0.92 |
2600   #+TBLFM: @@2$3=$1+$2;T::@@3$3=$1+$2;t
2601 @end group
2602 @end example
2604 Input duration values must be of the form @code{[HH:MM[:SS]}, where seconds
2605 are optional.  With the @code{T} flag, computed durations will be displayed
2606 as @code{[HH:MM:SS} (see the first formula above).  With the @code{t} flag,
2607 computed durations will be displayed according to the value of the variable
2608 @code{org-table-duration-custom-format}, which defaults to @code{'hours} and
2609 will display the result as a fraction of hours (see the second formula in the
2610 example above).
2612 Negative duration values can be manipulated as well, and integers will be
2613 considered as seconds in addition and subtraction.
2615 @node Field and range formulas, Column formulas, Durations and time values, The spreadsheet
2616 @subsection Field and range formulas
2617 @cindex field formula
2618 @cindex range formula
2619 @cindex formula, for individual table field
2620 @cindex formula, for range of fields
2622 To assign a formula to a particular field, type it directly into the field,
2623 preceded by @samp{:=}, for example @samp{:=vsum(@@II..III)}.  When you press
2624 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the field,
2625 the formula will be stored as the formula for this field, evaluated, and the
2626 current field will be replaced with the result.
2628 @cindex #+TBLFM
2629 Formulas are stored in a special line starting with @samp{#+TBLFM:} directly
2630 below the table.  If you type the equation in the 4th field of the 3rd data
2631 line in the table, the formula will look like @samp{@@3$4=$1+$2}.  When
2632 inserting/deleting/swapping column and rows with the appropriate commands,
2633 @i{absolute references} (but not relative ones) in stored formulas are
2634 modified in order to still reference the same field.  To avoid this from
2635 happening, in particular in range references, anchor ranges at the table
2636 borders (using @code{@@<}, @code{@@>}, @code{$<}, @code{$>}), or at hlines
2637 using the @code{@@I} notation.  Automatic adaptation of field references does
2638 of cause not happen if you edit the table structure with normal editing
2639 commands---then you must fix the equations yourself.
2641 Instead of typing an equation into the field, you may also use the following
2642 command
2644 @table @kbd
2645 @orgcmd{C-u C-c =,org-table-eval-formula}
2646 Install a new formula for the current field.  The command prompts for a
2647 formula with default taken from the @samp{#+TBLFM:} line, applies
2648 it to the current field, and stores it.
2649 @end table
2651 The left-hand side of a formula can also be a special expression in order to
2652 assign the formula to a number of different fields.  There is no keyboard
2653 shortcut to enter such range formulas.  To add them, use the formula editor
2654 (@pxref{Editing and debugging formulas}) or edit the @code{#+TBLFM:} line
2655 directly.
2657 @table @code
2658 @item $2=
2659 Column formula, valid for the entire column.  This is so common that Org
2660 treats these formulas in a special way, see @ref{Column formulas}.
2661 @item @@3=
2662 Row formula, applies to all fields in the specified row.  @code{@@>=} means
2663 the last row.
2664 @item @@1$2..@@4$3=
2665 Range formula, applies to all fields in the given rectangular range.  This
2666 can also be used to assign a formula to some but not all fields in a row.
2667 @item $name=
2668 Named field, see @ref{Advanced features}.
2669 @end table
2671 @node Column formulas, Editing and debugging formulas, Field and range formulas, The spreadsheet
2672 @subsection Column formulas
2673 @cindex column formula
2674 @cindex formula, for table column
2676 When you assign a formula to a simple column reference like @code{$3=}, the
2677 same formula will be used in all fields of that column, with the following
2678 very convenient exceptions: (i) If the table contains horizontal separator
2679 hlines, everything before the first such line is considered part of the table
2680 @emph{header} and will not be modified by column formulas.  (ii) Fields that
2681 already get a value from a field/range formula will be left alone by column
2682 formulas.  These conditions make column formulas very easy to use.
2684 To assign a formula to a column, type it directly into any field in the
2685 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
2686 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the field,
2687 the formula will be stored as the formula for the current column, evaluated
2688 and the current field replaced with the result.  If the field contains only
2689 @samp{=}, the previously stored formula for this column is used.  For each
2690 column, Org will only remember the most recently used formula.  In the
2691 @samp{#+TBLFM:} line, column formulas will look like @samp{$4=$1+$2}.  The
2692 left-hand side of a column formula can not be the name of column, it must be
2693 the numeric column reference or @code{$>}.
2695 Instead of typing an equation into the field, you may also use the
2696 following command:
2698 @table @kbd
2699 @orgcmd{C-c =,org-table-eval-formula}
2700 Install a new formula for the current column and replace current field with
2701 the result of the formula.  The command prompts for a formula, with default
2702 taken from the @samp{#+TBLFM} line, applies it to the current field and
2703 stores it.  With a numeric prefix argument(e.g.@: @kbd{C-5 C-c =}) the command
2704 will apply it to that many consecutive fields in the current column.
2705 @end table
2707 @node Editing and debugging formulas, Updating the table, Column formulas, The spreadsheet
2708 @subsection Editing and debugging formulas
2709 @cindex formula editing
2710 @cindex editing, of table formulas
2712 @vindex org-table-use-standard-references
2713 You can edit individual formulas in the minibuffer or directly in the
2714 field.  Org can also prepare a special buffer with all active
2715 formulas of a table.  When offering a formula for editing, Org
2716 converts references to the standard format (like @code{B3} or @code{D&})
2717 if possible.  If you prefer to only work with the internal format (like
2718 @code{@@3$2} or @code{$4}), configure the variable
2719 @code{org-table-use-standard-references}.
2721 @table @kbd
2722 @orgcmdkkc{C-c =,C-u C-c =,org-table-eval-formula}
2723 Edit the formula associated with the current column/field in the
2724 minibuffer.  See @ref{Column formulas}, and @ref{Field and range formulas}.
2725 @orgcmd{C-u C-u C-c =,org-table-eval-formula}
2726 Re-insert the active formula (either a
2727 field formula, or a column formula) into the current field, so that you
2728 can edit it directly in the field.  The advantage over editing in the
2729 minibuffer is that you can use the command @kbd{C-c ?}.
2730 @orgcmd{C-c ?,org-table-field-info}
2731 While editing a formula in a table field, highlight the field(s)
2732 referenced by the reference at the cursor position in the formula.
2733 @kindex C-c @}
2734 @findex org-table-toggle-coordinate-overlays
2735 @item C-c @}
2736 Toggle the display of row and column numbers for a table, using overlays
2737 (@command{org-table-toggle-coordinate-overlays}).  These are updated each
2738 time the table is aligned; you can force it with @kbd{C-c C-c}.
2739 @kindex C-c @{
2740 @findex org-table-toggle-formula-debugger
2741 @item C-c @{
2742 Toggle the formula debugger on and off
2743 (@command{org-table-toggle-formula-debugger}).  See below.
2744 @orgcmd{C-c ',org-table-edit-formulas}
2745 Edit all formulas for the current table in a special buffer, where the
2746 formulas will be displayed one per line.  If the current field has an
2747 active formula, the cursor in the formula editor will mark it.
2748 While inside the special buffer, Org will automatically highlight
2749 any field or range reference at the cursor position.  You may edit,
2750 remove and add formulas, and use the following commands:
2751 @table @kbd
2752 @orgcmdkkc{C-c C-c,C-x C-s,org-table-fedit-finish}
2753 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
2754 prefix, also apply the new formulas to the entire table.
2755 @orgcmd{C-c C-q,org-table-fedit-abort}
2756 Exit the formula editor without installing changes.
2757 @orgcmd{C-c C-r,org-table-fedit-toggle-ref-type}
2758 Toggle all references in the formula editor between standard (like
2759 @code{B3}) and internal (like @code{@@3$2}).
2760 @orgcmd{@key{TAB},org-table-fedit-lisp-indent}
2761 Pretty-print or indent Lisp formula at point.  When in a line containing
2762 a Lisp formula, format the formula according to Emacs Lisp rules.
2763 Another @key{TAB} collapses the formula back again.  In the open
2764 formula, @key{TAB} re-indents just like in Emacs Lisp mode.
2765 @orgcmd{M-@key{TAB},lisp-complete-symbol}
2766 Complete Lisp symbols, just like in Emacs Lisp mode.
2767 @kindex S-@key{up}
2768 @kindex S-@key{down}
2769 @kindex S-@key{left}
2770 @kindex S-@key{right}
2771 @findex org-table-fedit-ref-up
2772 @findex org-table-fedit-ref-down
2773 @findex org-table-fedit-ref-left
2774 @findex org-table-fedit-ref-right
2775 @item S-@key{up}/@key{down}/@key{left}/@key{right}
2776 Shift the reference at point.  For example, if the reference is
2777 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
2778 This also works for relative references and for hline references.
2779 @orgcmdkkcc{M-S-@key{up},M-S-@key{down},org-table-fedit-line-up,org-table-fedit-line-down}
2780 Move the test line for column formulas in the Org buffer up and
2781 down.
2782 @orgcmdkkcc{M-@key{up},M-@key{down},org-table-fedit-scroll-down,org-table-fedit-scroll-up}
2783 Scroll the window displaying the table.
2784 @kindex C-c @}
2785 @findex org-table-toggle-coordinate-overlays
2786 @item C-c @}
2787 Turn the coordinate grid in the table on and off.
2788 @end table
2789 @end table
2791 Making a table field blank does not remove the formula associated with
2792 the field, because that is stored in a different line (the @samp{#+TBLFM}
2793 line)---during the next recalculation the field will be filled again.
2794 To remove a formula from a field, you have to give an empty reply when
2795 prompted for the formula, or to edit the @samp{#+TBLFM} line.
2797 @kindex C-c C-c
2798 You may edit the @samp{#+TBLFM} directly and re-apply the changed
2799 equations with @kbd{C-c C-c} in that line or with the normal
2800 recalculation commands in the table.
2802 @subsubheading Debugging formulas
2803 @cindex formula debugging
2804 @cindex debugging, of table formulas
2805 When the evaluation of a formula leads to an error, the field content
2806 becomes the string @samp{#ERROR}.  If you would like see what is going
2807 on during variable substitution and calculation in order to find a bug,
2808 turn on formula debugging in the @code{Tbl} menu and repeat the
2809 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
2810 field.  Detailed information will be displayed.
2812 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
2813 @subsection Updating the table
2814 @cindex recomputing table fields
2815 @cindex updating, table
2817 Recalculation of a table is normally not automatic, but needs to be
2818 triggered by a command.  See @ref{Advanced features}, for a way to make
2819 recalculation at least semi-automatic.
2821 In order to recalculate a line of a table or the entire table, use the
2822 following commands:
2824 @table @kbd
2825 @orgcmd{C-c *,org-table-recalculate}
2826 Recalculate the current row by first applying the stored column formulas
2827 from left to right, and all field/range formulas in the current row.
2829 @kindex C-u C-c *
2830 @item C-u C-c *
2831 @kindex C-u C-c C-c
2832 @itemx C-u C-c C-c
2833 Recompute the entire table, line by line.  Any lines before the first
2834 hline are left alone, assuming that these are part of the table header.
2836 @orgcmdkkc{C-u C-u C-c *,C-u C-u C-c C-c,org-table-iterate}
2837 Iterate the table by recomputing it until no further changes occur.
2838 This may be necessary if some computed fields use the value of other
2839 fields that are computed @i{later} in the calculation sequence.
2840 @item M-x org-table-recalculate-buffer-tables
2841 @findex org-table-recalculate-buffer-tables
2842 Recompute all tables in the current buffer.
2843 @item M-x org-table-iterate-buffer-tables
2844 @findex org-table-iterate-buffer-tables
2845 Iterate all tables in the current buffer, in order to converge table-to-table
2846 dependencies.
2847 @end table
2849 @node Advanced features,  , Updating the table, The spreadsheet
2850 @subsection Advanced features
2852 If you want the recalculation of fields to happen automatically, or if you
2853 want to be able to assign @i{names}@footnote{Such names must start by an
2854 alphabetic character and use only alphanumeric/underscore characters.} to
2855 fields and columns, you need to reserve the first column of the table for
2856 special marking characters.
2858 @table @kbd
2859 @orgcmd{C-#,org-table-rotate-recalc-marks}
2860 Rotate the calculation mark in first column through the states @samp{ },
2861 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  When there is an active region,
2862 change all marks in the region.
2863 @end table
2865 Here is an example of a table that collects exam results of students and
2866 makes use of these features:
2868 @example
2869 @group
2870 |---+---------+--------+--------+--------+-------+------|
2871 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2872 |---+---------+--------+--------+--------+-------+------|
2873 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2874 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2875 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2876 |---+---------+--------+--------+--------+-------+------|
2877 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
2878 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
2879 |---+---------+--------+--------+--------+-------+------|
2880 |   | Average |        |        |        |  29.7 |      |
2881 | ^ |         |        |        |        |    at |      |
2882 | $ | max=50  |        |        |        |       |      |
2883 |---+---------+--------+--------+--------+-------+------|
2884 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
2885 @end group
2886 @end example
2888 @noindent @b{Important}: please note that for these special tables,
2889 recalculating the table with @kbd{C-u C-c *} will only affect rows that
2890 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
2891 to the field itself.  The column formulas are not applied in rows with
2892 empty first field.
2894 @cindex marking characters, tables
2895 The marking characters have the following meaning:
2896 @table @samp
2897 @item !
2898 The fields in this line define names for the columns, so that you may
2899 refer to a column as @samp{$Tot} instead of @samp{$6}.
2900 @item ^
2901 This row defines names for the fields @emph{above} the row.  With such
2902 a definition, any formula in the table may use @samp{$m1} to refer to
2903 the value @samp{10}.  Also, if you assign a formula to a names field, it
2904 will be stored as @samp{$name=...}.
2905 @item _
2906 Similar to @samp{^}, but defines names for the fields in the row
2907 @emph{below}.
2908 @item $
2909 Fields in this row can define @emph{parameters} for formulas.  For
2910 example, if a field in a @samp{$} row contains @samp{max=50}, then
2911 formulas in this table can refer to the value 50 using @samp{$max}.
2912 Parameters work exactly like constants, only that they can be defined on
2913 a per-table basis.
2914 @item #
2915 Fields in this row are automatically recalculated when pressing
2916 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
2917 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
2918 lines will be left alone by this command.
2919 @item *
2920 Selects this line for global recalculation with @kbd{C-u C-c *}, but
2921 not for automatic recalculation.  Use this when automatic
2922 recalculation slows down editing too much.
2923 @item
2924 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
2925 All lines that should be recalculated should be marked with @samp{#}
2926 or @samp{*}.
2927 @item /
2928 Do not export this line.  Useful for lines that contain the narrowing
2929 @samp{<N>} markers or column group markers.
2930 @end table
2932 Finally, just to whet your appetite for what can be done with the
2933 fantastic @file{calc.el} package, here is a table that computes the Taylor
2934 series of degree @code{n} at location @code{x} for a couple of
2935 functions.
2937 @example
2938 @group
2939 |---+-------------+---+-----+--------------------------------------|
2940 |   | Func        | n | x   | Result                               |
2941 |---+-------------+---+-----+--------------------------------------|
2942 | # | exp(x)      | 1 | x   | 1 + x                                |
2943 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
2944 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
2945 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
2946 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
2947 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
2948 |---+-------------+---+-----+--------------------------------------|
2949 #+TBLFM: $5=taylor($2,$4,$3);n3
2950 @end group
2951 @end example
2953 @node Org-Plot,  , The spreadsheet, Tables
2954 @section Org-Plot
2955 @cindex graph, in tables
2956 @cindex plot tables using Gnuplot
2957 @cindex #+PLOT
2959 Org-Plot can produce 2D and 3D graphs of information stored in org tables
2960 using @file{Gnuplot} @uref{http://www.gnuplot.info/} and @file{gnuplot-mode}
2961 @uref{http://cars9.uchicago.edu/~ravel/software/gnuplot-mode.html}.  To see
2962 this in action, ensure that you have both Gnuplot and Gnuplot mode installed
2963 on your system, then call @code{org-plot/gnuplot} on the following table.
2965 @example
2966 @group
2967 #+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
2968 | Sede      | Max cites | H-index |
2969 |-----------+-----------+---------|
2970 | Chile     |    257.72 |   21.39 |
2971 | Leeds     |    165.77 |   19.68 |
2972 | Sao Paolo |     71.00 |   11.50 |
2973 | Stockholm |    134.19 |   14.33 |
2974 | Morelia   |    257.56 |   17.67 |
2975 @end group
2976 @end example
2978 Notice that Org Plot is smart enough to apply the table's headers as labels.
2979 Further control over the labels, type, content, and appearance of plots can
2980 be exercised through the @code{#+PLOT:} lines preceding a table.  See below
2981 for a complete list of Org-plot options.  For more information and examples
2982 see the Org-plot tutorial at
2983 @uref{http://orgmode.org/worg/org-tutorials/org-plot.html}.
2985 @subsubheading Plot Options
2987 @table @code
2988 @item set
2989 Specify any @command{gnuplot} option to be set when graphing.
2991 @item title
2992 Specify the title of the plot.
2994 @item ind
2995 Specify which column of the table to use as the @code{x} axis.
2997 @item deps
2998 Specify the columns to graph as a Lisp style list, surrounded by parentheses
2999 and separated by spaces for example @code{dep:(3 4)} to graph the third and
3000 fourth columns (defaults to graphing all other columns aside from the @code{ind}
3001 column).
3003 @item type
3004 Specify whether the plot will be @code{2d}, @code{3d}, or @code{grid}.
3006 @item with
3007 Specify a @code{with} option to be inserted for every col being plotted
3008 (e.g.@: @code{lines}, @code{points}, @code{boxes}, @code{impulses}, etc...).
3009 Defaults to @code{lines}.
3011 @item file
3012 If you want to plot to a file, specify @code{"@var{path/to/desired/output-file}"}.
3014 @item labels
3015 List of labels to be used for the @code{deps} (defaults to the column headers
3016 if they exist).
3018 @item line
3019 Specify an entire line to be inserted in the Gnuplot script.
3021 @item map
3022 When plotting @code{3d} or @code{grid} types, set this to @code{t} to graph a
3023 flat mapping rather than a @code{3d} slope.
3025 @item timefmt
3026 Specify format of Org-mode timestamps as they will be parsed by Gnuplot.
3027 Defaults to @samp{%Y-%m-%d-%H:%M:%S}.
3029 @item script
3030 If you want total control, you can specify a script file (place the file name
3031 between double-quotes) which will be used to plot.  Before plotting, every
3032 instance of @code{$datafile} in the specified script will be replaced with
3033 the path to the generated data file.  Note: even if you set this option, you
3034 may still want to specify the plot type, as that can impact the content of
3035 the data file.
3036 @end table
3038 @node Hyperlinks, TODO Items, Tables, Top
3039 @chapter Hyperlinks
3040 @cindex hyperlinks
3042 Like HTML, Org provides links inside a file, external links to
3043 other files, Usenet articles, emails, and much more.
3045 @menu
3046 * Link format::                 How links in Org are formatted
3047 * Internal links::              Links to other places in the current file
3048 * External links::              URL-like links to the world
3049 * Handling links::              Creating, inserting and following
3050 * Using links outside Org::     Linking from my C source code?
3051 * Link abbreviations::          Shortcuts for writing complex links
3052 * Search options::              Linking to a specific location
3053 * Custom searches::             When the default search is not enough
3054 @end menu
3056 @node Link format, Internal links, Hyperlinks, Hyperlinks
3057 @section Link format
3058 @cindex link format
3059 @cindex format, of links
3061 Org will recognize plain URL-like links and activate them as
3062 clickable links.  The general link format, however, looks like this:
3064 @example
3065 [[link][description]]       @r{or alternatively}           [[link]]
3066 @end example
3068 @noindent
3069 Once a link in the buffer is complete (all brackets present), Org
3070 will change the display so that @samp{description} is displayed instead
3071 of @samp{[[link][description]]} and @samp{link} is displayed instead of
3072 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
3073 which by default is an underlined face.  You can directly edit the
3074 visible part of a link.  Note that this can be either the @samp{link}
3075 part (if there is no description) or the @samp{description} part.  To
3076 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
3077 cursor on the link.
3079 If you place the cursor at the beginning or just behind the end of the
3080 displayed text and press @key{BACKSPACE}, you will remove the
3081 (invisible) bracket at that location.  This makes the link incomplete
3082 and the internals are again displayed as plain text.  Inserting the
3083 missing bracket hides the link internals again.  To show the
3084 internal structure of all links, use the menu entry
3085 @code{Org->Hyperlinks->Literal links}.
3087 @node Internal links, External links, Link format, Hyperlinks
3088 @section Internal links
3089 @cindex internal links
3090 @cindex links, internal
3091 @cindex targets, for links
3093 @cindex property, CUSTOM_ID
3094 If the link does not look like a URL, it is considered to be internal in the
3095 current file.  The most important case is a link like
3096 @samp{[[#my-custom-id]]} which will link to the entry with the
3097 @code{CUSTOM_ID} property @samp{my-custom-id}.  Such custom IDs are very good
3098 for HTML export (@pxref{HTML export}) where they produce pretty section
3099 links.  You are responsible yourself to make sure these custom IDs are unique
3100 in a file.
3102 Links such as @samp{[[My Target]]} or @samp{[[My Target][Find my target]]}
3103 lead to a text search in the current file.
3105 The link can be followed with @kbd{C-c C-o} when the cursor is on the link,
3106 or with a mouse click (@pxref{Handling links}).  Links to custom IDs will
3107 point to the corresponding headline.  The preferred match for a text link is
3108 a @i{dedicated target}: the same string in double angular brackets.  Targets
3109 may be located anywhere; sometimes it is convenient to put them into a
3110 comment line.  For example
3112 @example
3113 # <<My Target>>
3114 @end example
3116 @noindent In HTML export (@pxref{HTML export}), such targets will become
3117 named anchors for direct access through @samp{http} links@footnote{Note that
3118 text before the first headline is usually not exported, so the first such
3119 target should be after the first headline, or in the line directly before the
3120 first headline.}.
3122 If no dedicated target exists, Org will search for a headline that is exactly
3123 the link text but may also include a TODO keyword and tags@footnote{To insert
3124 a link targeting a headline, in-buffer completion can be used.  Just type a
3125 star followed by a few optional letters into the buffer and press
3126 @kbd{M-@key{TAB}}.  All headlines in the current buffer will be offered as
3127 completions.}.  In non-Org files, the search will look for the words in the
3128 link text.  In the above example the search would be for @samp{my target}.
3130 Following a link pushes a mark onto Org's own mark ring.  You can
3131 return to the previous position with @kbd{C-c &}.  Using this command
3132 several times in direct succession goes back to positions recorded
3133 earlier.
3135 @menu
3136 * Radio targets::               Make targets trigger links in plain text
3137 @end menu
3139 @node Radio targets,  , Internal links, Internal links
3140 @subsection Radio targets
3141 @cindex radio targets
3142 @cindex targets, radio
3143 @cindex links, radio targets
3145 Org can automatically turn any occurrences of certain target names
3146 in normal text into a link.  So without explicitly creating a link, the
3147 text connects to the target radioing its position.  Radio targets are
3148 enclosed by triple angular brackets.  For example, a target @samp{<<<My
3149 Target>>>} causes each occurrence of @samp{my target} in normal text to
3150 become activated as a link.  The Org file is scanned automatically
3151 for radio targets only when the file is first loaded into Emacs.  To
3152 update the target list during editing, press @kbd{C-c C-c} with the
3153 cursor on or at a target.
3155 @node External links, Handling links, Internal links, Hyperlinks
3156 @section External links
3157 @cindex links, external
3158 @cindex external links
3159 @cindex links, external
3160 @cindex Gnus links
3161 @cindex BBDB links
3162 @cindex IRC links
3163 @cindex URL links
3164 @cindex file links
3165 @cindex VM links
3166 @cindex RMAIL links
3167 @cindex WANDERLUST links
3168 @cindex MH-E links
3169 @cindex USENET links
3170 @cindex SHELL links
3171 @cindex Info links
3172 @cindex Elisp links
3174 Org supports links to files, websites, Usenet and email messages,
3175 BBDB database entries and links to both IRC conversations and their
3176 logs.  External links are URL-like locators.  They start with a short
3177 identifying string followed by a colon.  There can be no space after
3178 the colon.  The following list shows examples for each link type.
3180 @example
3181 http://www.astro.uva.nl/~dominik          @r{on the web}
3182 doi:10.1000/182                           @r{DOI for an electronic resource}
3183 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
3184 /home/dominik/images/jupiter.jpg          @r{same as above}
3185 file:papers/last.pdf                      @r{file, relative path}
3186 ./papers/last.pdf                         @r{same as above}
3187 file:/myself@@some.where:papers/last.pdf   @r{file, path on remote machine}
3188 /myself@@some.where:papers/last.pdf        @r{same as above}
3189 file:sometextfile::NNN                    @r{file with line number to jump to}
3190 file:projects.org                         @r{another Org file}
3191 file:projects.org::some words             @r{text search in Org file}@footnote{
3192 The actual behavior of the search will depend on the value of
3193 the variable @code{org-link-search-must-match-exact-headline}.  If its value
3194 is nil, then a fuzzy text search will be done.  If it is t, then only the
3195 exact headline will be matched.  If the value is @code{'query-to-create},
3196 then an exact headline will be searched; if it is not found, then the user
3197 will be queried to create it.}
3198 file:projects.org::*task title            @r{heading search in Org file}
3199 docview:papers/last.pdf::NNN              @r{open file in doc-view mode at page NNN}
3200 id:B7423F4D-2E8A-471B-8810-C40F074717E9   @r{Link to heading by ID}
3201 news:comp.emacs                           @r{Usenet link}
3202 mailto:adent@@galaxy.net                   @r{Mail link}
3203 vm:folder                                 @r{VM folder link}
3204 vm:folder#id                              @r{VM message link}
3205 vm://myself@@some.where.org/folder#id      @r{VM on remote machine}
3206 wl:folder                                 @r{WANDERLUST folder link}
3207 wl:folder#id                              @r{WANDERLUST message link}
3208 mhe:folder                                @r{MH-E folder link}
3209 mhe:folder#id                             @r{MH-E message link}
3210 rmail:folder                              @r{RMAIL folder link}
3211 rmail:folder#id                           @r{RMAIL message link}
3212 gnus:group                                @r{Gnus group link}
3213 gnus:group#id                             @r{Gnus article link}
3214 bbdb:R.*Stallman                          @r{BBDB link (with regexp)}
3215 irc:/irc.com/#emacs/bob                   @r{IRC link}
3216 info:org#External links                   @r{Info node link}
3217 shell:ls *.org                            @r{A shell command}
3218 elisp:org-agenda                          @r{Interactive Elisp command}
3219 elisp:(find-file-other-frame "Elisp.org") @r{Elisp form to evaluate}
3220 @end example
3222 For customizing Org to add new link types @ref{Adding hyperlink types}.
3224 A link should be enclosed in double brackets and may contain a
3225 descriptive text to be displayed instead of the URL (@pxref{Link
3226 format}), for example:
3228 @example
3229 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
3230 @end example
3232 @noindent
3233 If the description is a file name or URL that points to an image, HTML
3234 export (@pxref{HTML export}) will inline the image as a clickable
3235 button.  If there is no description at all and the link points to an
3236 image,
3237 that image will be inlined into the exported HTML file.
3239 @cindex square brackets, around links
3240 @cindex plain text external links
3241 Org also finds external links in the normal text and activates them
3242 as links.  If spaces must be part of the link (for example in
3243 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
3244 about the end of the link, enclose them in square brackets.
3246 @node Handling links, Using links outside Org, External links, Hyperlinks
3247 @section Handling links
3248 @cindex links, handling
3250 Org provides methods to create a link in the correct syntax, to
3251 insert it into an Org file, and to follow the link.
3253 @table @kbd
3254 @orgcmd{C-c l,org-store-link}
3255 @cindex storing links
3256 Store a link to the current location.  This is a @emph{global} command (you
3257 must create the key binding yourself) which can be used in any buffer to
3258 create a link.  The link will be stored for later insertion into an Org
3259 buffer (see below).  What kind of link will be created depends on the current
3260 buffer:
3262 @b{Org-mode buffers}@*
3263 For Org files, if there is a @samp{<<target>>} at the cursor, the link points
3264 to the target.  Otherwise it points to the current headline, which will also
3265 be the description@footnote{If the headline contains a timestamp, it will be
3266 removed from the link and result in a wrong link -- you should avoid putting
3267 timestamp in the headline.}.
3269 @vindex org-link-to-org-use-id
3270 @cindex property, CUSTOM_ID
3271 @cindex property, ID
3272 If the headline has a @code{CUSTOM_ID} property, a link to this custom ID
3273 will be stored.  In addition or alternatively (depending on the value of
3274 @code{org-link-to-org-use-id}), a globally unique @code{ID} property will be
3275 created and/or used to construct a link.  So using this command in Org
3276 buffers will potentially create two links: a human-readable from the custom
3277 ID, and one that is globally unique and works even if the entry is moved from
3278 file to file.  Later, when inserting the link, you need to decide which one
3279 to use.
3281 @b{Email/News clients: VM, Rmail, Wanderlust, MH-E, Gnus}@*
3282 Pretty much all Emacs mail clients are supported.  The link will point to the
3283 current article, or, in some GNUS buffers, to the group.  The description is
3284 constructed from the author and the subject.
3286 @b{Web browsers: W3 and W3M}@*
3287 Here the link will be the current URL, with the page title as description.
3289 @b{Contacts: BBDB}@*
3290 Links created in a BBDB buffer will point to the current entry.
3292 @b{Chat: IRC}@*
3293 @vindex org-irc-link-to-logs
3294 For IRC links, if you set the variable @code{org-irc-link-to-logs} to
3295 @code{t}, a @samp{file:/} style link to the relevant point in the logs for
3296 the current conversation is created.  Otherwise an @samp{irc:/} style link to
3297 the user/channel/server under the point will be stored.
3299 @b{Other files}@*
3300 For any other files, the link will point to the file, with a search string
3301 (@pxref{Search options}) pointing to the contents of the current line.  If
3302 there is an active region, the selected words will form the basis of the
3303 search string.  If the automatically created link is not working correctly or
3304 accurately enough, you can write custom functions to select the search string
3305 and to do the search for particular file types---see @ref{Custom searches}.
3306 The key binding @kbd{C-c l} is only a suggestion---see @ref{Installation}.
3308 @b{Agenda view}@*
3309 When the cursor is in an agenda view, the created link points to the
3310 entry referenced by the current line.
3313 @orgcmd{C-c C-l,org-insert-link}
3314 @cindex link completion
3315 @cindex completion, of links
3316 @cindex inserting links
3317 @vindex org-keep-stored-link-after-insertion
3318 Insert a link@footnote{ Note that you don't have to use this command to
3319 insert a link.  Links in Org are plain text, and you can type or paste them
3320 straight into the buffer.  By using this command, the links are automatically
3321 enclosed in double brackets, and you will be asked for the optional
3322 descriptive text.}.  This prompts for a link to be inserted into the buffer.
3323 You can just type a link, using text for an internal link, or one of the link
3324 type prefixes mentioned in the examples above.  The link will be inserted
3325 into the buffer@footnote{After insertion of a stored link, the link will be
3326 removed from the list of stored links.  To keep it in the list later use, use
3327 a triple @kbd{C-u} prefix argument to @kbd{C-c C-l}, or configure the option
3328 @code{org-keep-stored-link-after-insertion}.}, along with a descriptive text.
3329 If some text was selected when this command is called, the selected text
3330 becomes the default description.
3332 @b{Inserting stored links}@*
3333 All links stored during the
3334 current session are part of the history for this prompt, so you can access
3335 them with @key{up} and @key{down} (or @kbd{M-p/n}).
3337 @b{Completion support}@* Completion with @key{TAB} will help you to insert
3338 valid link prefixes like @samp{http:} or @samp{ftp:}, including the prefixes
3339 defined through link abbreviations (@pxref{Link abbreviations}).  If you
3340 press @key{RET} after inserting only the @var{prefix}, Org will offer
3341 specific completion support for some link types@footnote{This works by
3342 calling a special function @code{org-PREFIX-complete-link}.}  For
3343 example, if you type @kbd{file @key{RET}}, file name completion (alternative
3344 access: @kbd{C-u C-c C-l}, see below) will be offered, and after @kbd{bbdb
3345 @key{RET}} you can complete contact names.
3346 @orgkey C-u C-c C-l
3347 @cindex file name completion
3348 @cindex completion, of file names
3349 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
3350 a file will be inserted and you may use file name completion to select
3351 the name of the file.  The path to the file is inserted relative to the
3352 directory of the current Org file, if the linked file is in the current
3353 directory or in a sub-directory of it, or if the path is written relative
3354 to the current directory using @samp{../}.  Otherwise an absolute path
3355 is used, if possible with @samp{~/} for your home directory.  You can
3356 force an absolute path with two @kbd{C-u} prefixes.
3358 @item C-c C-l @ @r{(with cursor on existing link)}
3359 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
3360 link and description parts of the link.
3362 @cindex following links
3363 @orgcmd{C-c C-o,org-open-at-point}
3364 @vindex org-file-apps
3365 @vindex org-link-frame-setup
3366 Open link at point.  This will launch a web browser for URLs (using
3367 @command{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB for
3368 the corresponding links, and execute the command in a shell link.  When the
3369 cursor is on an internal link, this command runs the corresponding search.
3370 When the cursor is on a TAG list in a headline, it creates the corresponding
3371 TAGS view.  If the cursor is on a timestamp, it compiles the agenda for that
3372 date.  Furthermore, it will visit text and remote files in @samp{file:} links
3373 with Emacs and select a suitable application for local non-text files.
3374 Classification of files is based on file extension only.  See option
3375 @code{org-file-apps}.  If you want to override the default application and
3376 visit the file with Emacs, use a @kbd{C-u} prefix.  If you want to avoid
3377 opening in Emacs, use a @kbd{C-u C-u} prefix.@*
3378 If the cursor is on a headline, but not on a link, offer all links in the
3379 headline and entry text.  If you want to setup the frame configuration for
3380 following links, customize @code{org-link-frame-setup}.
3382 @orgkey @key{RET}
3383 @vindex org-return-follows-link
3384 When @code{org-return-follows-link} is set, @kbd{@key{RET}} will also follow
3385 the link at point.
3387 @kindex mouse-2
3388 @kindex mouse-1
3389 @item mouse-2
3390 @itemx mouse-1
3391 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
3392 would.  Under Emacs 22 and later, @kbd{mouse-1} will also follow a link.
3394 @kindex mouse-3
3395 @item mouse-3
3396 @vindex org-display-internal-link-with-indirect-buffer
3397 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
3398 internal links to be displayed in another window@footnote{See the
3399 variable @code{org-display-internal-link-with-indirect-buffer}}.
3401 @orgcmd{C-c C-x C-v,org-toggle-inline-images}
3402 @cindex inlining images
3403 @cindex images, inlining
3404 @vindex org-startup-with-inline-images
3405 @cindex @code{inlineimages}, STARTUP keyword
3406 @cindex @code{noinlineimages}, STARTUP keyword
3407 Toggle the inline display of linked images.  Normally this will only inline
3408 images that have no description part in the link, i.e.@: images that will also
3409 be inlined during export.  When called with a prefix argument, also display
3410 images that do have a link description.  You can ask for inline images to be
3411 displayed at startup by configuring the variable
3412 @code{org-startup-with-inline-images}@footnote{with corresponding
3413 @code{#+STARTUP} keywords @code{inlineimages} and @code{inlineimages}}.
3414 @orgcmd{C-c %,org-mark-ring-push}
3415 @cindex mark ring
3416 Push the current position onto the mark ring, to be able to return
3417 easily.  Commands following an internal link do this automatically.
3419 @orgcmd{C-c &,org-mark-ring-goto}
3420 @cindex links, returning to
3421 Jump back to a recorded position.  A position is recorded by the
3422 commands following internal links, and by @kbd{C-c %}.  Using this
3423 command several times in direct succession moves through a ring of
3424 previously recorded positions.
3426 @orgcmdkkcc{C-c C-x C-n,C-c C-x C-p,org-next-link,org-previous-link}
3427 @cindex links, finding next/previous
3428 Move forward/backward to the next link in the buffer.  At the limit of
3429 the buffer, the search fails once, and then wraps around.  The key
3430 bindings for this are really too long; you might want to bind this also
3431 to @kbd{C-n} and @kbd{C-p}
3432 @lisp
3433 (add-hook 'org-load-hook
3434   (lambda ()
3435     (define-key org-mode-map "\C-n" 'org-next-link)
3436     (define-key org-mode-map "\C-p" 'org-previous-link)))
3437 @end lisp
3438 @end table
3440 @node Using links outside Org, Link abbreviations, Handling links, Hyperlinks
3441 @section Using links outside Org
3443 You can insert and follow links that have Org syntax not only in
3444 Org, but in any Emacs buffer.  For this, you should create two
3445 global commands, like this (please select suitable global keys
3446 yourself):
3448 @lisp
3449 (global-set-key "\C-c L" 'org-insert-link-global)
3450 (global-set-key "\C-c o" 'org-open-at-point-global)
3451 @end lisp
3453 @node Link abbreviations, Search options, Using links outside Org, Hyperlinks
3454 @section Link abbreviations
3455 @cindex link abbreviations
3456 @cindex abbreviation, links
3458 Long URLs can be cumbersome to type, and often many similar links are
3459 needed in a document.  For this you can use link abbreviations.  An
3460 abbreviated link looks like this
3462 @example
3463 [[linkword:tag][description]]
3464 @end example
3466 @noindent
3467 @vindex org-link-abbrev-alist
3468 where the tag is optional.
3469 The @i{linkword} must be a word, starting with a letter, followed by
3470 letters, numbers, @samp{-}, and @samp{_}.  Abbreviations are resolved
3471 according to the information in the variable @code{org-link-abbrev-alist}
3472 that relates the linkwords to replacement text.  Here is an example:
3474 @smalllisp
3475 @group
3476 (setq org-link-abbrev-alist
3477   '(("bugzilla" . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
3478     ("google"   . "http://www.google.com/search?q=")
3479     ("gmap"     . "http://maps.google.com/maps?q=%s")
3480     ("omap"     . "http://nominatim.openstreetmap.org/search?q=%s&polygon=1")
3481     ("ads"      . "http://adsabs.harvard.edu/cgi-bin/nph-abs_connect?author=%s&db_key=AST")))
3482 @end group
3483 @end smalllisp
3485 If the replacement text contains the string @samp{%s}, it will be
3486 replaced with the tag.  Otherwise the tag will be appended to the string
3487 in order to create the link.  You may also specify a function that will
3488 be called with the tag as the only argument to create the link.
3490 With the above setting, you could link to a specific bug with
3491 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
3492 @code{[[google:OrgMode]]}, show the map location of the Free Software
3493 Foundation @code{[[gmap:51 Franklin Street, Boston]]} or of Carsten office
3494 @code{[[omap:Science Park 904, Amsterdam, The Netherlands]]} and find out
3495 what the Org author is doing besides Emacs hacking with
3496 @code{[[ads:Dominik,C]]}.
3498 If you need special abbreviations just for a single Org buffer, you
3499 can define them in the file with
3501 @cindex #+LINK
3502 @example
3503 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
3504 #+LINK: google    http://www.google.com/search?q=%s
3505 @end example
3507 @noindent
3508 In-buffer completion (@pxref{Completion}) can be used after @samp{[} to
3509 complete link abbreviations.  You may also define a function
3510 @code{org-PREFIX-complete-link} that implements special (e.g.@: completion)
3511 support for inserting such a link with @kbd{C-c C-l}.  Such a function should
3512 not accept any arguments, and return the full link with prefix.
3514 @node Search options, Custom searches, Link abbreviations, Hyperlinks
3515 @section Search options in file links
3516 @cindex search option in file links
3517 @cindex file links, searching
3519 File links can contain additional information to make Emacs jump to a
3520 particular location in the file when following a link.  This can be a
3521 line number or a search option after a double@footnote{For backward
3522 compatibility, line numbers can also follow a single colon.} colon.  For
3523 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
3524 links}) to a file, it encodes the words in the current line as a search
3525 string that can be used to find this line back later when following the
3526 link with @kbd{C-c C-o}.
3528 Here is the syntax of the different ways to attach a search to a file
3529 link, together with an explanation:
3531 @example
3532 [[file:~/code/main.c::255]]
3533 [[file:~/xx.org::My Target]]
3534 [[file:~/xx.org::*My Target]]
3535 [[file:~/xx.org::#my-custom-id]]
3536 [[file:~/xx.org::/regexp/]]
3537 @end example
3539 @table @code
3540 @item 255
3541 Jump to line 255.
3542 @item My Target
3543 Search for a link target @samp{<<My Target>>}, or do a text search for
3544 @samp{my target}, similar to the search in internal links, see
3545 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
3546 link will become an HTML reference to the corresponding named anchor in
3547 the linked file.
3548 @item *My Target
3549 In an Org file, restrict search to headlines.
3550 @item #my-custom-id
3551 Link to a heading with a @code{CUSTOM_ID} property
3552 @item /regexp/
3553 Do a regular expression search for @code{regexp}.  This uses the Emacs
3554 command @code{occur} to list all matches in a separate window.  If the
3555 target file is in Org-mode, @code{org-occur} is used to create a
3556 sparse tree with the matches.
3557 @c If the target file is a directory,
3558 @c @code{grep} will be used to search all files in the directory.
3559 @end table
3561 As a degenerate case, a file link with an empty file name can be used
3562 to search the current file.  For example, @code{[[file:::find me]]} does
3563 a search for @samp{find me} in the current file, just as
3564 @samp{[[find me]]} would.
3566 @node Custom searches,  , Search options, Hyperlinks
3567 @section Custom Searches
3568 @cindex custom search strings
3569 @cindex search strings, custom
3571 The default mechanism for creating search strings and for doing the
3572 actual search related to a file link may not work correctly in all
3573 cases.  For example, Bib@TeX{} database files have many entries like
3574 @samp{year="1993"} which would not result in good search strings,
3575 because the only unique identification for a Bib@TeX{} entry is the
3576 citation key.
3578 @vindex org-create-file-search-functions
3579 @vindex org-execute-file-search-functions
3580 If you come across such a problem, you can write custom functions to set
3581 the right search string for a particular file type, and to do the search
3582 for the string in the file.  Using @code{add-hook}, these functions need
3583 to be added to the hook variables
3584 @code{org-create-file-search-functions} and
3585 @code{org-execute-file-search-functions}.  See the docstring for these
3586 variables for more information.  Org actually uses this mechanism
3587 for Bib@TeX{} database files, and you can use the corresponding code as
3588 an implementation example.  See the file @file{org-bibtex.el}.
3590 @node TODO Items, Tags, Hyperlinks, Top
3591 @chapter TODO items
3592 @cindex TODO items
3594 Org-mode does not maintain TODO lists as separate documents@footnote{Of
3595 course, you can make a document that contains only long lists of TODO items,
3596 but this is not required.}.  Instead, TODO items are an integral part of the
3597 notes file, because TODO items usually come up while taking notes!  With Org
3598 mode, simply mark any entry in a tree as being a TODO item.  In this way,
3599 information is not duplicated, and the entire context from which the TODO
3600 item emerged is always present.
3602 Of course, this technique for managing TODO items scatters them
3603 throughout your notes file.  Org-mode compensates for this by providing
3604 methods to give you an overview of all the things that you have to do.
3606 @menu
3607 * TODO basics::                 Marking and displaying TODO entries
3608 * TODO extensions::             Workflow and assignments
3609 * Progress logging::            Dates and notes for progress
3610 * Priorities::                  Some things are more important than others
3611 * Breaking down tasks::         Splitting a task into manageable pieces
3612 * Checkboxes::                  Tick-off lists
3613 @end menu
3615 @node TODO basics, TODO extensions, TODO Items, TODO Items
3616 @section Basic TODO functionality
3618 Any headline becomes a TODO item when it starts with the word
3619 @samp{TODO}, for example:
3621 @example
3622 *** TODO Write letter to Sam Fortune
3623 @end example
3625 @noindent
3626 The most important commands to work with TODO entries are:
3628 @table @kbd
3629 @orgcmd{C-c C-t,org-todo}
3630 @cindex cycling, of TODO states
3631 Rotate the TODO state of the current item among
3633 @example
3634 ,-> (unmarked) -> TODO -> DONE --.
3635 '--------------------------------'
3636 @end example
3638 The same rotation can also be done ``remotely'' from the timeline and
3639 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
3641 @orgkey{C-u C-c C-t}
3642 Select a specific keyword using completion or (if it has been set up)
3643 the fast selection interface.  For the latter, you need to assign keys
3644 to TODO states, see @ref{Per-file keywords}, and @ref{Setting tags}, for
3645 more information.
3647 @kindex S-@key{right}
3648 @kindex S-@key{left}
3649 @item S-@key{right} @ @r{/} @ S-@key{left}
3650 @vindex org-treat-S-cursor-todo-selection-as-state-change
3651 Select the following/preceding TODO state, similar to cycling.  Useful
3652 mostly if more than two TODO states are possible (@pxref{TODO
3653 extensions}).  See also @ref{Conflicts}, for a discussion of the interaction
3654 with @code{shift-selection-mode}.  See also the variable
3655 @code{org-treat-S-cursor-todo-selection-as-state-change}.
3656 @orgcmd{C-c / t,org-show-todo-key}
3657 @cindex sparse tree, for TODO
3658 @vindex org-todo-keywords
3659 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds the
3660 entire buffer, but shows all TODO items (with not-DONE state) and the
3661 headings hierarchy above them.  With a prefix argument (or by using @kbd{C-c
3662 / T}), search for a specific TODO.  You will be prompted for the keyword, and
3663 you can also give a list of keywords like @code{KWD1|KWD2|...} to list
3664 entries that match any one of these keywords.  With a numeric prefix argument
3665 N, show the tree for the Nth keyword in the variable
3666 @code{org-todo-keywords}.  With two prefix arguments, find all TODO states,
3667 both un-done and done.
3668 @orgcmd{C-c a t,org-todo-list}
3669 Show the global TODO list.  Collects the TODO items (with not-DONE states)
3670 from all agenda files (@pxref{Agenda Views}) into a single buffer.  The new
3671 buffer will be in @code{agenda-mode}, which provides commands to examine and
3672 manipulate the TODO entries from the new buffer (@pxref{Agenda commands}).
3673 @xref{Global TODO list}, for more information.
3674 @orgcmd{S-M-@key{RET},org-insert-todo-heading}
3675 Insert a new TODO entry below the current one.
3676 @end table
3678 @noindent
3679 @vindex org-todo-state-tags-triggers
3680 Changing a TODO state can also trigger tag changes.  See the docstring of the
3681 option @code{org-todo-state-tags-triggers} for details.
3683 @node TODO extensions, Progress logging, TODO basics, TODO Items
3684 @section Extended use of TODO keywords
3685 @cindex extended TODO keywords
3687 @vindex org-todo-keywords
3688 By default, marked TODO entries have one of only two states: TODO and
3689 DONE.  Org-mode allows you to classify TODO items in more complex ways
3690 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With
3691 special setup, the TODO keyword system can work differently in different
3692 files.
3694 Note that @i{tags} are another way to classify headlines in general and
3695 TODO items in particular (@pxref{Tags}).
3697 @menu
3698 * Workflow states::             From TODO to DONE in steps
3699 * TODO types::                  I do this, Fred does the rest
3700 * Multiple sets in one file::   Mixing it all, and still finding your way
3701 * Fast access to TODO states::  Single letter selection of a state
3702 * Per-file keywords::           Different files, different requirements
3703 * Faces for TODO keywords::     Highlighting states
3704 * TODO dependencies::           When one task needs to wait for others
3705 @end menu
3707 @node Workflow states, TODO types, TODO extensions, TODO extensions
3708 @subsection TODO keywords as workflow states
3709 @cindex TODO workflow
3710 @cindex workflow states as TODO keywords
3712 You can use TODO keywords to indicate different @emph{sequential} states
3713 in the process of working on an item, for example@footnote{Changing
3714 this variable only becomes effective after restarting Org-mode in a
3715 buffer.}:
3717 @lisp
3718 (setq org-todo-keywords
3719   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
3720 @end lisp
3722 The vertical bar separates the TODO keywords (states that @emph{need
3723 action}) from the DONE states (which need @emph{no further action}).  If
3724 you don't provide the separator bar, the last state is used as the DONE
3725 state.
3726 @cindex completion, of TODO keywords
3727 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
3728 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED.  You may
3729 also use a numeric prefix argument to quickly select a specific state.  For
3730 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY.
3731 Or you can use @kbd{S-@key{left}} to go backward through the sequence.  If you
3732 define many keywords, you can use in-buffer completion
3733 (@pxref{Completion}) or even a special one-key selection scheme
3734 (@pxref{Fast access to TODO states}) to insert these words into the
3735 buffer.  Changing a TODO state can be logged with a timestamp, see
3736 @ref{Tracking TODO state changes}, for more information.
3738 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
3739 @subsection TODO keywords as types
3740 @cindex TODO types
3741 @cindex names as TODO keywords
3742 @cindex types as TODO keywords
3744 The second possibility is to use TODO keywords to indicate different
3745 @emph{types} of action items.  For example, you might want to indicate
3746 that items are for ``work'' or ``home''.  Or, when you work with several
3747 people on a single project, you might want to assign action items
3748 directly to persons, by using their names as TODO keywords.  This would
3749 be set up like this:
3751 @lisp
3752 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
3753 @end lisp
3755 In this case, different keywords do not indicate a sequence, but rather
3756 different types.  So the normal work flow would be to assign a task to a
3757 person, and later to mark it DONE.  Org-mode supports this style by adapting
3758 the workings of the command @kbd{C-c C-t}@footnote{This is also true for the
3759 @kbd{t} command in the timeline and agenda buffers.}.  When used several
3760 times in succession, it will still cycle through all names, in order to first
3761 select the right type for a task.  But when you return to the item after some
3762 time and execute @kbd{C-c C-t} again, it will switch from any name directly
3763 to DONE.  Use prefix arguments or completion to quickly select a specific
3764 name.  You can also review the items of a specific TODO type in a sparse tree
3765 by using a numeric prefix to @kbd{C-c / t}.  For example, to see all things
3766 Lucy has to do, you would use @kbd{C-3 C-c / t}.  To collect Lucy's items
3767 from all agenda files into a single buffer, you would use the numeric prefix
3768 argument as well when creating the global TODO list: @kbd{C-3 C-c a t}.
3770 @node Multiple sets in one file, Fast access to TODO states, TODO types, TODO extensions
3771 @subsection Multiple keyword sets in one file
3772 @cindex TODO keyword sets
3774 Sometimes you may want to use different sets of TODO keywords in
3775 parallel.  For example, you may want to have the basic
3776 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
3777 separate state indicating that an item has been canceled (so it is not
3778 DONE, but also does not require action).  Your setup would then look
3779 like this:
3781 @lisp
3782 (setq org-todo-keywords
3783       '((sequence "TODO" "|" "DONE")
3784         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
3785         (sequence "|" "CANCELED")))
3786 @end lisp
3788 The keywords should all be different, this helps Org-mode to keep track
3789 of which subsequence should be used for a given entry.  In this setup,
3790 @kbd{C-c C-t} only operates within a subsequence, so it switches from
3791 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
3792 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
3793 select the correct sequence.  Besides the obvious ways like typing a
3794 keyword or using completion, you may also apply the following commands:
3796 @table @kbd
3797 @kindex C-S-@key{right}
3798 @kindex C-S-@key{left}
3799 @kindex C-u C-u C-c C-t
3800 @item C-u C-u C-c C-t
3801 @itemx C-S-@key{right}
3802 @itemx C-S-@key{left}
3803 These keys jump from one TODO subset to the next.  In the above example,
3804 @kbd{C-u C-u C-c C-t} or @kbd{C-S-@key{right}} would jump from @code{TODO} or
3805 @code{DONE} to @code{REPORT}, and any of the words in the second row to
3806 @code{CANCELED}.  Note that the @kbd{C-S-} key binding conflict with
3807 @code{shift-selection-mode} (@pxref{Conflicts}).
3808 @kindex S-@key{right}
3809 @kindex S-@key{left}
3810 @item S-@key{right}
3811 @itemx S-@key{left}
3812 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through @emph{all}
3813 keywords from all sets, so for example @kbd{S-@key{<right>}} would switch
3814 from @code{DONE} to @code{REPORT} in the example above.  See also
3815 @ref{Conflicts}, for a discussion of the interaction with
3816 @code{shift-selection-mode}.
3817 @end table
3819 @node Fast access to TODO states, Per-file keywords, Multiple sets in one file, TODO extensions
3820 @subsection Fast access to TODO states
3822 If you would like to quickly change an entry to an arbitrary TODO state
3823 instead of cycling through the states, you can set up keys for
3824 single-letter access to the states.  This is done by adding the section
3825 key after each keyword, in parentheses.  For example:
3827 @lisp
3828 (setq org-todo-keywords
3829       '((sequence "TODO(t)" "|" "DONE(d)")
3830         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
3831         (sequence "|" "CANCELED(c)")))
3832 @end lisp
3834 @vindex org-fast-tag-selection-include-todo
3835 If you then press @kbd{C-c C-t} followed by the selection key, the entry
3836 will be switched to this state.  @kbd{SPC} can be used to remove any TODO
3837 keyword from an entry.@footnote{Check also the variable
3838 @code{org-fast-tag-selection-include-todo}, it allows you to change the TODO
3839 state through the tags interface (@pxref{Setting tags}), in case you like to
3840 mingle the two concepts.  Note that this means you need to come up with
3841 unique keys across both sets of keywords.}
3843 @node Per-file keywords, Faces for TODO keywords, Fast access to TODO states, TODO extensions
3844 @subsection Setting up keywords for individual files
3845 @cindex keyword options
3846 @cindex per-file keywords
3847 @cindex #+TODO
3848 @cindex #+TYP_TODO
3849 @cindex #+SEQ_TODO
3851 It can be very useful to use different aspects of the TODO mechanism in
3852 different files.  For file-local settings, you need to add special lines
3853 to the file which set the keywords and interpretation for that file
3854 only.  For example, to set one of the two examples discussed above, you
3855 need one of the following lines, starting in column zero anywhere in the
3856 file:
3858 @example
3859 #+TODO: TODO FEEDBACK VERIFY | DONE CANCELED
3860 @end example
3861 @noindent (you may also write @code{#+SEQ_TODO} to be explicit about the
3862 interpretation, but it means the same as @code{#+TODO}), or
3863 @example
3864 #+TYP_TODO: Fred Sara Lucy Mike | DONE
3865 @end example
3867 A setup for using several sets in parallel would be:
3869 @example
3870 #+TODO: TODO | DONE
3871 #+TODO: REPORT BUG KNOWNCAUSE | FIXED
3872 #+TODO: | CANCELED
3873 @end example
3875 @cindex completion, of option keywords
3876 @kindex M-@key{TAB}
3877 @noindent To make sure you are using the correct keyword, type
3878 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
3880 @cindex DONE, final TODO keyword
3881 Remember that the keywords after the vertical bar (or the last keyword
3882 if no bar is there) must always mean that the item is DONE (although you
3883 may use a different word).  After changing one of these lines, use
3884 @kbd{C-c C-c} with the cursor still in the line to make the changes
3885 known to Org-mode@footnote{Org-mode parses these lines only when
3886 Org-mode is activated after visiting a file.  @kbd{C-c C-c} with the
3887 cursor in a line starting with @samp{#+} is simply restarting Org-mode
3888 for the current buffer.}.
3890 @node Faces for TODO keywords, TODO dependencies, Per-file keywords, TODO extensions
3891 @subsection Faces for TODO keywords
3892 @cindex faces, for TODO keywords
3894 @vindex org-todo @r{(face)}
3895 @vindex org-done @r{(face)}
3896 @vindex org-todo-keyword-faces
3897 Org-mode highlights TODO keywords with special faces: @code{org-todo}
3898 for keywords indicating that an item still has to be acted upon, and
3899 @code{org-done} for keywords indicating that an item is finished.  If
3900 you are using more than 2 different states, you might want to use
3901 special faces for some of them.  This can be done using the variable
3902 @code{org-todo-keyword-faces}.  For example:
3904 @lisp
3905 @group
3906 (setq org-todo-keyword-faces
3907       '(("TODO" . org-warning) ("STARTED" . "yellow")
3908         ("CANCELED" . (:foreground "blue" :weight bold))))
3909 @end group
3910 @end lisp
3912 While using a list with face properties as shown for CANCELED @emph{should}
3913 work, this does not aways seem to be the case.  If necessary, define a
3914 special face and use that.  A string is interpreted as a color.  The variable
3915 @code{org-faces-easy-properties} determines if that color is interpreted as a
3916 foreground or a background color.
3918 @node TODO dependencies,  , Faces for TODO keywords, TODO extensions
3919 @subsection TODO dependencies
3920 @cindex TODO dependencies
3921 @cindex dependencies, of TODO states
3923 @vindex org-enforce-todo-dependencies
3924 @cindex property, ORDERED
3925 The structure of Org files (hierarchy and lists) makes it easy to define TODO
3926 dependencies.  Usually, a parent TODO task should not be marked DONE until
3927 all subtasks (defined as children tasks) are marked as DONE.  And sometimes
3928 there is a logical sequence to a number of (sub)tasks, so that one task
3929 cannot be acted upon before all siblings above it are done.  If you customize
3930 the variable @code{org-enforce-todo-dependencies}, Org will block entries
3931 from changing state to DONE while they have children that are not DONE.
3932 Furthermore, if an entry has a property @code{ORDERED}, each of its children
3933 will be blocked until all earlier siblings are marked DONE.  Here is an
3934 example:
3936 @example
3937 * TODO Blocked until (two) is done
3938 ** DONE one
3939 ** TODO two
3941 * Parent
3942   :PROPERTIES:
3943   :ORDERED: t
3944   :END:
3945 ** TODO a
3946 ** TODO b, needs to wait for (a)
3947 ** TODO c, needs to wait for (a) and (b)
3948 @end example
3950 @table @kbd
3951 @orgcmd{C-c C-x o,org-toggle-ordered-property}
3952 @vindex org-track-ordered-property-with-tag
3953 @cindex property, ORDERED
3954 Toggle the @code{ORDERED} property of the current entry.  A property is used
3955 for this behavior because this should be local to the current entry, not
3956 inherited like a tag.  However, if you would like to @i{track} the value of
3957 this property with a tag for better visibility, customize the variable
3958 @code{org-track-ordered-property-with-tag}.
3959 @orgkey{C-u C-u C-u C-c C-t}
3960 Change TODO state, circumventing any state blocking.
3961 @end table
3963 @vindex org-agenda-dim-blocked-tasks
3964 If you set the variable @code{org-agenda-dim-blocked-tasks}, TODO entries
3965 that cannot be closed because of such dependencies will be shown in a dimmed
3966 font or even made invisible in agenda views (@pxref{Agenda Views}).
3968 @cindex checkboxes and TODO dependencies
3969 @vindex org-enforce-todo-dependencies
3970 You can also block changes of TODO states by looking at checkboxes
3971 (@pxref{Checkboxes}).  If you set the variable
3972 @code{org-enforce-todo-checkbox-dependencies}, an entry that has unchecked
3973 checkboxes will be blocked from switching to DONE.
3975 If you need more complex dependency structures, for example dependencies
3976 between entries in different trees or files, check out the contributed
3977 module @file{org-depend.el}.
3979 @page
3980 @node Progress logging, Priorities, TODO extensions, TODO Items
3981 @section Progress logging
3982 @cindex progress logging
3983 @cindex logging, of progress
3985 Org-mode can automatically record a timestamp and possibly a note when
3986 you mark a TODO item as DONE, or even each time you change the state of
3987 a TODO item.  This system is highly configurable, settings can be on a
3988 per-keyword basis and can be localized to a file or even a subtree.  For
3989 information on how to clock working time for a task, see @ref{Clocking
3990 work time}.
3992 @menu
3993 * Closing items::               When was this entry marked DONE?
3994 * Tracking TODO state changes::  When did the status change?
3995 * Tracking your habits::        How consistent have you been?
3996 @end menu
3998 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
3999 @subsection Closing items
4001 The most basic logging is to keep track of @emph{when} a certain TODO
4002 item was finished.  This is achieved with@footnote{The corresponding
4003 in-buffer setting is: @code{#+STARTUP: logdone}}
4005 @lisp
4006 (setq org-log-done 'time)
4007 @end lisp
4009 @noindent
4010 Then each time you turn an entry from a TODO (not-done) state into any
4011 of the DONE states, a line @samp{CLOSED: [timestamp]} will be inserted
4012 just after the headline.  If you turn the entry back into a TODO item
4013 through further state cycling, that line will be removed again.  If you
4014 want to record a note along with the timestamp, use@footnote{The
4015 corresponding in-buffer setting is: @code{#+STARTUP: lognotedone}}
4017 @lisp
4018 (setq org-log-done 'note)
4019 @end lisp
4021 @noindent
4022 You will then be prompted for a note, and that note will be stored below
4023 the entry with a @samp{Closing Note} heading.
4025 In the timeline (@pxref{Timeline}) and in the agenda
4026 (@pxref{Weekly/daily agenda}), you can then use the @kbd{l} key to
4027 display the TODO items with a @samp{CLOSED} timestamp on each day,
4028 giving you an overview of what has been done.
4030 @node Tracking TODO state changes, Tracking your habits, Closing items, Progress logging
4031 @subsection Tracking TODO state changes
4032 @cindex drawer, for state change recording
4034 @vindex org-log-states-order-reversed
4035 @vindex org-log-into-drawer
4036 @cindex property, LOG_INTO_DRAWER
4037 When TODO keywords are used as workflow states (@pxref{Workflow states}), you
4038 might want to keep track of when a state change occurred and maybe take a
4039 note about this change.  You can either record just a timestamp, or a
4040 time-stamped note for a change.  These records will be inserted after the
4041 headline as an itemized list, newest first@footnote{See the variable
4042 @code{org-log-states-order-reversed}}.  When taking a lot of notes, you might
4043 want to get the notes out of the way into a drawer (@pxref{Drawers}).
4044 Customize the variable @code{org-log-into-drawer} to get this
4045 behavior---the recommended drawer for this is called @code{LOGBOOK}.  You can
4046 also overrule the setting of this variable for a subtree by setting a
4047 @code{LOG_INTO_DRAWER} property.
4049 Since it is normally too much to record a note for every state, Org-mode
4050 expects configuration on a per-keyword basis for this.  This is achieved by
4051 adding special markers @samp{!} (for a timestamp) or @samp{@@} (for a note
4052 with timestamp) in parentheses after each keyword.  For example, with the
4053 setting
4055 @lisp
4056 (setq org-todo-keywords
4057   '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
4058 @end lisp
4060 To record a timestamp without a note for TODO keywords configured with
4061 @samp{@@}, just type @kbd{C-c C-c} to enter a blank note when prompted.
4063 @noindent
4064 @vindex org-log-done
4065 you not only define global TODO keywords and fast access keys, but also
4066 request that a time is recorded when the entry is set to
4067 DONE@footnote{It is possible that Org-mode will record two timestamps
4068 when you are using both @code{org-log-done} and state change logging.
4069 However, it will never prompt for two notes---if you have configured
4070 both, the state change recording note will take precedence and cancel
4071 the @samp{Closing Note}.}, and that a note is recorded when switching to
4072 WAIT or CANCELED.  The setting for WAIT is even more special: the
4073 @samp{!} after the slash means that in addition to the note taken when
4074 entering the state, a timestamp should be recorded when @i{leaving} the
4075 WAIT state, if and only if the @i{target} state does not configure
4076 logging for entering it.  So it has no effect when switching from WAIT
4077 to DONE, because DONE is configured to record a timestamp only.  But
4078 when switching from WAIT back to TODO, the @samp{/!} in the WAIT
4079 setting now triggers a timestamp even though TODO has no logging
4080 configured.
4082 You can use the exact same syntax for setting logging preferences local
4083 to a buffer:
4084 @example
4085 #+TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
4086 @end example
4088 @cindex property, LOGGING
4089 In order to define logging settings that are local to a subtree or a
4090 single item, define a LOGGING property in this entry.  Any non-empty
4091 LOGGING property resets all logging settings to nil.  You may then turn
4092 on logging for this specific tree using STARTUP keywords like
4093 @code{lognotedone} or @code{logrepeat}, as well as adding state specific
4094 settings like @code{TODO(!)}.  For example
4096 @example
4097 * TODO Log each state with only a time
4098   :PROPERTIES:
4099   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
4100   :END:
4101 * TODO Only log when switching to WAIT, and when repeating
4102   :PROPERTIES:
4103   :LOGGING: WAIT(@@) logrepeat
4104   :END:
4105 * TODO No logging at all
4106   :PROPERTIES:
4107   :LOGGING: nil
4108   :END:
4109 @end example
4111 @node Tracking your habits,  , Tracking TODO state changes, Progress logging
4112 @subsection Tracking your habits
4113 @cindex habits
4115 Org has the ability to track the consistency of a special category of TODOs,
4116 called ``habits''.  A habit has the following properties:
4118 @enumerate
4119 @item
4120 You have enabled the @code{habits} module by customizing the variable
4121 @code{org-modules}.
4122 @item
4123 The habit is a TODO item, with a TODO keyword representing an open state.
4124 @item
4125 The property @code{STYLE} is set to the value @code{habit}.
4126 @item
4127 The TODO has a scheduled date, usually with a @code{.+} style repeat
4128 interval.  A @code{++} style may be appropriate for habits with time
4129 constraints, e.g., must be done on weekends, or a @code{+} style for an
4130 unusual habit that can have a backlog, e.g., weekly reports.
4131 @item
4132 The TODO may also have minimum and maximum ranges specified by using the
4133 syntax @samp{.+2d/3d}, which says that you want to do the task at least every
4134 three days, but at most every two days.
4135 @item
4136 You must also have state logging for the @code{DONE} state enabled, in order
4137 for historical data to be represented in the consistency graph.  If it is not
4138 enabled it is not an error, but the consistency graphs will be largely
4139 meaningless.
4140 @end enumerate
4142 To give you an idea of what the above rules look like in action, here's an
4143 actual habit with some history:
4145 @example
4146 ** TODO Shave
4147    SCHEDULED: <2009-10-17 Sat .+2d/4d>
4148    - State "DONE"       from "TODO"       [2009-10-15 Thu]
4149    - State "DONE"       from "TODO"       [2009-10-12 Mon]
4150    - State "DONE"       from "TODO"       [2009-10-10 Sat]
4151    - State "DONE"       from "TODO"       [2009-10-04 Sun]
4152    - State "DONE"       from "TODO"       [2009-10-02 Fri]
4153    - State "DONE"       from "TODO"       [2009-09-29 Tue]
4154    - State "DONE"       from "TODO"       [2009-09-25 Fri]
4155    - State "DONE"       from "TODO"       [2009-09-19 Sat]
4156    - State "DONE"       from "TODO"       [2009-09-16 Wed]
4157    - State "DONE"       from "TODO"       [2009-09-12 Sat]
4158    :PROPERTIES:
4159    :STYLE:    habit
4160    :LAST_REPEAT: [2009-10-19 Mon 00:36]
4161    :END:
4162 @end example
4164 What this habit says is: I want to shave at most every 2 days (given by the
4165 @code{SCHEDULED} date and repeat interval) and at least every 4 days.  If
4166 today is the 15th, then the habit first appears in the agenda on Oct 17,
4167 after the minimum of 2 days has elapsed, and will appear overdue on Oct 19,
4168 after four days have elapsed.
4170 What's really useful about habits is that they are displayed along with a
4171 consistency graph, to show how consistent you've been at getting that task
4172 done in the past.  This graph shows every day that the task was done over the
4173 past three weeks, with colors for each day.  The colors used are:
4175 @table @code
4176 @item Blue
4177 If the task wasn't to be done yet on that day.
4178 @item Green
4179 If the task could have been done on that day.
4180 @item Yellow
4181 If the task was going to be overdue the next day.
4182 @item Red
4183 If the task was overdue on that day.
4184 @end table
4186 In addition to coloring each day, the day is also marked with an asterisk if
4187 the task was actually done that day, and an exclamation mark to show where
4188 the current day falls in the graph.
4190 There are several configuration variables that can be used to change the way
4191 habits are displayed in the agenda.
4193 @table @code
4194 @item org-habit-graph-column
4195 The buffer column at which the consistency graph should be drawn.  This will
4196 overwrite any text in that column, so it is a good idea to keep your habits'
4197 titles brief and to the point.
4198 @item org-habit-preceding-days
4199 The amount of history, in days before today, to appear in consistency graphs.
4200 @item org-habit-following-days
4201 The number of days after today that will appear in consistency graphs.
4202 @item org-habit-show-habits-only-for-today
4203 If non-nil, only show habits in today's agenda view.  This is set to true by
4204 default.
4205 @end table
4207 Lastly, pressing @kbd{K} in the agenda buffer will cause habits to
4208 temporarily be disabled and they won't appear at all.  Press @kbd{K} again to
4209 bring them back.  They are also subject to tag filtering, if you have habits
4210 which should only be done in certain contexts, for example.
4212 @node Priorities, Breaking down tasks, Progress logging, TODO Items
4213 @section Priorities
4214 @cindex priorities
4216 If you use Org-mode extensively, you may end up with enough TODO items that
4217 it starts to make sense to prioritize them.  Prioritizing can be done by
4218 placing a @emph{priority cookie} into the headline of a TODO item, like this
4220 @example
4221 *** TODO [#A] Write letter to Sam Fortune
4222 @end example
4224 @noindent
4225 @vindex org-priority-faces
4226 By default, Org-mode supports three priorities: @samp{A}, @samp{B}, and
4227 @samp{C}.  @samp{A} is the highest priority.  An entry without a cookie is
4228 treated just like priority @samp{B}.  Priorities make a difference only for
4229 sorting in the agenda (@pxref{Weekly/daily agenda}); outside the agenda, they
4230 have no inherent meaning to Org-mode.  The cookies can be highlighted with
4231 special faces by customizing the variable @code{org-priority-faces}.
4233 Priorities can be attached to any outline node; they do not need to be TODO
4234 items.
4236 @table @kbd
4237 @item @kbd{C-c ,}
4238 @kindex @kbd{C-c ,}
4239 @findex org-priority
4240 Set the priority of the current headline (@command{org-priority}).  The
4241 command prompts for a priority character @samp{A}, @samp{B} or @samp{C}.
4242 When you press @key{SPC} instead, the priority cookie is removed from the
4243 headline.  The priorities can also be changed ``remotely'' from the timeline
4244 and agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
4246 @orgcmdkkcc{S-@key{up},S-@key{down},org-priority-up,org-priority-down}
4247 @vindex org-priority-start-cycle-with-default
4248 Increase/decrease priority of current headline@footnote{See also the option
4249 @code{org-priority-start-cycle-with-default}.}.  Note that these keys are
4250 also used to modify timestamps (@pxref{Creating timestamps}).  See also
4251 @ref{Conflicts}, for a discussion of the interaction with
4252 @code{shift-selection-mode}.
4253 @end table
4255 @vindex org-highest-priority
4256 @vindex org-lowest-priority
4257 @vindex org-default-priority
4258 You can change the range of allowed priorities by setting the variables
4259 @code{org-highest-priority}, @code{org-lowest-priority}, and
4260 @code{org-default-priority}.  For an individual buffer, you may set
4261 these values (highest, lowest, default) like this (please make sure that
4262 the highest priority is earlier in the alphabet than the lowest
4263 priority):
4265 @cindex #+PRIORITIES
4266 @example
4267 #+PRIORITIES: A C B
4268 @end example
4270 @node Breaking down tasks, Checkboxes, Priorities, TODO Items
4271 @section Breaking tasks down into subtasks
4272 @cindex tasks, breaking down
4273 @cindex statistics, for TODO items
4275 @vindex org-agenda-todo-list-sublevels
4276 It is often advisable to break down large tasks into smaller, manageable
4277 subtasks.  You can do this by creating an outline tree below a TODO item,
4278 with detailed subtasks on the tree@footnote{To keep subtasks out of the
4279 global TODO list, see the @code{org-agenda-todo-list-sublevels}.}.  To keep
4280 the overview over the fraction of subtasks that are already completed, insert
4281 either @samp{[/]} or @samp{[%]} anywhere in the headline.  These cookies will
4282 be updated each time the TODO status of a child changes, or when pressing
4283 @kbd{C-c C-c} on the cookie.  For example:
4285 @example
4286 * Organize Party [33%]
4287 ** TODO Call people [1/2]
4288 *** TODO Peter
4289 *** DONE Sarah
4290 ** TODO Buy food
4291 ** DONE Talk to neighbor
4292 @end example
4294 @cindex property, COOKIE_DATA
4295 If a heading has both checkboxes and TODO children below it, the meaning of
4296 the statistics cookie become ambiguous.  Set the property
4297 @code{COOKIE_DATA} to either @samp{checkbox} or @samp{todo} to resolve
4298 this issue.
4300 @vindex org-hierarchical-todo-statistics
4301 If you would like to have the statistics cookie count any TODO entries in the
4302 subtree (not just direct children), configure the variable
4303 @code{org-hierarchical-todo-statistics}.  To do this for a single subtree,
4304 include the word @samp{recursive} into the value of the @code{COOKIE_DATA}
4305 property.
4307 @example
4308 * Parent capturing statistics [2/20]
4309   :PROPERTIES:
4310   :COOKIE_DATA: todo recursive
4311   :END:
4312 @end example
4314 If you would like a TODO entry to automatically change to DONE
4315 when all children are done, you can use the following setup:
4317 @example
4318 (defun org-summary-todo (n-done n-not-done)
4319   "Switch entry to DONE when all subentries are done, to TODO otherwise."
4320   (let (org-log-done org-log-states)   ; turn off logging
4321     (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
4323 (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
4324 @end example
4327 Another possibility is the use of checkboxes to identify (a hierarchy of) a
4328 large number of subtasks (@pxref{Checkboxes}).
4331 @node Checkboxes,  , Breaking down tasks, TODO Items
4332 @section Checkboxes
4333 @cindex checkboxes
4335 @vindex org-list-automatic-rules
4336 Every item in a plain list@footnote{With the exception of description
4337 lists.  But you can allow it by modifying @code{org-list-automatic-rules}
4338 accordingly.} (@pxref{Plain lists}) can be made into a checkbox by starting
4339 it with the string @samp{[ ]}.  This feature is similar to TODO items
4340 (@pxref{TODO Items}), but is more lightweight.  Checkboxes are not included
4341 into the global TODO list, so they are often great to split a task into a
4342 number of simple steps.  Or you can use them in a shopping list.  To toggle a
4343 checkbox, use @kbd{C-c C-c}, or use the mouse (thanks to Piotr Zielinski's
4344 @file{org-mouse.el}).
4346 Here is an example of a checkbox list.
4348 @example
4349 * TODO Organize party [2/4]
4350   - [-] call people [1/3]
4351     - [ ] Peter
4352     - [X] Sarah
4353     - [ ] Sam
4354   - [X] order food
4355   - [ ] think about what music to play
4356   - [X] talk to the neighbors
4357 @end example
4359 Checkboxes work hierarchically, so if a checkbox item has children that
4360 are checkboxes, toggling one of the children checkboxes will make the
4361 parent checkbox reflect if none, some, or all of the children are
4362 checked.
4364 @cindex statistics, for checkboxes
4365 @cindex checkbox statistics
4366 @cindex property, COOKIE_DATA
4367 @vindex org-hierarchical-checkbox-statistics
4368 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are cookies
4369 indicating how many checkboxes present in this entry have been checked off,
4370 and the total number of checkboxes present.  This can give you an idea on how
4371 many checkboxes remain, even without opening a folded entry.  The cookies can
4372 be placed into a headline or into (the first line of) a plain list item.
4373 Each cookie covers checkboxes of direct children structurally below the
4374 headline/item on which the cookie appears@footnote{Set the variable
4375 @code{org-hierarchical-checkbox-statistics} if you want such cookies to
4376 count all checkboxes below the cookie, not just those belonging to direct
4377 children.}.  You have to insert the cookie yourself by typing either
4378 @samp{[/]} or @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m}
4379 result, as in the examples above.  With @samp{[%]} you get information about
4380 the percentage of checkboxes checked (in the above example, this would be
4381 @samp{[50%]} and @samp{[33%]}, respectively).  In a headline, a cookie can
4382 count either checkboxes below the heading or TODO states of children, and it
4383 will display whatever was changed last.  Set the property @code{COOKIE_DATA}
4384 to either @samp{checkbox} or @samp{todo} to resolve this issue.
4386 @cindex blocking, of checkboxes
4387 @cindex checkbox blocking
4388 @cindex property, ORDERED
4389 If the current outline node has an @code{ORDERED} property, checkboxes must
4390 be checked off in sequence, and an error will be thrown if you try to check
4391 off a box while there are unchecked boxes above it.
4393 @noindent The following commands work with checkboxes:
4395 @table @kbd
4396 @orgcmd{C-c C-c,org-toggle-checkbox}
4397 Toggle checkbox status or (with prefix arg) checkbox presence at point.  With
4398 double prefix argument, set it to @samp{[-]}, which is considered to be an
4399 intermediate state.
4400 @orgcmd{C-c C-x C-b,org-toggle-checkbox}
4401 Toggle checkbox status or (with prefix arg) checkbox presence at point.  With
4402 double prefix argument, set it to @samp{[-]}, which is considered to be an
4403 intermediate state.
4404 @itemize @minus
4405 @item
4406 If there is an active region, toggle the first checkbox in the region
4407 and set all remaining boxes to the same status as the first.  With a prefix
4408 arg, add or remove the checkbox for all items in the region.
4409 @item
4410 If the cursor is in a headline, toggle checkboxes in the region between
4411 this headline and the next (so @emph{not} the entire subtree).
4412 @item
4413 If there is no active region, just toggle the checkbox at point.
4414 @end itemize
4415 @orgcmd{M-S-@key{RET},org-insert-todo-heading}
4416 Insert a new item with a checkbox.  This works only if the cursor is already
4417 in a plain list item (@pxref{Plain lists}).
4418 @orgcmd{C-c C-x o,org-toggle-ordered-property}
4419 @vindex org-track-ordered-property-with-tag
4420 @cindex property, ORDERED
4421 Toggle the @code{ORDERED} property of the entry, to toggle if checkboxes must
4422 be checked off in sequence.  A property is used for this behavior because
4423 this should be local to the current entry, not inherited like a tag.
4424 However, if you would like to @i{track} the value of this property with a tag
4425 for better visibility, customize the variable
4426 @code{org-track-ordered-property-with-tag}.
4427 @orgcmd{C-c #,org-update-statistics-cookies}
4428 Update the statistics cookie in the current outline entry.  When called with
4429 a @kbd{C-u} prefix, update the entire file.  Checkbox statistic cookies are
4430 updated automatically if you toggle checkboxes with @kbd{C-c C-c} and make
4431 new ones with @kbd{M-S-@key{RET}}.  TODO statistics cookies update when
4432 changing TODO states.  If you delete boxes/entries or add/change them by
4433 hand, use this command to get things back into sync.
4434 @end table
4436 @node Tags, Properties and Columns, TODO Items, Top
4437 @chapter Tags
4438 @cindex tags
4439 @cindex headline tagging
4440 @cindex matching, tags
4441 @cindex sparse tree, tag based
4443 An excellent way to implement labels and contexts for cross-correlating
4444 information is to assign @i{tags} to headlines.  Org-mode has extensive
4445 support for tags.
4447 @vindex org-tag-faces
4448 Every headline can contain a list of tags; they occur at the end of the
4449 headline.  Tags are normal words containing letters, numbers, @samp{_}, and
4450 @samp{@@}.  Tags must be preceded and followed by a single colon, e.g.,
4451 @samp{:work:}.  Several tags can be specified, as in @samp{:work:urgent:}.
4452 Tags will by default be in bold face with the same color as the headline.
4453 You may specify special faces for specific tags using the variable
4454 @code{org-tag-faces}, in much the same way as you can for TODO keywords
4455 (@pxref{Faces for TODO keywords}).
4457 @menu
4458 * Tag inheritance::             Tags use the tree structure of the outline
4459 * Setting tags::                How to assign tags to a headline
4460 * Tag searches::                Searching for combinations of tags
4461 @end menu
4463 @node Tag inheritance, Setting tags, Tags, Tags
4464 @section Tag inheritance
4465 @cindex tag inheritance
4466 @cindex inheritance, of tags
4467 @cindex sublevels, inclusion into tags match
4469 @i{Tags} make use of the hierarchical structure of outline trees.  If a
4470 heading has a certain tag, all subheadings will inherit the tag as
4471 well.  For example, in the list
4473 @example
4474 * Meeting with the French group      :work:
4475 ** Summary by Frank                  :boss:notes:
4476 *** TODO Prepare slides for him      :action:
4477 @end example
4479 @noindent
4480 the final heading will have the tags @samp{:work:}, @samp{:boss:},
4481 @samp{:notes:}, and @samp{:action:} even though the final heading is not
4482 explicitly marked with those tags.  You can also set tags that all entries in
4483 a file should inherit just as if these tags were defined in a hypothetical
4484 level zero that surrounds the entire file.  Use a line like this@footnote{As
4485 with all these in-buffer settings, pressing @kbd{C-c C-c} activates any
4486 changes in the line.}:
4488 @cindex #+FILETAGS
4489 @example
4490 #+FILETAGS: :Peter:Boss:Secret:
4491 @end example
4493 @noindent
4494 @vindex org-use-tag-inheritance
4495 @vindex org-tags-exclude-from-inheritance
4496 To limit tag inheritance to specific tags, or to turn it off entirely, use
4497 the variables @code{org-use-tag-inheritance} and
4498 @code{org-tags-exclude-from-inheritance}.
4500 @vindex org-tags-match-list-sublevels
4501 When a headline matches during a tags search while tag inheritance is turned
4502 on, all the sublevels in the same tree will (for a simple match form) match
4503 as well@footnote{This is only true if the search does not involve more
4504 complex tests including properties (@pxref{Property searches}).}.  The list
4505 of matches may then become very long.  If you only want to see the first tags
4506 match in a subtree, configure the variable
4507 @code{org-tags-match-list-sublevels} (not recommended).
4509 @node Setting tags, Tag searches, Tag inheritance, Tags
4510 @section Setting tags
4511 @cindex setting tags
4512 @cindex tags, setting
4514 @kindex M-@key{TAB}
4515 Tags can simply be typed into the buffer at the end of a headline.
4516 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
4517 also a special command for inserting tags:
4519 @table @kbd
4520 @orgcmd{C-c C-q,org-set-tags-command}
4521 @cindex completion, of tags
4522 @vindex org-tags-column
4523 Enter new tags for the current headline.  Org-mode will either offer
4524 completion or a special single-key interface for setting tags, see
4525 below.  After pressing @key{RET}, the tags will be inserted and aligned
4526 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
4527 tags in the current buffer will be aligned to that column, just to make
4528 things look nice.  TAGS are automatically realigned after promotion,
4529 demotion, and TODO state changes (@pxref{TODO basics}).
4530 @orgcmd{C-c C-c,org-set-tags-command}
4531 When the cursor is in a headline, this does the same as @kbd{C-c C-q}.
4532 @end table
4534 @vindex org-tag-alist
4535 Org supports tag insertion based on a @emph{list of tags}.  By
4536 default this list is constructed dynamically, containing all tags
4537 currently used in the buffer.  You may also globally specify a hard list
4538 of tags with the variable @code{org-tag-alist}.  Finally you can set
4539 the default tags for a given file with lines like
4541 @cindex #+TAGS
4542 @example
4543 #+TAGS: @@work @@home @@tennisclub
4544 #+TAGS: laptop car pc sailboat
4545 @end example
4547 If you have globally defined your preferred set of tags using the
4548 variable @code{org-tag-alist}, but would like to use a dynamic tag list
4549 in a specific file, add an empty TAGS option line to that file:
4551 @example
4552 #+TAGS:
4553 @end example
4555 @vindex org-tag-persistent-alist
4556 If you have a preferred set of tags that you would like to use in every file,
4557 in addition to those defined on a per-file basis by TAGS option lines, then
4558 you may specify a list of tags with the variable
4559 @code{org-tag-persistent-alist}.  You may turn this off on a per-file basis
4560 by adding a STARTUP option line to that file:
4562 @example
4563 #+STARTUP: noptag
4564 @end example
4566 By default Org-mode uses the standard minibuffer completion facilities for
4567 entering tags.  However, it also implements another, quicker, tag selection
4568 method called @emph{fast tag selection}.  This allows you to select and
4569 deselect tags with just a single key press.  For this to work well you should
4570 assign unique letters to most of your commonly used tags.  You can do this
4571 globally by configuring the variable @code{org-tag-alist} in your
4572 @file{.emacs} file.  For example, you may find the need to tag many items in
4573 different files with @samp{:@@home:}.  In this case you can set something
4574 like:
4576 @lisp
4577 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
4578 @end lisp
4580 @noindent If the tag is only relevant to the file you are working on, then you
4581 can instead set the TAGS option line as:
4583 @example
4584 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
4585 @end example
4587 @noindent The tags interface will show the available tags in a splash
4588 window.  If you want to start a new line after a specific tag, insert
4589 @samp{\n} into the tag list
4591 @example
4592 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t) \n laptop(l)  pc(p)
4593 @end example
4595 @noindent or write them in two lines:
4597 @example
4598 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)
4599 #+TAGS: laptop(l)  pc(p)
4600 @end example
4602 @noindent
4603 You can also group together tags that are mutually exclusive by using
4604 braces, as in:
4606 @example
4607 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
4608 @end example
4610 @noindent you indicate that at most one of @samp{@@work}, @samp{@@home},
4611 and @samp{@@tennisclub} should be selected.  Multiple such groups are allowed.
4613 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
4614 these lines to activate any changes.
4616 @noindent
4617 To set these mutually exclusive groups in the variable @code{org-tags-alist},
4618 you must use the dummy tags @code{:startgroup} and @code{:endgroup} instead
4619 of the braces.  Similarly, you can use @code{:newline} to indicate a line
4620 break.  The previous example would be set globally by the following
4621 configuration:
4623 @lisp
4624 (setq org-tag-alist '((:startgroup . nil)
4625                       ("@@work" . ?w) ("@@home" . ?h)
4626                       ("@@tennisclub" . ?t)
4627                       (:endgroup . nil)
4628                       ("laptop" . ?l) ("pc" . ?p)))
4629 @end lisp
4631 If at least one tag has a selection key then pressing @kbd{C-c C-c} will
4632 automatically present you with a special interface, listing inherited tags,
4633 the tags of the current headline, and a list of all valid tags with
4634 corresponding keys@footnote{Keys will automatically be assigned to tags which
4635 have no configured keys.}.  In this interface, you can use the following
4636 keys:
4638 @table @kbd
4639 @item a-z...
4640 Pressing keys assigned to tags will add or remove them from the list of
4641 tags in the current line.  Selecting a tag in a group of mutually
4642 exclusive tags will turn off any other tags from that group.
4643 @kindex @key{TAB}
4644 @item @key{TAB}
4645 Enter a tag in the minibuffer, even if the tag is not in the predefined
4646 list.  You will be able to complete on all tags present in the buffer.
4647 You can also add several tags: just separate them with a comma.
4649 @kindex @key{SPC}
4650 @item @key{SPC}
4651 Clear all tags for this line.
4652 @kindex @key{RET}
4653 @item @key{RET}
4654 Accept the modified set.
4655 @item C-g
4656 Abort without installing changes.
4657 @item q
4658 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
4659 @item !
4660 Turn off groups of mutually exclusive tags.  Use this to (as an
4661 exception) assign several tags from such a group.
4662 @item C-c
4663 Toggle auto-exit after the next change (see below).
4664 If you are using expert mode, the first @kbd{C-c} will display the
4665 selection window.
4666 @end table
4668 @noindent
4669 This method lets you assign tags to a headline with very few keys.  With
4670 the above setup, you could clear the current tags and set @samp{@@home},
4671 @samp{laptop} and @samp{pc} tags with just the following keys: @kbd{C-c
4672 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to
4673 @samp{@@work} would be done with @kbd{C-c C-c w @key{RET}} or
4674 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
4675 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
4676 @key{RET} @key{RET}}.
4678 @vindex org-fast-tag-selection-single-key
4679 If you find that most of the time you need only a single key press to
4680 modify your list of tags, set the variable
4681 @code{org-fast-tag-selection-single-key}.  Then you no longer have to
4682 press @key{RET} to exit fast tag selection---it will immediately exit
4683 after the first change.  If you then occasionally need more keys, press
4684 @kbd{C-c} to turn off auto-exit for the current tag selection process
4685 (in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
4686 C-c}).  If you set the variable to the value @code{expert}, the special
4687 window is not even shown for single-key tag selection, it comes up only
4688 when you press an extra @kbd{C-c}.
4690 @node Tag searches,  , Setting tags, Tags
4691 @section Tag searches
4692 @cindex tag searches
4693 @cindex searching for tags
4695 Once a system of tags has been set up, it can be used to collect related
4696 information into special lists.
4698 @table @kbd
4699 @orgcmdkkc{C-c / m,C-c \\,org-match-sparse-tree}
4700 Create a sparse tree with all headlines matching a tags search.  With a
4701 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
4702 @orgcmd{C-c a m,org-tags-view}
4703 Create a global list of tag matches from all agenda files.
4704 @xref{Matching tags and properties}.
4705 @orgcmd{C-c a M,org-tags-view}
4706 @vindex org-tags-match-list-sublevels
4707 Create a global list of tag matches from all agenda files, but check
4708 only TODO items and force checking subitems (see variable
4709 @code{org-tags-match-list-sublevels}).
4710 @end table
4712 These commands all prompt for a match string which allows basic Boolean logic
4713 like @samp{+boss+urgent-project1}, to find entries with tags @samp{boss} and
4714 @samp{urgent}, but not @samp{project1}, or @samp{Kathy|Sally} to find entries
4715 which are tagged, like @samp{Kathy} or @samp{Sally}.  The full syntax of the search
4716 string is rich and allows also matching against TODO keywords, entry levels
4717 and properties.  For a complete description with many examples, see
4718 @ref{Matching tags and properties}.
4721 @node Properties and Columns, Dates and Times, Tags, Top
4722 @chapter Properties and columns
4723 @cindex properties
4725 A property is a key-value pair associated with an entry.  Properties can be
4726 set so they are associated with a single entry, with every entry in a tree,
4727 or with every entry in an Org-mode file.
4729 There are two main applications for properties in Org-mode.  First,
4730 properties are like tags, but with a value.  Imagine maintaining a file where
4731 you document bugs and plan releases for a piece of software.  Instead of
4732 using tags like @code{:release_1:}, @code{:release_2:}, you can use a
4733 property, say @code{:Release:}, that in different subtrees has different
4734 values, such as @code{1.0} or @code{2.0}.  Second, you can use properties to
4735 implement (very basic) database capabilities in an Org buffer.  Imagine
4736 keeping track of your music CDs, where properties could be things such as the
4737 album, artist, date of release, number of tracks, and so on.
4739 Properties can be conveniently edited and viewed in column view
4740 (@pxref{Column view}).
4742 @menu
4743 * Property syntax::             How properties are spelled out
4744 * Special properties::          Access to other Org-mode features
4745 * Property searches::           Matching property values
4746 * Property inheritance::        Passing values down the tree
4747 * Column view::                 Tabular viewing and editing
4748 * Property API::                Properties for Lisp programmers
4749 @end menu
4751 @node Property syntax, Special properties, Properties and Columns, Properties and Columns
4752 @section Property syntax
4753 @cindex property syntax
4754 @cindex drawer, for properties
4756 Properties are key-value pairs.  When they are associated with a single entry
4757 or with a tree they need to be inserted into a special
4758 drawer (@pxref{Drawers}) with the name @code{PROPERTIES}.  Each property
4759 is specified on a single line, with the key (surrounded by colons)
4760 first, and the value after it.  Here is an example:
4762 @example
4763 * CD collection
4764 ** Classic
4765 *** Goldberg Variations
4766     :PROPERTIES:
4767     :Title:     Goldberg Variations
4768     :Composer:  J.S. Bach
4769     :Artist:    Glen Gould
4770     :Publisher: Deutsche Grammophon
4771     :NDisks:    1
4772     :END:
4773 @end example
4775 Depending on the value of @code{org-use-property-inheritance}, a property set
4776 this way will either be associated with a single entry, or the sub-tree
4777 defined by the entry, see @ref{Property inheritance}.
4779 You may define the allowed values for a particular property @samp{:Xyz:}
4780 by setting a property @samp{:Xyz_ALL:}.  This special property is
4781 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
4782 the entire tree.  When allowed values are defined, setting the
4783 corresponding property becomes easier and is less prone to typing
4784 errors.  For the example with the CD collection, we can predefine
4785 publishers and the number of disks in a box like this:
4787 @example
4788 * CD collection
4789   :PROPERTIES:
4790   :NDisks_ALL:  1 2 3 4
4791   :Publisher_ALL: "Deutsche Grammophon" Philips EMI
4792   :END:
4793 @end example
4795 If you want to set properties that can be inherited by any entry in a
4796 file, use a line like
4797 @cindex property, _ALL
4798 @cindex #+PROPERTY
4799 @example
4800 #+PROPERTY: NDisks_ALL 1 2 3 4
4801 @end example
4803 If you want to add to the value of an existing property, append a @code{+} to
4804 the property name.  The following results in the property @code{var} having
4805 the value ``foo=1 bar=2''.
4806 @cindex property, +
4807 @example
4808 #+PROPERTY: var  foo=1
4809 #+PROPERTY: var+ bar=2
4810 @end example
4812 It is also possible to add to the values of inherited properties.  The
4813 following results in the @code{genres} property having the value ``Classic
4814 Baroque'' under the @code{Goldberg Variations} subtree.
4815 @cindex property, +
4816 @example
4817 * CD collection
4818 ** Classic
4819     :PROPERTIES:
4820     :GENRES: Classic
4821     :END:
4822 *** Goldberg Variations
4823     :PROPERTIES:
4824     :Title:     Goldberg Variations
4825     :Composer:  J.S. Bach
4826     :Artist:    Glen Gould
4827     :Publisher: Deutsche Grammophon
4828     :NDisks:    1
4829     :GENRES+:   Baroque
4830     :END:
4831 @end example
4832 Note that a property can only have one entry per Drawer.
4834 @vindex org-global-properties
4835 Property values set with the global variable
4836 @code{org-global-properties} can be inherited by all entries in all
4837 Org files.
4839 @noindent
4840 The following commands help to work with properties:
4842 @table @kbd
4843 @orgcmd{M-@key{TAB},pcomplete}
4844 After an initial colon in a line, complete property keys.  All keys used
4845 in the current file will be offered as possible completions.
4846 @orgcmd{C-c C-x p,org-set-property}
4847 Set a property.  This prompts for a property name and a value.  If
4848 necessary, the property drawer is created as well.
4849 @item M-x org-insert-property-drawer
4850 @findex org-insert-property-drawer
4851 Insert a property drawer into the current entry.  The drawer will be
4852 inserted early in the entry, but after the lines with planning
4853 information like deadlines.
4854 @orgcmd{C-c C-c,org-property-action}
4855 With the cursor in a property drawer, this executes property commands.
4856 @orgcmd{C-c C-c s,org-set-property}
4857 Set a property in the current entry.  Both the property and the value
4858 can be inserted using completion.
4859 @orgcmdkkcc{S-@key{right},S-@key{left},org-property-next-allowed-value,org-property-previous-allowed-value}
4860 Switch property at point to the next/previous allowed value.
4861 @orgcmd{C-c C-c d,org-delete-property}
4862 Remove a property from the current entry.
4863 @orgcmd{C-c C-c D,org-delete-property-globally}
4864 Globally remove a property, from all entries in the current file.
4865 @orgcmd{C-c C-c c,org-compute-property-at-point}
4866 Compute the property at point, using the operator and scope from the
4867 nearest column format definition.
4868 @end table
4870 @node Special properties, Property searches, Property syntax, Properties and Columns
4871 @section Special properties
4872 @cindex properties, special
4874 Special properties provide an alternative access method to Org-mode features,
4875 like the TODO state or the priority of an entry, discussed in the previous
4876 chapters.  This interface exists so that you can include these states in a
4877 column view (@pxref{Column view}), or to use them in queries.  The following
4878 property names are special and (except for @code{:CATEGORY:}) should not be
4879 used as keys in the properties drawer:
4881 @cindex property, special, TODO
4882 @cindex property, special, TAGS
4883 @cindex property, special, ALLTAGS
4884 @cindex property, special, CATEGORY
4885 @cindex property, special, PRIORITY
4886 @cindex property, special, DEADLINE
4887 @cindex property, special, SCHEDULED
4888 @cindex property, special, CLOSED
4889 @cindex property, special, TIMESTAMP
4890 @cindex property, special, TIMESTAMP_IA
4891 @cindex property, special, CLOCKSUM
4892 @cindex property, special, BLOCKED
4893 @c guessing that ITEM is needed in this area; also, should this list be sorted?
4894 @cindex property, special, ITEM
4895 @cindex property, special, FILE
4896 @example
4897 TODO         @r{The TODO keyword of the entry.}
4898 TAGS         @r{The tags defined directly in the headline.}
4899 ALLTAGS      @r{All tags, including inherited ones.}
4900 CATEGORY     @r{The category of an entry.}
4901 PRIORITY     @r{The priority of the entry, a string with a single letter.}
4902 DEADLINE     @r{The deadline time string, without the angular brackets.}
4903 SCHEDULED    @r{The scheduling timestamp, without the angular brackets.}
4904 CLOSED       @r{When was this entry closed?}
4905 TIMESTAMP    @r{The first keyword-less timestamp in the entry.}
4906 TIMESTAMP_IA @r{The first inactive timestamp in the entry.}
4907 CLOCKSUM     @r{The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}}
4908              @r{must be run first to compute the values in the current buffer.}
4909 BLOCKED      @r{"t" if task is currently blocked by children or siblings}
4910 ITEM         @r{The content of the entry.}
4911 FILE         @r{The filename the entry is located in.}
4912 @end example
4914 @node Property searches, Property inheritance, Special properties, Properties and Columns
4915 @section Property searches
4916 @cindex properties, searching
4917 @cindex searching, of properties
4919 To create sparse trees and special lists with selection based on properties,
4920 the same commands are used as for tag searches (@pxref{Tag searches}).
4921 @table @kbd
4922 @orgcmdkkc{C-c / m,C-c \,org-match-sparse-tree}
4923 Create a sparse tree with all matching entries.  With a
4924 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
4925 @orgcmd{C-c a m,org-tags-view}
4926 Create a global list of tag/property  matches from all agenda files.
4927 @xref{Matching tags and properties}.
4928 @orgcmd{C-c a M,org-tags-view}
4929 @vindex org-tags-match-list-sublevels
4930 Create a global list of tag matches from all agenda files, but check
4931 only TODO items and force checking of subitems (see variable
4932 @code{org-tags-match-list-sublevels}).
4933 @end table
4935 The syntax for the search string is described in @ref{Matching tags and
4936 properties}.
4938 There is also a special command for creating sparse trees based on a
4939 single property:
4941 @table @kbd
4942 @orgkey{C-c / p}
4943 Create a sparse tree based on the value of a property.  This first
4944 prompts for the name of a property, and then for a value.  A sparse tree
4945 is created with all entries that define this property with the given
4946 value.  If you enclose the value in curly braces, it is interpreted as
4947 a regular expression and matched against the property values.
4948 @end table
4950 @node Property inheritance, Column view, Property searches, Properties and Columns
4951 @section Property Inheritance
4952 @cindex properties, inheritance
4953 @cindex inheritance, of properties
4955 @vindex org-use-property-inheritance
4956 The outline structure of Org-mode documents lends itself to an
4957 inheritance model of properties: if the parent in a tree has a certain
4958 property, the children can inherit this property.  Org-mode does not
4959 turn this on by default, because it can slow down property searches
4960 significantly and is often not needed.  However, if you find inheritance
4961 useful, you can turn it on by setting the variable
4962 @code{org-use-property-inheritance}.  It may be set to @code{t} to make
4963 all properties inherited from the parent, to a list of properties
4964 that should be inherited, or to a regular expression that matches
4965 inherited properties.  If a property has the value @samp{nil}, this is
4966 interpreted as an explicit undefine of the property, so that inheritance
4967 search will stop at this value and return @code{nil}.
4969 Org-mode has a few properties for which inheritance is hard-coded, at
4970 least for the special applications for which they are used:
4972 @cindex property, COLUMNS
4973 @table @code
4974 @item COLUMNS
4975 The @code{:COLUMNS:} property defines the format of column view
4976 (@pxref{Column view}).  It is inherited in the sense that the level
4977 where a @code{:COLUMNS:} property is defined is used as the starting
4978 point for a column view table, independently of the location in the
4979 subtree from where columns view is turned on.
4980 @item CATEGORY
4981 @cindex property, CATEGORY
4982 For agenda view, a category set through a @code{:CATEGORY:} property
4983 applies to the entire subtree.
4984 @item ARCHIVE
4985 @cindex property, ARCHIVE
4986 For archiving, the @code{:ARCHIVE:} property may define the archive
4987 location for the entire subtree (@pxref{Moving subtrees}).
4988 @item LOGGING
4989 @cindex property, LOGGING
4990 The LOGGING property may define logging settings for an entry or a
4991 subtree (@pxref{Tracking TODO state changes}).
4992 @end table
4994 @node Column view, Property API, Property inheritance, Properties and Columns
4995 @section Column view
4997 A great way to view and edit properties in an outline tree is
4998 @emph{column view}.  In column view, each outline node is turned into a
4999 table row.  Columns in this table provide access to properties of the
5000 entries.  Org-mode implements columns by overlaying a tabular structure
5001 over the headline of each item.  While the headlines have been turned
5002 into a table row, you can still change the visibility of the outline
5003 tree.  For example, you get a compact table by switching to CONTENTS
5004 view (@kbd{S-@key{TAB} S-@key{TAB}}, or simply @kbd{c} while column view
5005 is active), but you can still open, read, and edit the entry below each
5006 headline.  Or, you can switch to column view after executing a sparse
5007 tree command and in this way get a table only for the selected items.
5008 Column view also works in agenda buffers (@pxref{Agenda Views}) where
5009 queries have collected selected items, possibly from a number of files.
5011 @menu
5012 * Defining columns::            The COLUMNS format property
5013 * Using column view::           How to create and use column view
5014 * Capturing column view::       A dynamic block for column view
5015 @end menu
5017 @node Defining columns, Using column view, Column view, Column view
5018 @subsection Defining columns
5019 @cindex column view, for properties
5020 @cindex properties, column view
5022 Setting up a column view first requires defining the columns.  This is
5023 done by defining a column format line.
5025 @menu
5026 * Scope of column definitions::  Where defined, where valid?
5027 * Column attributes::           Appearance and content of a column
5028 @end menu
5030 @node Scope of column definitions, Column attributes, Defining columns, Defining columns
5031 @subsubsection Scope of column definitions
5033 To define a column format for an entire file, use a line like
5035 @cindex #+COLUMNS
5036 @example
5037 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5038 @end example
5040 To specify a format that only applies to a specific tree, add a
5041 @code{:COLUMNS:} property to the top node of that tree, for example:
5043 @example
5044 ** Top node for columns view
5045    :PROPERTIES:
5046    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
5047    :END:
5048 @end example
5050 If a @code{:COLUMNS:} property is present in an entry, it defines columns
5051 for the entry itself, and for the entire subtree below it.  Since the
5052 column definition is part of the hierarchical structure of the document,
5053 you can define columns on level 1 that are general enough for all
5054 sublevels, and more specific columns further down, when you edit a
5055 deeper part of the tree.
5057 @node Column attributes,  , Scope of column definitions, Defining columns
5058 @subsubsection Column attributes
5059 A column definition sets the attributes of a column.  The general
5060 definition looks like this:
5062 @example
5063  %[@var{width}]@var{property}[(@var{title})][@{@var{summary-type}@}]
5064 @end example
5066 @noindent
5067 Except for the percent sign and the property name, all items are
5068 optional.  The individual parts have the following meaning:
5070 @example
5071 @var{width}           @r{An integer specifying the width of the column in characters.}
5072                 @r{If omitted, the width will be determined automatically.}
5073 @var{property}        @r{The property that should be edited in this column.}
5074                 @r{Special properties representing meta data are allowed here}
5075                 @r{as well (@pxref{Special properties})}
5076 @var{title}           @r{The header text for the column.  If omitted, the property}
5077                 @r{name is used.}
5078 @{@var{summary-type}@}  @r{The summary type.  If specified, the column values for}
5079                 @r{parent nodes are computed from the children.}
5080                 @r{Supported summary types are:}
5081                 @{+@}       @r{Sum numbers in this column.}
5082                 @{+;%.1f@}  @r{Like @samp{+}, but format result with @samp{%.1f}.}
5083                 @{$@}       @r{Currency, short for @samp{+;%.2f}.}
5084                 @{:@}       @r{Sum times, HH:MM, plain numbers are hours.}
5085                 @{X@}       @r{Checkbox status, @samp{[X]} if all children are @samp{[X]}.}
5086                 @{X/@}      @r{Checkbox status, @samp{[n/m]}.}
5087                 @{X%@}      @r{Checkbox status, @samp{[n%]}.}
5088                 @{min@}     @r{Smallest number in column.}
5089                 @{max@}     @r{Largest number.}
5090                 @{mean@}    @r{Arithmetic mean of numbers.}
5091                 @{:min@}    @r{Smallest time value in column.}
5092                 @{:max@}    @r{Largest time value.}
5093                 @{:mean@}   @r{Arithmetic mean of time values.}
5094                 @{@@min@}    @r{Minimum age (in days/hours/mins/seconds).}
5095                 @{@@max@}    @r{Maximum age (in days/hours/mins/seconds).}
5096                 @{@@mean@}   @r{Arithmetic mean of ages (in days/hours/mins/seconds).}
5097                 @{est+@}    @r{Add low-high estimates.}
5098 @end example
5100 @noindent
5101 Be aware that you can only have one summary type for any property you
5102 include.  Subsequent columns referencing the same property will all display the
5103 same summary information.
5105 The @code{est+} summary type requires further explanation.  It is used for
5106 combining estimates, expressed as low-high ranges.  For example, instead
5107 of estimating a particular task will take 5 days, you might estimate it as
5108 5-6 days if you're fairly confident you know how much work is required, or
5109 1-10 days if you don't really know what needs to be done.  Both ranges
5110 average at 5.5 days, but the first represents a more predictable delivery.
5112 When combining a set of such estimates, simply adding the lows and highs
5113 produces an unrealistically wide result.  Instead, @code{est+} adds the
5114 statistical mean and variance of the sub-tasks, generating a final estimate
5115 from the sum.  For example, suppose you had ten tasks, each of which was
5116 estimated at 0.5 to 2 days of work.  Straight addition produces an estimate
5117 of 5 to 20 days, representing what to expect if everything goes either
5118 extremely well or extremely poorly.  In contrast, @code{est+} estimates the
5119 full job more realistically, at 10-15 days.
5121 Here is an example for a complete columns definition, along with allowed
5122 values.
5124 @example
5125 :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.}
5126                    %10Time_Estimate@{:@} %CLOCKSUM
5127 :Owner_ALL:    Tammy Mark Karl Lisa Don
5128 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
5129 :Approved_ALL: "[ ]" "[X]"
5130 @end example
5132 @noindent
5133 The first column, @samp{%25ITEM}, means the first 25 characters of the
5134 item itself, i.e.@: of the headline.  You probably always should start the
5135 column definition with the @samp{ITEM} specifier.  The other specifiers
5136 create columns @samp{Owner} with a list of names as allowed values, for
5137 @samp{Status} with four different possible values, and for a checkbox
5138 field @samp{Approved}.  When no width is given after the @samp{%}
5139 character, the column will be exactly as wide as it needs to be in order
5140 to fully display all values.  The @samp{Approved} column does have a
5141 modified title (@samp{Approved?}, with a question mark).  Summaries will
5142 be created for the @samp{Time_Estimate} column by adding time duration
5143 expressions like HH:MM, and for the @samp{Approved} column, by providing
5144 an @samp{[X]} status if all children have been checked.  The
5145 @samp{CLOCKSUM} column is special, it lists the sum of CLOCK intervals
5146 in the subtree.
5148 @node Using column view, Capturing column view, Defining columns, Column view
5149 @subsection Using column view
5151 @table @kbd
5152 @tsubheading{Turning column view on and off}
5153 @orgcmd{C-c C-x C-c,org-columns}
5154 @vindex org-columns-default-format
5155 Turn on column view.  If the cursor is before the first headline in the file,
5156 column view is turned on for the entire file, using the @code{#+COLUMNS}
5157 definition.  If the cursor is somewhere inside the outline, this command
5158 searches the hierarchy, up from point, for a @code{:COLUMNS:} property that
5159 defines a format.  When one is found, the column view table is established
5160 for the tree starting at the entry that contains the @code{:COLUMNS:}
5161 property.  If no such property is found, the format is taken from the
5162 @code{#+COLUMNS} line or from the variable @code{org-columns-default-format},
5163 and column view is established for the current entry and its subtree.
5164 @orgcmd{r,org-columns-redo}
5165 Recreate the column view, to include recent changes made in the buffer.
5166 @orgcmd{g,org-columns-redo}
5167 Same as @kbd{r}.
5168 @orgcmd{q,org-columns-quit}
5169 Exit column view.
5170 @tsubheading{Editing values}
5171 @item @key{left} @key{right} @key{up} @key{down}
5172 Move through the column view from field to field.
5173 @kindex S-@key{left}
5174 @kindex S-@key{right}
5175 @item  S-@key{left}/@key{right}
5176 Switch to the next/previous allowed value of the field.  For this, you
5177 have to have specified allowed values for a property.
5178 @item 1..9,0
5179 Directly select the Nth allowed value, @kbd{0} selects the 10th value.
5180 @orgcmdkkcc{n,p,org-columns-next-allowed-value,org-columns-previous-allowed-value}
5181 Same as @kbd{S-@key{left}/@key{right}}
5182 @orgcmd{e,org-columns-edit-value}
5183 Edit the property at point.  For the special properties, this will
5184 invoke the same interface that you normally use to change that
5185 property.  For example, when editing a TAGS property, the tag completion
5186 or fast selection interface will pop up.
5187 @orgcmd{C-c C-c,org-columns-set-tags-or-toggle}
5188 When there is a checkbox at point, toggle it.
5189 @orgcmd{v,org-columns-show-value}
5190 View the full value of this property.  This is useful if the width of
5191 the column is smaller than that of the value.
5192 @orgcmd{a,org-columns-edit-allowed}
5193 Edit the list of allowed values for this property.  If the list is found
5194 in the hierarchy, the modified values is stored there.  If no list is
5195 found, the new value is stored in the first entry that is part of the
5196 current column view.
5197 @tsubheading{Modifying the table structure}
5198 @orgcmdkkcc{<,>,org-columns-narrow,org-columns-widen}
5199 Make the column narrower/wider by one character.
5200 @orgcmd{S-M-@key{right},org-columns-new}
5201 Insert a new column, to the left of the current column.
5202 @orgcmd{S-M-@key{left},org-columns-delete}
5203 Delete the current column.
5204 @end table
5206 @node Capturing column view,  , Using column view, Column view
5207 @subsection Capturing column view
5209 Since column view is just an overlay over a buffer, it cannot be
5210 exported or printed directly.  If you want to capture a column view, use
5211 a @code{columnview} dynamic block (@pxref{Dynamic blocks}).  The frame
5212 of this block looks like this:
5214 @cindex #+BEGIN, columnview
5215 @example
5216 * The column view
5217 #+BEGIN: columnview :hlines 1 :id "label"
5219 #+END:
5220 @end example
5222 @noindent This dynamic block has the following parameters:
5224 @table @code
5225 @item :id
5226 This is the most important parameter.  Column view is a feature that is
5227 often localized to a certain (sub)tree, and the capture block might be
5228 at a different location in the file.  To identify the tree whose view to
5229 capture, you can use 4 values:
5230 @cindex property, ID
5231 @example
5232 local     @r{use the tree in which the capture block is located}
5233 global    @r{make a global view, including all headings in the file}
5234 "file:@var{path-to-file}"
5235           @r{run column view at the top of this file}
5236 "@var{ID}"      @r{call column view in the tree that has an @code{:ID:}}
5237           @r{property with the value @i{label}.  You can use}
5238           @r{@kbd{M-x org-id-copy} to create a globally unique ID for}
5239           @r{the current entry and copy it to the kill-ring.}
5240 @end example
5241 @item :hlines
5242 When @code{t}, insert an hline after every line.  When a number @var{N}, insert
5243 an hline before each headline with level @code{<= @var{N}}.
5244 @item :vlines
5245 When set to @code{t}, force column groups to get vertical lines.
5246 @item :maxlevel
5247 When set to a number, don't capture entries below this level.
5248 @item :skip-empty-rows
5249 When set to @code{t}, skip rows where the only non-empty specifier of the
5250 column view is @code{ITEM}.
5252 @end table
5254 @noindent
5255 The following commands insert or update the dynamic block:
5257 @table @kbd
5258 @orgcmd{C-c C-x i,org-insert-columns-dblock}
5259 Insert a dynamic block capturing a column view.  You will be prompted
5260 for the scope or ID of the view.
5261 @orgcmdkkc{C-c C-c,C-c C-x C-u,org-dblock-update}
5262 Update dynamic block at point.  The cursor needs to be in the
5263 @code{#+BEGIN} line of the dynamic block.
5264 @orgcmd{C-u C-c C-x C-u,org-update-all-dblocks}
5265 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
5266 you have several clock table blocks, column-capturing blocks or other dynamic
5267 blocks in a buffer.
5268 @end table
5270 You can add formulas to the column view table and you may add plotting
5271 instructions in front of the table---these will survive an update of the
5272 block.  If there is a @code{#+TBLFM:} after the table, the table will
5273 actually be recalculated automatically after an update.
5275 An alternative way to capture and process property values into a table is
5276 provided by Eric Schulte's @file{org-collector.el} which is a contributed
5277 package@footnote{Contributed packages are not part of Emacs, but are
5278 distributed with the main distribution of Org (visit
5279 @uref{http://orgmode.org}).}.  It provides a general API to collect
5280 properties from entries in a certain scope, and arbitrary Lisp expressions to
5281 process these values before inserting them into a table or a dynamic block.
5283 @node Property API,  , Column view, Properties and Columns
5284 @section The Property API
5285 @cindex properties, API
5286 @cindex API, for properties
5288 There is a full API for accessing and changing properties.  This API can
5289 be used by Emacs Lisp programs to work with properties and to implement
5290 features based on them.  For more information see @ref{Using the
5291 property API}.
5293 @node Dates and Times, Capture - Refile - Archive, Properties and Columns, Top
5294 @chapter Dates and times
5295 @cindex dates
5296 @cindex times
5297 @cindex timestamp
5298 @cindex date stamp
5300 To assist project planning, TODO items can be labeled with a date and/or
5301 a time.  The specially formatted string carrying the date and time
5302 information is called a @emph{timestamp} in Org-mode.  This may be a
5303 little confusing because timestamp is often used as indicating when
5304 something was created or last changed.  However, in Org-mode this term
5305 is used in a much wider sense.
5307 @menu
5308 * Timestamps::                  Assigning a time to a tree entry
5309 * Creating timestamps::         Commands which insert timestamps
5310 * Deadlines and scheduling::    Planning your work
5311 * Clocking work time::          Tracking how long you spend on a task
5312 * Effort estimates::            Planning work effort in advance
5313 * Relative timer::              Notes with a running timer
5314 * Countdown timer::             Starting a countdown timer for a task
5315 @end menu
5318 @node Timestamps, Creating timestamps, Dates and Times, Dates and Times
5319 @section Timestamps, deadlines, and scheduling
5320 @cindex timestamps
5321 @cindex ranges, time
5322 @cindex date stamps
5323 @cindex deadlines
5324 @cindex scheduling
5326 A timestamp is a specification of a date (possibly with a time or a range of
5327 times) in a special format, either @samp{<2003-09-16 Tue>}@footnote{In this
5328 simplest form, the day name is optional when you type the date yourself.
5329 However, any dates inserted or modified by Org will add that day name, for
5330 reading convenience.} or @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16
5331 Tue 12:00-12:30>}@footnote{This is inspired by the standard ISO 8601
5332 date/time format.  To use an alternative format, see @ref{Custom time
5333 format}.}.  A timestamp can appear anywhere in the headline or body of an Org
5334 tree entry.  Its presence causes entries to be shown on specific dates in the
5335 agenda (@pxref{Weekly/daily agenda}).  We distinguish:
5337 @table @var
5338 @item Plain timestamp; Event; Appointment
5339 @cindex timestamp
5340 @cindex appointment
5341 A simple timestamp just assigns a date/time to an item.  This is just
5342 like writing down an appointment or event in a paper agenda.  In the
5343 timeline and agenda displays, the headline of an entry associated with a
5344 plain timestamp will be shown exactly on that date.
5346 @example
5347 * Meet Peter at the movies <2006-11-01 Wed 19:15>
5348 * Discussion on climate change <2006-11-02 Thu 20:00-22:00>
5349 @end example
5351 @item Timestamp with repeater interval
5352 @cindex timestamp, with repeater interval
5353 A timestamp may contain a @emph{repeater interval}, indicating that it
5354 applies not only on the given date, but again and again after a certain
5355 interval of N days (d), weeks (w), months (m), or years (y).  The
5356 following will show up in the agenda every Wednesday:
5358 @example
5359 * Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
5360 @end example
5362 @item Diary-style sexp entries
5363 For more complex date specifications, Org-mode supports using the special
5364 sexp diary entries implemented in the Emacs calendar/diary
5365 package@footnote{When working with the standard diary sexp functions, you
5366 need to be very careful with the order of the arguments.  That order depend
5367 evilly on the variable @code{calendar-date-style} (or, for older Emacs
5368 versions, @code{european-calendar-style}).  For example, to specify a date
5369 December 12, 2005, the call might look like @code{(diary-date 12 1 2005)} or
5370 @code{(diary-date 1 12 2005)} or @code{(diary-date 2005 12 1)}, depending on
5371 the settings.  This has been the source of much confusion.  Org-mode users
5372 can resort to special versions of these functions like @code{org-date} or
5373 @code{org-anniversary}.  These work just like the corresponding @code{diary-}
5374 functions, but with stable ISO order of arguments (year, month, day) wherever
5375 applicable, independent of the value of @code{calendar-date-style}.}.  For example
5377 @example
5378 * The nerd meeting on every 2nd Thursday of the month
5379   <%%(org-float t 4 2)>
5380 @end example
5382 @item Time/Date range
5383 @cindex timerange
5384 @cindex date range
5385 Two timestamps connected by @samp{--} denote a range.  The headline
5386 will be shown on the first and last day of the range, and on any dates
5387 that are displayed and fall in the range.  Here is an example:
5389 @example
5390 ** Meeting in Amsterdam
5391    <2004-08-23 Mon>--<2004-08-26 Thu>
5392 @end example
5394 @item Inactive timestamp
5395 @cindex timestamp, inactive
5396 @cindex inactive timestamp
5397 Just like a plain timestamp, but with square brackets instead of
5398 angular ones.  These timestamps are inactive in the sense that they do
5399 @emph{not} trigger an entry to show up in the agenda.
5401 @example
5402 * Gillian comes late for the fifth time [2006-11-01 Wed]
5403 @end example
5405 @end table
5407 @node Creating timestamps, Deadlines and scheduling, Timestamps, Dates and Times
5408 @section Creating timestamps
5409 @cindex creating timestamps
5410 @cindex timestamps, creating
5412 For Org-mode to recognize timestamps, they need to be in the specific
5413 format.  All commands listed below produce timestamps in the correct
5414 format.
5416 @table @kbd
5417 @orgcmd{C-c .,org-time-stamp}
5418 Prompt for a date and insert a corresponding timestamp.  When the cursor is
5419 at an existing timestamp in the buffer, the command is used to modify this
5420 timestamp instead of inserting a new one.  When this command is used twice in
5421 succession, a time range is inserted.
5423 @orgcmd{C-c !,org-time-stamp-inactive}
5424 Like @kbd{C-c .}, but insert an inactive timestamp that will not cause
5425 an agenda entry.
5427 @kindex C-u C-c .
5428 @kindex C-u C-c !
5429 @item C-u C-c .
5430 @itemx C-u C-c !
5431 @vindex org-time-stamp-rounding-minutes
5432 Like @kbd{C-c .} and @kbd{C-c !}, but use the alternative format which
5433 contains date and time.  The default time can be rounded to multiples of 5
5434 minutes, see the option @code{org-time-stamp-rounding-minutes}.
5436 @orgkey{C-c C-c}
5437 Normalize timestamp, insert/fix day name if missing or wrong.
5439 @orgcmd{C-c <,org-date-from-calendar}
5440 Insert a timestamp corresponding to the cursor date in the Calendar.
5442 @orgcmd{C-c >,org-goto-calendar}
5443 Access the Emacs calendar for the current date.  If there is a
5444 timestamp in the current line, go to the corresponding date
5445 instead.
5447 @orgcmd{C-c C-o,org-open-at-point}
5448 Access the agenda for the date given by the timestamp or -range at
5449 point (@pxref{Weekly/daily agenda}).
5451 @orgcmdkkcc{S-@key{left},S-@key{right},org-timestamp-down-day,org-timestamp-up-day}
5452 Change date at cursor by one day.  These key bindings conflict with
5453 shift-selection and related modes (@pxref{Conflicts}).
5455 @orgcmdkkcc{S-@key{up},S-@key{down},org-timestamp-up,org-timestamp-down-down}
5456 Change the item under the cursor in a timestamp.  The cursor can be on a
5457 year, month, day, hour or minute.  When the timestamp contains a time range
5458 like @samp{15:30-16:30}, modifying the first time will also shift the second,
5459 shifting the time block with constant length.  To change the length, modify
5460 the second time.  Note that if the cursor is in a headline and not at a
5461 timestamp, these same keys modify the priority of an item.
5462 (@pxref{Priorities}).  The key bindings also conflict with shift-selection and
5463 related modes (@pxref{Conflicts}).
5465 @orgcmd{C-c C-y,org-evaluate-time-range}
5466 @cindex evaluate time range
5467 Evaluate a time range by computing the difference between start and end.
5468 With a prefix argument, insert result after the time range (in a table: into
5469 the following column).
5470 @end table
5473 @menu
5474 * The date/time prompt::        How Org-mode helps you entering date and time
5475 * Custom time format::          Making dates look different
5476 @end menu
5478 @node The date/time prompt, Custom time format, Creating timestamps, Creating timestamps
5479 @subsection The date/time prompt
5480 @cindex date, reading in minibuffer
5481 @cindex time, reading in minibuffer
5483 @vindex org-read-date-prefer-future
5484 When Org-mode prompts for a date/time, the default is shown in default
5485 date/time format, and the prompt therefore seems to ask for a specific
5486 format.  But it will in fact accept any string containing some date and/or
5487 time information, and it is really smart about interpreting your input.  You
5488 can, for example, use @kbd{C-y} to paste a (possibly multi-line) string
5489 copied from an email message.  Org-mode will find whatever information is in
5490 there and derive anything you have not specified from the @emph{default date
5491 and time}.  The default is usually the current date and time, but when
5492 modifying an existing timestamp, or when entering the second stamp of a
5493 range, it is taken from the stamp in the buffer.  When filling in
5494 information, Org-mode assumes that most of the time you will want to enter a
5495 date in the future: if you omit the month/year and the given day/month is
5496 @i{before} today, it will assume that you mean a future date@footnote{See the
5497 variable @code{org-read-date-prefer-future}.  You may set that variable to
5498 the symbol @code{time} to even make a time before now shift the date to
5499 tomorrow.}.  If the date has been automatically shifted into the future, the
5500 time prompt will show this with @samp{(=>F).}
5502 For example, let's assume that today is @b{June 13, 2006}.  Here is how
5503 various inputs will be interpreted, the items filled in by Org-mode are
5504 in @b{bold}.
5506 @example
5507 3-2-5         @result{} 2003-02-05
5508 2/5/3         @result{} 2003-02-05
5509 14            @result{} @b{2006}-@b{06}-14
5510 12            @result{} @b{2006}-@b{07}-12
5511 2/5           @result{} @b{2007}-02-05
5512 Fri           @result{} nearest Friday (default date or later)
5513 sep 15        @result{} @b{2006}-09-15
5514 feb 15        @result{} @b{2007}-02-15
5515 sep 12 9      @result{} 2009-09-12
5516 12:45         @result{} @b{2006}-@b{06}-@b{13} 12:45
5517 22 sept 0:34  @result{} @b{2006}-09-22 0:34
5518 w4            @result{} ISO week for of the current year @b{2006}
5519 2012 w4 fri   @result{} Friday of ISO week 4 in 2012
5520 2012-w04-5    @result{} Same as above
5521 @end example
5523 Furthermore you can specify a relative date by giving, as the
5524 @emph{first} thing in the input: a plus/minus sign, a number and a
5525 letter ([dwmy]) to indicate change in days, weeks, months, or years.  With a
5526 single plus or minus, the date is always relative to today.  With a
5527 double plus or minus, it is relative to the default date.  If instead of
5528 a single letter, you use the abbreviation of day name, the date will be
5529 the Nth such day, e.g.@:
5531 @example
5532 +0            @result{} today
5533 .             @result{} today
5534 +4d           @result{} four days from today
5535 +4            @result{} same as above
5536 +2w           @result{} two weeks from today
5537 ++5           @result{} five days from default date
5538 +2tue         @result{} second Tuesday from now.
5539 @end example
5541 @vindex parse-time-months
5542 @vindex parse-time-weekdays
5543 The function understands English month and weekday abbreviations.  If
5544 you want to use unabbreviated names and/or other languages, configure
5545 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
5547 @vindex org-read-date-force-compatible-dates
5548 Not all dates can be represented in a given Emacs implementation.  By default
5549 Org mode forces dates into the compatibility range 1970--2037 which works on
5550 all Emacs implementations.  If you want to use dates outside of this range,
5551 read the docstring of the variable
5552 @code{org-read-date-force-compatible-dates}.
5554 You can specify a time range by giving start and end times or by giving a
5555 start time and a duration (in HH:MM format).  Use one or two dash(es) as the
5556 separator in the former case and use '+' as the separator in the latter
5557 case, e.g.@:
5559 @example
5560 11am-1:15pm    @result{} 11:00-13:15
5561 11am--1:15pm   @result{} same as above
5562 11am+2:15      @result{} same as above
5563 @end example
5565 @cindex calendar, for selecting date
5566 @vindex org-popup-calendar-for-date-prompt
5567 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
5568 you don't need/want the calendar, configure the variable
5569 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
5570 prompt, either by clicking on a date in the calendar, or by pressing
5571 @key{RET}, the date selected in the calendar will be combined with the
5572 information entered at the prompt.  You can control the calendar fully
5573 from the minibuffer:
5575 @kindex <
5576 @kindex >
5577 @kindex M-v
5578 @kindex C-v
5579 @kindex mouse-1
5580 @kindex S-@key{right}
5581 @kindex S-@key{left}
5582 @kindex S-@key{down}
5583 @kindex S-@key{up}
5584 @kindex M-S-@key{right}
5585 @kindex M-S-@key{left}
5586 @kindex @key{RET}
5587 @example
5588 @key{RET}           @r{Choose date at cursor in calendar.}
5589 mouse-1        @r{Select date by clicking on it.}
5590 S-@key{right}/@key{left}     @r{One day forward/backward.}
5591 S-@key{down}/@key{up}     @r{One week forward/backward.}
5592 M-S-@key{right}/@key{left}   @r{One month forward/backward.}
5593 > / <          @r{Scroll calendar forward/backward by one month.}
5594 M-v / C-v      @r{Scroll calendar forward/backward by 3 months.}
5595 @end example
5597 @vindex org-read-date-display-live
5598 The actions of the date/time prompt may seem complex, but I assure you they
5599 will grow on you, and you will start getting annoyed by pretty much any other
5600 way of entering a date/time out there.  To help you understand what is going
5601 on, the current interpretation of your input will be displayed live in the
5602 minibuffer@footnote{If you find this distracting, turn the display of with
5603 @code{org-read-date-display-live}.}.
5605 @node Custom time format,  , The date/time prompt, Creating timestamps
5606 @subsection Custom time format
5607 @cindex custom date/time format
5608 @cindex time format, custom
5609 @cindex date format, custom
5611 @vindex org-display-custom-times
5612 @vindex org-time-stamp-custom-formats
5613 Org-mode uses the standard ISO notation for dates and times as it is
5614 defined in ISO 8601.  If you cannot get used to this and require another
5615 representation of date and time to keep you happy, you can get it by
5616 customizing the variables @code{org-display-custom-times} and
5617 @code{org-time-stamp-custom-formats}.
5619 @table @kbd
5620 @orgcmd{C-c C-x C-t,org-toggle-time-stamp-overlays}
5621 Toggle the display of custom formats for dates and times.
5622 @end table
5624 @noindent
5625 Org-mode needs the default format for scanning, so the custom date/time
5626 format does not @emph{replace} the default format---instead it is put
5627 @emph{over} the default format using text properties.  This has the
5628 following consequences:
5629 @itemize @bullet
5630 @item
5631 You cannot place the cursor onto a timestamp anymore, only before or
5632 after.
5633 @item
5634 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
5635 each component of a timestamp.  If the cursor is at the beginning of
5636 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
5637 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
5638 time will be changed by one minute.
5639 @item
5640 If the timestamp contains a range of clock times or a repeater, these
5641 will not be overlaid, but remain in the buffer as they were.
5642 @item
5643 When you delete a timestamp character-by-character, it will only
5644 disappear from the buffer after @emph{all} (invisible) characters
5645 belonging to the ISO timestamp have been removed.
5646 @item
5647 If the custom timestamp format is longer than the default and you are
5648 using dates in tables, table alignment will be messed up.  If the custom
5649 format is shorter, things do work as expected.
5650 @end itemize
5653 @node Deadlines and scheduling, Clocking work time, Creating timestamps, Dates and Times
5654 @section Deadlines and scheduling
5656 A timestamp may be preceded by special keywords to facilitate planning:
5658 @table @var
5659 @item DEADLINE
5660 @cindex DEADLINE keyword
5662 Meaning: the task (most likely a TODO item, though not necessarily) is supposed
5663 to be finished on that date.
5665 @vindex org-deadline-warning-days
5666 On the deadline date, the task will be listed in the agenda.  In
5667 addition, the agenda for @emph{today} will carry a warning about the
5668 approaching or missed deadline, starting
5669 @code{org-deadline-warning-days} before the due date, and continuing
5670 until the entry is marked DONE.  An example:
5672 @example
5673 *** TODO write article about the Earth for the Guide
5674     The editor in charge is [[bbdb:Ford Prefect]]
5675     DEADLINE: <2004-02-29 Sun>
5676 @end example
5678 You can specify a different lead time for warnings for a specific
5679 deadlines using the following syntax.  Here is an example with a warning
5680 period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.
5682 @item SCHEDULED
5683 @cindex SCHEDULED keyword
5685 Meaning: you are planning to start working on that task on the given
5686 date.
5688 @vindex org-agenda-skip-scheduled-if-done
5689 The headline will be listed under the given date@footnote{It will still
5690 be listed on that date after it has been marked DONE.  If you don't like
5691 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
5692 addition, a reminder that the scheduled date has passed will be present
5693 in the compilation for @emph{today}, until the entry is marked DONE, i.e.@:
5694 the task will automatically be forwarded until completed.
5696 @example
5697 *** TODO Call Trillian for a date on New Years Eve.
5698     SCHEDULED: <2004-12-25 Sat>
5699 @end example
5701 @noindent
5702 @b{Important:} Scheduling an item in Org-mode should @i{not} be
5703 understood in the same way that we understand @i{scheduling a meeting}.
5704 Setting a date for a meeting is just a simple appointment, you should
5705 mark this entry with a simple plain timestamp, to get this item shown
5706 on the date where it applies.  This is a frequent misunderstanding by
5707 Org users.  In Org-mode, @i{scheduling} means setting a date when you
5708 want to start working on an action item.
5709 @end table
5711 You may use timestamps with repeaters in scheduling and deadline
5712 entries.  Org-mode will issue early and late warnings based on the
5713 assumption that the timestamp represents the @i{nearest instance} of
5714 the repeater.  However, the use of diary sexp entries like
5716 @code{<%%(org-float t 42)>}
5718 in scheduling and deadline timestamps is limited.  Org-mode does not
5719 know enough about the internals of each sexp function to issue early and
5720 late warnings.  However, it will show the item on each day where the
5721 sexp entry matches.
5723 @menu
5724 * Inserting deadline/schedule::  Planning items
5725 * Repeated tasks::              Items that show up again and again
5726 @end menu
5728 @node Inserting deadline/schedule, Repeated tasks, Deadlines and scheduling, Deadlines and scheduling
5729 @subsection Inserting deadlines or schedules
5731 The following commands allow you to quickly insert@footnote{The @samp{SCHEDULED} and
5732 @samp{DEADLINE} dates are inserted on the line right below the headline.  Don't put
5733 any text between this line and the headline.} a deadline or to schedule
5734 an item:
5736 @table @kbd
5738 @orgcmd{C-c C-d,org-deadline}
5739 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will happen
5740 in the line directly following the headline.  Any CLOSED timestamp will be
5741 removed.  When called with a prefix arg, an existing deadline will be removed
5742 from the entry.  Depending on the variable @code{org-log-redeadline}@footnote{with corresponding
5743 @code{#+STARTUP} keywords @code{logredeadline}, @code{lognoteredeadline},
5744 and @code{nologredeadline}}, a note will be taken when changing an existing
5745 deadline.
5747 @orgcmd{C-c C-s,org-schedule}
5748 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
5749 happen in the line directly following the headline.  Any CLOSED timestamp
5750 will be removed.  When called with a prefix argument, remove the scheduling
5751 date from the entry.  Depending on the variable
5752 @code{org-log-reschedule}@footnote{with corresponding @code{#+STARTUP}
5753 keywords @code{logreschedule}, @code{lognotereschedule}, and
5754 @code{nologreschedule}}, a note will be taken when changing an existing
5755 scheduling time.
5757 @orgcmd{C-c C-x C-k,org-mark-entry-for-agenda-action}
5758 @kindex k a
5759 @kindex k s
5760 Mark the current entry for agenda action.  After you have marked the entry
5761 like this, you can open the agenda or the calendar to find an appropriate
5762 date.  With the cursor on the selected date, press @kbd{k s} or @kbd{k d} to
5763 schedule the marked item.
5765 @orgcmd{C-c / d,org-check-deadlines}
5766 @cindex sparse tree, for deadlines
5767 @vindex org-deadline-warning-days
5768 Create a sparse tree with all deadlines that are either past-due, or
5769 which will become due within @code{org-deadline-warning-days}.
5770 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
5771 prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows
5772 all deadlines due tomorrow.
5774 @orgcmd{C-c / b,org-check-before-date}
5775 Sparse tree for deadlines and scheduled items before a given date.
5777 @orgcmd{C-c / a,org-check-after-date}
5778 Sparse tree for deadlines and scheduled items after a given date.
5779 @end table
5781 Note that @code{org-schedule} and @code{org-deadline} supports
5782 setting the date by indicating a relative time: e.g. +1d will set
5783 the date to the next day after today, and --1w will set the date
5784 to the previous week before any current timestamp.
5786 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
5787 @subsection Repeated tasks
5788 @cindex tasks, repeated
5789 @cindex repeated tasks
5791 Some tasks need to be repeated again and again.  Org-mode helps to
5792 organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
5793 or plain timestamp.  In the following example
5794 @example
5795 ** TODO Pay the rent
5796    DEADLINE: <2005-10-01 Sat +1m>
5797 @end example
5798 @noindent
5799 the @code{+1m} is a repeater; the intended interpretation is that the task
5800 has a deadline on <2005-10-01> and repeats itself every (one) month starting
5801 from that time.  If you need both a repeater and a special warning period in
5802 a deadline entry, the repeater should come first and the warning period last:
5803 @code{DEADLINE: <2005-10-01 Sat +1m -3d>}.
5805 @vindex org-todo-repeat-to-state
5806 Deadlines and scheduled items produce entries in the agenda when they are
5807 over-due, so it is important to be able to mark such an entry as completed
5808 once you have done so.  When you mark a DEADLINE or a SCHEDULE with the TODO
5809 keyword DONE, it will no longer produce entries in the agenda.  The problem
5810 with this is, however, that then also the @emph{next} instance of the
5811 repeated entry will not be active.  Org-mode deals with this in the following
5812 way: When you try to mark such an entry DONE (using @kbd{C-c C-t}), it will
5813 shift the base date of the repeating timestamp by the repeater interval, and
5814 immediately set the entry state back to TODO@footnote{In fact, the target
5815 state is taken from, in this sequence, the @code{REPEAT_TO_STATE} property or
5816 the variable @code{org-todo-repeat-to-state}.  If neither of these is
5817 specified, the target state defaults to the first state of the TODO state
5818 sequence.}.  In the example above, setting the state to DONE would actually
5819 switch the date like this:
5821 @example
5822 ** TODO Pay the rent
5823    DEADLINE: <2005-11-01 Tue +1m>
5824 @end example
5826 @vindex org-log-repeat
5827 A timestamp@footnote{You can change this using the option
5828 @code{org-log-repeat}, or the @code{#+STARTUP} options @code{logrepeat},
5829 @code{lognoterepeat}, and @code{nologrepeat}.  With @code{lognoterepeat}, you
5830 will also be prompted for a note.} will be added under the deadline, to keep
5831 a record that you actually acted on the previous instance of this deadline.
5833 As a consequence of shifting the base date, this entry will no longer be
5834 visible in the agenda when checking past dates, but all future instances
5835 will be visible.
5837 With the @samp{+1m} cookie, the date shift will always be exactly one
5838 month.  So if you have not paid the rent for three months, marking this
5839 entry DONE will still keep it as an overdue deadline.  Depending on the
5840 task, this may not be the best way to handle it.  For example, if you
5841 forgot to call your father for 3 weeks, it does not make sense to call
5842 him 3 times in a single day to make up for it.  Finally, there are tasks
5843 like changing batteries which should always repeat a certain time
5844 @i{after} the last time you did it.  For these tasks, Org-mode has
5845 special repeaters  @samp{++} and @samp{.+}.  For example:
5847 @example
5848 ** TODO Call Father
5849    DEADLINE: <2008-02-10 Sun ++1w>
5850    Marking this DONE will shift the date by at least one week,
5851    but also by as many weeks as it takes to get this date into
5852    the future.  However, it stays on a Sunday, even if you called
5853    and marked it done on Saturday.
5854 ** TODO Check the batteries in the smoke detectors
5855    DEADLINE: <2005-11-01 Tue .+1m>
5856    Marking this DONE will shift the date to one month after
5857    today.
5858 @end example
5860 You may have both scheduling and deadline information for a specific
5861 task---just make sure that the repeater intervals on both are the same.
5863 An alternative to using a repeater is to create a number of copies of a task
5864 subtree, with dates shifted in each copy.  The command @kbd{C-c C-x c} was
5865 created for this purpose, it is described in @ref{Structure editing}.
5868 @node Clocking work time, Effort estimates, Deadlines and scheduling, Dates and Times
5869 @section Clocking work time
5870 @cindex clocking time
5871 @cindex time clocking
5873 Org-mode allows you to clock the time you spend on specific tasks in a
5874 project.  When you start working on an item, you can start the clock.
5875 When you stop working on that task, or when you mark the task done, the
5876 clock is stopped and the corresponding time interval is recorded.  It
5877 also computes the total time spent on each subtree of a project.  And it
5878 remembers a history or tasks recently clocked, to that you can jump quickly
5879 between a number of tasks absorbing your time.
5881 To save the clock history across Emacs sessions, use
5882 @lisp
5883 (setq org-clock-persist 'history)
5884 (org-clock-persistence-insinuate)
5885 @end lisp
5886 When you clock into a new task after resuming Emacs, the incomplete
5887 clock@footnote{To resume the clock under the assumption that you have worked
5888 on this task while outside Emacs, use @code{(setq org-clock-persist t)}.}
5889 will be found (@pxref{Resolving idle time}) and you will be prompted about
5890 what to do with it.
5892 @menu
5893 * Clocking commands::           Starting and stopping a clock
5894 * The clock table::             Detailed reports
5895 * Resolving idle time::         Resolving time when you've been idle
5896 @end menu
5898 @node Clocking commands, The clock table, Clocking work time, Clocking work time
5899 @subsection Clocking commands
5901 @table @kbd
5902 @orgcmd{C-c C-x C-i,org-clock-in}
5903 @vindex org-clock-into-drawer
5904 @cindex property, LOG_INTO_DRAWER
5905 Start the clock on the current item (clock-in).  This inserts the CLOCK
5906 keyword together with a timestamp.  If this is not the first clocking of
5907 this item, the multiple CLOCK lines will be wrapped into a
5908 @code{:LOGBOOK:} drawer (see also the variable
5909 @code{org-clock-into-drawer}).  You can also overrule
5910 the setting of this variable for a subtree by setting a
5911 @code{CLOCK_INTO_DRAWER} or @code{LOG_INTO_DRAWER} property.
5912 When called with a @kbd{C-u} prefix argument,
5913 select the task from a list of recently clocked tasks.  With two @kbd{C-u
5914 C-u} prefixes, clock into the task at point and mark it as the default task.
5915 The default task will always be available when selecting a clocking task,
5916 with letter @kbd{d}.@*
5917 @cindex property: CLOCK_MODELINE_TOTAL
5918 @cindex property: LAST_REPEAT
5919 @vindex org-clock-modeline-total
5920 While the clock is running, the current clocking time is shown in the mode
5921 line, along with the title of the task.  The clock time shown will be all
5922 time ever clocked for this task and its children.  If the task has an effort
5923 estimate (@pxref{Effort estimates}), the mode line displays the current
5924 clocking time against it@footnote{To add an effort estimate ``on the fly'',
5925 hook a function doing this to @code{org-clock-in-prepare-hook}.}  If the task
5926 is a repeating one (@pxref{Repeated tasks}), only the time since the last
5927 reset of the task @footnote{as recorded by the @code{LAST_REPEAT} property}
5928 will be shown.  More control over what time is shown can be exercised with
5929 the @code{CLOCK_MODELINE_TOTAL} property.  It may have the values
5930 @code{current} to show only the current clocking instance, @code{today} to
5931 show all time clocked on this tasks today (see also the variable
5932 @code{org-extend-today-until}), @code{all} to include all time, or
5933 @code{auto} which is the default@footnote{See also the variable
5934 @code{org-clock-modeline-total}.}.@* Clicking with @kbd{mouse-1} onto the
5935 mode line entry will pop up a menu with clocking options.
5937 @orgcmd{C-c C-x C-o,org-clock-out}
5938 @vindex org-log-note-clock-out
5939 Stop the clock (clock-out).  This inserts another timestamp at the same
5940 location where the clock was last started.  It also directly computes
5941 the resulting time in inserts it after the time range as @samp{=>
5942 HH:MM}.  See the variable @code{org-log-note-clock-out} for the
5943 possibility to record an additional note together with the clock-out
5944 timestamp@footnote{The corresponding in-buffer setting is:
5945 @code{#+STARTUP: lognoteclock-out}}.
5946 @orgcmd{C-c C-x C-e,org-clock-modify-effort-estimate}
5947 Update the effort estimate for the current clock task.
5948 @kindex C-c C-y
5949 @kindex C-c C-c
5950 @orgcmdkkc{C-c C-c,C-c C-y,org-evaluate-time-range}
5951 Recompute the time interval after changing one of the timestamps.  This
5952 is only necessary if you edit the timestamps directly.  If you change
5953 them with @kbd{S-@key{cursor}} keys, the update is automatic.
5954 @orgcmd{C-S-@key{up/down},org-clock-timestamps-up/down}
5955 On @code{CLOCK} log lines, increase/decrease both timestamps at the same
5956 time so that duration keeps the same.
5957 @orgcmd{C-c C-t,org-todo}
5958 Changing the TODO state of an item to DONE automatically stops the clock
5959 if it is running in this same item.
5960 @orgcmd{C-c C-x C-x,org-clock-cancel}
5961 Cancel the current clock.  This is useful if a clock was started by
5962 mistake, or if you ended up working on something else.
5963 @orgcmd{C-c C-x C-j,org-clock-goto}
5964 Jump to the headline of the currently clocked in task.  With a @kbd{C-u}
5965 prefix arg, select the target task from a list of recently clocked tasks.
5966 @orgcmd{C-c C-x C-d,org-clock-display}
5967 @vindex org-remove-highlights-with-change
5968 Display time summaries for each subtree in the current buffer.  This puts
5969 overlays at the end of each headline, showing the total time recorded under
5970 that heading, including the time of any subheadings.  You can use visibility
5971 cycling to study the tree, but the overlays disappear when you change the
5972 buffer (see variable @code{org-remove-highlights-with-change}) or press
5973 @kbd{C-c C-c}.
5974 @end table
5976 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
5977 the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
5978 worked on or closed during a day.
5980 @node The clock table, Resolving idle time, Clocking commands, Clocking work time
5981 @subsection The clock table
5982 @cindex clocktable, dynamic block
5983 @cindex report, of clocked time
5985 Org mode can produce quite complex reports based on the time clocking
5986 information.  Such a report is called a @emph{clock table}, because it is
5987 formatted as one or several Org tables.
5989 @table @kbd
5990 @orgcmd{C-c C-x C-r,org-clock-report}
5991 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
5992 report as an Org-mode table into the current file.  When the cursor is
5993 at an existing clock table, just update it.  When called with a prefix
5994 argument, jump to the first clock report in the current document and
5995 update it.   The clock table always includes also trees with
5996 @code{:ARCHIVE:} tag.
5997 @orgcmdkkc{C-c C-c,C-c C-x C-u,org-dblock-update}
5998 Update dynamic block at point.  The cursor needs to be in the
5999 @code{#+BEGIN} line of the dynamic block.
6000 @orgkey{C-u C-c C-x C-u}
6001 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
6002 you have several clock table blocks in a buffer.
6003 @orgcmdkxkc{S-@key{left},S-@key{right},org-clocktable-try-shift}
6004 Shift the current @code{:block} interval and update the table.  The cursor
6005 needs to be in the @code{#+BEGIN: clocktable} line for this command.  If
6006 @code{:block} is @code{today}, it will be shifted to @code{today-1} etc.
6007 @end table
6010 Here is an example of the frame for a clock table as it is inserted into the
6011 buffer with the @kbd{C-c C-x C-r} command:
6013 @cindex #+BEGIN, clocktable
6014 @example
6015 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
6016 #+END: clocktable
6017 @end example
6018 @noindent
6019 @vindex org-clocktable-defaults
6020 The @samp{BEGIN} line and specify a number of options to define the scope,
6021 structure, and formatting of the report.  Defaults for all these options can
6022 be configured in the variable @code{org-clocktable-defaults}.
6024 @noindent First there are options that determine which clock entries are to
6025 be selected:
6026 @example
6027 :maxlevel    @r{Maximum level depth to which times are listed in the table.}
6028              @r{Clocks at deeper levels will be summed into the upper level.}
6029 :scope       @r{The scope to consider.  This can be any of the following:}
6030              nil        @r{the current buffer or narrowed region}
6031              file       @r{the full current buffer}
6032              subtree    @r{the subtree where the clocktable is located}
6033              tree@var{N}      @r{the surrounding level @var{N} tree, for example @code{tree3}}
6034              tree       @r{the surrounding level 1 tree}
6035              agenda     @r{all agenda files}
6036              ("file"..) @r{scan these files}
6037              file-with-archives    @r{current file and its archives}
6038              agenda-with-archives  @r{all agenda files, including archives}
6039 :block       @r{The time block to consider.  This block is specified either}
6040              @r{absolute, or relative to the current time and may be any of}
6041              @r{these formats:}
6042              2007-12-31    @r{New year eve 2007}
6043              2007-12       @r{December 2007}
6044              2007-W50      @r{ISO-week 50 in 2007}
6045              2007-Q2       @r{2nd quarter in 2007}
6046              2007          @r{the year 2007}
6047              today, yesterday, today-@var{N}          @r{a relative day}
6048              thisweek, lastweek, thisweek-@var{N}     @r{a relative week}
6049              thismonth, lastmonth, thismonth-@var{N}  @r{a relative month}
6050              thisyear, lastyear, thisyear-@var{N}     @r{a relative year}
6051              @r{Use @kbd{S-@key{left}/@key{right}} keys to shift the time interval.}
6052 :tstart      @r{A time string specifying when to start considering times.}
6053 :tend        @r{A time string specifying when to stop considering times.}
6054 :step        @r{@code{week} or @code{day}, to split the table into chunks.}
6055              @r{To use this, @code{:block} or @code{:tstart}, @code{:tend} are needed.}
6056 :stepskip0   @r{Do not show steps that have zero time.}
6057 :fileskip0   @r{Do not show table sections from files which did not contribute.}
6058 :tags        @r{A tags match to select entries that should contribute.  See}
6059              @r{@ref{Matching tags and properties} for the match syntax.}
6060 @end example
6062 Then there are options which determine the formatting of the table.  There
6063 options are interpreted by the function @code{org-clocktable-write-default},
6064 but you can specify your own function using the @code{:formatter} parameter.
6065 @example
6066 :emphasize   @r{When @code{t}, emphasize level one and level two items.}
6067 :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".}
6068 :link        @r{Link the item headlines in the table to their origins.}
6069 :narrow      @r{An integer to limit the width of the headline column in}
6070              @r{the org table.  If you write it like @samp{50!}, then the}
6071              @r{headline will also be shortened in export.}
6072 :indent      @r{Indent each headline field according to its level.}
6073 :tcolumns    @r{Number of columns to be used for times.  If this is smaller}
6074              @r{than @code{:maxlevel}, lower levels will be lumped into one column.}
6075 :level       @r{Should a level number column be included?}
6076 :compact     @r{Abbreviation for @code{:level nil :indent t :narrow 40! :tcolumns 1}}
6077              @r{All are overwritten except if there is an explicit @code{:narrow}}
6078 :timestamp   @r{A timestamp for the entry, when available.  Look for SCHEDULED,}
6079              @r{DEADLINE, TIMESTAMP and TIMESTAMP_IA, in this order.}
6080 :properties  @r{List of properties that should be shown in the table.  Each}
6081              @r{property will get its own column.}
6082 :inherit-props @r{When this flag is @code{t}, the values for @code{:properties} will be inherited.}
6083 :formula     @r{Content of a @code{#+TBLFM} line to be added and evaluated.}
6084              @r{As a special case, @samp{:formula %} adds a column with % time.}
6085              @r{If you do not specify a formula here, any existing formula}
6086              @r{below the clock table will survive updates and be evaluated.}
6087 :formatter   @r{A function to format clock data and insert it into the buffer.}
6088 @end example
6089 To get a clock summary of the current level 1 tree, for the current
6090 day, you could write
6091 @example
6092 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
6093 #+END: clocktable
6094 @end example
6095 @noindent
6096 and to use a specific time range you could write@footnote{Note that all
6097 parameters must be specified in a single line---the line is broken here
6098 only to fit it into the manual.}
6099 @example
6100 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
6101                     :tend "<2006-08-10 Thu 12:00>"
6102 #+END: clocktable
6103 @end example
6104 A summary of the current subtree with % times would be
6105 @example
6106 #+BEGIN: clocktable :scope subtree :link t :formula %
6107 #+END: clocktable
6108 @end example
6109 A horizontally compact representation of everything clocked during last week
6110 would be
6111 @example
6112 #+BEGIN: clocktable :scope agenda :block lastweek :compact t
6113 #+END: clocktable
6114 @end example
6116 @node Resolving idle time,  , The clock table, Clocking work time
6117 @subsection Resolving idle time
6118 @cindex resolve idle time
6120 @cindex idle, resolve, dangling
6121 If you clock in on a work item, and then walk away from your
6122 computer---perhaps to take a phone call---you often need to ``resolve'' the
6123 time you were away by either subtracting it from the current clock, or
6124 applying it to another one.
6126 @vindex org-clock-idle-time
6127 By customizing the variable @code{org-clock-idle-time} to some integer, such
6128 as 10 or 15, Emacs can alert you when you get back to your computer after
6129 being idle for that many minutes@footnote{On computers using Mac OS X,
6130 idleness is based on actual user idleness, not just Emacs' idle time.  For
6131 X11, you can install a utility program @file{x11idle.c}, available in the
6132 UTILITIES directory of the Org git distribution, to get the same general
6133 treatment of idleness.  On other systems, idle time refers to Emacs idle time
6134 only.}, and ask what you want to do with the idle time.  There will be a
6135 question waiting for you when you get back, indicating how much idle time has
6136 passed (constantly updated with the current amount), as well as a set of
6137 choices to correct the discrepancy:
6139 @table @kbd
6140 @item k
6141 To keep some or all of the minutes and stay clocked in, press @kbd{k}.  Org
6142 will ask how many of the minutes to keep.  Press @key{RET} to keep them all,
6143 effectively changing nothing, or enter a number to keep that many minutes.
6144 @item K
6145 If you use the shift key and press @kbd{K}, it will keep however many minutes
6146 you request and then immediately clock out of that task.  If you keep all of
6147 the minutes, this is the same as just clocking out of the current task.
6148 @item s
6149 To keep none of the minutes, use @kbd{s} to subtract all the away time from
6150 the clock, and then check back in from the moment you returned.
6151 @item S
6152 To keep none of the minutes and just clock out at the start of the away time,
6153 use the shift key and press @kbd{S}.  Remember that using shift will always
6154 leave you clocked out, no matter which option you choose.
6155 @item C
6156 To cancel the clock altogether, use @kbd{C}.  Note that if instead of
6157 canceling you subtract the away time, and the resulting clock amount is less
6158 than a minute, the clock will still be canceled rather than clutter up the
6159 log with an empty entry.
6160 @end table
6162 What if you subtracted those away minutes from the current clock, and now
6163 want to apply them to a new clock?  Simply clock in to any task immediately
6164 after the subtraction.  Org will notice that you have subtracted time ``on
6165 the books'', so to speak, and will ask if you want to apply those minutes to
6166 the next task you clock in on.
6168 There is one other instance when this clock resolution magic occurs.  Say you
6169 were clocked in and hacking away, and suddenly your cat chased a mouse who
6170 scared a hamster that crashed into your UPS's power button!  You suddenly
6171 lose all your buffers, but thanks to auto-save you still have your recent Org
6172 mode changes, including your last clock in.
6174 If you restart Emacs and clock into any task, Org will notice that you have a
6175 dangling clock which was never clocked out from your last session.  Using
6176 that clock's starting time as the beginning of the unaccounted-for period,
6177 Org will ask how you want to resolve that time.  The logic and behavior is
6178 identical to dealing with away time due to idleness; it is just happening due
6179 to a recovery event rather than a set amount of idle time.
6181 You can also check all the files visited by your Org agenda for dangling
6182 clocks at any time using @kbd{M-x org-resolve-clocks}.
6184 @node Effort estimates, Relative timer, Clocking work time, Dates and Times
6185 @section Effort estimates
6186 @cindex effort estimates
6188 @cindex property, Effort
6189 @vindex org-effort-property
6190 If you want to plan your work in a very detailed way, or if you need to
6191 produce offers with quotations of the estimated work effort, you may want to
6192 assign effort estimates to entries.  If you are also clocking your work, you
6193 may later want to compare the planned effort with the actual working time, a
6194 great way to improve planning estimates.  Effort estimates are stored in a
6195 special property @samp{Effort}@footnote{You may change the property being
6196 used with the variable @code{org-effort-property}.}.  You can set the effort
6197 for an entry with the following commands:
6199 @table @kbd
6200 @orgcmd{C-c C-x e,org-set-effort}
6201 Set the effort estimate for the current entry.  With a numeric prefix
6202 argument, set it to the Nth allowed value (see below).  This command is also
6203 accessible from the agenda with the @kbd{e} key.
6204 @orgcmd{C-c C-x C-e,org-clock-modify-effort-estimate}
6205 Modify the effort estimate of the item currently being clocked.
6206 @end table
6208 Clearly the best way to work with effort estimates is through column view
6209 (@pxref{Column view}).  You should start by setting up discrete values for
6210 effort estimates, and a @code{COLUMNS} format that displays these values
6211 together with clock sums (if you want to clock your time).  For a specific
6212 buffer you can use
6214 @example
6215 #+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00
6216 #+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort)@{:@} %CLOCKSUM
6217 @end example
6219 @noindent
6220 @vindex org-global-properties
6221 @vindex org-columns-default-format
6222 or, even better, you can set up these values globally by customizing the
6223 variables @code{org-global-properties} and @code{org-columns-default-format}.
6224 In particular if you want to use this setup also in the agenda, a global
6225 setup may be advised.
6227 The way to assign estimates to individual items is then to switch to column
6228 mode, and to use @kbd{S-@key{right}} and @kbd{S-@key{left}} to change the
6229 value.  The values you enter will immediately be summed up in the hierarchy.
6230 In the column next to it, any clocked time will be displayed.
6232 @vindex org-agenda-columns-add-appointments-to-effort-sum
6233 If you switch to column view in the daily/weekly agenda, the effort column
6234 will summarize the estimated work effort for each day@footnote{Please note
6235 the pitfalls of summing hierarchical data in a flat list (@pxref{Agenda
6236 column view}).}, and you can use this to find space in your schedule.  To get
6237 an overview of the entire part of the day that is committed, you can set the
6238 option @code{org-agenda-columns-add-appointments-to-effort-sum}.  The
6239 appointments on a day that take place over a specified time interval will
6240 then also be added to the load estimate of the day.
6242 Effort estimates can be used in secondary agenda filtering that is triggered
6243 with the @kbd{/} key in the agenda (@pxref{Agenda commands}).  If you have
6244 these estimates defined consistently, two or three key presses will narrow
6245 down the list to stuff that fits into an available time slot.
6247 @node Relative timer, Countdown timer, Effort estimates, Dates and Times
6248 @section Taking notes with a relative timer
6249 @cindex relative timer
6251 When taking notes during, for example, a meeting or a video viewing, it can
6252 be useful to have access to times relative to a starting time.  Org provides
6253 such a relative timer and make it easy to create timed notes.
6255 @table @kbd
6256 @orgcmd{C-c C-x .,org-timer}
6257 Insert a relative time into the buffer.  The first time you use this, the
6258 timer will be started.  When called with a prefix argument, the timer is
6259 restarted.
6260 @orgcmd{C-c C-x -,org-timer-item}
6261 Insert a description list item with the current relative time.  With a prefix
6262 argument, first reset the timer to 0.
6263 @orgcmd{M-@key{RET},org-insert-heading}
6264 Once the timer list is started, you can also use @kbd{M-@key{RET}} to insert
6265 new timer items.
6266 @c for key sequences with a comma, command name macros fail :(
6267 @kindex C-c C-x ,
6268 @item C-c C-x ,
6269 Pause the timer, or continue it if it is already paused
6270 (@command{org-timer-pause-or-continue}).
6271 @c removed the sentence because it is redundant to the following item
6272 @kindex C-u C-c C-x ,
6273 @item C-u C-c C-x ,
6274 Stop the timer.  After this, you can only start a new timer, not continue the
6275 old one.  This command also removes the timer from the mode line.
6276 @orgcmd{C-c C-x 0,org-timer-start}
6277 Reset the timer without inserting anything into the buffer.  By default, the
6278 timer is reset to 0.  When called with a @kbd{C-u} prefix, reset the timer to
6279 specific starting offset.  The user is prompted for the offset, with a
6280 default taken from a timer string at point, if any, So this can be used to
6281 restart taking notes after a break in the process.  When called with a double
6282 prefix argument @kbd{C-u C-u}, change all timer strings in the active region
6283 by a certain amount.  This can be used to fix timer strings if the timer was
6284 not started at exactly the right moment.
6285 @end table
6287 @node Countdown timer,  , Relative timer, Dates and Times
6288 @section Countdown timer
6289 @cindex Countdown timer
6290 @kindex C-c C-x ;
6291 @kindex ;
6293 Calling @code{org-timer-set-timer} from an Org-mode buffer runs a countdown
6294 timer.  Use @kbd{;} from agenda buffers, @key{C-c C-x ;} everwhere else.
6296 @code{org-timer-set-timer} prompts the user for a duration and displays a
6297 countdown timer in the modeline.  @code{org-timer-default-timer} sets the
6298 default countdown value.  Giving a prefix numeric argument overrides this
6299 default value.
6301 @node Capture - Refile - Archive, Agenda Views, Dates and Times, Top
6302 @chapter Capture - Refile - Archive
6303 @cindex capture
6305 An important part of any organization system is the ability to quickly
6306 capture new ideas and tasks, and to associate reference material with them.
6307 Org does this using a process called @i{capture}.  It also can store files
6308 related to a task (@i{attachments}) in a special directory.  Once in the
6309 system, tasks and projects need to be moved around.  Moving completed project
6310 trees to an archive file keeps the system compact and fast.
6312 @menu
6313 * Capture::                     Capturing new stuff
6314 * Attachments::                 Add files to tasks
6315 * RSS Feeds::                   Getting input from RSS feeds
6316 * Protocols::                   External (e.g.@: Browser) access to Emacs and Org
6317 * Refiling notes::              Moving a tree from one place to another
6318 * Archiving::                   What to do with finished projects
6319 @end menu
6321 @node Capture, Attachments, Capture - Refile - Archive, Capture - Refile - Archive
6322 @section Capture
6323 @cindex capture
6325 Org's method for capturing new items is heavily inspired by John Wiegley
6326 excellent remember package.  Up to version 6.36 Org used a special setup
6327 for @file{remember.el}.  @file{org-remember.el} is still part of Org-mode for
6328 backward compatibility with existing setups.  You can find the documentation
6329 for org-remember at @url{http://orgmode.org/org-remember.pdf}.
6331 The new capturing setup described here is preferred and should be used by new
6332 users.  To convert your @code{org-remember-templates}, run the command
6333 @example
6334 @kbd{M-x org-capture-import-remember-templates @key{RET}}
6335 @end example
6336 @noindent and then customize the new variable with @kbd{M-x
6337 customize-variable org-capture-templates}, check the result, and save the
6338 customization.  You can then use both remember and capture until
6339 you are familiar with the new mechanism.
6341 Capture lets you quickly store notes with little interruption of your work
6342 flow.  The basic process of capturing is very similar to remember, but Org
6343 does enhance it with templates and more.
6345 @menu
6346 * Setting up capture::          Where notes will be stored
6347 * Using capture::               Commands to invoke and terminate capture
6348 * Capture templates::           Define the outline of different note types
6349 @end menu
6351 @node Setting up capture, Using capture, Capture, Capture
6352 @subsection Setting up capture
6354 The following customization sets a default target file for notes, and defines
6355 a global key@footnote{Please select your own key, @kbd{C-c c} is only a
6356 suggestion.}  for capturing new material.
6358 @vindex org-default-notes-file
6359 @example
6360 (setq org-default-notes-file (concat org-directory "/notes.org"))
6361 (define-key global-map "\C-cc" 'org-capture)
6362 @end example
6364 @node Using capture, Capture templates, Setting up capture, Capture
6365 @subsection Using capture
6367 @table @kbd
6368 @orgcmd{C-c c,org-capture}
6369 Call the command @code{org-capture}.  Note that this keybinding is global and
6370 not active by default - you need to install it.  If you have templates
6371 @cindex date tree
6372 defined @pxref{Capture templates}, it will offer these templates for
6373 selection or use a new Org outline node as the default template.  It will
6374 insert the template into the target file and switch to an indirect buffer
6375 narrowed to this new node.  You may then insert the information you want.
6377 @orgcmd{C-c C-c,org-capture-finalize}
6378 Once you have finished entering information into the capture buffer, @kbd{C-c
6379 C-c} will return you to the window configuration before the capture process,
6380 so that you can resume your work without further distraction.  When called
6381 with a prefix arg, finalize and then jump to the captured item.
6383 @orgcmd{C-c C-w,org-capture-refile}
6384 Finalize the capture process by refiling (@pxref{Refiling notes}) the note to
6385 a different place.  Please realize that this is a normal refiling command
6386 that will be executed---so the cursor position at the moment you run this
6387 command is important.  If you have inserted a tree with a parent and
6388 children, first move the cursor back to the parent.  Any prefix argument
6389 given to this command will be passed on to the @code{org-refile} command.
6391 @orgcmd{C-c C-k,org-capture-kill}
6392 Abort the capture process and return to the previous state.
6394 @end table
6396 You can also call @code{org-capture} in a special way from the agenda, using
6397 the @kbd{k c} key combination.  With this access, any timestamps inserted by
6398 the selected capture template will default to the cursor date in the agenda,
6399 rather than to the current date.
6401 To find the locations of the last stored capture, use @code{org-capture} with
6402 prefix commands:
6404 @table @kbd
6405 @orgkey{C-u C-c c}
6406 Visit the target location of a capture template.  You get to select the
6407 template in the usual way.
6408 @orgkey{C-u C-u C-c c}
6409 Visit the last stored capture item in its buffer.
6410 @end table
6412 @node Capture templates,  , Using capture, Capture
6413 @subsection Capture templates
6414 @cindex templates, for Capture
6416 You can use templates for different types of capture items, and
6417 for different target locations.  The easiest way to create such templates is
6418 through the customize interface.
6420 @table @kbd
6421 @orgkey{C-c c C}
6422 Customize the variable @code{org-capture-templates}.
6423 @end table
6425 Before we give the formal description of template definitions, let's look at
6426 an example.  Say you would like to use one template to create general TODO
6427 entries, and you want to put these entries under the heading @samp{Tasks} in
6428 your file @file{~/org/gtd.org}.  Also, a date tree in the file
6429 @file{journal.org} should capture journal entries.  A possible configuration
6430 would look like:
6432 @example
6433 (setq org-capture-templates
6434  '(("t" "Todo" entry (file+headline "~/org/gtd.org" "Tasks")
6435         "* TODO %?\n  %i\n  %a")
6436    ("j" "Journal" entry (file+datetree "~/org/journal.org")
6437         "* %?\nEntered on %U\n  %i\n  %a")))
6438 @end example
6440 @noindent If you then press @kbd{C-c c t}, Org will prepare the template
6441 for you like this:
6442 @example
6443 * TODO
6444   [[file:@var{link to where you initiated capture}]]
6445 @end example
6447 @noindent
6448 During expansion of the template, @code{%a} has been replaced by a link to
6449 the location from where you called the capture command.  This can be
6450 extremely useful for deriving tasks from emails, for example.  You fill in
6451 the task definition, press @code{C-c C-c} and Org returns you to the same
6452 place where you started the capture process.
6454 To define special keys to capture to a particular template without going
6455 through the interactive template selection, you can create your key binding
6456 like this:
6458 @lisp
6459 (define-key global-map "\C-cx"
6460    (lambda () (interactive) (org-capture nil "x")))
6461 @end lisp
6463 @menu
6464 * Template elements::           What is needed for a complete template entry
6465 * Template expansion::          Filling in information about time and context
6466 @end menu
6468 @node Template elements, Template expansion, Capture templates, Capture templates
6469 @subsubsection Template elements
6471 Now lets look at the elements of a template definition.  Each entry in
6472 @code{org-capture-templates} is a list with the following items:
6474 @table @var
6475 @item keys
6476 The keys that will select the template, as a string, characters
6477 only, for example @code{"a"} for a template to be selected with a
6478 single key, or @code{"bt"} for selection with two keys.  When using
6479 several keys, keys using the same prefix key must be sequential
6480 in the list and preceded by a 2-element entry explaining the
6481 prefix key, for example
6482 @example
6483          ("b" "Templates for marking stuff to buy")
6484 @end example
6485 @noindent If you do not define a template for the @kbd{C} key, this key will
6486 be used to open the customize buffer for this complex variable.
6488 @item description
6489 A short string describing the template, which will be shown during
6490 selection.
6492 @item type
6493 The type of entry, a symbol.  Valid values are:
6494 @table @code
6495 @item entry
6496 An Org-mode node, with a headline.  Will be filed as the child of the target
6497 entry or as a top-level entry.  The target file should be an Org-mode file.
6498 @item item
6499 A plain list item, placed in the first plain  list at the target
6500 location.  Again the target file should be an Org file.
6501 @item checkitem
6502 A checkbox item.  This only differs from the plain list item by the
6503 default template.
6504 @item table-line
6505 a new line in the first table at the target location.  Where exactly the
6506 line will be inserted depends on the properties @code{:prepend} and
6507 @code{:table-line-pos} (see below).
6508 @item plain
6509 Text to be inserted as it is.
6510 @end table
6512 @item target
6513 @vindex org-default-notes-file
6514 Specification of where the captured item should be placed.  In Org-mode
6515 files, targets usually define a node.  Entries will become children of this
6516 node.  Other types will be added to the table or list in the body of this
6517 node.  Most target specifications contain a file name.  If that file name is
6518 the empty string, it defaults to @code{org-default-notes-file}.  A file can
6519 also be given as a variable, function, or Emacs Lisp form.
6521 Valid values are:
6522 @table @code
6523 @item (file "path/to/file")
6524 Text will be placed at the beginning or end of that file.
6526 @item (id "id of existing org entry")
6527 Filing as child of this entry, or in the body of the entry.
6529 @item (file+headline "path/to/file" "node headline")
6530 Fast configuration if the target heading is unique in the file.
6532 @item (file+olp "path/to/file" "Level 1 heading" "Level 2" ...)
6533 For non-unique headings, the full path is safer.
6535 @item (file+regexp  "path/to/file" "regexp to find location")
6536 Use a regular expression to position the cursor.
6538 @item (file+datetree "path/to/file")
6539 Will create a heading in a date tree for today's date.
6541 @item (file+datetree+prompt "path/to/file")
6542 Will create a heading in a date tree, but will prompt for the date.
6544 @item (file+function "path/to/file" function-finding-location)
6545 A function to find the right location in the file.
6547 @item (clock)
6548 File to the entry that is currently being clocked.
6550 @item (function function-finding-location)
6551 Most general way, write your own function to find both
6552 file and location.
6553 @end table
6555 @item template
6556 The template for creating the capture item.  If you leave this empty, an
6557 appropriate default template will be used.  Otherwise this is a string with
6558 escape codes, which will be replaced depending on time and context of the
6559 capture call.  The string with escapes may be loaded from a template file,
6560 using the special syntax @code{(file "path/to/template")}.  See below for
6561 more details.
6563 @item properties
6564 The rest of the entry is a property list of additional options.
6565 Recognized properties are:
6566 @table @code
6567 @item :prepend
6568 Normally new captured information will be appended at
6569 the target location (last child, last table line, last list item...).
6570 Setting this property will change that.
6572 @item :immediate-finish
6573 When set, do not offer to edit the information, just
6574 file it away immediately.  This makes sense if the template only needs
6575 information that can be added automatically.
6577 @item :empty-lines
6578 Set this to the number of lines to insert
6579 before and after the new item.  Default 0, only common other value is 1.
6581 @item :clock-in
6582 Start the clock in this item.
6584 @item :clock-keep
6585 Keep the clock running when filing the captured entry.
6587 @item :clock-resume
6588 If starting the capture interrupted a clock, restart that clock when finished
6589 with the capture.  Note that @code{:clock-keep} has precedence over
6590 @code{:clock-resume}.  When setting both to @code{t}, the current clock will
6591 run and the previous one will not be resumed.
6593 @item :unnarrowed
6594 Do not narrow the target buffer, simply show the full buffer.  Default is to
6595 narrow it so that you only see the new material.
6597 @item :table-line-pos
6598 Specification of the location in the table where the new line should be
6599 inserted.  It should be a string like @code{"II-3"} meaning that the new
6600 line should become the third line before the second horizontal separator
6601 line.
6603 @item :kill-buffer
6604 If the target file was not yet visited when capture was invoked, kill the
6605 buffer again after capture is completed.
6606 @end table
6607 @end table
6609 @node Template expansion,  , Template elements, Capture templates
6610 @subsubsection Template expansion
6612 In the template itself, special @kbd{%}-escapes@footnote{If you need one of
6613 these sequences literally, escape the @kbd{%} with a backslash.}  allow
6614 dynamic insertion of content. The templates are expanded in the order given here:
6616 @smallexample
6617 %[@var{file}]     @r{insert the contents of the file given by @var{file}.}
6618 %(@var{sexp})     @r{evaluate Elisp @var{sexp} and replace with the result.}
6619 %<...>      @r{the result of format-time-string on the ... format specification.}
6620 %t          @r{timestamp, date only.}
6621 %T          @r{timestamp with date and time.}
6622 %u, %U      @r{like the above, but inactive timestamps.}
6623 %a          @r{annotation, normally the link created with @code{org-store-link}.}
6624 %i          @r{initial content, the region when capture is called while the}
6625             @r{region is active.}
6626             @r{The entire text will be indented like @code{%i} itself.}
6627 %A          @r{like @code{%a}, but prompt for the description part.}
6628 %c          @r{Current kill ring head.}
6629 %x          @r{Content of the X clipboard.}
6630 %k          @r{title of the currently clocked task.}
6631 %K          @r{link to the currently clocked task.}
6632 %n          @r{user name (taken from @code{user-full-name}).}
6633 %f          @r{file visited by current buffer when org-capture was called.}
6634 %F          @r{full path of the file or directory visited by current buffer.}
6635 %:keyword   @r{specific information for certain link types, see below.}
6636 %^g         @r{prompt for tags, with completion on tags in target file.}
6637 %^G         @r{prompt for tags, with completion all tags in all agenda files.}
6638 %^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}.}
6639             @r{You may define a prompt like @code{%^@{Birthday@}t}.}
6640 %^C         @r{Interactive selection of which kill or clip to use.}
6641 %^L         @r{Like @code{%^C}, but insert as link.}
6642 %^@{@var{prop}@}p   @r{Prompt the user for a value for property @var{prop}.}
6643 %^@{@var{prompt}@}  @r{prompt the user for a string and replace this sequence with it.}
6644             @r{You may specify a default value and a completion table with}
6645             @r{%^@{prompt|default|completion2|completion3...@}.}
6646             @r{The arrow keys access a prompt-specific history.}
6647 @end smallexample
6649 @noindent
6650 For specific link types, the following keywords will be
6651 defined@footnote{If you define your own link types (@pxref{Adding
6652 hyperlink types}), any property you store with
6653 @code{org-store-link-props} can be accessed in capture templates in a
6654 similar way.}:
6656 @vindex org-from-is-user-regexp
6657 @smallexample
6658 Link type               |  Available keywords
6659 ------------------------+----------------------------------------------
6660 bbdb                    |  %:name %:company
6661 irc                     |  %:server %:port %:nick
6662 vm, wl, mh, mew, rmail  |  %:type %:subject %:message-id
6663                         |  %:from %:fromname %:fromaddress
6664                         |  %:to   %:toname   %:toaddress
6665                         |  %:date @r{(message date header field)}
6666                         |  %:date-timestamp @r{(date as active timestamp)}
6667                         |  %:date-timestamp-inactive @r{(date as inactive timestamp)}
6668                         |  %: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}.}}
6669 gnus                    |  %:group, @r{for messages also all email fields}
6670 w3, w3m                 |  %:url
6671 info                    |  %:file %:node
6672 calendar                |  %:date
6673 @end smallexample
6675 @noindent
6676 To place the cursor after template expansion use:
6678 @smallexample
6679 %?          @r{After completing the template, position cursor here.}
6680 @end smallexample
6683 @node Attachments, RSS Feeds, Capture, Capture - Refile - Archive
6684 @section Attachments
6685 @cindex attachments
6687 @vindex org-attach-directory
6688 It is often useful to associate reference material with an outline node/task.
6689 Small chunks of plain text can simply be stored in the subtree of a project.
6690 Hyperlinks (@pxref{Hyperlinks}) can establish associations with
6691 files that live elsewhere on your computer or in the cloud, like emails or
6692 source code files belonging to a project.  Another method is @i{attachments},
6693 which are files located in a directory belonging to an outline node.  Org
6694 uses directories named by the unique ID of each entry.  These directories are
6695 located in the @file{data} directory which lives in the same directory where
6696 your Org file lives@footnote{If you move entries or Org files from one
6697 directory to another, you may want to configure @code{org-attach-directory}
6698 to contain an absolute path.}.  If you initialize this directory with
6699 @code{git init}, Org will automatically commit changes when it sees them.
6700 The attachment system has been contributed to Org by John Wiegley.
6702 In cases where it seems better to do so, you can also attach a directory of your
6703 choice to an entry.  You can also make children inherit the attachment
6704 directory from a parent, so that an entire subtree uses the same attached
6705 directory.
6707 @noindent The following commands deal with attachments:
6709 @table @kbd
6711 @orgcmd{C-c C-a,org-attach}
6712 The dispatcher for commands related to the attachment system.  After these
6713 keys, a list of commands is displayed and you must press an additional key
6714 to select a command:
6716 @table @kbd
6717 @orgcmdtkc{a,C-c C-a a,org-attach-attach}
6718 @vindex org-attach-method
6719 Select a file and move it into the task's attachment directory.  The file
6720 will be copied, moved, or linked, depending on @code{org-attach-method}.
6721 Note that hard links are not supported on all systems.
6723 @kindex C-c C-a c
6724 @kindex C-c C-a m
6725 @kindex C-c C-a l
6726 @item c/m/l
6727 Attach a file using the copy/move/link method.
6728 Note that hard links are not supported on all systems.
6730 @orgcmdtkc{n,C-c C-a n,org-attach-new}
6731 Create a new attachment as an Emacs buffer.
6733 @orgcmdtkc{z,C-c C-a z,org-attach-sync}
6734 Synchronize the current task with its attachment directory, in case you added
6735 attachments yourself.
6737 @orgcmdtkc{o,C-c C-a o,org-attach-open}
6738 @vindex org-file-apps
6739 Open current task's attachment.  If there is more than one, prompt for a
6740 file name first.  Opening will follow the rules set by @code{org-file-apps}.
6741 For more details, see the information on following hyperlinks
6742 (@pxref{Handling links}).
6744 @orgcmdtkc{O,C-c C-a O,org-attach-open-in-emacs}
6745 Also open the attachment, but force opening the file in Emacs.
6747 @orgcmdtkc{f,C-c C-a f,org-attach-reveal}
6748 Open the current task's attachment directory.
6750 @orgcmdtkc{F,C-c C-a F,org-attach-reveal-in-emacs}
6751 Also open the directory, but force using @command{dired} in Emacs.
6753 @orgcmdtkc{d,C-c C-a d,org-attach-delete-one}
6754 Select and delete a single attachment.
6756 @orgcmdtkc{D,C-c C-a D,org-attach-delete-all}
6757 Delete all of a task's attachments.  A safer way is to open the directory in
6758 @command{dired} and delete from there.
6760 @orgcmdtkc{s,C-c C-a s,org-attach-set-directory}
6761 @cindex property, ATTACH_DIR
6762 Set a specific directory as the entry's attachment directory.  This works by
6763 putting the directory path into the @code{ATTACH_DIR} property.
6765 @orgcmdtkc{i,C-c C-a i,org-attach-set-inherit}
6766 @cindex property, ATTACH_DIR_INHERIT
6767 Set the @code{ATTACH_DIR_INHERIT} property, so that children will use the
6768 same directory for attachments as the parent does.
6769 @end table
6770 @end table
6772 @node RSS Feeds, Protocols, Attachments, Capture - Refile - Archive
6773 @section RSS feeds
6774 @cindex RSS feeds
6775 @cindex Atom feeds
6777 Org can add and change entries based on information found in RSS feeds and
6778 Atom feeds.  You could use this to make a task out of each new podcast in a
6779 podcast feed.  Or you could use a phone-based note-creating service on the
6780 web to import tasks into Org.  To access feeds, configure the variable
6781 @code{org-feed-alist}.  The docstring of this variable has detailed
6782 information.  Here is just an example:
6784 @example
6785 (setq org-feed-alist
6786      '(("Slashdot"
6787          "http://rss.slashdot.org/Slashdot/slashdot"
6788          "~/txt/org/feeds.org" "Slashdot Entries")))
6789 @end example
6791 @noindent
6792 will configure that new items from the feed provided by
6793 @code{rss.slashdot.org} will result in new entries in the file
6794 @file{~/org/feeds.org} under the heading @samp{Slashdot Entries}, whenever
6795 the following command is used:
6797 @table @kbd
6798 @orgcmd{C-c C-x g,org-feed-update-all}
6799 @item C-c C-x g
6800 Collect items from the feeds configured in @code{org-feed-alist} and act upon
6801 them.
6802 @orgcmd{C-c C-x G,org-feed-goto-inbox}
6803 Prompt for a feed name and go to the inbox configured for this feed.
6804 @end table
6806 Under the same headline, Org will create a drawer @samp{FEEDSTATUS} in which
6807 it will store information about the status of items in the feed, to avoid
6808 adding the same item several times.  You should add @samp{FEEDSTATUS} to the
6809 list of drawers in that file:
6811 @example
6812 #+DRAWERS: LOGBOOK PROPERTIES FEEDSTATUS
6813 @end example
6815 For more information, including how to read atom feeds, see
6816 @file{org-feed.el} and the docstring of @code{org-feed-alist}.
6818 @node Protocols, Refiling notes, RSS Feeds, Capture - Refile - Archive
6819 @section Protocols for external access
6820 @cindex protocols, for external access
6821 @cindex emacsserver
6823 You can set up Org for handling protocol calls from outside applications that
6824 are passed to Emacs through the @file{emacsserver}.  For example, you can
6825 configure bookmarks in your web browser to send a link to the current page to
6826 Org and create a note from it using capture (@pxref{Capture}).  Or you
6827 could create a bookmark that will tell Emacs to open the local source file of
6828 a remote website you are looking at with the browser.  See
6829 @uref{http://orgmode.org/worg/org-contrib/org-protocol.php} for detailed
6830 documentation and setup instructions.
6832 @node Refiling notes, Archiving, Protocols, Capture - Refile - Archive
6833 @section Refiling notes
6834 @cindex refiling notes
6836 When reviewing the captured data, you may want to refile some of the entries
6837 into a different list, for example into a project.  Cutting, finding the
6838 right location, and then pasting the note is cumbersome.  To simplify this
6839 process, you can use the following special command:
6841 @table @kbd
6842 @orgcmd{C-c C-w,org-refile}
6843 @vindex org-reverse-note-order
6844 @vindex org-refile-targets
6845 @vindex org-refile-use-outline-path
6846 @vindex org-outline-path-complete-in-steps
6847 @vindex org-refile-allow-creating-parent-nodes
6848 @vindex org-log-refile
6849 @vindex org-refile-use-cache
6850 Refile the entry or region at point.  This command offers possible locations
6851 for refiling the entry and lets you select one with completion.  The item (or
6852 all items in the region) is filed below the target heading as a subitem.
6853 Depending on @code{org-reverse-note-order}, it will be either the first or
6854 last subitem.@*
6855 By default, all level 1 headlines in the current buffer are considered to be
6856 targets, but you can have more complex definitions across a number of files.
6857 See the variable @code{org-refile-targets} for details.  If you would like to
6858 select a location via a file-path-like completion along the outline path, see
6859 the variables @code{org-refile-use-outline-path} and
6860 @code{org-outline-path-complete-in-steps}.  If you would like to be able to
6861 create new nodes as new parents for refiling on the fly, check the
6862 variable @code{org-refile-allow-creating-parent-nodes}.
6863 When the variable @code{org-log-refile}@footnote{with corresponding
6864 @code{#+STARTUP} keywords @code{logrefile}, @code{lognoterefile},
6865 and @code{nologrefile}} is set, a timestamp or a note will be
6866 recorded when an entry has been refiled.
6867 @orgkey{C-u C-c C-w}
6868 Use the refile interface to jump to a heading.
6869 @orgcmd{C-u C-u C-c C-w,org-refile-goto-last-stored}
6870 Jump to the location where @code{org-refile} last moved a tree to.
6871 @item C-2 C-c C-w
6872 Refile as the child of the item currently being clocked.
6873 @item C-0 C-c C-w @ @r{or} @ C-u C-u C-u C-c C-w
6875 @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}
6877 Clear the target cache.  Caching of refile targets can be turned on by
6878 setting @code{org-refile-use-cache}.  To make the command see new possible
6879 targets, you have to clear the cache with this command.
6880 @end table
6882 @node Archiving,  , Refiling notes, Capture - Refile - Archive
6883 @section Archiving
6884 @cindex archiving
6886 When a project represented by a (sub)tree is finished, you may want
6887 to move the tree out of the way and to stop it from contributing to the
6888 agenda.  Archiving is important to keep your working files compact and global
6889 searches like the construction of agenda views fast.
6891 @table @kbd
6892 @orgcmd{C-c C-x C-a,org-archive-subtree-default}
6893 @vindex org-archive-default-command
6894 Archive the current entry using the command specified in the variable
6895 @code{org-archive-default-command}.
6896 @end table
6898 @menu
6899 * Moving subtrees::             Moving a tree to an archive file
6900 * Internal archiving::          Switch off a tree but keep it in the file
6901 @end menu
6903 @node Moving subtrees, Internal archiving, Archiving, Archiving
6904 @subsection Moving a tree to the archive file
6905 @cindex external archiving
6907 The most common archiving action is to move a project tree to another file,
6908 the archive file.
6910 @table @kbd
6911 @orgcmdkskc{C-c C-x C-s,C-c $,org-archive-subtree}
6912 @vindex org-archive-location
6913 Archive the subtree starting at the cursor position to the location
6914 given by @code{org-archive-location}.
6915 @orgkey{C-u C-c C-x C-s}
6916 Check if any direct children of the current headline could be moved to
6917 the archive.  To do this, each subtree is checked for open TODO entries.
6918 If none are found, the command offers to move it to the archive
6919 location.  If the cursor is @emph{not} on a headline when this command
6920 is invoked, the level 1 trees will be checked.
6921 @end table
6923 @cindex archive locations
6924 The default archive location is a file in the same directory as the
6925 current file, with the name derived by appending @file{_archive} to the
6926 current file name.  For information and examples on how to change this,
6927 see the documentation string of the variable
6928 @code{org-archive-location}.  There is also an in-buffer option for
6929 setting this variable, for example@footnote{For backward compatibility,
6930 the following also works: If there are several such lines in a file,
6931 each specifies the archive location for the text below it.  The first
6932 such line also applies to any text before its definition.  However,
6933 using this method is @emph{strongly} deprecated as it is incompatible
6934 with the outline structure of the document.  The correct method for
6935 setting multiple archive locations in a buffer is using properties.}:
6937 @cindex #+ARCHIVE
6938 @example
6939 #+ARCHIVE: %s_done::
6940 @end example
6942 @cindex property, ARCHIVE
6943 @noindent
6944 If you would like to have a special ARCHIVE location for a single entry
6945 or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
6946 location as the value (@pxref{Properties and Columns}).
6948 @vindex org-archive-save-context-info
6949 When a subtree is moved, it receives a number of special properties that
6950 record context information like the file from where the entry came, its
6951 outline path the archiving time etc.  Configure the variable
6952 @code{org-archive-save-context-info} to adjust the amount of information
6953 added.
6956 @node Internal archiving,  , Moving subtrees, Archiving
6957 @subsection Internal archiving
6959 If you want to just switch off (for agenda views) certain subtrees without
6960 moving them to a different file, you can use the @code{ARCHIVE tag}.
6962 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
6963 its location in the outline tree, but behaves in the following way:
6964 @itemize @minus
6965 @item
6966 @vindex org-cycle-open-archived-trees
6967 It does not open when you attempt to do so with a visibility cycling
6968 command (@pxref{Visibility cycling}).  You can force cycling archived
6969 subtrees with @kbd{C-@key{TAB}}, or by setting the option
6970 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
6971 @code{show-all} will open archived subtrees.
6972 @item
6973 @vindex org-sparse-tree-open-archived-trees
6974 During sparse tree construction (@pxref{Sparse trees}), matches in
6975 archived subtrees are not exposed, unless you configure the option
6976 @code{org-sparse-tree-open-archived-trees}.
6977 @item
6978 @vindex org-agenda-skip-archived-trees
6979 During agenda view construction (@pxref{Agenda Views}), the content of
6980 archived trees is ignored unless you configure the option
6981 @code{org-agenda-skip-archived-trees}, in which case these trees will always
6982 be included.  In the agenda you can press @kbd{v a} to get archives
6983 temporarily included.
6984 @item
6985 @vindex org-export-with-archived-trees
6986 Archived trees are not exported (@pxref{Exporting}), only the headline
6987 is.  Configure the details using the variable
6988 @code{org-export-with-archived-trees}.
6989 @item
6990 @vindex org-columns-skip-archived-trees
6991 Archived trees are excluded from column view unless the variable
6992 @code{org-columns-skip-archived-trees} is configured to @code{nil}.
6993 @end itemize
6995 The following commands help manage the ARCHIVE tag:
6997 @table @kbd
6998 @orgcmd{C-c C-x a,org-toggle-archive-tag}
6999 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
7000 the headline changes to a shadowed face, and the subtree below it is
7001 hidden.
7002 @orgkey{C-u C-c C-x a}
7003 Check if any direct children of the current headline should be archived.
7004 To do this, each subtree is checked for open TODO entries.  If none are
7005 found, the command offers to set the ARCHIVE tag for the child.  If the
7006 cursor is @emph{not} on a headline when this command is invoked, the
7007 level 1 trees will be checked.
7008 @orgcmd{C-@kbd{TAB},org-force-cycle-archived}
7009 Cycle a tree even if it is tagged with ARCHIVE.
7010 @orgcmd{C-c C-x A,org-archive-to-archive-sibling}
7011 Move the current entry to the @emph{Archive Sibling}.  This is a sibling of
7012 the entry with the heading @samp{Archive} and the tag @samp{ARCHIVE}.  The
7013 entry becomes a child of that sibling and in this way retains a lot of its
7014 original context, including inherited tags and approximate position in the
7015 outline.
7016 @end table
7019 @node Agenda Views, Markup, Capture - Refile - Archive, Top
7020 @chapter Agenda views
7021 @cindex agenda views
7023 Due to the way Org works, TODO items, time-stamped items, and
7024 tagged headlines can be scattered throughout a file or even a number of
7025 files.  To get an overview of open action items, or of events that are
7026 important for a particular date, this information must be collected,
7027 sorted and displayed in an organized way.
7029 Org can select items based on various criteria and display them
7030 in a separate buffer.  Seven different view types are provided:
7032 @itemize @bullet
7033 @item
7034 an @emph{agenda} that is like a calendar and shows information
7035 for specific dates,
7036 @item
7037 a @emph{TODO list} that covers all unfinished
7038 action items,
7039 @item
7040 a @emph{match view}, showings headlines based on the tags, properties, and
7041 TODO state associated with them,
7042 @item
7043 a @emph{timeline view} that shows all events in a single Org file,
7044 in time-sorted view,
7045 @item
7046 a @emph{text search view} that shows all entries from multiple files
7047 that contain specified keywords,
7048 @item
7049 a @emph{stuck projects view} showing projects that currently don't move
7050 along, and
7051 @item
7052 @emph{custom views} that are special searches and combinations of different
7053 views.
7054 @end itemize
7056 @noindent
7057 The extracted information is displayed in a special @emph{agenda
7058 buffer}.  This buffer is read-only, but provides commands to visit the
7059 corresponding locations in the original Org files, and even to
7060 edit these files remotely.
7062 @vindex org-agenda-window-setup
7063 @vindex org-agenda-restore-windows-after-quit
7064 Two variables control how the agenda buffer is displayed and whether the
7065 window configuration is restored when the agenda exits:
7066 @code{org-agenda-window-setup} and
7067 @code{org-agenda-restore-windows-after-quit}.
7069 @menu
7070 * Agenda files::                Files being searched for agenda information
7071 * Agenda dispatcher::           Keyboard access to agenda views
7072 * Built-in agenda views::       What is available out of the box?
7073 * Presentation and sorting::    How agenda items are prepared for display
7074 * Agenda commands::             Remote editing of Org trees
7075 * Custom agenda views::         Defining special searches and views
7076 * Exporting Agenda Views::      Writing a view to a file
7077 * Agenda column view::          Using column view for collected entries
7078 @end menu
7080 @node Agenda files, Agenda dispatcher, Agenda Views, Agenda Views
7081 @section Agenda files
7082 @cindex agenda files
7083 @cindex files for agenda
7085 @vindex org-agenda-files
7086 The information to be shown is normally collected from all @emph{agenda
7087 files}, the files listed in the variable
7088 @code{org-agenda-files}@footnote{If the value of that variable is not a
7089 list, but a single file name, then the list of agenda files will be
7090 maintained in that external file.}.  If a directory is part of this list,
7091 all files with the extension @file{.org} in this directory will be part
7092 of the list.
7094 Thus, even if you only work with a single Org file, that file should
7095 be put into the list@footnote{When using the dispatcher, pressing
7096 @kbd{<} before selecting a command will actually limit the command to
7097 the current file, and ignore @code{org-agenda-files} until the next
7098 dispatcher command.}.  You can customize @code{org-agenda-files}, but
7099 the easiest way to maintain it is through the following commands
7101 @cindex files, adding to agenda list
7102 @table @kbd
7103 @orgcmd{C-c [,org-agenda-file-to-front}
7104 Add current file to the list of agenda files.  The file is added to
7105 the front of the list.  If it was already in the list, it is moved to
7106 the front.  With a prefix argument, file is added/moved to the end.
7107 @orgcmd{C-c ],org-remove-file}
7108 Remove current file from the list of agenda files.
7109 @kindex C-,
7110 @orgcmd{C-',org-cycle-agenda-files}
7111 @itemx C-,
7112 Cycle through agenda file list, visiting one file after the other.
7113 @kindex M-x org-iswitchb
7114 @item M-x org-iswitchb
7115 Command to use an @code{iswitchb}-like interface to switch to and between Org
7116 buffers.
7117 @end table
7119 @noindent
7120 The Org menu contains the current list of files and can be used
7121 to visit any of them.
7123 If you would like to focus the agenda temporarily on a file not in
7124 this list, or on just one file in the list, or even on only a subtree in a
7125 file, then this can be done in different ways.  For a single agenda command,
7126 you may press @kbd{<} once or several times in the dispatcher
7127 (@pxref{Agenda dispatcher}).  To restrict the agenda scope for an
7128 extended period, use the following commands:
7130 @table @kbd
7131 @orgcmd{C-c C-x <,org-agenda-set-restriction-lock}
7132 Permanently restrict the agenda to the current subtree.  When with a
7133 prefix argument, or with the cursor before the first headline in a file,
7134 the agenda scope is set to the entire file.  This restriction remains in
7135 effect until removed with @kbd{C-c C-x >}, or by typing either @kbd{<}
7136 or @kbd{>} in the agenda dispatcher.  If there is a window displaying an
7137 agenda view, the new restriction takes effect immediately.
7138 @orgcmd{C-c C-x >,org-agenda-remove-restriction-lock}
7139 Remove the permanent restriction created by @kbd{C-c C-x <}.
7140 @end table
7142 @noindent
7143 When working with @file{speedbar.el}, you can use the following commands in
7144 the Speedbar frame:
7145 @table @kbd
7146 @orgcmdtkc{< @r{in the speedbar frame},<,org-speedbar-set-agenda-restriction}
7147 Permanently restrict the agenda to the item---either an Org file or a subtree
7148 in such a file---at the cursor in the Speedbar frame.
7149 If there is a window displaying an agenda view, the new restriction takes
7150 effect immediately.
7151 @orgcmdtkc{> @r{in the speedbar frame},>,org-agenda-remove-restriction-lock}
7152 Lift the restriction.
7153 @end table
7155 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda Views
7156 @section The agenda dispatcher
7157 @cindex agenda dispatcher
7158 @cindex dispatching agenda commands
7159 The views are created through a dispatcher, which should be bound to a
7160 global key---for example @kbd{C-c a} (@pxref{Activation}).  In the
7161 following we will assume that @kbd{C-c a} is indeed how the dispatcher
7162 is accessed and list keyboard access to commands accordingly.  After
7163 pressing @kbd{C-c a}, an additional letter is required to execute a
7164 command.  The dispatcher offers the following default commands:
7165 @table @kbd
7166 @item a
7167 Create the calendar-like agenda (@pxref{Weekly/daily agenda}).
7168 @item t @r{/} T
7169 Create a list of all TODO items (@pxref{Global TODO list}).
7170 @item m @r{/} M
7171 Create a list of headlines matching a TAGS expression (@pxref{Matching
7172 tags and properties}).
7173 @item L
7174 Create the timeline view for the current buffer (@pxref{Timeline}).
7175 @item s
7176 Create a list of entries selected by a boolean expression of keywords
7177 and/or regular expressions that must or must not occur in the entry.
7178 @item /
7179 @vindex org-agenda-text-search-extra-files
7180 Search for a regular expression in all agenda files and additionally in
7181 the files listed in @code{org-agenda-text-search-extra-files}.  This
7182 uses the Emacs command @code{multi-occur}.  A prefix argument can be
7183 used to specify the number of context lines for each match, default is
7185 @item # @r{/} !
7186 Create a list of stuck projects (@pxref{Stuck projects}).
7187 @item <
7188 Restrict an agenda command to the current buffer@footnote{For backward
7189 compatibility, you can also press @kbd{1} to restrict to the current
7190 buffer.}.  After pressing @kbd{<}, you still need to press the character
7191 selecting the command.
7192 @item < <
7193 If there is an active region, restrict the following agenda command to
7194 the region.  Otherwise, restrict it to the current subtree@footnote{For
7195 backward compatibility, you can also press @kbd{0} to restrict to the
7196 current region/subtree.}.  After pressing @kbd{< <}, you still need to press the
7197 character selecting the command.
7198 @end table
7200 You can also define custom commands that will be accessible through the
7201 dispatcher, just like the default commands.  This includes the
7202 possibility to create extended agenda buffers that contain several
7203 blocks together, for example the weekly agenda, the global TODO list and
7204 a number of special tags matches.  @xref{Custom agenda views}.
7206 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda Views
7207 @section The built-in agenda views
7209 In this section we describe the built-in views.
7211 @menu
7212 * Weekly/daily agenda::         The calendar page with current tasks
7213 * Global TODO list::            All unfinished action items
7214 * Matching tags and properties::  Structured information with fine-tuned search
7215 * Timeline::                    Time-sorted view for single file
7216 * Search view::                 Find entries by searching for text
7217 * Stuck projects::              Find projects you need to review
7218 @end menu
7220 @node Weekly/daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
7221 @subsection The weekly/daily agenda
7222 @cindex agenda
7223 @cindex weekly agenda
7224 @cindex daily agenda
7226 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
7227 paper agenda, showing all the tasks for the current week or day.
7229 @table @kbd
7230 @cindex org-agenda, command
7231 @orgcmd{C-c a a,org-agenda-list}
7232 Compile an agenda for the current week from a list of Org files.  The agenda
7233 shows the entries for each day.  With a numeric prefix@footnote{For backward
7234 compatibility, the universal prefix @kbd{C-u} causes all TODO entries to be
7235 listed before the agenda.  This feature is deprecated, use the dedicated TODO
7236 list, or a block agenda instead (@pxref{Block agenda}).}  (like @kbd{C-u 2 1
7237 C-c a a}) you may set the number of days to be displayed.
7238 @end table
7240 @vindex org-agenda-span
7241 @vindex org-agenda-ndays
7242 The default number of days displayed in the agenda is set by the variable
7243 @code{org-agenda-span} (or the obsolete @code{org-agenda-ndays}).  This
7244 variable can be set to any number of days you want to see by default in the
7245 agenda, or to a span name, such a @code{day}, @code{week}, @code{month} or
7246 @code{year}.
7248 Remote editing from the agenda buffer means, for example, that you can
7249 change the dates of deadlines and appointments from the agenda buffer.
7250 The commands available in the Agenda buffer are listed in @ref{Agenda
7251 commands}.
7253 @subsubheading Calendar/Diary integration
7254 @cindex calendar integration
7255 @cindex diary integration
7257 Emacs contains the calendar and diary by Edward M. Reingold.  The
7258 calendar displays a three-month calendar with holidays from different
7259 countries and cultures.  The diary allows you to keep track of
7260 anniversaries, lunar phases, sunrise/set, recurrent appointments
7261 (weekly, monthly) and more.  In this way, it is quite complementary to
7262 Org.  It can be very useful to combine output from Org with
7263 the diary.
7265 In order to include entries from the Emacs diary into Org-mode's
7266 agenda, you only need to customize the variable
7268 @lisp
7269 (setq org-agenda-include-diary t)
7270 @end lisp
7272 @noindent After that, everything will happen automatically.  All diary
7273 entries including holidays, anniversaries, etc., will be included in the
7274 agenda buffer created by Org-mode.  @key{SPC}, @key{TAB}, and
7275 @key{RET} can be used from the agenda buffer to jump to the diary
7276 file in order to edit existing diary entries.  The @kbd{i} command to
7277 insert new entries for the current date works in the agenda buffer, as
7278 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
7279 Sunrise/Sunset times, show lunar phases and to convert to other
7280 calendars, respectively.  @kbd{c} can be used to switch back and forth
7281 between calendar and agenda.
7283 If you are using the diary only for sexp entries and holidays, it is
7284 faster to not use the above setting, but instead to copy or even move
7285 the entries into an Org file.  Org-mode evaluates diary-style sexp
7286 entries, and does it faster because there is no overhead for first
7287 creating the diary display.  Note that the sexp entries must start at
7288 the left margin, no whitespace is allowed before them.  For example,
7289 the following segment of an Org file will be processed and entries
7290 will be made in the agenda:
7292 @example
7293 * Birthdays and similar stuff
7294 #+CATEGORY: Holiday
7295 %%(org-calendar-holiday)   ; special function for holiday names
7296 #+CATEGORY: Ann
7297 %%(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
7298 %%(org-anniversary 1869 10  2) Mahatma Gandhi would be %d years old
7299 @end example
7301 @subsubheading Anniversaries from BBDB
7302 @cindex BBDB, anniversaries
7303 @cindex anniversaries, from BBDB
7305 If you are using the Big Brothers Database to store your contacts, you will
7306 very likely prefer to store anniversaries in BBDB rather than in a
7307 separate Org or diary file.  Org supports this and will show BBDB
7308 anniversaries as part of the agenda.  All you need to do is to add the
7309 following to one your your agenda files:
7311 @example
7312 * Anniversaries
7313   :PROPERTIES:
7314   :CATEGORY: Anniv
7315   :END:
7316 %%(org-bbdb-anniversaries)
7317 @end example
7319 You can then go ahead and define anniversaries for a BBDB record.  Basically,
7320 you need to press @kbd{C-o anniversary @key{RET}} with the cursor in a BBDB
7321 record and then add the date in the format @code{YYYY-MM-DD} or @code{MM-DD},
7322 followed by a space and the class of the anniversary (@samp{birthday} or
7323 @samp{wedding}, or a format string).  If you omit the class, it will default to
7324 @samp{birthday}.  Here are a few examples, the header for the file
7325 @file{org-bbdb.el} contains more detailed information.
7327 @example
7328 1973-06-22
7329 06-22
7330 1955-08-02 wedding
7331 2008-04-14 %s released version 6.01 of org-mode, %d years ago
7332 @end example
7334 After a change to BBDB, or for the first agenda display during an Emacs
7335 session, the agenda display will suffer a short delay as Org updates its
7336 hash with anniversaries.  However, from then on things will be very fast---much
7337 faster in fact than a long list of @samp{%%(diary-anniversary)} entries
7338 in an Org or Diary file.
7340 @subsubheading Appointment reminders
7341 @cindex @file{appt.el}
7342 @cindex appointment reminders
7343 @cindex appointment
7344 @cindex reminders
7346 Org can interact with Emacs appointments notification facility.  To add all
7347 the appointments of your agenda files, use the command
7348 @code{org-agenda-to-appt}.  This command also lets you filter through the
7349 list of your appointments and add only those belonging to a specific category
7350 or matching a regular expression.  See the docstring for details.
7352 @node Global TODO list, Matching tags and properties, Weekly/daily agenda, Built-in agenda views
7353 @subsection The global TODO list
7354 @cindex global TODO list
7355 @cindex TODO list, global
7357 The global TODO list contains all unfinished TODO items formatted and
7358 collected into a single place.
7360 @table @kbd
7361 @orgcmd{C-c a t,org-todo-list}
7362 Show the global TODO list.  This collects the TODO items from all agenda
7363 files (@pxref{Agenda Views}) into a single buffer.  By default, this lists
7364 items with a state the is not a DONE state.  The buffer is in
7365 @code{agenda-mode}, so there are commands to examine and manipulate the TODO
7366 entries directly from that buffer (@pxref{Agenda commands}).
7367 @orgcmd{C-c a T,org-todo-list}
7368 @cindex TODO keyword matching
7369 @vindex org-todo-keywords
7370 Like the above, but allows selection of a specific TODO keyword.  You can
7371 also do this by specifying a prefix argument to @kbd{C-c a t}.  You are
7372 prompted for a keyword, and you may also specify several keywords by
7373 separating them with @samp{|} as the boolean OR operator.  With a numeric
7374 prefix, the Nth keyword in @code{org-todo-keywords} is selected.
7375 @kindex r
7376 The @kbd{r} key in the agenda buffer regenerates it, and you can give
7377 a prefix argument to this command to change the selected TODO keyword,
7378 for example @kbd{3 r}.  If you often need a search for a specific
7379 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
7380 Matching specific TODO keywords can also be done as part of a tags
7381 search (@pxref{Tag searches}).
7382 @end table
7384 Remote editing of TODO items means that you can change the state of a
7385 TODO entry with a single key press.  The commands available in the
7386 TODO list are described in @ref{Agenda commands}.
7388 @cindex sublevels, inclusion into TODO list
7389 Normally the global TODO list simply shows all headlines with TODO
7390 keywords.  This list can become very long.  There are two ways to keep
7391 it more compact:
7392 @itemize @minus
7393 @item
7394 @vindex org-agenda-todo-ignore-scheduled
7395 @vindex org-agenda-todo-ignore-deadlines
7396 @vindex org-agenda-todo-ignore-timestamp
7397 @vindex org-agenda-todo-ignore-with-date
7398 Some people view a TODO item that has been @emph{scheduled} for execution or
7399 have a @emph{deadline} (@pxref{Timestamps}) as no longer @emph{open}.
7400 Configure the variables @code{org-agenda-todo-ignore-scheduled},
7401 @code{org-agenda-todo-ignore-deadlines},
7402 @code{org-agenda-todo-ignore-timestamp} and/or
7403 @code{org-agenda-todo-ignore-with-date} to exclude such items from the global
7404 TODO list.
7405 @item
7406 @vindex org-agenda-todo-list-sublevels
7407 TODO items may have sublevels to break up the task into subtasks.  In
7408 such cases it may be enough to list only the highest level TODO headline
7409 and omit the sublevels from the global list.  Configure the variable
7410 @code{org-agenda-todo-list-sublevels} to get this behavior.
7411 @end itemize
7413 @node Matching tags and properties, Timeline, Global TODO list, Built-in agenda views
7414 @subsection Matching tags and properties
7415 @cindex matching, of tags
7416 @cindex matching, of properties
7417 @cindex tags view
7418 @cindex match view
7420 If headlines in the agenda files are marked with @emph{tags} (@pxref{Tags}),
7421 or have properties (@pxref{Properties and Columns}), you can select headlines
7422 based on this metadata and collect them into an agenda buffer.  The match
7423 syntax described here also applies when creating sparse trees with @kbd{C-c /
7426 @table @kbd
7427 @orgcmd{C-c a m,org-tags-view}
7428 Produce a list of all headlines that match a given set of tags.  The
7429 command prompts for a selection criterion, which is a boolean logic
7430 expression with tags, like @samp{+work+urgent-withboss} or
7431 @samp{work|home} (@pxref{Tags}).  If you often need a specific search,
7432 define a custom command for it (@pxref{Agenda dispatcher}).
7433 @orgcmd{C-c a M,org-tags-view}
7434 @vindex org-tags-match-list-sublevels
7435 @vindex org-agenda-tags-todo-honor-ignore-options
7436 Like @kbd{C-c a m}, but only select headlines that are also TODO items in a
7437 not-DONE state and force checking subitems (see variable
7438 @code{org-tags-match-list-sublevels}).  To exclude scheduled/deadline items,
7439 see the variable @code{org-agenda-tags-todo-honor-ignore-options}.  Matching
7440 specific TODO keywords together with a tags match is also possible, see
7441 @ref{Tag searches}.
7442 @end table
7444 The commands available in the tags list are described in @ref{Agenda
7445 commands}.
7447 @subsubheading Match syntax
7449 @cindex Boolean logic, for tag/property searches
7450 A search string can use Boolean operators @samp{&} for AND and @samp{|} for
7451 OR.  @samp{&} binds more strongly than @samp{|}.  Parentheses are currently
7452 not implemented.  Each element in the search is either a tag, a regular
7453 expression matching tags, or an expression like @code{PROPERTY OPERATOR
7454 VALUE} with a comparison operator, accessing a property value.  Each element
7455 may be preceded by @samp{-}, to select against it, and @samp{+} is syntactic
7456 sugar for positive selection.  The AND operator @samp{&} is optional when
7457 @samp{+} or @samp{-} is present.  Here are some examples, using only tags.
7459 @table @samp
7460 @item +work-boss
7461 Select headlines tagged @samp{:work:}, but discard those also tagged
7462 @samp{:boss:}.
7463 @item work|laptop
7464 Selects lines tagged @samp{:work:} or @samp{:laptop:}.
7465 @item work|laptop+night
7466 Like before, but require the @samp{:laptop:} lines to be tagged also
7467 @samp{:night:}.
7468 @end table
7470 @cindex regular expressions, with tags search
7471 Instead of a tag, you may also specify a regular expression enclosed in curly
7472 braces.  For example,
7473 @samp{work+@{^boss.*@}} matches headlines that contain the tag
7474 @samp{:work:} and any tag @i{starting} with @samp{boss}.
7476 @cindex TODO keyword matching, with tags search
7477 @cindex level, require for tags/property match
7478 @cindex category, require for tags/property match
7479 @vindex org-odd-levels-only
7480 You may also test for properties (@pxref{Properties and Columns}) at the same
7481 time as matching tags.  The properties may be real properties, or special
7482 properties that represent other metadata (@pxref{Special properties}).  For
7483 example, the ``property'' @code{TODO} represents the TODO keyword of the
7484 entry.  Or, the ``property'' @code{LEVEL} represents the level of an entry.
7485 So a search @samp{+LEVEL=3+boss-TODO="DONE"} lists all level three headlines
7486 that have the tag @samp{boss} and are @emph{not} marked with the TODO keyword
7487 DONE.  In buffers with @code{org-odd-levels-only} set, @samp{LEVEL} does not
7488 count the number of stars, but @samp{LEVEL=2} will correspond to 3 stars etc.
7490 Here are more examples:
7491 @table @samp
7492 @item work+TODO="WAITING"
7493 Select @samp{:work:}-tagged TODO lines with the specific TODO
7494 keyword @samp{WAITING}.
7495 @item work+TODO="WAITING"|home+TODO="WAITING"
7496 Waiting tasks both at work and at home.
7497 @end table
7499 When matching properties, a number of different operators can be used to test
7500 the value of a property.  Here is a complex example:
7502 @example
7503 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2         \
7504          +With=@{Sarah\|Denny@}+SCHEDULED>="<2008-10-11>"
7505 @end example
7507 @noindent
7508 The type of comparison will depend on how the comparison value is written:
7509 @itemize @minus
7510 @item
7511 If the comparison value is a plain number, a numerical comparison is done,
7512 and the allowed operators are @samp{<}, @samp{=}, @samp{>}, @samp{<=},
7513 @samp{>=}, and @samp{<>}.
7514 @item
7515 If the comparison value is enclosed in double-quotes,
7516 a string comparison is done, and the same operators are allowed.
7517 @item
7518 If the comparison value is enclosed in double-quotes @emph{and} angular
7519 brackets (like @samp{DEADLINE<="<2008-12-24 18:30>"}), both values are
7520 assumed to be date/time specifications in the standard Org way, and the
7521 comparison will be done accordingly.  Special values that will be recognized
7522 are @code{"<now>"} for now (including time), and @code{"<today>"}, and
7523 @code{"<tomorrow>"} for these days at 0:00 hours, i.e.@: without a time
7524 specification.  Also strings like @code{"<+5d>"} or @code{"<-2m>"} with units
7525 @code{d}, @code{w}, @code{m}, and @code{y} for day, week, month, and year,
7526 respectively, can be used.
7527 @item
7528 If the comparison value is enclosed
7529 in curly braces, a regexp match is performed, with @samp{=} meaning that the
7530 regexp matches the property value, and @samp{<>} meaning that it does not
7531 match.
7532 @end itemize
7534 So the search string in the example finds entries tagged @samp{:work:} but
7535 not @samp{:boss:}, which also have a priority value @samp{A}, a
7536 @samp{:Coffee:} property with the value @samp{unlimited}, an @samp{Effort}
7537 property that is numerically smaller than 2, a @samp{:With:} property that is
7538 matched by the regular expression @samp{Sarah\|Denny}, and that are scheduled
7539 on or after October 11, 2008.
7541 Accessing TODO, LEVEL, and CATEGORY during a search is fast.  Accessing any
7542 other properties will slow down the search.  However, once you have paid the
7543 price by accessing one property, testing additional properties is cheap
7544 again.
7546 You can configure Org-mode to use property inheritance during a search, but
7547 beware that this can slow down searches considerably.  See @ref{Property
7548 inheritance}, for details.
7550 For backward compatibility, and also for typing speed, there is also a
7551 different way to test TODO states in a search.  For this, terminate the
7552 tags/property part of the search string (which may include several terms
7553 connected with @samp{|}) with a @samp{/} and then specify a Boolean
7554 expression just for TODO keywords.  The syntax is then similar to that for
7555 tags, but should be applied with care: for example, a positive selection on
7556 several TODO keywords cannot meaningfully be combined with boolean AND.
7557 However, @emph{negative selection} combined with AND can be meaningful.  To
7558 make sure that only lines are checked that actually have any TODO keyword
7559 (resulting in a speed-up), use @kbd{C-c a M}, or equivalently start the TODO
7560 part after the slash with @samp{!}.  Using @kbd{C-c a M} or @samp{/!} will
7561 not match TODO keywords in a DONE state.  Examples:
7563 @table @samp
7564 @item work/WAITING
7565 Same as @samp{work+TODO="WAITING"}
7566 @item work/!-WAITING-NEXT
7567 Select @samp{:work:}-tagged TODO lines that are neither @samp{WAITING}
7568 nor @samp{NEXT}
7569 @item work/!+WAITING|+NEXT
7570 Select @samp{:work:}-tagged TODO lines that are either @samp{WAITING} or
7571 @samp{NEXT}.
7572 @end table
7574 @node Timeline, Search view, Matching tags and properties, Built-in agenda views
7575 @subsection Timeline for a single file
7576 @cindex timeline, single file
7577 @cindex time-sorted view
7579 The timeline summarizes all time-stamped items from a single Org-mode
7580 file in a @emph{time-sorted view}.  The main purpose of this command is
7581 to give an overview over events in a project.
7583 @table @kbd
7584 @orgcmd{C-c a L,org-timeline}
7585 Show a time-sorted view of the Org file, with all time-stamped items.
7586 When called with a @kbd{C-u} prefix, all unfinished TODO entries
7587 (scheduled or not) are also listed under the current date.
7588 @end table
7590 @noindent
7591 The commands available in the timeline buffer are listed in
7592 @ref{Agenda commands}.
7594 @node Search view, Stuck projects, Timeline, Built-in agenda views
7595 @subsection Search view
7596 @cindex search view
7597 @cindex text search
7598 @cindex searching, for text
7600 This agenda view is a general text search facility for Org-mode entries.
7601 It is particularly useful to find notes.
7603 @table @kbd
7604 @orgcmd{C-c a s,org-search-view}
7605 This is a special search that lets you select entries by matching a substring
7606 or specific words using a boolean logic.
7607 @end table
7608 For example, the search string @samp{computer equipment} will find entries
7609 that contain @samp{computer equipment} as a substring.  If the two words are
7610 separated by more space or a line break, the search will still match.
7611 Search view can also search for specific keywords in the entry, using Boolean
7612 logic.  The search string @samp{+computer +wifi -ethernet -@{8\.11[bg]@}}
7613 will search for note entries that contain the keywords @code{computer}
7614 and @code{wifi}, but not the keyword @code{ethernet}, and which are also
7615 not matched by the regular expression @code{8\.11[bg]}, meaning to
7616 exclude both 8.11b and 8.11g.  The first @samp{+} is necessary to turn on
7617 word search, other @samp{+} characters are optional.  For more details, see
7618 the docstring of the command @code{org-search-view}.
7620 @vindex org-agenda-text-search-extra-files
7621 Note that in addition to the agenda files, this command will also search
7622 the files listed in @code{org-agenda-text-search-extra-files}.
7624 @node Stuck projects,  , Search view, Built-in agenda views
7625 @subsection Stuck projects
7626 @pindex GTD, Getting Things Done
7628 If you are following a system like David Allen's GTD to organize your
7629 work, one of the ``duties'' you have is a regular review to make sure
7630 that all projects move along.  A @emph{stuck} project is a project that
7631 has no defined next actions, so it will never show up in the TODO lists
7632 Org-mode produces.  During the review, you need to identify such
7633 projects and define next actions for them.
7635 @table @kbd
7636 @orgcmd{C-c a #,org-agenda-list-stuck-projects}
7637 List projects that are stuck.
7638 @kindex C-c a !
7639 @item C-c a !
7640 @vindex org-stuck-projects
7641 Customize the variable @code{org-stuck-projects} to define what a stuck
7642 project is and how to find it.
7643 @end table
7645 You almost certainly will have to configure this view before it will
7646 work for you.  The built-in default assumes that all your projects are
7647 level-2 headlines, and that a project is not stuck if it has at least
7648 one entry marked with a TODO keyword TODO or NEXT or NEXTACTION.
7650 Let's assume that you, in your own way of using Org-mode, identify
7651 projects with a tag PROJECT, and that you use a TODO keyword MAYBE to
7652 indicate a project that should not be considered yet.  Let's further
7653 assume that the TODO keyword DONE marks finished projects, and that NEXT
7654 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
7655 is a next action even without the NEXT tag.  Finally, if the project
7656 contains the special word IGNORE anywhere, it should not be listed
7657 either.  In this case you would start by identifying eligible projects
7658 with a tags/todo match@footnote{@xref{Tag searches}.}
7659 @samp{+PROJECT/-MAYBE-DONE}, and then check for TODO, NEXT, @@SHOP, and
7660 IGNORE in the subtree to identify projects that are not stuck.  The
7661 correct customization for this is
7663 @lisp
7664 (setq org-stuck-projects
7665       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
7666                                "\\<IGNORE\\>"))
7667 @end lisp
7669 Note that if a project is identified as non-stuck, the subtree of this entry
7670 will still be searched for stuck projects.
7672 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda Views
7673 @section Presentation and sorting
7674 @cindex presentation, of agenda items
7676 @vindex org-agenda-prefix-format
7677 @vindex org-agenda-tags-column
7678 Before displaying items in an agenda view, Org-mode visually prepares the
7679 items and sorts them.  Each item occupies a single line.  The line starts
7680 with a @emph{prefix} that contains the @emph{category} (@pxref{Categories})
7681 of the item and other important information.  You can customize in which
7682 column tags will be displayed through @code{org-agenda-tags-column}.  You can
7683 also customize the prefix using the option @code{org-agenda-prefix-format}.
7684 This prefix is followed by a cleaned-up version of the outline headline
7685 associated with the item.
7687 @menu
7688 * Categories::                  Not all tasks are equal
7689 * Time-of-day specifications::  How the agenda knows the time
7690 * Sorting of agenda items::     The order of things
7691 @end menu
7693 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
7694 @subsection Categories
7696 @cindex category
7697 @cindex #+CATEGORY
7698 The category is a broad label assigned to each agenda item.  By default,
7699 the category is simply derived from the file name, but you can also
7700 specify it with a special line in the buffer, like this@footnote{For
7701 backward compatibility, the following also works: if there are several
7702 such lines in a file, each specifies the category for the text below it.
7703 The first category also applies to any text before the first CATEGORY
7704 line.  However, using this method is @emph{strongly} deprecated as it is
7705 incompatible with the outline structure of the document.  The correct
7706 method for setting multiple categories in a buffer is using a
7707 property.}:
7709 @example
7710 #+CATEGORY: Thesis
7711 @end example
7713 @noindent
7714 @cindex property, CATEGORY
7715 If you would like to have a special CATEGORY for a single entry or a
7716 (sub)tree, give the entry a @code{:CATEGORY:} property with the
7717 special category you want to apply as the value.
7719 @noindent
7720 The display in the agenda buffer looks best if the category is not
7721 longer than 10 characters.
7723 @noindent
7724 You can set up icons for category by customizing the
7725 @code{org-agenda-category-icon-alist} variable.
7727 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
7728 @subsection Time-of-day specifications
7729 @cindex time-of-day specification
7731 Org-mode checks each agenda item for a time-of-day specification.  The
7732 time can be part of the timestamp that triggered inclusion into the
7733 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
7734 ranges can be specified with two timestamps, like
7736 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
7738 In the headline of the entry itself, a time(range) may also appear as
7739 plain text (like @samp{12:45} or a @samp{8:30-1pm}).  If the agenda
7740 integrates the Emacs diary (@pxref{Weekly/daily agenda}), time
7741 specifications in diary entries are recognized as well.
7743 For agenda display, Org-mode extracts the time and displays it in a
7744 standard 24 hour format as part of the prefix.  The example times in
7745 the previous paragraphs would end up in the agenda like this:
7747 @example
7748     8:30-13:00 Arthur Dent lies in front of the bulldozer
7749    12:45...... Ford Prefect arrives and takes Arthur to the pub
7750    19:00...... The Vogon reads his poem
7751    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
7752 @end example
7754 @cindex time grid
7755 If the agenda is in single-day mode, or for the display of today, the
7756 timed entries are embedded in a time grid, like
7758 @example
7759     8:00...... ------------------
7760     8:30-13:00 Arthur Dent lies in front of the bulldozer
7761    10:00...... ------------------
7762    12:00...... ------------------
7763    12:45...... Ford Prefect arrives and takes Arthur to the pub
7764    14:00...... ------------------
7765    16:00...... ------------------
7766    18:00...... ------------------
7767    19:00...... The Vogon reads his poem
7768    20:00...... ------------------
7769    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
7770 @end example
7772 @vindex org-agenda-use-time-grid
7773 @vindex org-agenda-time-grid
7774 The time grid can be turned on and off with the variable
7775 @code{org-agenda-use-time-grid}, and can be configured with
7776 @code{org-agenda-time-grid}.
7778 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
7779 @subsection Sorting of agenda items
7780 @cindex sorting, of agenda items
7781 @cindex priorities, of agenda items
7782 Before being inserted into a view, the items are sorted.  How this is
7783 done depends on the type of view.
7784 @itemize @bullet
7785 @item
7786 @vindex org-agenda-files
7787 For the daily/weekly agenda, the items for each day are sorted.  The
7788 default order is to first collect all items containing an explicit
7789 time-of-day specification.  These entries will be shown at the beginning
7790 of the list, as a @emph{schedule} for the day.  After that, items remain
7791 grouped in categories, in the sequence given by @code{org-agenda-files}.
7792 Within each category, items are sorted by priority (@pxref{Priorities}),
7793 which is composed of the base priority (2000 for priority @samp{A}, 1000
7794 for @samp{B}, and 0 for @samp{C}), plus additional increments for
7795 overdue scheduled or deadline items.
7796 @item
7797 For the TODO list, items remain in the order of categories, but within
7798 each category, sorting takes place according to priority
7799 (@pxref{Priorities}).  The priority used for sorting derives from the
7800 priority cookie, with additions depending on how close an item is to its due
7801 or scheduled date.
7802 @item
7803 For tags matches, items are not sorted at all, but just appear in the
7804 sequence in which they are found in the agenda files.
7805 @end itemize
7807 @vindex org-agenda-sorting-strategy
7808 Sorting can be customized using the variable
7809 @code{org-agenda-sorting-strategy}, and may also include criteria based on
7810 the estimated effort of an entry (@pxref{Effort estimates}).
7812 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda Views
7813 @section Commands in the agenda buffer
7814 @cindex commands, in agenda buffer
7816 Entries in the agenda buffer are linked back to the Org file or diary
7817 file where they originate.  You are not allowed to edit the agenda
7818 buffer itself, but commands are provided to show and jump to the
7819 original entry location, and to edit the Org files ``remotely'' from
7820 the agenda buffer.  In this way, all information is stored only once,
7821 removing the risk that your agenda and note files may diverge.
7823 Some commands can be executed with mouse clicks on agenda lines.  For
7824 the other commands, the cursor needs to be in the desired line.
7826 @table @kbd
7827 @tsubheading{Motion}
7828 @cindex motion commands in agenda
7829 @orgcmd{n,org-agenda-next-line}
7830 Next line (same as @key{up} and @kbd{C-p}).
7831 @orgcmd{p,org-agenda-previous-line}
7832 Previous line (same as @key{down} and @kbd{C-n}).
7833 @tsubheading{View/Go to Org file}
7834 @orgcmdkkc{@key{SPC},mouse-3,org-agenda-show-and-scroll-up}
7835 Display the original location of the item in another window.
7836 With prefix arg, make sure that the entire entry is made visible in the
7837 outline, not only the heading.
7839 @orgcmd{L,org-agenda-recenter}
7840 Display original location and recenter that window.
7842 @orgcmdkkc{@key{TAB},mouse-2,org-agenda-goto}
7843 Go to the original location of the item in another window.
7845 @orgcmd{@key{RET},org-agenda-switch-to}
7846 Go to the original location of the item and delete other windows.
7848 @orgcmd{F,org-agenda-follow-mode}
7849 @vindex org-agenda-start-with-follow-mode
7850 Toggle Follow mode.  In Follow mode, as you move the cursor through
7851 the agenda buffer, the other window always shows the corresponding
7852 location in the Org file.  The initial setting for this mode in new
7853 agenda buffers can be set with the variable
7854 @code{org-agenda-start-with-follow-mode}.
7856 @orgcmd{C-c C-x b,org-agenda-tree-to-indirect-buffer}
7857 Display the entire subtree of the current item in an indirect buffer.  With a
7858 numeric prefix argument N, go up to level N and then take that tree.  If N is
7859 negative, go up that many levels.  With a @kbd{C-u} prefix, do not remove the
7860 previously used indirect buffer.
7862 @orgcmd{C-c C-o,org-agenda-open-link}
7863 Follow a link in the entry.  This will offer a selection of any links in the
7864 text belonging to the referenced Org node.  If there is only one link, it
7865 will be followed without a selection prompt.
7867 @tsubheading{Change display}
7868 @cindex display changing, in agenda
7869 @kindex A
7870 @item A
7871 Interactively select another agenda view and append it to the current view.
7873 @kindex o
7874 @item o
7875 Delete other windows.
7877 @orgcmdkskc{v d,d,org-agenda-day-view}
7878 @xorgcmdkskc{v w,w,org-agenda-day-view}
7879 @xorgcmd{v m,org-agenda-month-view}
7880 @xorgcmd{v y,org-agenda-month-year}
7881 @xorgcmd{v SPC,org-agenda-reset-view}
7882 @vindex org-agenda-span
7883 Switch to day/week/month/year view.  When switching to day or week view, this
7884 setting becomes the default for subsequent agenda refreshes.  Since month and
7885 year views are slow to create, they do not become the default.  A numeric
7886 prefix argument may be used to jump directly to a specific day of the year,
7887 ISO week, month, or year, respectively.  For example, @kbd{32 d} jumps to
7888 February 1st, @kbd{9 w} to ISO week number 9.  When setting day, week, or
7889 month view, a year may be encoded in the prefix argument as well.  For
7890 example, @kbd{200712 w} will jump to week 12 in 2007.  If such a year
7891 specification has only one or two digits, it will be mapped to the interval
7892 1938-2037.  @kbd{v @key{SPC}} will reset to what is set in
7893 @code{org-agenda-span}.
7895 @orgcmd{f,org-agenda-later}
7896 Go forward in time to display the following @code{org-agenda-current-span} days.
7897 For example, if the display covers a week, switch to the following week.
7898 With prefix arg, go forward that many times @code{org-agenda-current-span} days.
7900 @orgcmd{b,org-agenda-earlier}
7901 Go backward in time to display earlier dates.
7903 @orgcmd{.,org-agenda-goto-today}
7904 Go to today.
7906 @orgcmd{j,org-agenda-goto-date}
7907 Prompt for a date and go there.
7909 @orgcmd{J,org-agenda-clock-goto}
7910 Go to the currently clocked-in task @i{in the agenda buffer}.
7912 @orgcmd{D,org-agenda-toggle-diary}
7913 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
7915 @orgcmdkskc{v l,l,org-agenda-log-mode}
7916 @kindex v L
7917 @vindex org-log-done
7918 @vindex org-agenda-log-mode-items
7919 Toggle Logbook mode.  In Logbook mode, entries that were marked DONE while
7920 logging was on (variable @code{org-log-done}) are shown in the agenda, as are
7921 entries that have been clocked on that day.  You can configure the entry
7922 types that should be included in log mode using the variable
7923 @code{org-agenda-log-mode-items}.  When called with a @kbd{C-u} prefix, show
7924 all possible logbook entries, including state changes.  When called with two
7925 prefix args @kbd{C-u C-u}, show only logging information, nothing else.
7926 @kbd{v L} is equivalent to @kbd{C-u v l}.
7928 @orgcmdkskc{v [,[,org-agenda-manipulate-query-add}
7929 Include inactive timestamps into the current view.  Only for weekly/daily
7930 agenda and timeline views.
7932 @orgcmd{v a,org-agenda-archives-mode}
7933 @xorgcmd{v A,org-agenda-archives-mode 'files}
7934 Toggle Archives mode.  In Archives mode, trees that are marked
7935 @code{ARCHIVED} are also scanned when producing the agenda.  When you use the
7936 capital @kbd{A}, even all archive files are included.  To exit archives mode,
7937 press @kbd{v a} again.
7939 @orgcmdkskc{v R,R,org-agenda-clockreport-mode}
7940 @vindex org-agenda-start-with-clockreport-mode
7941 Toggle Clockreport mode.  In Clockreport mode, the daily/weekly agenda will
7942 always show a table with the clocked times for the timespan and file scope
7943 covered by the current agenda view.  The initial setting for this mode in new
7944 agenda buffers can be set with the variable
7945 @code{org-agenda-start-with-clockreport-mode}.  By using a prefix argument
7946 when toggling this mode (i.e.@: @kbd{C-u R}), the clock table will not show
7947 contributions from entries that are hidden by agenda filtering@footnote{Only
7948 tags filtering will be respected here, effort filtering is ignored.}.
7950 @orgkey{v c}
7951 @vindex org-agenda-clock-consistency-checks
7952 Show overlapping clock entries, clocking gaps, and other clocking problems in
7953 the current agenda range.  You can then visit clocking lines and fix them
7954 manually.  See the variable @code{org-agenda-clock-consistency-checks} for
7955 information on how to customize the definition of what constituted a clocking
7956 problem.  To return to normal agenda display, press @kbd{l} to exit Logbook
7957 mode.
7959 @orgcmdkskc{v E,E,org-agenda-entry-text-mode}
7960 @vindex org-agenda-start-with-entry-text-mode
7961 @vindex org-agenda-entry-text-maxlines
7962 Toggle entry text mode.  In entry text mode, a number of lines from the Org
7963 outline node referenced by an agenda line will be displayed below the line.
7964 The maximum number of lines is given by the variable
7965 @code{org-agenda-entry-text-maxlines}.  Calling this command with a numeric
7966 prefix argument will temporarily modify that number to the prefix value.
7968 @orgcmd{G,org-agenda-toggle-time-grid}
7969 @vindex org-agenda-use-time-grid
7970 @vindex org-agenda-time-grid
7971 Toggle the time grid on and off.  See also the variables
7972 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
7974 @orgcmd{r,org-agenda-redo}
7975 Recreate the agenda buffer, for example to reflect the changes after
7976 modification of the timestamps of items with @kbd{S-@key{left}} and
7977 @kbd{S-@key{right}}.  When the buffer is the global TODO list, a prefix
7978 argument is interpreted to create a selective list for a specific TODO
7979 keyword.
7980 @orgcmd{g,org-agenda-redo}
7981 Same as @kbd{r}.
7983 @orgcmdkskc{C-x C-s,s,org-save-all-org-buffers}
7984 Save all Org buffers in the current Emacs session, and also the locations of
7985 IDs.
7987 @orgcmd{C-c C-x C-c,org-agenda-columns}
7988 @vindex org-columns-default-format
7989 Invoke column view (@pxref{Column view}) in the agenda buffer.  The column
7990 view format is taken from the entry at point, or (if there is no entry at
7991 point), from the first entry in the agenda view.  So whatever the format for
7992 that entry would be in the original buffer (taken from a property, from a
7993 @code{#+COLUMNS} line, or from the default variable
7994 @code{org-columns-default-format}), will be used in the agenda.
7996 @orgcmd{C-c C-x >,org-agenda-remove-restriction-lock}
7997 Remove the restriction lock on the agenda, if it is currently restricted to a
7998 file or subtree (@pxref{Agenda files}).
8000 @tsubheading{Secondary filtering and query editing}
8001 @cindex filtering, by tag and effort, in agenda
8002 @cindex tag filtering, in agenda
8003 @cindex effort filtering, in agenda
8004 @cindex query editing, in agenda
8006 @orgcmd{/,org-agenda-filter-by-tag}
8007 @vindex org-agenda-filter-preset
8008 Filter the current agenda view with respect to a tag and/or effort estimates.
8009 The difference between this and a custom agenda command is that filtering is
8010 very fast, so that you can switch quickly between different filters without
8011 having to recreate the agenda.@footnote{Custom commands can preset a filter by
8012 binding the variable @code{org-agenda-filter-preset} as an option.  This
8013 filter will then be applied to the view and persist as a basic filter through
8014 refreshes and more secondary filtering.  The filter is a global property of
8015 the entire agenda view---in a block agenda, you should only set this in the
8016 global options section, not in the section of an individual block.}
8018 You will be prompted for a tag selection letter; @key{SPC} will mean any tag at
8019 all.  Pressing @key{TAB} at that prompt will offer use completion to select a
8020 tag (including any tags that do not have a selection character).  The command
8021 then hides all entries that do not contain or inherit this tag.  When called
8022 with prefix arg, remove the entries that @emph{do} have the tag.  A second
8023 @kbd{/} at the prompt will turn off the filter and unhide any hidden entries.
8024 If the first key you press is either @kbd{+} or @kbd{-}, the previous filter
8025 will be narrowed by requiring or forbidding the selected additional tag.
8026 Instead of pressing @kbd{+} or @kbd{-} after @kbd{/}, you can also
8027 immediately use the @kbd{\} command.
8029 @vindex org-sort-agenda-noeffort-is-high
8030 In order to filter for effort estimates, you should set up allowed
8031 efforts globally, for example
8032 @lisp
8033 (setq org-global-properties
8034     '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
8035 @end lisp
8036 You can then filter for an effort by first typing an operator, one of
8037 @kbd{<}, @kbd{>}, and @kbd{=}, and then the one-digit index of an effort
8038 estimate in your array of allowed values, where @kbd{0} means the 10th value.
8039 The filter will then restrict to entries with effort smaller-or-equal, equal,
8040 or larger-or-equal than the selected value.  If the digits 0-9 are not used
8041 as fast access keys to tags, you can also simply press the index digit
8042 directly without an operator.  In this case, @kbd{<} will be assumed.  For
8043 application of the operator, entries without a defined effort will be treated
8044 according to the value of @code{org-sort-agenda-noeffort-is-high}.  To filter
8045 for tasks without effort definition, press @kbd{?} as the operator.
8047 Org also supports automatic, context-aware tag filtering.  If the variable
8048 @code{org-agenda-auto-exclude-function} is set to a user-defined function,
8049 that function can decide which tags should be excluded from the agenda
8050 automatically.  Once this is set, the @kbd{/} command then accepts @kbd{RET}
8051 as a sub-option key and runs the auto exclusion logic.  For example, let's
8052 say you use a @code{Net} tag to identify tasks which need network access, an
8053 @code{Errand} tag for errands in town, and a @code{Call} tag for making phone
8054 calls.  You could auto-exclude these tags based on the availability of the
8055 Internet, and outside of business hours, with something like this:
8057 @lisp
8058 @group
8059 (defun org-my-auto-exclude-function (tag)
8060   (and (cond
8061         ((string= tag "Net")
8062          (/= 0 (call-process "/sbin/ping" nil nil nil
8063                              "-c1" "-q" "-t1" "mail.gnu.org")))
8064         ((or (string= tag "Errand") (string= tag "Call"))
8065          (let ((hour (nth 2 (decode-time))))
8066            (or (< hour 8) (> hour 21)))))
8067        (concat "-" tag)))
8069 (setq org-agenda-auto-exclude-function 'org-my-auto-exclude-function)
8070 @end group
8071 @end lisp
8073 @orgcmd{\\,org-agenda-filter-by-tag-refine}
8074 Narrow the current agenda filter by an additional condition.  When called with
8075 prefix arg, remove the entries that @emph{do} have the tag, or that do match
8076 the effort criterion.  You can achieve the same effect by pressing @kbd{+} or
8077 @kbd{-} as the first key after the @kbd{/} command.
8080 @kindex [
8081 @kindex ]
8082 @kindex @{
8083 @kindex @}
8084 @item [ ] @{ @}
8085 @table @i
8086 @item @r{in} search view
8087 add new search words (@kbd{[} and @kbd{]}) or new regular expressions
8088 (@kbd{@{} and @kbd{@}}) to the query string.  The opening bracket/brace will
8089 add a positive search term prefixed by @samp{+}, indicating that this search
8090 term @i{must} occur/match in the entry.  The closing bracket/brace will add a
8091 negative search term which @i{must not} occur/match in the entry for it to be
8092 selected.
8093 @end table
8095 @tsubheading{Remote editing}
8096 @cindex remote editing, from agenda
8098 @item 0-9
8099 Digit argument.
8101 @cindex undoing remote-editing events
8102 @cindex remote editing, undo
8103 @orgcmd{C-_,org-agenda-undo}
8104 Undo a change due to a remote editing command.  The change is undone
8105 both in the agenda buffer and in the remote buffer.
8107 @orgcmd{t,org-agenda-todo}
8108 Change the TODO state of the item, both in the agenda and in the
8109 original org file.
8111 @orgcmd{C-S-@key{right},org-agenda-todo-nextset}
8112 @orgcmd{C-S-@key{left},org-agenda-todo-previousset}
8113 Switch to the next/previous set of TODO keywords.
8115 @orgcmd{C-k,org-agenda-kill}
8116 @vindex org-agenda-confirm-kill
8117 Delete the current agenda item along with the entire subtree belonging
8118 to it in the original Org file.  If the text to be deleted remotely
8119 is longer than one line, the kill needs to be confirmed by the user.  See
8120 variable @code{org-agenda-confirm-kill}.
8122 @orgcmd{C-c C-w,org-agenda-refile}
8123 Refile the entry at point.
8125 @orgcmdkskc{C-c C-x C-a,a,org-agenda-archive-default-with-confirmation}
8126 @vindex org-archive-default-command
8127 Archive the subtree corresponding to the entry at point using the default
8128 archiving command set in @code{org-archive-default-command}.  When using the
8129 @code{a} key, confirmation will be required.
8131 @orgcmd{C-c C-x a,org-agenda-toggle-archive-tag}
8132 Toggle the ARCHIVE tag for the current headline.
8134 @orgcmd{C-c C-x A,org-agenda-archive-to-archive-sibling}
8135 Move the subtree corresponding to the current entry to its @emph{archive
8136 sibling}.
8138 @orgcmdkskc{C-c C-x C-s,$,org-agenda-archive}
8139 Archive the subtree corresponding to the current headline.  This means the
8140 entry will be moved to the configured archive location, most likely a
8141 different file.
8143 @orgcmd{T,org-agenda-show-tags}
8144 @vindex org-agenda-show-inherited-tags
8145 Show all tags associated with the current item.  This is useful if you have
8146 turned off @code{org-agenda-show-inherited-tags}, but still want to see all
8147 tags of a headline occasionally.
8149 @orgcmd{:,org-agenda-set-tags}
8150 Set tags for the current headline.  If there is an active region in the
8151 agenda, change a tag for all headings in the region.
8153 @kindex ,
8154 @item ,
8155 Set the priority for the current item (@command{org-agenda-priority}).
8156 Org-mode prompts for the priority character.  If you reply with @key{SPC},
8157 the priority cookie is removed from the entry.
8159 @orgcmd{P,org-agenda-show-priority}
8160 Display weighted priority of current item.
8162 @orgcmdkkc{+,S-@key{up},org-agenda-priority-up}
8163 Increase the priority of the current item.  The priority is changed in
8164 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
8165 key for this.
8167 @orgcmdkkc{-,S-@key{down},org-agenda-priority-down}
8168 Decrease the priority of the current item.
8170 @orgcmdkkc{z,C-c C-z,org-agenda-add-note}
8171 @vindex org-log-into-drawer
8172 Add a note to the entry.  This note will be recorded, and then filed to the
8173 same location where state change notes are put.  Depending on
8174 @code{org-log-into-drawer}, this may be inside a drawer.
8176 @orgcmd{C-c C-a,org-attach}
8177 Dispatcher for all command related to attachments.
8179 @orgcmd{C-c C-s,org-agenda-schedule}
8180 Schedule this item.  With prefix arg remove the scheduling timestamp
8182 @orgcmd{C-c C-d,org-agenda-deadline}
8183 Set a deadline for this item.  With prefix arg remove the deadline.
8185 @orgcmd{k,org-agenda-action}
8186 Agenda actions, to set dates for selected items to the cursor date.
8187 This command also works in the calendar!  The command prompts for an
8188 additional key:
8189 @example
8190 m   @r{Mark the entry at point for action.  You can also make entries}
8191     @r{in Org files with @kbd{C-c C-x C-k}.}
8192 d   @r{Set the deadline of the marked entry to the date at point.}
8193 s   @r{Schedule the marked entry at the date at point.}
8194 r   @r{Call @code{org-capture} with the cursor date as default date.}
8195 @end example
8196 @noindent
8197 Press @kbd{r} afterward to refresh the agenda and see the effect of the
8198 command.
8200 @orgcmd{S-@key{right},org-agenda-do-date-later}
8201 Change the timestamp associated with the current line by one day into the
8202 future.  If the date is in the past, the first call to this command will move
8203 it to today.@*
8204 With a numeric prefix argument, change it by that many days.  For example,
8205 @kbd{3 6 5 S-@key{right}} will change it by a year.  With a @kbd{C-u} prefix,
8206 change the time by one hour.  If you immediately repeat the command, it will
8207 continue to change hours even without the prefix arg.  With a double @kbd{C-u
8208 C-u} prefix, do the same for changing minutes.@*
8209 The stamp is changed in the original Org file, but the change is not directly
8210 reflected in the agenda buffer.  Use @kbd{r} or @kbd{g} to update the buffer.
8212 @orgcmd{S-@key{left},org-agenda-do-date-earlier}
8213 Change the timestamp associated with the current line by one day
8214 into the past.
8216 @orgcmd{>,org-agenda-date-prompt}
8217 Change the timestamp associated with the current line.  The key @kbd{>} has
8218 been chosen, because it is the same as @kbd{S-.}  on my keyboard.
8220 @orgcmd{I,org-agenda-clock-in}
8221 Start the clock on the current item.  If a clock is running already, it
8222 is stopped first.
8224 @orgcmd{O,org-agenda-clock-out}
8225 Stop the previously started clock.
8227 @orgcmd{X,org-agenda-clock-cancel}
8228 Cancel the currently running clock.
8230 @orgcmd{J,org-agenda-clock-goto}
8231 Jump to the running clock in another window.
8233 @tsubheading{Bulk remote editing selected entries}
8234 @cindex remote editing, bulk, from agenda
8236 @orgcmd{m,org-agenda-bulk-mark}
8237 Mark the entry at point for bulk action.  With prefix arg, mark that many
8238 successive entries.
8240 @orgcmd{%,org-agenda-bulk-mark-regexp}
8241 Mark entries matching a regular expression for bulk action.
8243 @orgcmd{u,org-agenda-bulk-unmark}
8244 Unmark entry for bulk action.
8246 @orgcmd{U,org-agenda-bulk-remove-all-marks}
8247 Unmark all marked entries for bulk action.
8249 @orgcmd{B,org-agenda-bulk-action}
8250 Bulk action: act on all marked entries in the agenda.  This will prompt for
8251 another key to select the action to be applied.  The prefix arg to @kbd{B}
8252 will be passed through to the @kbd{s} and @kbd{d} commands, to bulk-remove
8253 these special timestamps.
8254 @example
8255 r  @r{Prompt for a single refile target and move all entries.  The entries}
8256    @r{will no longer be in the agenda; refresh (@kbd{g}) to bring them back.}
8257 $  @r{Archive all selected entries.}
8258 A  @r{Archive entries by moving them to their respective archive siblings.}
8259 t  @r{Change TODO state.  This prompts for a single TODO keyword and}
8260    @r{changes the state of all selected entries, bypassing blocking and}
8261    @r{suppressing logging notes (but not timestamps).}
8262 +  @r{Add a tag to all selected entries.}
8263 -  @r{Remove a tag from all selected entries.}
8264 s  @r{Schedule all items to a new date.  To shift existing schedule dates}
8265    @r{by a fixed number of days, use something starting with double plus}
8266    @r{at the prompt, for example @samp{++8d} or @samp{++2w}.}
8267 S  @r{Reschedule randomly into the coming N days.  N will be prompted for.}
8268    @r{With prefix arg (@kbd{C-u B S}), scatter only across weekdays.}
8269 d  @r{Set deadline to a specific date.}
8270 f  @r{Apply a function to marked entries.}
8271    @r{For example, the function below sets the CATEGORY property of the}
8272    @r{entries to web.}
8273    @r{(defun set-category ()}
8274    @r{  (interactive "P")}
8275    @r{  (let* ((marker (or (org-get-at-bol 'org-hd-marker)}
8276    @r{                     (org-agenda-error)))}
8277    @r{            (buffer (marker-buffer marker)))}
8278    @r{       (with-current-buffer buffer}
8279    @r{         (save-excursion}
8280    @r{           (save-restriction}
8281    @r{             (widen)}
8282    @r{             (goto-char marker)}
8283    @r{             (org-back-to-heading t)}
8284    @r{             (org-set-property "CATEGORY" "web"))))))}
8285 @end example
8288 @tsubheading{Calendar commands}
8289 @cindex calendar commands, from agenda
8291 @orgcmd{c,org-agenda-goto-calendar}
8292 Open the Emacs calendar and move to the date at the agenda cursor.
8294 @orgcmd{c,org-calendar-goto-agenda}
8295 When in the calendar, compute and show the Org-mode agenda for the
8296 date at the cursor.
8298 @cindex diary entries, creating from agenda
8299 @orgcmd{i,org-agenda-diary-entry}
8300 @vindex org-agenda-diary-file
8301 Insert a new entry into the diary, using the date at the cursor and (for
8302 block entries) the date at the mark.  This will add to the Emacs diary
8303 file@footnote{This file is parsed for the agenda when
8304 @code{org-agenda-include-diary} is set.}, in a way similar to the @kbd{i}
8305 command in the calendar.  The diary file will pop up in another window, where
8306 you can add the entry.
8308 If you configure @code{org-agenda-diary-file} to point to an Org-mode file,
8309 Org will create entries (in org-mode syntax) in that file instead.  Most
8310 entries will be stored in a date-based outline tree that will later make it
8311 easy to archive appointments from previous months/years.  The tree will be
8312 built under an entry with a @code{DATE_TREE} property, or else with years as
8313 top-level entries.  Emacs will prompt you for the entry text---if you specify
8314 it, the entry will be created in @code{org-agenda-diary-file} without further
8315 interaction.  If you directly press @key{RET} at the prompt without typing
8316 text, the target file will be shown in another window for you to finish the
8317 entry there.  See also the @kbd{k r} command.
8319 @orgcmd{M,org-agenda-phases-of-moon}
8320 Show the phases of the moon for the three months around current date.
8322 @orgcmd{S,org-agenda-sunrise-sunset}
8323 Show sunrise and sunset times.  The geographical location must be set
8324 with calendar variables, see the documentation for the Emacs calendar.
8326 @orgcmd{C,org-agenda-convert-date}
8327 Convert the date at cursor into many other cultural and historic
8328 calendars.
8330 @orgcmd{H,org-agenda-holidays}
8331 Show holidays for three months around the cursor date.
8333 @item M-x org-export-icalendar-combine-agenda-files
8334 Export a single iCalendar file containing entries from all agenda files.
8335 This is a globally available command, and also available in the agenda menu.
8337 @tsubheading{Exporting to a file}
8338 @orgcmd{C-x C-w,org-write-agenda}
8339 @cindex exporting agenda views
8340 @cindex agenda views, exporting
8341 @vindex org-agenda-exporter-settings
8342 Write the agenda view to a file.  Depending on the extension of the selected
8343 file name, the view will be exported as HTML (extension @file{.html} or
8344 @file{.htm}), Postscript (extension @file{.ps}), PDF (extension @file{.pdf}),
8345 and plain text (any other extension).  When called with a @kbd{C-u} prefix
8346 argument, immediately open the newly created file.  Use the variable
8347 @code{org-agenda-exporter-settings} to set options for @file{ps-print} and
8348 for @file{htmlize} to be used during export.
8350 @tsubheading{Quit and Exit}
8351 @orgcmd{q,org-agenda-quit}
8352 Quit agenda, remove the agenda buffer.
8354 @cindex agenda files, removing buffers
8355 @orgcmd{x,org-agenda-exit}
8356 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
8357 for the compilation of the agenda.  Buffers created by the user to
8358 visit Org files will not be removed.
8359 @end table
8362 @node Custom agenda views, Exporting Agenda Views, Agenda commands, Agenda Views
8363 @section Custom agenda views
8364 @cindex custom agenda views
8365 @cindex agenda views, custom
8367 Custom agenda commands serve two purposes: to store and quickly access
8368 frequently used TODO and tags searches, and to create special composite
8369 agenda buffers.  Custom agenda commands will be accessible through the
8370 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
8372 @menu
8373 * Storing searches::            Type once, use often
8374 * Block agenda::                All the stuff you need in a single buffer
8375 * Setting Options::             Changing the rules
8376 @end menu
8378 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
8379 @subsection Storing searches
8381 The first application of custom searches is the definition of keyboard
8382 shortcuts for frequently used searches, either creating an agenda
8383 buffer, or a sparse tree (the latter covering of course only the current
8384 buffer).
8385 @kindex C-c a C
8386 @vindex org-agenda-custom-commands
8387 Custom commands are configured in the variable
8388 @code{org-agenda-custom-commands}.  You can customize this variable, for
8389 example by pressing @kbd{C-c a C}.  You can also directly set it with
8390 Emacs Lisp in @file{.emacs}.  The following example contains all valid
8391 search types:
8393 @lisp
8394 @group
8395 (setq org-agenda-custom-commands
8396       '(("w" todo "WAITING")
8397         ("W" todo-tree "WAITING")
8398         ("u" tags "+boss-urgent")
8399         ("v" tags-todo "+boss-urgent")
8400         ("U" tags-tree "+boss-urgent")
8401         ("f" occur-tree "\\<FIXME\\>")
8402         ("h" . "HOME+Name tags searches") ; description for "h" prefix
8403         ("hl" tags "+home+Lisa")
8404         ("hp" tags "+home+Peter")
8405         ("hk" tags "+home+Kim")))
8406 @end group
8407 @end lisp
8409 @noindent
8410 The initial string in each entry defines the keys you have to press
8411 after the dispatcher command @kbd{C-c a} in order to access the command.
8412 Usually this will be just a single character, but if you have many
8413 similar commands, you can also define two-letter combinations where the
8414 first character is the same in several combinations and serves as a
8415 prefix key@footnote{You can provide a description for a prefix key by
8416 inserting a cons cell with the prefix and the description.}.  The second
8417 parameter is the search type, followed by the string or regular
8418 expression to be used for the matching.  The example above will
8419 therefore define:
8421 @table @kbd
8422 @item C-c a w
8423 as a global search for TODO entries with @samp{WAITING} as the TODO
8424 keyword
8425 @item C-c a W
8426 as the same search, but only in the current buffer and displaying the
8427 results as a sparse tree
8428 @item C-c a u
8429 as a global tags search for headlines marked @samp{:boss:} but not
8430 @samp{:urgent:}
8431 @item C-c a v
8432 as the same search as @kbd{C-c a u}, but limiting the search to
8433 headlines that are also TODO items
8434 @item C-c a U
8435 as the same search as @kbd{C-c a u}, but only in the current buffer and
8436 displaying the result as a sparse tree
8437 @item C-c a f
8438 to create a sparse tree (again: current buffer only) with all entries
8439 containing the word @samp{FIXME}
8440 @item C-c a h
8441 as a prefix command for a HOME tags search where you have to press an
8442 additional key (@kbd{l}, @kbd{p} or @kbd{k}) to select a name (Lisa,
8443 Peter, or Kim) as additional tag to match.
8444 @end table
8446 @node Block agenda, Setting Options, Storing searches, Custom agenda views
8447 @subsection Block agenda
8448 @cindex block agenda
8449 @cindex agenda, with block views
8451 Another possibility is the construction of agenda views that comprise
8452 the results of @emph{several} commands, each of which creates a block in
8453 the agenda buffer.  The available commands include @code{agenda} for the
8454 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
8455 for the global TODO list (as constructed with @kbd{C-c a t}), and the
8456 matching commands discussed above: @code{todo}, @code{tags}, and
8457 @code{tags-todo}.  Here are two examples:
8459 @lisp
8460 @group
8461 (setq org-agenda-custom-commands
8462       '(("h" "Agenda and Home-related tasks"
8463          ((agenda "")
8464           (tags-todo "home")
8465           (tags "garden")))
8466         ("o" "Agenda and Office-related tasks"
8467          ((agenda "")
8468           (tags-todo "work")
8469           (tags "office")))))
8470 @end group
8471 @end lisp
8473 @noindent
8474 This will define @kbd{C-c a h} to create a multi-block view for stuff
8475 you need to attend to at home.  The resulting agenda buffer will contain
8476 your agenda for the current week, all TODO items that carry the tag
8477 @samp{home}, and also all lines tagged with @samp{garden}.  Finally the
8478 command @kbd{C-c a o} provides a similar view for office tasks.
8480 @node Setting Options,  , Block agenda, Custom agenda views
8481 @subsection Setting options for custom commands
8482 @cindex options, for custom agenda views
8484 @vindex org-agenda-custom-commands
8485 Org-mode contains a number of variables regulating agenda construction
8486 and display.  The global variables define the behavior for all agenda
8487 commands, including the custom commands.  However, if you want to change
8488 some settings just for a single custom view, you can do so.  Setting
8489 options requires inserting a list of variable names and values at the
8490 right spot in @code{org-agenda-custom-commands}.  For example:
8492 @lisp
8493 @group
8494 (setq org-agenda-custom-commands
8495       '(("w" todo "WAITING"
8496          ((org-agenda-sorting-strategy '(priority-down))
8497           (org-agenda-prefix-format "  Mixed: ")))
8498         ("U" tags-tree "+boss-urgent"
8499          ((org-show-following-heading nil)
8500           (org-show-hierarchy-above nil)))
8501         ("N" search ""
8502          ((org-agenda-files '("~org/notes.org"))
8503           (org-agenda-text-search-extra-files nil)))))
8504 @end group
8505 @end lisp
8507 @noindent
8508 Now the @kbd{C-c a w} command will sort the collected entries only by
8509 priority, and the prefix format is modified to just say @samp{  Mixed: }
8510 instead of giving the category of the entry.  The sparse tags tree of
8511 @kbd{C-c a U} will now turn out ultra-compact, because neither the
8512 headline hierarchy above the match, nor the headline following the match
8513 will be shown.  The command @kbd{C-c a N} will do a text search limited
8514 to only a single file.
8516 @vindex org-agenda-custom-commands
8517 For command sets creating a block agenda,
8518 @code{org-agenda-custom-commands} has two separate spots for setting
8519 options.  You can add options that should be valid for just a single
8520 command in the set, and options that should be valid for all commands in
8521 the set.  The former are just added to the command entry; the latter
8522 must come after the list of command entries.  Going back to the block
8523 agenda example (@pxref{Block agenda}), let's change the sorting strategy
8524 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
8525 the results for GARDEN tags query in the opposite order,
8526 @code{priority-up}.  This would look like this:
8528 @lisp
8529 @group
8530 (setq org-agenda-custom-commands
8531       '(("h" "Agenda and Home-related tasks"
8532          ((agenda)
8533           (tags-todo "home")
8534           (tags "garden"
8535                 ((org-agenda-sorting-strategy '(priority-up)))))
8536          ((org-agenda-sorting-strategy '(priority-down))))
8537         ("o" "Agenda and Office-related tasks"
8538          ((agenda)
8539           (tags-todo "work")
8540           (tags "office")))))
8541 @end group
8542 @end lisp
8544 As you see, the values and parentheses setting is a little complex.
8545 When in doubt, use the customize interface to set this variable---it
8546 fully supports its structure.  Just one caveat: when setting options in
8547 this interface, the @emph{values} are just Lisp expressions.  So if the
8548 value is a string, you need to add the double-quotes around the value
8549 yourself.
8552 @node Exporting Agenda Views, Agenda column view, Custom agenda views, Agenda Views
8553 @section Exporting Agenda Views
8554 @cindex agenda views, exporting
8556 If you are away from your computer, it can be very useful to have a printed
8557 version of some agenda views to carry around.  Org-mode can export custom
8558 agenda views as plain text, HTML@footnote{You need to install Hrvoje Niksic's
8559 @file{htmlize.el}.}, Postscript, PDF@footnote{To create PDF output, the
8560 ghostscript @file{ps2pdf} utility must be installed on the system.  Selecting
8561 a PDF file will also create the postscript file.}, and iCalendar files.  If
8562 you want to do this only occasionally, use the command
8564 @table @kbd
8565 @orgcmd{C-x C-w,org-write-agenda}
8566 @cindex exporting agenda views
8567 @cindex agenda views, exporting
8568 @vindex org-agenda-exporter-settings
8569 Write the agenda view to a file.  Depending on the extension of the selected
8570 file name, the view will be exported as HTML (extension @file{.html} or
8571 @file{.htm}), Postscript (extension @file{.ps}), iCalendar (extension
8572 @file{.ics}), or plain text (any other extension).  Use the variable
8573 @code{org-agenda-exporter-settings} to set options for @file{ps-print} and
8574 for @file{htmlize} to be used during export, for example
8576 @vindex org-agenda-add-entry-text-maxlines
8577 @vindex htmlize-output-type
8578 @vindex ps-number-of-columns
8579 @vindex ps-landscape-mode
8580 @lisp
8581 (setq org-agenda-exporter-settings
8582       '((ps-number-of-columns 2)
8583         (ps-landscape-mode t)
8584         (org-agenda-add-entry-text-maxlines 5)
8585         (htmlize-output-type 'css)))
8586 @end lisp
8587 @end table
8589 If you need to export certain agenda views frequently, you can associate
8590 any custom agenda command with a list of output file names
8591 @footnote{If you want to store standard views like the weekly agenda
8592 or the global TODO list as well, you need to define custom commands for
8593 them in order to be able to specify file names.}.  Here is an example
8594 that first defines custom commands for the agenda and the global
8595 TODO list, together with a number of files to which to export them.
8596 Then we define two block agenda commands and specify file names for them
8597 as well.  File names can be relative to the current working directory,
8598 or absolute.
8600 @lisp
8601 @group
8602 (setq org-agenda-custom-commands
8603       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
8604         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
8605         ("h" "Agenda and Home-related tasks"
8606          ((agenda "")
8607           (tags-todo "home")
8608           (tags "garden"))
8609          nil
8610          ("~/views/home.html"))
8611         ("o" "Agenda and Office-related tasks"
8612          ((agenda)
8613           (tags-todo "work")
8614           (tags "office"))
8615          nil
8616          ("~/views/office.ps" "~/calendars/office.ics"))))
8617 @end group
8618 @end lisp
8620 The extension of the file name determines the type of export.  If it is
8621 @file{.html}, Org-mode will use the @file{htmlize.el} package to convert
8622 the buffer to HTML and save it to this file name.  If the extension is
8623 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
8624 Postscript output.  If the extension is @file{.ics}, iCalendar export is
8625 run export over all files that were used to construct the agenda, and
8626 limit the export to entries listed in the agenda.  Any other
8627 extension produces a plain ASCII file.
8629 The export files are @emph{not} created when you use one of those
8630 commands interactively because this might use too much overhead.
8631 Instead, there is a special command to produce @emph{all} specified
8632 files in one step:
8634 @table @kbd
8635 @orgcmd{C-c a e,org-store-agenda-views}
8636 Export all agenda views that have export file names associated with
8637 them.
8638 @end table
8640 You can use the options section of the custom agenda commands to also
8641 set options for the export commands.  For example:
8643 @lisp
8644 (setq org-agenda-custom-commands
8645       '(("X" agenda ""
8646          ((ps-number-of-columns 2)
8647           (ps-landscape-mode t)
8648           (org-agenda-prefix-format " [ ] ")
8649           (org-agenda-with-colors nil)
8650           (org-agenda-remove-tags t))
8651          ("theagenda.ps"))))
8652 @end lisp
8654 @noindent
8655 This command sets two options for the Postscript exporter, to make it
8656 print in two columns in landscape format---the resulting page can be cut
8657 in two and then used in a paper agenda.  The remaining settings modify
8658 the agenda prefix to omit category and scheduling information, and
8659 instead include a checkbox to check off items.  We also remove the tags
8660 to make the lines compact, and we don't want to use colors for the
8661 black-and-white printer.  Settings specified in
8662 @code{org-agenda-exporter-settings} will also apply, but the settings
8663 in @code{org-agenda-custom-commands} take precedence.
8665 @noindent
8666 From the command line you may also use
8667 @example
8668 emacs -eval (org-batch-store-agenda-views) -kill
8669 @end example
8670 @noindent
8671 or, if you need to modify some parameters@footnote{Quoting depends on the
8672 system you use, please check the FAQ for examples.}
8673 @example
8674 emacs -eval '(org-batch-store-agenda-views                      \
8675               org-agenda-span (quote month)                     \
8676               org-agenda-start-day "2007-11-01"                 \
8677               org-agenda-include-diary nil                      \
8678               org-agenda-files (quote ("~/org/project.org")))'  \
8679       -kill
8680 @end example
8681 @noindent
8682 which will create the agenda views restricted to the file
8683 @file{~/org/project.org}, without diary entries and with a 30-day
8684 extent.
8686 You can also extract agenda information in a way that allows further
8687 processing by other programs.  See @ref{Extracting agenda information}, for
8688 more information.
8691 @node Agenda column view,  , Exporting Agenda Views, Agenda Views
8692 @section Using column view in the agenda
8693 @cindex column view, in agenda
8694 @cindex agenda, column view
8696 Column view (@pxref{Column view}) is normally used to view and edit
8697 properties embedded in the hierarchical structure of an Org file.  It can be
8698 quite useful to use column view also from the agenda, where entries are
8699 collected by certain criteria.
8701 @table @kbd
8702 @orgcmd{C-c C-x C-c,org-agenda-columns}
8703 Turn on column view in the agenda.
8704 @end table
8706 To understand how to use this properly, it is important to realize that the
8707 entries in the agenda are no longer in their proper outline environment.
8708 This causes the following issues:
8710 @enumerate
8711 @item
8712 @vindex org-columns-default-format
8713 @vindex org-overriding-columns-format
8714 Org needs to make a decision which @code{COLUMNS} format to use.  Since the
8715 entries in the agenda are collected from different files, and different files
8716 may have different @code{COLUMNS} formats, this is a non-trivial problem.
8717 Org first checks if the variable @code{org-agenda-overriding-columns-format} is
8718 currently set, and if so, takes the format from there.  Otherwise it takes
8719 the format associated with the first item in the agenda, or, if that item
8720 does not have a specific format (defined in a property, or in its file), it
8721 uses @code{org-columns-default-format}.
8722 @item
8723 @cindex property, special, CLOCKSUM
8724 If any of the columns has a summary type defined (@pxref{Column attributes}),
8725 turning on column view in the agenda will visit all relevant agenda files and
8726 make sure that the computations of this property are up to date.  This is
8727 also true for the special @code{CLOCKSUM} property.  Org will then sum the
8728 values displayed in the agenda.  In the daily/weekly agenda, the sums will
8729 cover a single day; in all other views they cover the entire block.  It is
8730 vital to realize that the agenda may show the same entry @emph{twice} (for
8731 example as scheduled and as a deadline), and it may show two entries from the
8732 same hierarchy (for example a @emph{parent} and its @emph{child}).  In these
8733 cases, the summation in the agenda will lead to incorrect results because
8734 some values will count double.
8735 @item
8736 When the column view in the agenda shows the @code{CLOCKSUM}, that is always
8737 the entire clocked time for this item.  So even in the daily/weekly agenda,
8738 the clocksum listed in column view may originate from times outside the
8739 current view.  This has the advantage that you can compare these values with
8740 a column listing the planned total effort for a task---one of the major
8741 applications for column view in the agenda.  If you want information about
8742 clocked time in the displayed period use clock table mode (press @kbd{R} in
8743 the agenda).
8744 @end enumerate
8747 @node Markup, Exporting, Agenda Views, Top
8748 @chapter Markup for rich export
8750 When exporting Org-mode documents, the exporter tries to reflect the
8751 structure of the document as accurately as possible in the backend.  Since
8752 export targets like HTML, @LaTeX{}, or DocBook allow much richer formatting,
8753 Org-mode has rules on how to prepare text for rich export.  This section
8754 summarizes the markup rules used in an Org-mode buffer.
8756 @menu
8757 * Structural markup elements::  The basic structure as seen by the exporter
8758 * Images and tables::           Tables and Images will be included
8759 * Literal examples::            Source code examples with special formatting
8760 * Include files::               Include additional files into a document
8761 * Index entries::               Making an index
8762 * Macro replacement::           Use macros to create complex output
8763 * Embedded LaTeX::              LaTeX can be freely used inside Org documents
8764 @end menu
8766 @node Structural markup elements, Images and tables, Markup, Markup
8767 @section Structural markup elements
8769 @menu
8770 * Document title::              Where the title is taken from
8771 * Headings and sections::       The document structure as seen by the exporter
8772 * Table of contents::           The if and where of the table of contents
8773 * Initial text::                Text before the first heading?
8774 * Lists::                       Lists
8775 * Paragraphs::                  Paragraphs
8776 * Footnote markup::             Footnotes
8777 * Emphasis and monospace::      Bold, italic, etc.
8778 * Horizontal rules::            Make a line
8779 * Comment lines::               What will *not* be exported
8780 @end menu
8782 @node Document title, Headings and sections, Structural markup elements, Structural markup elements
8783 @subheading Document title
8784 @cindex document title, markup rules
8786 @noindent
8787 The title of the exported document is taken from the special line
8789 @cindex #+TITLE
8790 @example
8791 #+TITLE: This is the title of the document
8792 @end example
8794 @noindent
8795 If this line does not exist, the title is derived from the first non-empty,
8796 non-comment line in the buffer.  If no such line exists, or if you have
8797 turned off exporting of the text before the first headline (see below), the
8798 title will be the file name without extension.
8800 @cindex property, EXPORT_TITLE
8801 If you are exporting only a subtree by marking is as the region, the heading
8802 of the subtree will become the title of the document.  If the subtree has a
8803 property @code{EXPORT_TITLE}, that will take precedence.
8805 @node Headings and sections, Table of contents, Document title, Structural markup elements
8806 @subheading Headings and sections
8807 @cindex headings and sections, markup rules
8809 @vindex org-export-headline-levels
8810 The outline structure of the document as described in @ref{Document
8811 Structure}, forms the basis for defining sections of the exported document.
8812 However, since the outline structure is also used for (for example) lists of
8813 tasks, only the first three outline levels will be used as headings.  Deeper
8814 levels will become itemized lists.  You can change the location of this
8815 switch globally by setting the variable @code{org-export-headline-levels}, or on a
8816 per-file basis with a line
8818 @cindex #+OPTIONS
8819 @example
8820 #+OPTIONS: H:4
8821 @end example
8823 @node Table of contents, Initial text, Headings and sections, Structural markup elements
8824 @subheading Table of contents
8825 @cindex table of contents, markup rules
8827 @vindex org-export-with-toc
8828 The table of contents is normally inserted directly before the first headline
8829 of the file.  If you would like to get it to a different location, insert the
8830 string @code{[TABLE-OF-CONTENTS]} on a line by itself at the desired
8831 location.  The depth of the table of contents is by default the same as the
8832 number of headline levels, but you can choose a smaller number, or turn off
8833 the table of contents entirely, by configuring the variable
8834 @code{org-export-with-toc}, or on a per-file basis with a line like
8836 @example
8837 #+OPTIONS: toc:2          (only to two levels in TOC)
8838 #+OPTIONS: toc:nil        (no TOC at all)
8839 @end example
8841 @node Initial text, Lists, Table of contents, Structural markup elements
8842 @subheading Text before the first headline
8843 @cindex text before first headline, markup rules
8844 @cindex #+TEXT
8846 Org-mode normally exports the text before the first headline, and even uses
8847 the first line as the document title.  The text will be fully marked up.  If
8848 you need to include literal HTML, @LaTeX{}, or DocBook code, use the special
8849 constructs described below in the sections for the individual exporters.
8851 @vindex org-export-skip-text-before-1st-heading
8852 Some people like to use the space before the first headline for setup and
8853 internal links and therefore would like to control the exported text before
8854 the first headline in a different way.  You can do so by setting the variable
8855 @code{org-export-skip-text-before-1st-heading} to @code{t}.  On a per-file
8856 basis, you can get the same effect with @samp{#+OPTIONS: skip:t}.
8858 @noindent
8859 If you still want to have some text before the first headline, use the
8860 @code{#+TEXT} construct:
8862 @example
8863 #+OPTIONS: skip:t
8864 #+TEXT: This text will go before the *first* headline.
8865 #+TEXT: [TABLE-OF-CONTENTS]
8866 #+TEXT: This goes between the table of contents and the *first* headline
8867 @end example
8869 @node Lists, Paragraphs, Initial text, Structural markup elements
8870 @subheading Lists
8871 @cindex lists, markup rules
8873 Plain lists as described in @ref{Plain lists}, are translated to the backend's
8874 syntax for such lists.  Most backends support unordered, ordered, and
8875 description lists.
8877 @node Paragraphs, Footnote markup, Lists, Structural markup elements
8878 @subheading Paragraphs, line breaks, and quoting
8879 @cindex paragraphs, markup rules
8881 Paragraphs are separated by at least one empty line.  If you need to enforce
8882 a line break within a paragraph, use @samp{\\} at the end of a line.
8884 To keep the line breaks in a region, but otherwise use normal formatting, you
8885 can use this construct, which can also be used to format poetry.
8887 @cindex #+BEGIN_VERSE
8888 @example
8889 #+BEGIN_VERSE
8890  Great clouds overhead
8891  Tiny black birds rise and fall
8892  Snow covers Emacs
8894      -- AlexSchroeder
8895 #+END_VERSE
8896 @end example
8898 When quoting a passage from another document, it is customary to format this
8899 as a paragraph that is indented on both the left and the right margin.  You
8900 can include quotations in Org-mode documents like this:
8902 @cindex #+BEGIN_QUOTE
8903 @example
8904 #+BEGIN_QUOTE
8905 Everything should be made as simple as possible,
8906 but not any simpler -- Albert Einstein
8907 #+END_QUOTE
8908 @end example
8910 If you would like to center some text, do it like this:
8911 @cindex #+BEGIN_CENTER
8912 @example
8913 #+BEGIN_CENTER
8914 Everything should be made as simple as possible, \\
8915 but not any simpler
8916 #+END_CENTER
8917 @end example
8920 @node Footnote markup, Emphasis and monospace, Paragraphs, Structural markup elements
8921 @subheading Footnote markup
8922 @cindex footnotes, markup rules
8923 @cindex @file{footnote.el}
8925 Footnotes defined in the way described in @ref{Footnotes}, will be exported
8926 by all backends.  Org allows multiple references to the same note, and
8927 multiple footnotes side by side.
8929 @node Emphasis and monospace, Horizontal rules, Footnote markup, Structural markup elements
8930 @subheading Emphasis and monospace
8932 @cindex underlined text, markup rules
8933 @cindex bold text, markup rules
8934 @cindex italic text, markup rules
8935 @cindex verbatim text, markup rules
8936 @cindex code text, markup rules
8937 @cindex strike-through text, markup rules
8938 You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
8939 and @code{~verbatim~}, and, if you must, @samp{+strike-through+}.  Text
8940 in the code and verbatim string is not processed for Org-mode specific
8941 syntax; it is exported verbatim.
8943 @node Horizontal rules, Comment lines, Emphasis and monospace, Structural markup elements
8944 @subheading  Horizontal rules
8945 @cindex horizontal rules, markup rules
8946 A line consisting of only dashes, and at least 5 of them, will be exported as
8947 a horizontal line (@samp{<hr/>} in HTML and @code{\hrule} in @LaTeX{}).
8949 @node Comment lines,  , Horizontal rules, Structural markup elements
8950 @subheading Comment lines
8951 @cindex comment lines
8952 @cindex exporting, not
8953 @cindex #+BEGIN_COMMENT
8955 Lines starting with @samp{#} in column zero are treated as comments and will
8956 never be exported.  If you want an indented line to be treated as a comment,
8957 start it with @samp{#+ }.  Also entire subtrees starting with the word
8958 @samp{COMMENT} will never be exported.  Finally, regions surrounded by
8959 @samp{#+BEGIN_COMMENT} ... @samp{#+END_COMMENT} will not be exported.
8961 @table @kbd
8962 @kindex C-c ;
8963 @item C-c ;
8964 Toggle the COMMENT keyword at the beginning of an entry.
8965 @end table
8968 @node Images and tables, Literal examples, Structural markup elements, Markup
8969 @section Images and Tables
8971 @cindex tables, markup rules
8972 @cindex #+CAPTION
8973 @cindex #+LABEL
8974 Both the native Org-mode tables (@pxref{Tables}) and tables formatted with
8975 the @file{table.el} package will be exported properly.  For Org-mode tables,
8976 the lines before the first horizontal separator line will become table header
8977 lines.  You can use the following lines somewhere before the table to assign
8978 a caption and a label for cross references, and in the text you can refer to
8979 the object with @code{\ref@{tab:basic-data@}}:
8981 @example
8982 #+CAPTION: This is the caption for the next table (or link)
8983 #+LABEL:   tbl:basic-data
8984    | ... | ...|
8985    |-----|----|
8986 @end example
8988 Optionally, the caption can take the form:
8989 @example
8990 #+CAPTION: [Caption for list of figures]@{Caption for table (or link).@}
8991 @end example
8993 @cindex inlined images, markup rules
8994 Some backends (HTML, @LaTeX{}, and DocBook) allow you to directly include
8995 images into the exported document.  Org does this, if a link to an image
8996 files does not have a description part, for example @code{[[./img/a.jpg]]}.
8997 If you wish to define a caption for the image and maybe a label for internal
8998 cross references, make sure that the link is on a line by itself and precede
8999 it with @code{#+CAPTION} and @code{#+LABEL} as follows:
9001 @example
9002 #+CAPTION: This is the caption for the next figure link (or table)
9003 #+LABEL:   fig:SED-HR4049
9004 [[./img/a.jpg]]
9005 @end example
9007 You may also define additional attributes for the figure.  As this is
9008 backend-specific, see the sections about the individual backends for more
9009 information.
9011 @xref{Handling links,the discussion of image links}.
9013 @node Literal examples, Include files, Images and tables, Markup
9014 @section Literal examples
9015 @cindex literal examples, markup rules
9016 @cindex code line references, markup rules
9018 You can include literal examples that should not be subjected to
9019 markup.  Such examples will be typeset in monospace, so this is well suited
9020 for source code and similar examples.
9021 @cindex #+BEGIN_EXAMPLE
9023 @example
9024 #+BEGIN_EXAMPLE
9025 Some example from a text file.
9026 #+END_EXAMPLE
9027 @end example
9029 Note that such blocks may be @i{indented} in order to align nicely with
9030 indented text and in particular with plain list structure (@pxref{Plain
9031 lists}).  For simplicity when using small examples, you can also start the
9032 example lines with a colon followed by a space.  There may also be additional
9033 whitespace before the colon:
9035 @example
9036 Here is an example
9037    : Some example from a text file.
9038 @end example
9040 @cindex formatting source code, markup rules
9041 If the example is source code from a programming language, or any other text
9042 that can be marked up by font-lock in Emacs, you can ask for the example to
9043 look like the fontified Emacs buffer@footnote{This works automatically for
9044 the HTML backend (it requires version 1.34 of the @file{htmlize.el} package,
9045 which is distributed with Org).  Fontified code chunks in LaTeX can be
9046 achieved using either the listings or the
9047 @url{http://code.google.com/p/minted, minted,} package.  To use listings, turn
9048 on the variable @code{org-export-latex-listings} and ensure that the listings
9049 package is included by the LaTeX header (e.g.@: by configuring
9050 @code{org-export-latex-packages-alist}).  See the listings documentation for
9051 configuration options, including obtaining colored output.  For minted it is
9052 necessary to install the program @url{http://pygments.org, pygments}, in
9053 addition to setting @code{org-export-latex-minted}, ensuring that the minted
9054 package is included by the LaTeX header, and ensuring that the
9055 @code{-shell-escape} option is passed to @file{pdflatex} (see
9056 @code{org-latex-to-pdf-process}).  See the documentation of the variables
9057 @code{org-export-latex-listings} and @code{org-export-latex-minted} for
9058 further details.}.  This is done with the @samp{src} block, where you also
9059 need to specify the name of the major mode that should be used to fontify the
9060 example@footnote{Code in @samp{src} blocks may also be evaluated either
9061 interactively or on export.  See @pxref{Working With Source Code} for more
9062 information on evaluating code blocks.}, see @ref{Easy Templates} for
9063 shortcuts to easily insert code blocks.
9064 @cindex #+BEGIN_SRC
9066 @example
9067 #+BEGIN_SRC emacs-lisp
9068   (defun org-xor (a b)
9069      "Exclusive or."
9070      (if a (not b) b))
9071 #+END_SRC
9072 @end example
9074 Both in @code{example} and in @code{src} snippets, you can add a @code{-n}
9075 switch to the end of the @code{BEGIN} line, to get the lines of the example
9076 numbered.  If you use a @code{+n} switch, the numbering from the previous
9077 numbered snippet will be continued in the current one.  In literal examples,
9078 Org will interpret strings like @samp{(ref:name)} as labels, and use them as
9079 targets for special hyperlinks like @code{[[(name)]]} (i.e.@: the reference name
9080 enclosed in single parenthesis).  In HTML, hovering the mouse over such a
9081 link will remote-highlight the corresponding code line, which is kind of
9082 cool.
9084 You can also add a @code{-r} switch which @i{removes} the labels from the
9085 source code@footnote{Adding @code{-k} to @code{-n -r} will @i{keep} the
9086 labels in the source code while using line numbers for the links, which might
9087 be useful to explain those in an org-mode example code.}.  With the @code{-n}
9088 switch, links to these references will be labeled by the line numbers from
9089 the code listing, otherwise links will use the labels with no parentheses.
9090 Here is an example:
9092 @example
9093 #+BEGIN_SRC emacs-lisp -n -r
9094 (save-excursion                  (ref:sc)
9095    (goto-char (point-min))       (ref:jump)
9096 #+END_SRC
9097 In line [[(sc)]] we remember the current position.  [[(jump)][Line (jump)]]
9098 jumps to point-min.
9099 @end example
9101 @vindex org-coderef-label-format
9102 If the syntax for the label format conflicts with the language syntax, use a
9103 @code{-l} switch to change the format, for example @samp{#+BEGIN_SRC pascal
9104 -n -r -l "((%s))"}.  See also the variable @code{org-coderef-label-format}.
9106 HTML export also allows examples to be published as text areas (@pxref{Text
9107 areas in HTML export}).
9109 Because the @code{#+BEGIN_...} and @code{#+END_...} patterns need to be added
9110 so often, shortcuts are provided using the Easy Templates facility
9111 (@pxref{Easy Templates}).
9113 @table @kbd
9114 @kindex C-c '
9115 @item C-c '
9116 Edit the source code example at point in its native mode.  This works by
9117 switching to a temporary buffer with the source code.  You need to exit by
9118 pressing @kbd{C-c '} again@footnote{Upon exit, lines starting with @samp{*}
9119 or @samp{#} will get a comma prepended, to keep them from being interpreted
9120 by Org as outline nodes or special comments.  These commas will be stripped
9121 for editing with @kbd{C-c '}, and also for export.}.  The edited version will
9122 then replace the old version in the Org buffer.  Fixed-width regions
9123 (where each line starts with a colon followed by a space) will be edited
9124 using @code{artist-mode}@footnote{You may select a different-mode with the
9125 variable @code{org-edit-fixed-width-region-mode}.} to allow creating ASCII
9126 drawings easily.  Using this command in an empty line will create a new
9127 fixed-width region.
9128 @kindex C-c l
9129 @item C-c l
9130 Calling @code{org-store-link} while editing a source code example in a
9131 temporary buffer created with @kbd{C-c '} will prompt for a label.  Make sure
9132 that it is unique in the current buffer, and insert it with the proper
9133 formatting like @samp{(ref:label)} at the end of the current line.  Then the
9134 label is stored as a link @samp{(label)}, for retrieval with @kbd{C-c C-l}.
9135 @end table
9138 @node Include files, Index entries, Literal examples, Markup
9139 @section Include files
9140 @cindex include files, markup rules
9142 During export, you can include the content of another file.  For example, to
9143 include your @file{.emacs} file, you could use:
9144 @cindex #+INCLUDE
9146 @example
9147 #+INCLUDE: "~/.emacs" src emacs-lisp
9148 @end example
9149 @noindent
9150 The optional second and third parameter are the markup (e.g.@: @samp{quote},
9151 @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
9152 language for formatting the contents.  The markup is optional; if it is not
9153 given, the text will be assumed to be in Org-mode format and will be
9154 processed normally.  The include line will also allow additional keyword
9155 parameters @code{:prefix1} and @code{:prefix} to specify prefixes for the
9156 first line and for each following line, @code{:minlevel} in order to get
9157 org-mode content demoted to a specified level, as well as any options
9158 accepted by the selected markup.  For example, to include a file as an item,
9161 @example
9162 #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
9163 @end example
9165 You can also include a portion of a file by specifying a lines range using
9166 the @code{:lines} parameter.  The line at the upper end of the range will not
9167 be included.  The start and/or the end of the range may be omitted to use the
9168 obvious defaults.
9170 @example
9171 #+INCLUDE: "~/.emacs" :lines "5-10"   @r{Include lines 5 to 10, 10 excluded}
9172 #+INCLUDE: "~/.emacs" :lines "-10"    @r{Include lines 1 to 10, 10 excluded}
9173 #+INCLUDE: "~/.emacs" :lines "10-"    @r{Include lines from 10 to EOF}
9174 @end example
9176 @table @kbd
9177 @kindex C-c '
9178 @item C-c '
9179 Visit the include file at point.
9180 @end table
9182 @node Index entries, Macro replacement, Include files, Markup
9183 @section Index entries
9184 @cindex index entries, for publishing
9186 You can specify entries that will be used for generating an index during
9187 publishing.  This is done by lines starting with @code{#+INDEX}.  An entry
9188 the contains an exclamation mark will create a sub item.  See @ref{Generating
9189 an index} for more information.
9191 @example
9192 * Curriculum Vitae
9193 #+INDEX: CV
9194 #+INDEX: Application!CV
9195 @end example
9200 @node Macro replacement, Embedded LaTeX, Index entries, Markup
9201 @section Macro replacement
9202 @cindex macro replacement, during export
9203 @cindex #+MACRO
9205 You can define text snippets with
9207 @example
9208 #+MACRO: name   replacement text $1, $2 are arguments
9209 @end example
9211 @noindent which can be referenced anywhere in the document (even in
9212 code examples) with @code{@{@{@{name(arg1,arg2)@}@}@}}.  In addition to
9213 defined macros, @code{@{@{@{title@}@}@}}, @code{@{@{@{author@}@}@}}, etc.,
9214 will reference information set by the @code{#+TITLE:}, @code{#+AUTHOR:}, and
9215 similar lines.  Also, @code{@{@{@{date(@var{FORMAT})@}@}@}} and
9216 @code{@{@{@{modification-time(@var{FORMAT})@}@}@}} refer to current date time
9217 and to the modification time of the file being exported, respectively.
9218 @var{FORMAT} should be a format string understood by
9219 @code{format-time-string}.
9221 Macro expansion takes place during export, and some people use it to
9222 construct complex HTML code.
9225 @node Embedded LaTeX,  , Macro replacement, Markup
9226 @section Embedded @LaTeX{}
9227 @cindex @TeX{} interpretation
9228 @cindex @LaTeX{} interpretation
9230 Plain ASCII is normally sufficient for almost all note taking.  Exceptions
9231 include scientific notes, which often require mathematical symbols and the
9232 occasional formula.  @LaTeX{}@footnote{@LaTeX{} is a macro system based on
9233 Donald E. Knuth's @TeX{} system.  Many of the features described here as
9234 ``@LaTeX{}'' are really from @TeX{}, but for simplicity I am blurring this
9235 distinction.}  is widely used to typeset scientific documents.  Org-mode
9236 supports embedding @LaTeX{} code into its files, because many academics are
9237 used to writing and reading @LaTeX{} source code, and because it can be
9238 readily processed to produce pretty output for a number of export backends.
9240 @menu
9241 * Special symbols::             Greek letters and other symbols
9242 * Subscripts and superscripts::  Simple syntax for raising/lowering text
9243 * LaTeX fragments::             Complex formulas made easy
9244 * Previewing LaTeX fragments::  What will this snippet look like?
9245 * CDLaTeX mode::                Speed up entering of formulas
9246 @end menu
9248 @node Special symbols, Subscripts and superscripts, Embedded LaTeX, Embedded LaTeX
9249 @subsection Special symbols
9250 @cindex math symbols
9251 @cindex special symbols
9252 @cindex @TeX{} macros
9253 @cindex @LaTeX{} fragments, markup rules
9254 @cindex HTML entities
9255 @cindex @LaTeX{} entities
9257 You can use @LaTeX{} macros to insert special symbols like @samp{\alpha} to
9258 indicate the Greek letter, or @samp{\to} to indicate an arrow.  Completion
9259 for these macros is available, just type @samp{\} and maybe a few letters,
9260 and press @kbd{M-@key{TAB}} to see possible completions.  Unlike @LaTeX{}
9261 code, Org-mode allows these macros to be present without surrounding math
9262 delimiters, for example:
9264 @example
9265 Angles are written as Greek letters \alpha, \beta and \gamma.
9266 @end example
9268 @vindex org-entities
9269 During export, these symbols will be transformed into the native format of
9270 the exporter backend.  Strings like @code{\alpha} will be exported as
9271 @code{&alpha;} in the HTML output, and as @code{$\alpha$} in the @LaTeX{}
9272 output.  Similarly, @code{\nbsp} will become @code{&nbsp;} in HTML and
9273 @code{~} in @LaTeX{}.  If you need such a symbol inside a word, terminate it
9274 like this: @samp{\Aacute@{@}stor}.
9276 A large number of entities is provided, with names taken from both HTML and
9277 @LaTeX{}; see the variable @code{org-entities} for the complete list.
9278 @samp{\-} is treated as a shy hyphen, and @samp{--}, @samp{---}, and
9279 @samp{...} are all converted into special commands creating hyphens of
9280 different lengths or a compact set of dots.
9282 If you would like to see entities displayed as UTF8 characters, use the
9283 following command@footnote{You can turn this on by default by setting the
9284 variable @code{org-pretty-entities}, or on a per-file base with the
9285 @code{#+STARTUP} option @code{entitiespretty}.}:
9287 @table @kbd
9288 @kindex C-c C-x \
9289 @item C-c C-x \
9290 Toggle display of entities as UTF-8 characters.  This does not change the
9291 buffer content which remains plain ASCII, but it overlays the UTF-8 character
9292 for display purposes only.
9293 @end table
9295 @node Subscripts and superscripts, LaTeX fragments, Special symbols, Embedded LaTeX
9296 @subsection Subscripts and superscripts
9297 @cindex subscript
9298 @cindex superscript
9300 Just like in @LaTeX{}, @samp{^} and @samp{_} are used to indicate super-
9301 and subscripts.  Again, these can be used without embedding them in
9302 math-mode delimiters.  To increase the readability of ASCII text, it is
9303 not necessary (but OK) to surround multi-character sub- and superscripts
9304 with curly braces.  For example
9306 @example
9307 The mass of the sun is M_sun = 1.989 x 10^30 kg.  The radius of
9308 the sun is R_@{sun@} = 6.96 x 10^8 m.
9309 @end example
9311 @vindex org-export-with-sub-superscripts
9312 To avoid interpretation as raised or lowered text, you can quote @samp{^} and
9313 @samp{_} with a backslash: @samp{\^} and @samp{\_}.  If you write a text
9314 where the underscore is often used in a different context, Org's convention
9315 to always interpret these as subscripts can get in your way.  Configure the
9316 variable @code{org-export-with-sub-superscripts} to globally change this
9317 convention, or use, on a per-file basis:
9319 @example
9320 #+OPTIONS: ^:@{@}
9321 @end example
9323 @noindent With this setting, @samp{a_b} will not be interpreted as a
9324 subscript, but @samp{a_@{b@}} will.
9326 @table @kbd
9327 @kindex C-c C-x \
9328 @item C-c C-x \
9329 In addition to showing entities as UTF-8 characters, this command will also
9330 format sub- and superscripts in a WYSIWYM way.
9331 @end table
9333 @node LaTeX fragments, Previewing LaTeX fragments, Subscripts and superscripts, Embedded LaTeX
9334 @subsection @LaTeX{} fragments
9335 @cindex @LaTeX{} fragments
9337 @vindex org-format-latex-header
9338 Going beyond symbols and sub- and superscripts, a full formula language is
9339 needed.  Org-mode can contain @LaTeX{} math fragments, and it supports ways
9340 to process these for several export backends.  When exporting to @LaTeX{},
9341 the code is obviously left as it is.  When exporting to HTML, Org invokes the
9342 @uref{http://www.mathjax.org, MathJax library} (@pxref{Math formatting in
9343 HTML export}) to process and display the math@footnote{If you plan to use
9344 this regularly or on pages with significant page views, you should install
9345 @file{MathJax} on your own
9346 server in order to limit the load of our server.}.  Finally, it can also
9347 process the mathematical expressions into images@footnote{For this to work
9348 you need to be on a system with a working @LaTeX{} installation.  You also
9349 need the @file{dvipng} program, available at
9350 @url{http://sourceforge.net/projects/dvipng/}.  The @LaTeX{} header that will
9351 be used when processing a fragment can be configured with the variable
9352 @code{org-format-latex-header}.}  that can be displayed in a browser or in
9353 DocBook documents.
9355 @LaTeX{} fragments don't need any special marking at all.  The following
9356 snippets will be identified as @LaTeX{} source code:
9357 @itemize @bullet
9358 @item
9359 Environments of any kind@footnote{When @file{MathJax} is used, only the
9360 environment recognized by @file{MathJax} will be processed.  When
9361 @file{dvipng} is used to create images, any @LaTeX{} environments will be
9362 handled.}.  The only requirement is that the @code{\begin} statement appears
9363 on a new line, preceded by only whitespace.
9364 @item
9365 Text within the usual @LaTeX{} math delimiters.  To avoid conflicts with
9366 currency specifications, single @samp{$} characters are only recognized as
9367 math delimiters if the enclosed text contains at most two line breaks, is
9368 directly attached to the @samp{$} characters with no whitespace in between,
9369 and if the closing @samp{$} is followed by whitespace, punctuation or a dash.
9370 For the other delimiters, there is no such restriction, so when in doubt, use
9371 @samp{\(...\)} as inline math delimiters.
9372 @end itemize
9374 @noindent For example:
9376 @example
9377 \begin@{equation@}                          % arbitrary environments,
9378 x=\sqrt@{b@}                                % even tables, figures
9379 \end@{equation@}                            % etc
9381 If $a^2=b$ and \( b=2 \), then the solution must be
9382 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
9383 @end example
9385 @noindent
9386 @vindex org-format-latex-options
9387 If you need any of the delimiter ASCII sequences for other purposes, you
9388 can configure the option @code{org-format-latex-options} to deselect the
9389 ones you do not wish to have interpreted by the @LaTeX{} converter.
9391 @vindex org-export-with-LaTeX-fragments
9392 LaTeX processing can be configured with the variable
9393 @code{org-export-with-LaTeX-fragments}.  The default setting is @code{t}
9394 which means @file{MathJax} for HTML, and no processing for DocBook, ASCII and
9395 LaTeX backends.  You can also set this variable on a per-file basis using one
9396 of these lines:
9398 @example
9399 #+OPTIONS: LaTeX:t          @r{Do the right thing automatically (MathJax)}
9400 #+OPTIONS: LaTeX:dvipng     @r{Force using dvipng images}
9401 #+OPTIONS: LaTeX:nil        @r{Do not process @LaTeX{} fragments at all}
9402 #+OPTIONS: LaTeX:verbatim   @r{Verbatim export, for jsMath or so}
9403 @end example
9405 @node Previewing LaTeX fragments, CDLaTeX mode, LaTeX fragments, Embedded LaTeX
9406 @subsection Previewing LaTeX fragments
9407 @cindex LaTeX fragments, preview
9409 If you have @file{dvipng} installed, @LaTeX{} fragments can be processed to
9410 produce preview images of the typeset expressions:
9412 @table @kbd
9413 @kindex C-c C-x C-l
9414 @item C-c C-x C-l
9415 Produce a preview image of the @LaTeX{} fragment at point and overlay it
9416 over the source code.  If there is no fragment at point, process all
9417 fragments in the current entry (between two headlines).  When called
9418 with a prefix argument, process the entire subtree.  When called with
9419 two prefix arguments, or when the cursor is before the first headline,
9420 process the entire buffer.
9421 @kindex C-c C-c
9422 @item C-c C-c
9423 Remove the overlay preview images.
9424 @end table
9426 @vindex org-format-latex-options
9427 You can customize the variable @code{org-format-latex-options} to influence
9428 some aspects of the preview.  In particular, the @code{:scale} (and for HTML
9429 export, @code{:html-scale}) property can be used to adjust the size of the
9430 preview images.
9432 @node CDLaTeX mode,  , Previewing LaTeX fragments, Embedded LaTeX
9433 @subsection Using CDLa@TeX{} to enter math
9434 @cindex CDLa@TeX{}
9436 CDLa@TeX{} mode is a minor mode that is normally used in combination with a
9437 major @LaTeX{} mode like AUC@TeX{} in order to speed-up insertion of
9438 environments and math templates.  Inside Org-mode, you can make use of
9439 some of the features of CDLa@TeX{} mode.  You need to install
9440 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
9441 AUC@TeX{}) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
9442 Don't use CDLa@TeX{} mode itself under Org-mode, but use the light
9443 version @code{org-cdlatex-mode} that comes as part of Org-mode.  Turn it
9444 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
9445 Org files with
9447 @lisp
9448 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
9449 @end lisp
9451 When this mode is enabled, the following features are present (for more
9452 details see the documentation of CDLa@TeX{} mode):
9453 @itemize @bullet
9454 @kindex C-c @{
9455 @item
9456 Environment templates can be inserted with @kbd{C-c @{}.
9457 @item
9458 @kindex @key{TAB}
9459 The @key{TAB} key will do template expansion if the cursor is inside a
9460 @LaTeX{} fragment@footnote{Org-mode has a method to test if the cursor is
9461 inside such a fragment, see the documentation of the function
9462 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
9463 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
9464 correctly inside the first brace.  Another @key{TAB} will get you into
9465 the second brace.  Even outside fragments, @key{TAB} will expand
9466 environment abbreviations at the beginning of a line.  For example, if
9467 you write @samp{equ} at the beginning of a line and press @key{TAB},
9468 this abbreviation will be expanded to an @code{equation} environment.
9469 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
9470 @item
9471 @kindex _
9472 @kindex ^
9473 @vindex cdlatex-simplify-sub-super-scripts
9474 Pressing @kbd{_} and @kbd{^} inside a @LaTeX{} fragment will insert these
9475 characters together with a pair of braces.  If you use @key{TAB} to move
9476 out of the braces, and if the braces surround only a single character or
9477 macro, they are removed again (depending on the variable
9478 @code{cdlatex-simplify-sub-super-scripts}).
9479 @item
9480 @kindex `
9481 Pressing the backquote @kbd{`} followed by a character inserts math
9482 macros, also outside @LaTeX{} fragments.  If you wait more than 1.5 seconds
9483 after the backquote, a help window will pop up.
9484 @item
9485 @kindex '
9486 Pressing the single-quote @kbd{'} followed by another character modifies
9487 the symbol before point with an accent or a font.  If you wait more than
9488 1.5 seconds after the single-quote, a help window will pop up.  Character
9489 modification will work only inside @LaTeX{} fragments; outside the quote
9490 is normal.
9491 @end itemize
9493 @node Exporting, Publishing, Markup, Top
9494 @chapter Exporting
9495 @cindex exporting
9497 Org-mode documents can be exported into a variety of other formats.  For
9498 printing and sharing of notes, ASCII export produces a readable and simple
9499 version of an Org file.  HTML export allows you to publish a notes file on
9500 the web, while the XOXO format provides a solid base for exchange with a
9501 broad range of other applications.  @LaTeX{} export lets you use Org-mode and
9502 its structured editing functions to easily create @LaTeX{} files.  DocBook
9503 export makes it possible to convert Org files to many other formats using
9504 DocBook tools.  OpenDocument Text(@acronym{ODT}) export allows seamless
9505 colloboration across organizational boundaries.  For project management you
9506 can create gantt and resource charts by using TaskJuggler export.  To
9507 incorporate entries with associated times like deadlines or appointments into
9508 a desktop calendar program like iCal, Org-mode can also produce extracts in
9509 the iCalendar format.  Currently Org-mode only supports export, not import of
9510 these different formats.
9512 Org supports export of selected regions when @code{transient-mark-mode} is
9513 enabled (default in Emacs 23).
9515 @menu
9516 * Selective export::            Using tags to select and exclude trees
9517 * Export options::              Per-file export settings
9518 * The export dispatcher::       How to access exporter commands
9519 * ASCII/Latin-1/UTF-8 export::  Exporting to flat files with encoding
9520 * HTML export::                 Exporting to HTML
9521 * LaTeX and PDF export::        Exporting to @LaTeX{}, and processing to PDF
9522 * DocBook export::              Exporting to DocBook
9523 * OpenDocument Text export::    Exporting to OpenDocument Text
9524 * TaskJuggler export::          Exporting to TaskJuggler
9525 * Freemind export::             Exporting to Freemind mind maps
9526 * XOXO export::                 Exporting to XOXO
9527 * iCalendar export::            Exporting in iCalendar format
9528 @end menu
9530 @node Selective export, Export options, Exporting, Exporting
9531 @section Selective export
9532 @cindex export, selective by tags or TODO keyword
9534 @vindex org-export-select-tags
9535 @vindex org-export-exclude-tags
9536 @cindex org-export-with-tasks
9537 You may use tags to select the parts of a document that should be exported,
9538 or to exclude parts from export.  This behavior is governed by two variables:
9539 @code{org-export-select-tags} and @code{org-export-exclude-tags},
9540 respectively defaulting to @code{'(:export:)} and @code{'(:noexport:)}.
9542 @enumerate
9543 @item
9544 Org first checks if any of the @emph{select} tags is present in the
9545 buffer.  If yes, all trees that do not carry one of these tags will be
9546 excluded.  If a selected tree is a subtree, the heading hierarchy above it
9547 will also be selected for export, but not the text below those headings.
9549 @item
9550 If none of the select tags is found, the whole buffer will be selected for
9551 export.
9553 @item
9554 Finally, all subtrees that are marked by any of the @emph{exclude} tags will
9555 be removed from the export buffer.
9556 @end enumerate
9558 The variable @code{org-export-with-tasks} can be configured to select which
9559 kind of tasks should be included for export.  See the docstring of the
9560 variable for more information.
9562 @node Export options, The export dispatcher, Selective export, Exporting
9563 @section Export options
9564 @cindex options, for export
9566 @cindex completion, of option keywords
9567 The exporter recognizes special lines in the buffer which provide
9568 additional information.  These lines may be put anywhere in the file.
9569 The whole set of lines can be inserted into the buffer with @kbd{C-c
9570 C-e t}.  For individual lines, a good way to make sure the keyword is
9571 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
9572 (@pxref{Completion}).   For a summary of other in-buffer settings not
9573 specifically related to export, see @ref{In-buffer settings}.
9574 In particular, note that you can place commonly-used (export) options in
9575 a separate file which can be included using @code{#+SETUPFILE}.
9577 @table @kbd
9578 @orgcmd{C-c C-e t,org-insert-export-options-template}
9579 Insert template with export options, see example below.
9580 @end table
9582 @cindex #+TITLE
9583 @cindex #+AUTHOR
9584 @cindex #+DATE
9585 @cindex #+EMAIL
9586 @cindex #+DESCRIPTION
9587 @cindex #+KEYWORDS
9588 @cindex #+LANGUAGE
9589 @cindex #+TEXT
9590 @cindex #+OPTIONS
9591 @cindex #+BIND
9592 @cindex #+LINK_UP
9593 @cindex #+LINK_HOME
9594 @cindex #+EXPORT_SELECT_TAGS
9595 @cindex #+EXPORT_EXCLUDE_TAGS
9596 @cindex #+XSLT
9597 @cindex #+LATEX_HEADER
9598 @vindex user-full-name
9599 @vindex user-mail-address
9600 @vindex org-export-default-language
9601 @example
9602 #+TITLE:       the title to be shown (default is the buffer name)
9603 #+AUTHOR:      the author (default taken from @code{user-full-name})
9604 #+DATE:        a date, fixed, or a format string for @code{format-time-string}
9605 #+EMAIL:       his/her email address (default from @code{user-mail-address})
9606 #+DESCRIPTION: the page description, e.g.@: for the XHTML meta tag
9607 #+KEYWORDS:    the page keywords, e.g.@: for the XHTML meta tag
9608 #+LANGUAGE:    language for HTML, e.g.@: @samp{en} (@code{org-export-default-language})
9609 #+TEXT:        Some descriptive text to be inserted at the beginning.
9610 #+TEXT:        Several lines may be given.
9611 #+OPTIONS:     H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
9612 #+BIND:        lisp-var lisp-val, e.g.@:: org-export-latex-low-levels itemize
9613                @r{You need to confirm using these, or configure @code{org-export-allow-BIND}}
9614 #+LINK_UP:     the ``up'' link of an exported page
9615 #+LINK_HOME:   the ``home'' link of an exported page
9616 #+LATEX_HEADER: extra line(s) for the LaTeX header, like \usepackage@{xyz@}
9617 #+EXPORT_SELECT_TAGS:   Tags that select a tree for export
9618 #+EXPORT_EXCLUDE_TAGS:  Tags that exclude a tree from export
9619 #+XSLT:        the XSLT stylesheet used by DocBook exporter to generate FO file
9620 @end example
9622 @noindent
9623 The OPTIONS line is a compact@footnote{If you want to configure many options
9624 this way, you can use several OPTIONS lines.} form to specify export
9625 settings.  Here you can:
9626 @cindex headline levels
9627 @cindex section-numbers
9628 @cindex table of contents
9629 @cindex line-break preservation
9630 @cindex quoted HTML tags
9631 @cindex fixed-width sections
9632 @cindex tables
9633 @cindex @TeX{}-like syntax for sub- and superscripts
9634 @cindex footnotes
9635 @cindex special strings
9636 @cindex emphasized text
9637 @cindex @TeX{} macros
9638 @cindex @LaTeX{} fragments
9639 @cindex author info, in export
9640 @cindex time info, in export
9641 @vindex org-export-plist-vars
9642 @vindex org-export-author-info
9643 @vindex org-export-creator-info
9644 @vindex org-export-email-info
9645 @vindex org-export-time-stamp-file
9646 @example
9647 H:         @r{set the number of headline levels for export}
9648 num:       @r{turn on/off section-numbers}
9649 toc:       @r{turn on/off table of contents, or set level limit (integer)}
9650 \n:        @r{turn on/off line-break-preservation (DOES NOT WORK)}
9651 @@:         @r{turn on/off quoted HTML tags}
9652 ::         @r{turn on/off fixed-width sections}
9653 |:         @r{turn on/off tables}
9654 ^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
9655            @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
9656            @r{the simple @code{a_b} will be left as it is.}
9657 -:         @r{turn on/off conversion of special strings.}
9658 f:         @r{turn on/off footnotes like this[1].}
9659 todo:      @r{turn on/off inclusion of TODO keywords into exported text}
9660 tasks:     @r{turn on/off inclusion of tasks (TODO items), can be nil to remove}
9661            @r{all tasks, @code{todo} to remove DONE tasks, or list of kwds to keep}
9662 pri:       @r{turn on/off priority cookies}
9663 tags:      @r{turn on/off inclusion of tags, may also be @code{not-in-toc}}
9664 <:         @r{turn on/off inclusion of any time/date stamps like DEADLINES}
9665 *:         @r{turn on/off emphasized text (bold, italic, underlined)}
9666 TeX:       @r{turn on/off simple @TeX{} macros in plain text}
9667 LaTeX:     @r{configure export of @LaTeX{} fragments.  Default @code{auto}}
9668 skip:      @r{turn on/off skipping the text before the first heading}
9669 author:    @r{turn on/off inclusion of author name/email into exported file}
9670 email:     @r{turn on/off inclusion of author email into exported file}
9671 creator:   @r{turn on/off inclusion of creator info into exported file}
9672 timestamp: @r{turn on/off inclusion creation time into exported file}
9673 d:         @r{turn on/off inclusion of drawers}
9674 @end example
9675 @noindent
9676 These options take effect in both the HTML and @LaTeX{} export, except for
9677 @code{TeX} and @code{LaTeX} options, which are respectively @code{t} and
9678 @code{nil} for the @LaTeX{} export.
9680 The default values for these and many other options are given by a set of
9681 variables.  For a list of such variables, the corresponding OPTIONS keys and
9682 also the publishing keys (@pxref{Project alist}), see the constant
9683 @code{org-export-plist-vars}.
9685 When exporting only a single subtree by selecting it with @kbd{C-c @@} before
9686 calling an export command, the subtree can overrule some of the file's export
9687 settings with properties @code{EXPORT_FILE_NAME}, @code{EXPORT_TITLE},
9688 @code{EXPORT_TEXT}, @code{EXPORT_AUTHOR}, @code{EXPORT_DATE}, and
9689 @code{EXPORT_OPTIONS}.
9691 @node The export dispatcher, ASCII/Latin-1/UTF-8 export, Export options, Exporting
9692 @section The export dispatcher
9693 @cindex dispatcher, for export commands
9695 All export commands can be reached using the export dispatcher, which is a
9696 prefix key that prompts for an additional key specifying the command.
9697 Normally the entire file is exported, but if there is an active region that
9698 contains one outline tree, the first heading is used as document title and
9699 the subtrees are exported.
9701 @table @kbd
9702 @orgcmd{C-c C-e,org-export}
9703 @vindex org-export-run-in-background
9704 Dispatcher for export and publishing commands.  Displays a help-window
9705 listing the additional key(s) needed to launch an export or publishing
9706 command.  The prefix arg is passed through to the exporter.  A double prefix
9707 @kbd{C-u C-u} causes most commands to be executed in the background, in a
9708 separate Emacs process@footnote{To make this behavior the default, customize
9709 the variable @code{org-export-run-in-background}.}.
9710 @orgcmd{C-c C-e v,org-export-visible}
9711 Like @kbd{C-c C-e}, but only export the text that is currently visible
9712 (i.e.@: not hidden by outline visibility).
9713 @orgcmd{C-u C-u C-c C-e,org-export}
9714 @vindex org-export-run-in-background
9715 Call the exporter, but reverse the setting of
9716 @code{org-export-run-in-background}, i.e.@: request background processing if
9717 not set, or force processing in the current Emacs process if set.
9718 @end table
9720 @node ASCII/Latin-1/UTF-8 export, HTML export, The export dispatcher, Exporting
9721 @section ASCII/Latin-1/UTF-8 export
9722 @cindex ASCII export
9723 @cindex Latin-1 export
9724 @cindex UTF-8 export
9726 ASCII export produces a simple and very readable version of an Org-mode
9727 file, containing only plain ASCII.  Latin-1 and UTF-8 export augment the file
9728 with special characters and symbols available in these encodings.
9730 @cindex region, active
9731 @cindex active region
9732 @cindex transient-mark-mode
9733 @table @kbd
9734 @orgcmd{C-c C-e a,org-export-as-ascii}
9735 @cindex property, EXPORT_FILE_NAME
9736 Export as ASCII file.  For an Org file, @file{myfile.org}, the ASCII file
9737 will be @file{myfile.txt}.  The file will be overwritten without
9738 warning.  If there is an active region@footnote{This requires
9739 @code{transient-mark-mode} be turned on.}, only the region will be
9740 exported.  If the selected region is a single tree@footnote{To select the
9741 current subtree, use @kbd{C-c @@}.}, the tree head will
9742 become the document title.  If the tree head entry has or inherits an
9743 @code{EXPORT_FILE_NAME} property, that name will be used for the
9744 export.
9745 @orgcmd{C-c C-e A,org-export-as-ascii-to-buffer}
9746 Export to a temporary buffer.  Do not create a file.
9747 @orgcmd{C-c C-e n,org-export-as-latin1}
9748 @xorgcmd{C-c C-e N,org-export-as-latin1-to-buffer}
9749 Like the above commands, but use Latin-1 encoding.
9750 @orgcmd{C-c C-e u,org-export-as-utf8}
9751 @xorgcmd{C-c C-e U,org-export-as-utf8-to-buffer}
9752 Like the above commands, but use UTF-8 encoding.
9753 @item C-c C-e v a/n/u
9754 Export only the visible part of the document.
9755 @end table
9757 @cindex headline levels, for exporting
9758 In the exported version, the first 3 outline levels will become
9759 headlines, defining a general document structure.  Additional levels
9760 will be exported as itemized lists.  If you want that transition to occur
9761 at a different level, specify it with a prefix argument.  For example,
9763 @example
9764 @kbd{C-1 C-c C-e a}
9765 @end example
9767 @noindent
9768 creates only top level headlines and does the rest as items.  When
9769 headlines are converted to items, the indentation of the text following
9770 the headline is changed to fit nicely under the item.  This is done with
9771 the assumption that the first body line indicates the base indentation of
9772 the body text.  Any indentation larger than this is adjusted to preserve
9773 the layout relative to the first line.  Should there be lines with less
9774 indentation than the first, these are left alone.
9776 @vindex org-export-ascii-links-to-notes
9777 Links will be exported in a footnote-like style, with the descriptive part in
9778 the text and the link in a note before the next heading.  See the variable
9779 @code{org-export-ascii-links-to-notes} for details and other options.
9781 @node HTML export, LaTeX and PDF export, ASCII/Latin-1/UTF-8 export, Exporting
9782 @section HTML export
9783 @cindex HTML export
9785 Org-mode contains an HTML (XHTML 1.0 strict) exporter with extensive
9786 HTML formatting, in ways similar to John Gruber's @emph{markdown}
9787 language, but with additional support for tables.
9789 @menu
9790 * HTML Export commands::        How to invoke HTML export
9791 * HTML preamble and postamble::  How to insert a preamble and a postamble
9792 * Quoting HTML tags::           Using direct HTML in Org-mode
9793 * Links in HTML export::        How links will be interpreted and formatted
9794 * Tables in HTML export::       How to modify the formatting of tables
9795 * Images in HTML export::       How to insert figures into HTML output
9796 * Math formatting in HTML export::  Beautiful math also on the web
9797 * Text areas in HTML export::   An alternative way to show an example
9798 * CSS support::                 Changing the appearance of the output
9799 * JavaScript support::          Info and Folding in a web browser
9800 @end menu
9802 @node HTML Export commands, HTML preamble and postamble, HTML export, HTML export
9803 @subsection HTML export commands
9805 @cindex region, active
9806 @cindex active region
9807 @cindex transient-mark-mode
9808 @table @kbd
9809 @orgcmd{C-c C-e h,org-export-as-html}
9810 @cindex property, EXPORT_FILE_NAME
9811 Export as HTML file.  For an Org file @file{myfile.org},
9812 the HTML file will be @file{myfile.html}.  The file will be overwritten
9813 without warning.  If there is an active region@footnote{This requires
9814 @code{transient-mark-mode} be turned on.}, only the region will be
9815 exported.  If the selected region is a single tree@footnote{To select the
9816 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
9817 title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
9818 property, that name will be used for the export.
9819 @orgcmd{C-c C-e b,org-export-as-html-and-open}
9820 Export as HTML file and immediately open it with a browser.
9821 @orgcmd{C-c C-e H,org-export-as-html-to-buffer}
9822 Export to a temporary buffer.  Do not create a file.
9823 @orgcmd{C-c C-e R,org-export-region-as-html}
9824 Export the active region to a temporary buffer.  With a prefix argument, do
9825 not produce the file header and footer, but just the plain HTML section for
9826 the region.  This is good for cut-and-paste operations.
9827 @item C-c C-e v h/b/H/R
9828 Export only the visible part of the document.
9829 @item M-x org-export-region-as-html
9830 Convert the region to HTML under the assumption that it was Org-mode
9831 syntax before.  This is a global command that can be invoked in any
9832 buffer.
9833 @item M-x org-replace-region-by-HTML
9834 Replace the active region (assumed to be in Org-mode syntax) by HTML
9835 code.
9836 @end table
9838 @cindex headline levels, for exporting
9839 In the exported version, the first 3 outline levels will become headlines,
9840 defining a general document structure.  Additional levels will be exported as
9841 itemized lists.  If you want that transition to occur at a different level,
9842 specify it with a numeric prefix argument.  For example,
9844 @example
9845 @kbd{C-2 C-c C-e b}
9846 @end example
9848 @noindent
9849 creates two levels of headings and does the rest as items.
9852 @node HTML preamble and postamble, Quoting HTML tags, HTML Export commands, HTML export
9853 @subsection HTML preamble and postamble
9854 @vindex org-export-html-preamble
9855 @vindex org-export-html-postamble
9856 @vindex org-export-html-preamble-format
9857 @vindex org-export-html-postamble-format
9858 @vindex org-export-html-validation-link
9859 @vindex org-export-author-info
9860 @vindex org-export-email-info
9861 @vindex org-export-creator-info
9862 @vindex org-export-time-stamp-file
9864 The HTML exporter lets you define a preamble and a postamble.
9866 The default value for @code{org-export-html-preamble} is @code{t}, which
9867 means that the preamble is inserted depending on the relevant formatting
9868 string in @code{org-export-html-preamble-format}.
9870 Setting @code{org-export-html-preamble} to a string will override the default
9871 formatting string.  Setting it to a function, will insert the output of the
9872 function, which must be a string; such a function takes no argument but you
9873 can check against the value of @code{opt-plist}, which contains the list of
9874 publishing properties for the current file.  Setting to @code{nil} will not
9875 insert any preamble.
9877 The default value for @code{org-export-html-postamble} is @code{'auto}, which
9878 means that the HTML exporter will look for the value of
9879 @code{org-export-author-info}, @code{org-export-email-info},
9880 @code{org-export-creator-info} and @code{org-export-time-stamp-file},
9881 @code{org-export-html-validation-link} and build the postamble from these
9882 values.  Setting @code{org-export-html-postamble} to @code{t} will insert the
9883 postamble from the relevant formatting string found in
9884 @code{org-export-html-postamble-format}.  Setting it to @code{nil} will not
9885 insert any postamble.
9887 @node Quoting HTML tags, Links in HTML export, HTML preamble and postamble, HTML export
9888 @subsection Quoting HTML tags
9890 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
9891 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
9892 which should be interpreted as such, mark them with @samp{@@} as in
9893 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
9894 simple tags.  For more extensive HTML that should be copied verbatim to
9895 the exported file use either
9897 @cindex #+HTML
9898 @cindex #+BEGIN_HTML
9899 @example
9900 #+HTML: Literal HTML code for export
9901 @end example
9903 @noindent or
9904 @cindex #+BEGIN_HTML
9906 @example
9907 #+BEGIN_HTML
9908 All lines between these markers are exported literally
9909 #+END_HTML
9910 @end example
9913 @node Links in HTML export, Tables in HTML export, Quoting HTML tags, HTML export
9914 @subsection Links in HTML export
9916 @cindex links, in HTML export
9917 @cindex internal links, in HTML export
9918 @cindex external links, in HTML export
9919 Internal links (@pxref{Internal links}) will continue to work in HTML.  This
9920 includes automatic links created by radio targets (@pxref{Radio
9921 targets}).  Links to external files will still work if the target file is on
9922 the same @i{relative} path as the published Org file.  Links to other
9923 @file{.org} files will be translated into HTML links under the assumption
9924 that an HTML version also exists of the linked file, at the same relative
9925 path.  @samp{id:} links can then be used to jump to specific entries across
9926 files.  For information related to linking files while publishing them to a
9927 publishing directory see @ref{Publishing links}.
9929 If you want to specify attributes for links, you can do so using a special
9930 @code{#+ATTR_HTML} line to define attributes that will be added to the
9931 @code{<a>} or @code{<img>} tags.  Here is an example that sets @code{title}
9932 and @code{style} attributes for a link:
9934 @cindex #+ATTR_HTML
9935 @example
9936 #+ATTR_HTML: title="The Org-mode homepage" style="color:red;"
9937 [[http://orgmode.org]]
9938 @end example
9940 @node Tables in HTML export, Images in HTML export, Links in HTML export, HTML export
9941 @subsection Tables
9942 @cindex tables, in HTML
9943 @vindex org-export-html-table-tag
9945 Org-mode tables are exported to HTML using the table tag defined in
9946 @code{org-export-html-table-tag}.  The default setting makes tables without
9947 cell borders and frame.  If you would like to change this for individual
9948 tables, place something like the following before the table:
9950 @cindex #+CAPTION
9951 @cindex #+ATTR_HTML
9952 @example
9953 #+CAPTION: This is a table with lines around and between cells
9954 #+ATTR_HTML: border="2" rules="all" frame="all"
9955 @end example
9957 @node Images in HTML export, Math formatting in HTML export, Tables in HTML export, HTML export
9958 @subsection Images in HTML export
9960 @cindex images, inline in HTML
9961 @cindex inlining images in HTML
9962 @vindex org-export-html-inline-images
9963 HTML export can inline images given as links in the Org file, and
9964 it can make an image the clickable part of a link.  By
9965 default@footnote{But see the variable
9966 @code{org-export-html-inline-images}.}, images are inlined if a link does
9967 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
9968 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
9969 @samp{the image} that points to the image.  If the description part
9970 itself is a @code{file:} link or a @code{http:} URL pointing to an
9971 image, this image will be inlined and activated so that clicking on the
9972 image will activate the link.  For example, to include a thumbnail that
9973 will link to a high resolution version of the image, you could use:
9975 @example
9976 [[file:highres.jpg][file:thumb.jpg]]
9977 @end example
9979 If you need to add attributes to an inlined image, use a @code{#+ATTR_HTML}.
9980 In the example below we specify the @code{alt} and @code{title} attributes to
9981 support text viewers and accessibility, and align it to the right.
9983 @cindex #+CAPTION
9984 @cindex #+ATTR_HTML
9985 @example
9986 #+CAPTION: A black cat stalking a spider
9987 #+ATTR_HTML: alt="cat/spider image" title="Action!" align="right"
9988 [[./img/a.jpg]]
9989 @end example
9991 @noindent
9992 You could use @code{http} addresses just as well.
9994 @node Math formatting in HTML export, Text areas in HTML export, Images in HTML export, HTML export
9995 @subsection Math formatting in HTML export
9996 @cindex MathJax
9997 @cindex dvipng
9999 @LaTeX{} math snippets (@pxref{LaTeX fragments}) can be displayed in two
10000 different ways on HTML pages.  The default is to use the
10001 @uref{http://www.mathjax.org, MathJax system} which should work out of the
10002 box with Org mode installation because @code{http://orgmode.org} serves
10003 @file{MathJax} for Org-mode users for small applications and for testing
10004 purposes.  @b{If you plan to use this regularly or on pages with significant
10005 page views, you should install@footnote{Installation instructions can be
10006 found on the MathJax website, see
10007 @uref{http://www.mathjax.org/resources/docs/?installation.html}.} MathJax on
10008 your own server in order to limit the load of our server.}  To configure
10009 @file{MathJax}, use the variable @code{org-export-html-mathjax-options} or
10010 insert something like the following into the buffer:
10012 @example
10013 #+MATHJAX: align:"left" mathml:t path:"/MathJax/MathJax.js"
10014 @end example
10016 @noindent See the docstring of the variable
10017 @code{org-export-html-mathjax-options} for the meaning of the parameters in
10018 this line.
10020 If you prefer, you can also request that @LaTeX{} fragments are processed
10021 into small images that will be inserted into the browser page.  Before the
10022 availability of MathJax, this was the default method for Org files.  This
10023 method requires that the @file{dvipng} program is available on your system.
10024 You can still get this processing with
10026 @example
10027 #+OPTIONS: LaTeX:dvipng
10028 @end example
10030 @node Text areas in HTML export, CSS support, Math formatting in HTML export, HTML export
10031 @subsection Text areas in HTML export
10033 @cindex text areas, in HTML
10034 An alternative way to publish literal code examples in HTML is to use text
10035 areas, where the example can even be edited before pasting it into an
10036 application.  It is triggered by a @code{-t} switch at an @code{example} or
10037 @code{src} block.  Using this switch disables any options for syntax and
10038 label highlighting, and line numbering, which may be present.  You may also
10039 use @code{-h} and @code{-w} switches to specify the height and width of the
10040 text area, which default to the number of lines in the example, and 80,
10041 respectively.  For example
10043 @example
10044 #+BEGIN_EXAMPLE -t -w 40
10045   (defun org-xor (a b)
10046      "Exclusive or."
10047      (if a (not b) b))
10048 #+END_EXAMPLE
10049 @end example
10052 @node CSS support, JavaScript support, Text areas in HTML export, HTML export
10053 @subsection CSS support
10054 @cindex CSS, for HTML export
10055 @cindex HTML export, CSS
10057 @vindex org-export-html-todo-kwd-class-prefix
10058 @vindex org-export-html-tag-class-prefix
10059 You can also give style information for the exported file.  The HTML exporter
10060 assigns the following special CSS classes@footnote{If the classes on TODO
10061 keywords and tags lead to conflicts, use the variables
10062 @code{org-export-html-todo-kwd-class-prefix} and
10063 @code{org-export-html-tag-class-prefix} to make them unique.} to appropriate
10064 parts of the document---your style specifications may change these, in
10065 addition to any of the standard classes like for headlines, tables, etc.
10066 @example
10067 p.author            @r{author information, including email}
10068 p.date              @r{publishing date}
10069 p.creator           @r{creator info, about org-mode version}
10070 .title              @r{document title}
10071 .todo               @r{TODO keywords, all not-done states}
10072 .done               @r{the DONE keywords, all states that count as done}
10073 .WAITING            @r{each TODO keyword also uses a class named after itself}
10074 .timestamp          @r{timestamp}
10075 .timestamp-kwd      @r{keyword associated with a timestamp, like SCHEDULED}
10076 .timestamp-wrapper  @r{span around keyword plus timestamp}
10077 .tag                @r{tag in a headline}
10078 ._HOME              @r{each tag uses itself as a class, "@@" replaced by "_"}
10079 .target             @r{target for links}
10080 .linenr             @r{the line number in a code example}
10081 .code-highlighted   @r{for highlighting referenced code lines}
10082 div.outline-N       @r{div for outline level N (headline plus text))}
10083 div.outline-text-N  @r{extra div for text at outline level N}
10084 .section-number-N   @r{section number in headlines, different for each level}
10085 div.figure          @r{how to format an inlined image}
10086 pre.src             @r{formatted source code}
10087 pre.example         @r{normal example}
10088 p.verse             @r{verse paragraph}
10089 div.footnotes       @r{footnote section headline}
10090 p.footnote          @r{footnote definition paragraph, containing a footnote}
10091 .footref            @r{a footnote reference number (always a <sup>)}
10092 .footnum            @r{footnote number in footnote definition (always <sup>)}
10093 @end example
10095 @vindex org-export-html-style-default
10096 @vindex org-export-html-style-include-default
10097 @vindex org-export-html-style
10098 @vindex org-export-html-extra
10099 @vindex org-export-html-style-default
10100 Each exported file contains a compact default style that defines these
10101 classes in a basic way@footnote{This style is defined in the constant
10102 @code{org-export-html-style-default}, which you should not modify.  To turn
10103 inclusion of these defaults off, customize
10104 @code{org-export-html-style-include-default}}.  You may overwrite these
10105 settings, or add to them by using the variables @code{org-export-html-style}
10106 (for Org-wide settings) and @code{org-export-html-style-extra} (for more
10107 fine-grained settings, like file-local settings).  To set the latter variable
10108 individually for each file, you can use
10110 @cindex #+STYLE
10111 @example
10112 #+STYLE: <link rel="stylesheet" type="text/css" href="stylesheet.css" />
10113 @end example
10115 @noindent
10116 For longer style definitions, you can use several such lines.  You could also
10117 directly write a @code{<style>} @code{</style>} section in this way, without
10118 referring to an external file.
10120 In order to add styles to a subtree, use the @code{:HTML_CONTAINER_CLASS:}
10121 property to assign a class to the tree.  In order to specify CSS styles for a
10122 particular headline, you can use the id specified in a @code{:CUSTOM_ID:}
10123 property.
10125 @c FIXME: More about header and footer styles
10126 @c FIXME: Talk about links and targets.
10128 @node JavaScript support,  , CSS support, HTML export
10129 @subsection JavaScript supported display of web pages
10131 @cindex Rose, Sebastian
10132 Sebastian Rose has written a JavaScript program especially designed to
10133 enhance the web viewing experience of HTML files created with Org.  This
10134 program allows you to view large files in two different ways.  The first one
10135 is an @emph{Info}-like mode where each section is displayed separately and
10136 navigation can be done with the @kbd{n} and @kbd{p} keys (and some other keys
10137 as well, press @kbd{?} for an overview of the available keys).  The second
10138 view type is a @emph{folding} view much like Org provides inside Emacs.  The
10139 script is available at @url{http://orgmode.org/org-info.js} and you can find
10140 the documentation for it at @url{http://orgmode.org/worg/code/org-info-js/}.
10141 We host the script at our site, but if you use it a lot, you might
10142 not want to be dependent on @url{orgmode.org} and prefer to install a local
10143 copy on your own web server.
10145 To use the script, you need to make sure that the @file{org-jsinfo.el} module
10146 gets loaded.  It should be loaded by default, but you can try @kbd{M-x
10147 customize-variable @key{RET} org-modules @key{RET}} to convince yourself that
10148 this is indeed the case.  All it then takes to make use of the program is
10149 adding a single line to the Org file:
10151 @cindex #+INFOJS_OPT
10152 @example
10153 #+INFOJS_OPT: view:info toc:nil
10154 @end example
10156 @noindent
10157 If this line is found, the HTML header will automatically contain the code
10158 needed to invoke the script.  Using the line above, you can set the following
10159 viewing options:
10161 @example
10162 path:    @r{The path to the script.  The default is to grab the script from}
10163          @r{@url{http://orgmode.org/org-info.js}, but you might want to have}
10164          @r{a local copy and use a path like @samp{../scripts/org-info.js}.}
10165 view:    @r{Initial view when website is first shown.  Possible values are:}
10166          info      @r{Info-like interface with one section per page.}
10167          overview  @r{Folding interface, initially showing only top-level.}
10168          content   @r{Folding interface, starting with all headlines visible.}
10169          showall   @r{Folding interface, all headlines and text visible.}
10170 sdepth:  @r{Maximum headline level that will still become an independent}
10171          @r{section for info and folding modes.  The default is taken from}
10172          @r{@code{org-export-headline-levels} (= the @code{H} switch in @code{#+OPTIONS}).}
10173          @r{If this is smaller than in @code{org-export-headline-levels}, each}
10174          @r{info/folding section can still contain child headlines.}
10175 toc:     @r{Should the table of contents @emph{initially} be visible?}
10176          @r{Even when @code{nil}, you can always get to the "toc" with @kbd{i}.}
10177 tdepth:  @r{The depth of the table of contents.  The defaults are taken from}
10178          @r{the variables @code{org-export-headline-levels} and @code{org-export-with-toc}.}
10179 ftoc:    @r{Does the CSS of the page specify a fixed position for the "toc"?}
10180          @r{If yes, the toc will never be displayed as a section.}
10181 ltoc:    @r{Should there be short contents (children) in each section?}
10182          @r{Make this @code{above} if the section should be above initial text.}
10183 mouse:   @r{Headings are highlighted when the mouse is over them.  Should be}
10184          @r{@samp{underline} (default) or a background color like @samp{#cccccc}.}
10185 buttons: @r{Should view-toggle buttons be everywhere?  When @code{nil} (the}
10186          @r{default), only one such button will be present.}
10187 @end example
10188 @noindent
10189 @vindex org-infojs-options
10190 @vindex org-export-html-use-infojs
10191 You can choose default values for these options by customizing the variable
10192 @code{org-infojs-options}.  If you always want to apply the script to your
10193 pages, configure the variable @code{org-export-html-use-infojs}.
10195 @node LaTeX and PDF export, DocBook export, HTML export, Exporting
10196 @section @LaTeX{} and PDF export
10197 @cindex @LaTeX{} export
10198 @cindex PDF export
10199 @cindex Guerry, Bastien
10201 Org-mode contains a @LaTeX{} exporter written by Bastien Guerry.  With
10202 further processing@footnote{The default LaTeX output is designed for
10203 processing with pdftex or latex.  It includes packages that are not
10204 compatible with xetex and possibly luatex.  See the variables
10205 @code{org-export-latex-default-packages-alist} and
10206 @code{org-export-latex-packages-alist}.}, this backend is also used to
10207 produce PDF output.  Since the @LaTeX{} output uses @file{hyperref} to
10208 implement links and cross references, the PDF output file will be fully
10209 linked.  Beware of the fact that your @code{org} file has to be properly
10210 structured in order to be correctly exported: respect the hierarchy of
10211 sections.
10213 @menu
10214 * LaTeX/PDF export commands::   Which key invokes which commands
10215 * Header and sectioning::       Setting up the export file structure
10216 * Quoting LaTeX code::          Incorporating literal @LaTeX{} code
10217 * Tables in LaTeX export::      Options for exporting tables to @LaTeX{}
10218 * Images in LaTeX export::      How to insert figures into @LaTeX{} output
10219 * Beamer class export::         Turning the file into a presentation
10220 @end menu
10222 @node LaTeX/PDF export commands, Header and sectioning, LaTeX and PDF export, LaTeX and PDF export
10223 @subsection @LaTeX{} export commands
10225 @cindex region, active
10226 @cindex active region
10227 @cindex transient-mark-mode
10228 @table @kbd
10229 @orgcmd{C-c C-e l,org-export-as-latex}
10230 @cindex property EXPORT_FILE_NAME
10231 Export as @LaTeX{} file.  For an Org file
10232 @file{myfile.org}, the @LaTeX{} file will be @file{myfile.tex}.  The file will
10233 be overwritten without warning.  If there is an active region@footnote{This
10234 requires @code{transient-mark-mode} be turned on.}, only the region will be
10235 exported.  If the selected region is a single tree@footnote{To select the
10236 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
10237 title.  If the tree head entry has or inherits an @code{EXPORT_FILE_NAME}
10238 property, that name will be used for the export.
10239 @orgcmd{C-c C-e L,org-export-as-latex-to-buffer}
10240 Export to a temporary buffer.  Do not create a file.
10241 @item C-c C-e v l/L
10242 Export only the visible part of the document.
10243 @item M-x org-export-region-as-latex
10244 Convert the region to @LaTeX{} under the assumption that it was Org-mode
10245 syntax before.  This is a global command that can be invoked in any
10246 buffer.
10247 @item M-x org-replace-region-by-latex
10248 Replace the active region (assumed to be in Org-mode syntax) by @LaTeX{}
10249 code.
10250 @orgcmd{C-c C-e p,org-export-as-pdf}
10251 Export as @LaTeX{} and then process to PDF.
10252 @orgcmd{C-c C-e d,org-export-as-pdf-and-open}
10253 Export as @LaTeX{} and then process to PDF, then open the resulting PDF file.
10254 @end table
10256 @cindex headline levels, for exporting
10257 @vindex org-latex-low-levels
10258 In the exported version, the first 3 outline levels will become
10259 headlines, defining a general document structure.  Additional levels
10260 will be exported as description lists.  The exporter can ignore them or
10261 convert them to a custom string depending on
10262 @code{org-latex-low-levels}.
10264 If you want that transition to occur at a different level, specify it
10265 with a numeric prefix argument.  For example,
10267 @example
10268 @kbd{C-2 C-c C-e l}
10269 @end example
10271 @noindent
10272 creates two levels of headings and does the rest as items.
10274 @node Header and sectioning, Quoting LaTeX code, LaTeX/PDF export commands, LaTeX and PDF export
10275 @subsection Header and sectioning structure
10276 @cindex @LaTeX{} class
10277 @cindex @LaTeX{} sectioning structure
10278 @cindex @LaTeX{} header
10279 @cindex header, for LaTeX files
10280 @cindex sectioning structure, for LaTeX export
10282 By default, the @LaTeX{} output uses the class @code{article}.
10284 @vindex org-export-latex-default-class
10285 @vindex org-export-latex-classes
10286 @vindex org-export-latex-default-packages-alist
10287 @vindex org-export-latex-packages-alist
10288 @cindex #+LATEX_HEADER
10289 @cindex #+LATEX_CLASS
10290 @cindex #+LATEX_CLASS_OPTIONS
10291 @cindex property, LATEX_CLASS
10292 @cindex property, LATEX_CLASS_OPTIONS
10293 You can change this globally by setting a different value for
10294 @code{org-export-latex-default-class} or locally by adding an option like
10295 @code{#+LaTeX_CLASS: myclass} in your file, or with a @code{:LaTeX_CLASS:}
10296 property that applies when exporting a region containing only this (sub)tree.
10297 The class must be listed in @code{org-export-latex-classes}.  This variable
10298 defines a header template for each class@footnote{Into which the values of
10299 @code{org-export-latex-default-packages-alist} and
10300 @code{org-export-latex-packages-alist} are spliced.}, and allows you to
10301 define the sectioning structure for each class.  You can also define your own
10302 classes there.  @code{#+LaTeX_CLASS_OPTIONS} or a @code{LaTeX_CLASS_OPTIONS}
10303 property can specify the options for the @code{\documentclass} macro.  You
10304 can also use @code{#+LATEX_HEADER: \usepackage@{xyz@}} to add lines to the
10305 header.  See the docstring of @code{org-export-latex-classes} for more
10306 information.
10308 @node Quoting LaTeX code, Tables in LaTeX export, Header and sectioning, LaTeX and PDF export
10309 @subsection Quoting @LaTeX{} code
10311 Embedded @LaTeX{} as described in @ref{Embedded LaTeX}, will be correctly
10312 inserted into the @LaTeX{} file.  This includes simple macros like
10313 @samp{\ref@{LABEL@}} to create a cross reference to a figure.  Furthermore,
10314 you can add special code that should only be present in @LaTeX{} export with
10315 the following constructs:
10317 @cindex #+LaTeX
10318 @cindex #+BEGIN_LaTeX
10319 @example
10320 #+LaTeX: Literal LaTeX code for export
10321 @end example
10323 @noindent or
10324 @cindex #+BEGIN_LaTeX
10326 @example
10327 #+BEGIN_LaTeX
10328 All lines between these markers are exported literally
10329 #+END_LaTeX
10330 @end example
10333 @node Tables in LaTeX export, Images in LaTeX export, Quoting LaTeX code, LaTeX and PDF export
10334 @subsection Tables in @LaTeX{} export
10335 @cindex tables, in @LaTeX{} export
10337 For @LaTeX{} export of a table, you can specify a label, a caption and
10338 placement options (@pxref{Images and tables}).  You can also use the
10339 @code{ATTR_LaTeX} line to request a @code{longtable} environment for the
10340 table, so that it may span several pages, or to change the default table
10341 environment from @code{table} to @code{table*} or to change the default inner
10342 tabular environment to @code{tabularx} or @code{tabulary}.  Finally, you can
10343 set the alignment string, and (with @code{tabularx} or @code{tabulary}) the
10344 width:
10346 @cindex #+CAPTION
10347 @cindex #+LABEL
10348 @cindex #+ATTR_LaTeX
10349 @example
10350 #+CAPTION: A long table
10351 #+LABEL: tbl:long
10352 #+ATTR_LaTeX: longtable align=l|lp@{3cm@}r|l
10353 | ..... | ..... |
10354 | ..... | ..... |
10355 @end example
10357 or to specify a multicolumn table with @code{tabulary}
10359 @cindex #+CAPTION
10360 @cindex #+LABEL
10361 @cindex #+ATTR_LaTeX
10362 @example
10363 #+CAPTION: A wide table with tabulary
10364 #+LABEL: tbl:wide
10365 #+ATTR_LaTeX: table* tabulary width=\textwidth
10366 | ..... | ..... |
10367 | ..... | ..... |
10368 @end example
10370 @node Images in LaTeX export, Beamer class export, Tables in LaTeX export, LaTeX and PDF export
10371 @subsection Images in @LaTeX{} export
10372 @cindex images, inline in @LaTeX{}
10373 @cindex inlining images in @LaTeX{}
10375 Images that are linked to without a description part in the link, like
10376 @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]} will be inserted into the PDF
10377 output file resulting from @LaTeX{} processing.  Org will use an
10378 @code{\includegraphics} macro to insert the image.  If you have specified a
10379 caption and/or a label as described in @ref{Images and tables}, the figure
10380 will be wrapped into a @code{figure} environment and thus become a floating
10381 element.  You can use an @code{#+ATTR_LaTeX:} line to specify various other
10382 options.  You can ask org to export an image as a float without specifying
10383 a label or a caption by using the keyword @code{float} in this line.  Various
10384 optional arguments to the @code{\includegraphics} macro can also be specified
10385 in this fashion.  To modify the placement option of the floating environment,
10386 add something like @samp{placement=[h!]} to the attributes.  It is to be noted
10387 this option can be used with tables as well@footnote{One can also take
10388 advantage of this option to pass other, unrelated options into the figure or
10389 table environment.  For an example see the section ``Exporting org files'' in
10390 @url{http://orgmode.org/worg/org-hacks.html}}.  For example the
10391 @code{#+ATTR_LaTeX:} line below is exported as the @code{figure} environment
10392 below it.
10394 If you would like to let text flow around the image, add the word @samp{wrap}
10395 to the @code{#+ATTR_LaTeX:} line, which will make the figure occupy the left
10396 half of the page.  To fine-tune, the @code{placement} field will be the set
10397 of additional arguments needed by the @code{wrapfigure} environment.  Note
10398 that if you change the size of the image, you need to use compatible settings
10399 for @code{\includegraphics} and @code{wrapfigure}.
10401 @cindex #+CAPTION
10402 @cindex #+LABEL
10403 @cindex #+ATTR_LaTeX
10404 @example
10405 #+CAPTION:    The black-body emission of the disk around HR 4049
10406 #+LABEL:      fig:SED-HR4049
10407 #+ATTR_LaTeX: width=5cm,angle=90
10408 [[./img/sed-hr4049.pdf]]
10410 #+ATTR_LaTeX: width=0.38\textwidth wrap placement=@{r@}@{0.4\textwidth@}
10411 [[./img/hst.png]]
10412 @end example
10414 If you wish to include an image which spans multiple columns in a page, you
10415 can use the keyword @code{multicolumn} in the @code{#+ATTR_LaTeX} line.  This
10416 will export the image wrapped in a @code{figure*} environment.
10418 If you need references to a label created in this way, write
10419 @samp{\ref@{fig:SED-HR4049@}} just like in @LaTeX{}.
10421 @node Beamer class export,  , Images in LaTeX export, LaTeX and PDF export
10422 @subsection Beamer class export
10424 The LaTeX class @file{beamer} allows production of high quality presentations
10425 using LaTeX and pdf processing.  Org-mode has special support for turning an
10426 Org-mode file or tree into a @file{beamer} presentation.
10428 When the LaTeX class for the current buffer (as set with @code{#+LaTeX_CLASS:
10429 beamer}) or subtree (set with a @code{LaTeX_CLASS} property) is
10430 @code{beamer}, a special export mode will turn the file or tree into a beamer
10431 presentation.  Any tree with not-too-deep level nesting should in principle be
10432 exportable as a beamer presentation.  By default, the top-level entries (or
10433 the first level below the selected subtree heading) will be turned into
10434 frames, and the outline structure below this level will become itemize lists.
10435 You can also configure the variable @code{org-beamer-frame-level} to a
10436 different level---then the hierarchy above frames will produce the sectioning
10437 structure of the presentation.
10439 A template for useful in-buffer settings or properties can be inserted into
10440 the buffer with @kbd{M-x org-insert-beamer-options-template}.  Among other
10441 things, this will install a column view format which is very handy for
10442 editing special properties used by beamer.
10444 You can influence the structure of the presentation using the following
10445 properties:
10447 @table @code
10448 @item BEAMER_env
10449 The environment that should be used to format this entry.  Valid environments
10450 are defined in the constant @code{org-beamer-environments-default}, and you
10451 can define more in @code{org-beamer-environments-extra}.  If this property is
10452 set, the entry will also get a @code{:B_environment:} tag to make this
10453 visible.  This tag has no semantic meaning, it is only a visual aid.
10454 @item BEAMER_envargs
10455 The beamer-special arguments that should be used for the environment, like
10456 @code{[t]} or @code{[<+->]} of @code{<2-3>}.  If the @code{BEAMER_col}
10457 property is also set, something like @code{C[t]} can be added here as well to
10458 set an options argument for the implied @code{columns} environment.
10459 @code{c[t]} or @code{c<2->} will set an options for the implied @code{column}
10460 environment.
10461 @item BEAMER_col
10462 The width of a column that should start with this entry.  If this property is
10463 set, the entry will also get a @code{:BMCOL:} property to make this visible.
10464 Also this tag is only a visual aid.  When this is a plain number, it will be
10465 interpreted as a fraction of @code{\textwidth}.  Otherwise it will be assumed
10466 that you have specified the units, like @samp{3cm}.  The first such property
10467 in a frame will start a @code{columns} environment to surround the columns.
10468 This environment is closed when an entry has a @code{BEAMER_col} property
10469 with value 0 or 1, or automatically at the end of the frame.
10470 @item BEAMER_extra
10471 Additional commands that should be inserted after the environment has been
10472 opened.  For example, when creating a frame, this can be used to specify
10473 transitions.
10474 @end table
10476 Frames will automatically receive a @code{fragile} option if they contain
10477 source code that uses the verbatim environment.  Special @file{beamer}
10478 specific code can be inserted using @code{#+BEAMER:} and
10479 @code{#+BEGIN_beamer...#+end_beamer} constructs, similar to other export
10480 backends, but with the difference that @code{#+LaTeX:} stuff will be included
10481 in the presentation as well.
10483 Outline nodes with @code{BEAMER_env} property value @samp{note} or
10484 @samp{noteNH} will be formatted as beamer notes, i,e, they will be wrapped
10485 into @code{\note@{...@}}.  The former will include the heading as part of the
10486 note text, the latter will ignore the heading of that node.  To simplify note
10487 generation, it is actually enough to mark the note with a @emph{tag} (either
10488 @code{:B_note:} or @code{:B_noteNH:}) instead of creating the
10489 @code{BEAMER_env} property.
10491 You can turn on a special minor mode @code{org-beamer-mode} for editing
10492 support with
10494 @example
10495 #+STARTUP: beamer
10496 @end example
10498 @table @kbd
10499 @orgcmd{C-c C-b,org-beamer-select-environment}
10500 In @code{org-beamer-mode}, this key offers fast selection of a beamer
10501 environment or the @code{BEAMER_col} property.
10502 @end table
10504 Column view provides a great way to set the environment of a node and other
10505 important parameters.  Make sure you are using a COLUMN format that is geared
10506 toward this special purpose.  The command @kbd{M-x
10507 org-insert-beamer-options-template} defines such a format.
10509 Here is a simple example Org document that is intended for beamer export.
10511 @smallexample
10512 #+LaTeX_CLASS: beamer
10513 #+TITLE: Example Presentation
10514 #+AUTHOR: Carsten Dominik
10515 #+LaTeX_CLASS_OPTIONS: [presentation]
10516 #+BEAMER_FRAME_LEVEL: 2
10517 #+BEAMER_HEADER_EXTRA: \usetheme@{Madrid@}\usecolortheme@{default@}
10518 #+COLUMNS: %35ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Args) %4BEAMER_col(Col) %8BEAMER_extra(Ex)
10520 * This is the first structural section
10522 ** Frame 1 \\ with a subtitle
10523 *** Thanks to Eric Fraga                                      :BMCOL:B_block:
10524     :PROPERTIES:
10525     :BEAMER_env: block
10526     :BEAMER_envargs: C[t]
10527     :BEAMER_col: 0.5
10528     :END:
10529     for the first viable beamer setup in Org
10530 *** Thanks to everyone else                                   :BMCOL:B_block:
10531     :PROPERTIES:
10532     :BEAMER_col: 0.5
10533     :BEAMER_env: block
10534     :BEAMER_envargs: <2->
10535     :END:
10536     for contributing to the discussion
10537 **** This will be formatted as a beamer note                  :B_note:
10538 ** Frame 2 \\ where we will not use columns
10539 *** Request                                                   :B_block:
10540     Please test this stuff!
10541     :PROPERTIES:
10542     :BEAMER_env: block
10543     :END:
10544 @end smallexample
10546 For more information, see the documentation on Worg.
10548 @node DocBook export, OpenDocument Text export, LaTeX and PDF export, Exporting
10549 @section DocBook export
10550 @cindex DocBook export
10551 @cindex PDF export
10552 @cindex Cui, Baoqiu
10554 Org contains a DocBook exporter written by Baoqiu Cui.  Once an Org file is
10555 exported to DocBook format, it can be further processed to produce other
10556 formats, including PDF, HTML, man pages, etc., using many available DocBook
10557 tools and stylesheets.
10559 Currently DocBook exporter only supports DocBook V5.0.
10561 @menu
10562 * DocBook export commands::     How to invoke DocBook export
10563 * Quoting DocBook code::        Incorporating DocBook code in Org files
10564 * Recursive sections::          Recursive sections in DocBook
10565 * Tables in DocBook export::    Tables are exported as HTML tables
10566 * Images in DocBook export::    How to insert figures into DocBook output
10567 * Special characters::          How to handle special characters
10568 @end menu
10570 @node DocBook export commands, Quoting DocBook code, DocBook export, DocBook export
10571 @subsection DocBook export commands
10573 @cindex region, active
10574 @cindex active region
10575 @cindex transient-mark-mode
10576 @table @kbd
10577 @orgcmd{C-c C-e D,org-export-as-docbook}
10578 @cindex property EXPORT_FILE_NAME
10579 Export as DocBook file.  For an Org file, @file{myfile.org}, the DocBook XML
10580 file will be @file{myfile.xml}.  The file will be overwritten without
10581 warning.  If there is an active region@footnote{This requires
10582 @code{transient-mark-mode} to be turned on}, only the region will be
10583 exported.  If the selected region is a single tree@footnote{To select the
10584 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
10585 title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
10586 property, that name will be used for the export.
10587 @orgcmd{C-c C-e V,org-export-as-docbook-pdf-and-open}
10588 Export as DocBook file, process to PDF, then open the resulting PDF file.
10590 @vindex org-export-docbook-xslt-proc-command
10591 @vindex org-export-docbook-xsl-fo-proc-command
10592 Note that, in order to produce PDF output based on exported DocBook file, you
10593 need to have XSLT processor and XSL-FO processor software installed on your
10594 system.  Check variables @code{org-export-docbook-xslt-proc-command} and
10595 @code{org-export-docbook-xsl-fo-proc-command}.
10597 @vindex org-export-docbook-xslt-stylesheet
10598 The stylesheet argument @code{%s} in variable
10599 @code{org-export-docbook-xslt-proc-command} is replaced by the value of
10600 variable @code{org-export-docbook-xslt-stylesheet}, which needs to be set by
10601 the user.  You can also overrule this global setting on a per-file basis by
10602 adding an in-buffer setting @code{#+XSLT:} to the Org file.
10604 @orgkey{C-c C-e v D}
10605 Export only the visible part of the document.
10606 @end table
10608 @node Quoting DocBook code, Recursive sections, DocBook export commands, DocBook export
10609 @subsection Quoting DocBook code
10611 You can quote DocBook code in Org files and copy it verbatim into exported
10612 DocBook file with the following constructs:
10614 @cindex #+DOCBOOK
10615 @cindex #+BEGIN_DOCBOOK
10616 @example
10617 #+DOCBOOK: Literal DocBook code for export
10618 @end example
10620 @noindent or
10621 @cindex #+BEGIN_DOCBOOK
10623 @example
10624 #+BEGIN_DOCBOOK
10625 All lines between these markers are exported by DocBook exporter
10626 literally.
10627 #+END_DOCBOOK
10628 @end example
10630 For example, you can use the following lines to include a DocBook warning
10631 admonition.  As to what this warning says, you should pay attention to the
10632 document context when quoting DocBook code in Org files.  You may make
10633 exported DocBook XML files invalid by not quoting DocBook code correctly.
10635 @example
10636 #+BEGIN_DOCBOOK
10637 <warning>
10638   <para>You should know what you are doing when quoting DocBook XML code
10639   in your Org file.  Invalid DocBook XML may be generated by
10640   DocBook exporter if you are not careful!</para>
10641 </warning>
10642 #+END_DOCBOOK
10643 @end example
10645 @node Recursive sections, Tables in DocBook export, Quoting DocBook code, DocBook export
10646 @subsection Recursive sections
10647 @cindex DocBook recursive sections
10649 DocBook exporter exports Org files as articles using the @code{article}
10650 element in DocBook.  Recursive sections, i.e.@: @code{section} elements, are
10651 used in exported articles.  Top level headlines in Org files are exported as
10652 top level sections, and lower level headlines are exported as nested
10653 sections.  The entire structure of Org files will be exported completely, no
10654 matter how many nested levels of headlines there are.
10656 Using recursive sections makes it easy to port and reuse exported DocBook
10657 code in other DocBook document types like @code{book} or @code{set}.
10659 @node Tables in DocBook export, Images in DocBook export, Recursive sections, DocBook export
10660 @subsection Tables in DocBook export
10661 @cindex tables, in DocBook export
10663 Tables in Org files are exported as HTML tables, which have been supported since
10664 DocBook V4.3.
10666 If a table does not have a caption, an informal table is generated using the
10667 @code{informaltable} element; otherwise, a formal table will be generated
10668 using the @code{table} element.
10670 @node Images in DocBook export, Special characters, Tables in DocBook export, DocBook export
10671 @subsection Images in DocBook export
10672 @cindex images, inline in DocBook
10673 @cindex inlining images in DocBook
10675 Images that are linked to without a description part in the link, like
10676 @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]}, will be exported to DocBook
10677 using @code{mediaobject} elements.  Each @code{mediaobject} element contains
10678 an @code{imageobject} that wraps an @code{imagedata} element.  If you have
10679 specified a caption for an image as described in @ref{Images and tables}, a
10680 @code{caption} element will be added in @code{mediaobject}.  If a label is
10681 also specified, it will be exported as an @code{xml:id} attribute of the
10682 @code{mediaobject} element.
10684 @vindex org-export-docbook-default-image-attributes
10685 Image attributes supported by the @code{imagedata} element, like @code{align}
10686 or @code{width}, can be specified in two ways: you can either customize
10687 variable @code{org-export-docbook-default-image-attributes} or use the
10688 @code{#+ATTR_DOCBOOK:} line.  Attributes specified in variable
10689 @code{org-export-docbook-default-image-attributes} are applied to all inline
10690 images in the Org file to be exported (unless they are overridden by image
10691 attributes specified in @code{#+ATTR_DOCBOOK:} lines).
10693 The @code{#+ATTR_DOCBOOK:} line can be used to specify additional image
10694 attributes or override default image attributes for individual images.  If
10695 the same attribute appears in both the @code{#+ATTR_DOCBOOK:} line and
10696 variable @code{org-export-docbook-default-image-attributes}, the former
10697 takes precedence.  Here is an example about how image attributes can be
10698 set:
10700 @cindex #+CAPTION
10701 @cindex #+LABEL
10702 @cindex #+ATTR_DOCBOOK
10703 @example
10704 #+CAPTION:    The logo of Org-mode
10705 #+LABEL:      unicorn-svg
10706 #+ATTR_DOCBOOK: scalefit="1" width="100%" depth="100%"
10707 [[./img/org-mode-unicorn.svg]]
10708 @end example
10710 @vindex org-export-docbook-inline-image-extensions
10711 By default, DocBook exporter recognizes the following image file types:
10712 @file{jpeg}, @file{jpg}, @file{png}, @file{gif}, and @file{svg}.  You can
10713 customize variable @code{org-export-docbook-inline-image-extensions} to add
10714 more types to this list as long as DocBook supports them.
10716 @node Special characters,  , Images in DocBook export, DocBook export
10717 @subsection Special characters in DocBook export
10718 @cindex Special characters in DocBook export
10720 @vindex org-export-docbook-doctype
10721 @vindex org-entities
10722 Special characters that are written in @TeX{}-like syntax, such as @code{\alpha},
10723 @code{\Gamma}, and @code{\Zeta}, are supported by DocBook exporter.  These
10724 characters are rewritten to XML entities, like @code{&alpha;},
10725 @code{&Gamma;}, and @code{&Zeta;}, based on the list saved in variable
10726 @code{org-entities}.  As long as the generated DocBook file includes the
10727 corresponding entities, these special characters are recognized.
10729 You can customize variable @code{org-export-docbook-doctype} to include the
10730 entities you need.  For example, you can set variable
10731 @code{org-export-docbook-doctype} to the following value to recognize all
10732 special characters included in XHTML entities:
10734 @example
10735 "<!DOCTYPE article [
10736 <!ENTITY % xhtml1-symbol PUBLIC
10737 \"-//W3C//ENTITIES Symbol for HTML//EN//XML\"
10738 \"http://www.w3.org/2003/entities/2007/xhtml1-symbol.ent\"
10740 %xhtml1-symbol;
10743 @end example
10745 @c begin opendocument
10747 @node OpenDocument Text export, TaskJuggler export, DocBook export, Exporting
10748 @section OpenDocument Text export
10749 @cindex K, Jambunathan
10750 @cindex ODT
10751 @cindex OpenDocument
10752 @cindex export, OpenDocument
10753 @cindex LibreOffice
10754 @cindex org-odt.el
10755 @cindex org-modules
10757 Orgmode@footnote{Versions 7.8 or later} supports export to OpenDocument
10758 Text(@acronym{ODT}) format using @file{org-odt.el} module.  Documents created
10759 by this exporter use @cite{OpenDocument-v1.2
10760 specification}@footnote{@url{http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html,
10761 Open Document Format for Office Applications (OpenDocument) Version 1.2}} and
10762 are compatible with LibreOffice 3.4.
10764 @menu
10765 * Pre-requisites for @acronym{ODT} export::
10766 * @acronym{ODT} export commands::  How to invoke @acronym{ODT} export
10767 * Applying Custom Styles::      How to apply custom styles to the output
10768 * Links in @acronym{ODT} export::  How links will be interpreted and formatted
10769 * Tables in @acronym{ODT} export::  How Tables are exported
10770 * Images in @acronym{ODT} export::  How to insert images
10771 * Math formatting in @acronym{ODT} export::  How @LaTeX{} fragments are formatted
10772 * Literal Examples in @acronym{ODT} export::  How source and example blocks are formatted
10773 * Working with raw OpenDocument XML::
10774 * Advanced topics in @acronym{ODT} export::
10775 @end menu
10777 @node Pre-requisites for @acronym{ODT} export, @acronym{ODT} export commands, OpenDocument Text export, OpenDocument Text export
10778 @subsection Pre-requisites for @acronym{ODT} export
10779 @cindex zip
10780 @acronym{ODT} exporter relies on @file{zip} program to create the final
10781 output.  Check the availability of this program before proceeding further.
10783 @node @acronym{ODT} export commands, Applying Custom Styles, Pre-requisites for @acronym{ODT} export, OpenDocument Text export
10784 @subsection @acronym{ODT} export commands
10786 @subsubheading Exporting to @acronym{ODT}
10787 @anchor{x-export-to-odt}
10789 @cindex region, active
10790 @cindex active region
10791 @cindex transient-mark-mode
10792 @table @kbd
10793 @orgcmd{C-c C-e o,org-export-as-odt}
10794 @cindex property EXPORT_FILE_NAME
10796 Export as OpenDocument Text file.
10797 @vindex org-export-odt-preferred-output-format
10798 If @code{org-export-odt-preferred-output-format} is specfied, automatically
10799 convert the exported file to that format.
10800 @xref{x-export-to-other-formats,,Automatically Exporting to Other formats}.
10802 For an Org file, @file{myfile.org}, the @acronym{ODT} file will be
10803 @file{myfile.odt}.  The file will be overwritten without warning.  If there
10804 is an active region@footnote{This requires @code{transient-mark-mode} to be
10805 turned on}, only the region will be exported.  If the selected region is a
10806 single tree@footnote{To select the current subtree, use @kbd{C-c @@}.}, the
10807 tree head will become the document title.  If the tree head entry has, or
10808 inherits, an @code{EXPORT_FILE_NAME} property, that name will be used for the
10809 export.
10811 @orgcmd{C-c C-e O,org-export-as-odt-and-open}
10812 Export as OpenDocument Text file and open the resulting file.
10813 @vindex org-export-odt-preferred-output-format
10814 If @code{org-export-odt-preferred-output-format} is specified, open the
10815 converted file instead.
10816 @xref{x-export-to-other-formats,,Automatically Exporting to Other formats}.
10817 @end table
10819 @subsubheading Automatically Exporting to Other formats
10820 @anchor{x-export-to-other-formats}
10821 @vindex org-export-odt-preferred-output-format
10822 Very often, you will find yourself exporting to @acronym{ODT} format, only to
10823 immediately save the exported document to a different format like @samp{doc},
10824 @samp{pdf} etc.  In such cases, you will find it convenient to configure a
10825 converter (@pxref{Configuring  a converter}) and specify your preferred
10826 output format by customizing the variable
10827 @code{org-export-odt-preferred-output-format}.  This way the export commands
10828 (@pxref{x-export-to-odt,,Exporting to ODT}) can be extended to also export to
10829 the preferred format.
10831 @node Applying Custom Styles, Links in @acronym{ODT} export, @acronym{ODT} export commands, OpenDocument Text export
10832 @subsection Applying Custom Styles
10833 @cindex styles, custom
10834 @cindex template, custom
10836 The @acronym{ODT} exporter ships with a set of OpenDocument styles (@pxref{A
10837 note on the internals of @acronym{ODT} exporter}) that ensure a
10838 well-formatted output.  These factory styles, however, may not cater to your
10839 specific tastes.  To customize the output, you can either modify the above
10840 styles files directly or generate the required styles using an application
10841 like LibreOffice.  The latter method is suitable for both expert and
10842 non-expert users alike and is described here.
10844 @subsubsection Applying custom styles - The Easy way
10846 @enumerate
10847 @item
10848 Create a sample @file{example.org} file with the below settings and export it
10849 to @acronym{ODT} format.
10851 @example
10852 #+OPTIONS: H:10 num:t
10853 @end example
10855 @item
10856 Open the above @file{example.odt} using LibreOffice.  Use the @file{Stylist}
10857 to locate the target styles - these typically have @samp{Org} prefix - and
10858 modify those to your taste.  Save the modified file either as an OpenDocument
10859 Text (@file{.odt}) or OpenDocument Template (@file{.ott}) file.
10861 @item
10862 @cindex #+ODT_STYLES_FILE
10863 @vindex org-export-odt-styles-file
10864 Customize the variable @code{org-export-odt-styles-file} and point it to the
10865 newly created file.
10867 If you would like to choose a style on per-file basis, you can use the
10868 @code{#+ODT_STYLES_FILE} option. A typical setting will look like
10870 @example
10871 #+ODT_STYLES_FILE: "/path/to/example.ott"
10872 @end example
10874 @end enumerate
10876 @subsubsection Using Third-party Styles and Templates
10878 You can use third-party styles and templates for customizing your output.
10879 This will produce the desired output only if the template provides all
10880 style-names that the @samp{ODT} exporter relies on.  Unless this condition is
10881 met, the output is going to be less than satisfactory.  So it is highly
10882 recommended that you only work with templates that are directly derived from
10883 the factory settings.
10885 @node Links in @acronym{ODT} export, Tables in @acronym{ODT} export, Applying Custom Styles, OpenDocument Text export
10886 @subsection Links in @acronym{ODT} export
10887 @cindex tables, in DocBook export
10889 @acronym{ODT} exporter creates cross-references (aka bookmarks) for links
10890 that are destined locally.  It creates internet style links for all other
10891 links.
10893 @node Tables in @acronym{ODT} export, Images in @acronym{ODT} export, Links in @acronym{ODT} export, OpenDocument Text export
10894 @subsection Tables in @acronym{ODT} export
10895 @cindex tables, in DocBook export
10897 Export of native Org-mode tables (@pxref{Tables}) and simple @file{table.el}
10898 tables is supported.  However export of complex @file{table.el} tables -
10899 tables that have column or row spans - are not supported. Such tables are
10900 stripped from the exported document.
10902 By default, a table is exported with with top and bottom frames and with
10903 rules separating row and column groups (@pxref{Column groups}).  If the table
10904 specifies alignment and relative width for it's columns (@pxref{Column width
10905 and alignment}) then these are honored on export@footnote{The column widths
10906 are interpreted as weighted ratios with the default weight being 1}.
10908 @cindex #+ATTR_ODT
10909 You can override the default formatting of the table by specifying a custom
10910 table style with the @code{#+ATTR_ODT} line.
10912 @node Images in @acronym{ODT} export, Math formatting in @acronym{ODT} export, Tables in @acronym{ODT} export, OpenDocument Text export
10913 @subsection Images in @acronym{ODT} export
10914 @cindex images, embedding in @acronym{ODT}
10915 @cindex embedding images in @acronym{ODT}
10917 @subsubheading Embedding images
10918 You can embed images within the exported document by providing a link to the
10919 desired image file with no link description.  For example, to embed
10920 @samp{img.png} do either of the following:
10922 @example
10923 [[file:img.png]]
10924 @end example
10926 @example
10927 [[./img.png]]
10928 @end example
10930 @subsubheading Embedding clickable images
10931 You can create clickable images by providing a link whose description is a
10932 link to an image file.  For example, to embed a image
10933 @file{org-mode-unicorn.png} which when clicked jumps to
10934 @uref{http://Orgmode.org} website, do the following
10936 @example
10937 [[http://orgmode.org][./org-mode-unicorn.png]]
10938 @end example
10940 You can control the size and scale of the embedded images using the
10941 @code{#+ATTR_ODT} attribute.
10943 @subsubheading How image size is computed
10944 In order to scale the embedded images, the exporter needs to compute the size
10945 of the image.  This is done by retrieving the image size in pixels and
10946 converting the pixel units to centimetres using
10947 @code{org-export-odt-pixels-per-inch}.  The default value of this variable is
10948 set to @code{display-pixels-per-inch}.  You can tweak this variable to
10949 achieve the best results.
10951 @subsubheading Sizing and scaling of embedded images
10952 @c @vindex org-export-odt-pixels-per-inch
10954 Note that the exporter specifies the desired size of the image in the final
10955 document in units of centimetres.  To compute the size of the original image
10956 in centimetres, the To convert the image size in pixels to equivalent units
10957 in cms @code{org-export-odt-pixels-per-inch} is used.
10959 The examples below illustrate the various possibilities.
10961 @table @asis
10963 @item Explicitly size the image
10964 To embed @file{img.png} as a 10 cm x 10 cm image, do the following:
10966 @example
10967 #+ATTR_ODT: :width 10 :height 10
10968 [[./img.png]]
10969 @end example
10971 @item Scale the image
10972 To embed @file{img.png} at half it's size, do the following:
10974 @example
10975 #+ATTR_ODT: :scale 0.5
10976 [[./img.png]]
10977 @end example
10979 @item Scale the image to a specific width
10980 To embed @file{img.png} to occupy a width of 10 cm while retaining the
10981 original height:width ratio, do the following:
10983 @example
10984 #+ATTR_ODT: :width 10
10985 [[./img.png]]
10986 @end example
10988 @item Scale the image to a specific height
10989 To embed @file{img.png} to occupy a height of 10 cm while retaining the
10990 original height:width ratio, do the following
10992 @example
10993 #+ATTR_ODT: :height 10
10994 [[./img.png]]
10995 @end example
10996 @end table
10998 @node Math formatting in @acronym{ODT} export, Literal Examples in @acronym{ODT} export, Images in @acronym{ODT} export, OpenDocument Text export
10999 @subsection Math formatting in @acronym{ODT} export
11001 @LaTeX{} math snippets (@pxref{LaTeX fragments}) can be embedded in the ODT
11002 document using one of the following ways:
11004 @cindex MathML
11005 @enumerate
11006 @item MathML
11008 This option is activated on a per-file basis with
11010 @example
11011 #+OPTIONS: LaTeX:t
11012 @end example
11014 With this option, @LaTeX{} fragments are first converted in to MathML
11015 fragments using an external LaTeX-to-MathML converter program.  The resulting
11016 MathML fragments are then embedded as a OpenDocument Formula in the exported
11017 document.
11019 @vindex org-latex-to-mathml-convert-command
11020 @vindex org-latex-to-mathml-jar-file
11022 You can specify the LaTeX-to-MathML converter by customizing the variables
11023 @code{org-latex-to-mathml-convert-command} and
11024 @code{org-latex-to-mathml-jar-file}.
11026 If you prefer to use @file{MathToWeb}@footnote{See
11027 @uref{http://www.mathtoweb.com/cgi-bin/mathtoweb_home.pl, MathToWeb}} as your
11028 converter, you can configure the above variables as shown below.
11030 @lisp
11031 (setq org-latex-to-mathml-convert-command
11032       "java -jar %j -unicode -force -df %o %I"
11033       org-latex-to-mathml-jar-file
11034       "/path/to/mathtoweb.jar")
11035 @end lisp
11037 @cindex dvipng
11039 @item png
11041 This option is activated on a per-file basis with
11043 @example
11044 #+OPTIONS: LaTeX:dvipng
11045 @end example
11047 With this option, @LaTeX{} fragments are processed into png images and the
11048 resulting images are embedded in the exported document.  This method requires
11049 that the @file{dvipng} program be available on your system.
11051 @end enumerate
11053 @node Literal Examples in @acronym{ODT} export, Working with raw OpenDocument XML, Math formatting in @acronym{ODT} export, OpenDocument Text export
11054 @subsection Literal Examples in @acronym{ODT} export
11056 Export of Literal examples (@pxref{Literal examples}) with full fontification
11057 is supported.  This feature is enabled by default and is activated
11058 automatically if an enhanced version of @file{htmlfontify.el} is available in
11059 the @code{load-path}@footnote{@file{htmlfontify.el} that ships with standard
11060 Emacs <= 24.1 has no support for @acronym{ODT} fontification.  A copy of the
11061 proposed version is available as an attachment to
11062 @url{http://debbugs.gnu.org/cgi/bugreport.cgi?msg=5;filename=htmlfontify.el;att=9;bug=9914, Emacs Bug #9914}.}
11064 @vindex org-export-odt-fontify-srcblocks
11066 The character styles used for fontification of the Literal blocks are
11067 auto-generated by the exporter in conjunction with @file{htmlfontify.el}
11068 library and need not be included in the default @file{styles.xml} file.
11069 These auto-generated styles have @samp{OrgSrc} prefix and inherit their color
11070 based on the face used by Emacs @code{font-lock} library.
11072 @vindex org-export-odt-create-custom-styles-for-srcblocks
11073 If you prefer to use your own custom styles for fontification and disable
11074 their auto-generation altogether, you can do so by customizing the variable
11075 @code{org-export-odt-create-custom-styles-for-srcblocks}.
11077 You can turn off fontification support for Literal examples by customizing
11078 the variable @code{org-export-odt-fontify-srcblocks}.
11080 @node Working with raw OpenDocument XML, Advanced topics in @acronym{ODT} export, Literal Examples in @acronym{ODT} export, OpenDocument Text export
11081 @subsection Working with raw OpenDocument XML
11083 There are times when you would want one-off formatting in the exported
11084 document.  You can achieve this by embedding raw OpenDocument XML in the Org
11085 file.  The use of this feature is better illustrated with couple of examples.
11087 @enumerate
11088 @item Embedding ODT tags as part of regular text
11090 You can include simple OpenDocument tags by prepending them with them with
11091 @samp{@@}. For example, to highlight a region of text do the following:
11093 @example
11094 @@<text:span text:style-name="Highlight">This is a
11095 highlighted text@@</text:span>. But this is a
11096 regular text.
11097 @end example
11099 @strong{Hint:} To see the above example in action, edit your
11100 @file{styles.xml} and add a custom @samp{Highlight} style as shown below.
11102 @example
11103 <style:style style:name="Highlight" style:family="text">
11104   <style:text-properties fo:background-color="#ff0000"/>
11105 </style:style>
11106 @end example
11108 @item Embedding a one-line OpenDocument XML
11110 You can add a simple OpenDocument one-liner using the @code{#+ODT:}
11111 directive.  For example to force a page break do the following
11113 @example
11114 #+ODT: <text:p text:style-name="PageBreak"/>
11115 @end example
11117 @strong{Hint:} To see the above example in action, edit your
11118 @file{styles.xml} and add a custom @samp{PageBreak} style as shown below.
11120 @example
11121 <style:style style:name="PageBreak" style:family="paragraph"
11122              style:parent-style-name="Text_20_body">
11123   <style:paragraph-properties fo:break-before="page"/>
11124 </style:style>
11125 @end example
11127 @item Embedding a block of OpenDocument XML
11129 You can add a large block of OpenDocument XML using the
11130 @code{#+BEGIN_ODT}@dots{}@code{#+END_ODT} construct.
11132 For example to create a one-off paragraph that uses bold text do the
11133 following:
11135 @example
11136 #+BEGIN_ODT
11137 <text:p text:style-name="Text_20_body_20_bold">
11138 This paragraph is specially formatted and uses bold text.
11139 </text:p>
11140 #+END_ODT
11141 @end example
11143 @end enumerate
11145 @node Advanced topics in @acronym{ODT} export,  , Working with raw OpenDocument XML, OpenDocument Text export
11146 @subsection Advanced topics in @acronym{ODT} export
11148 @menu
11149 * Exporting and Converting to Other formats::
11150 * Configuring a converter::
11151 * Using the converter::
11152 * Customizing Tables in @acronym{ODT} export::
11153 * A note on the internals of @acronym{ODT} exporter::
11154 @end menu
11156 @node Exporting and Converting to Other formats, Configuring a converter, Advanced topics in @acronym{ODT} export, Advanced topics in @acronym{ODT} export
11157 @subsubsection Exporting and Converting to Other formats
11158 @cindex convert
11159 @cindex doc, docx
11161 @acronym{ODT} exporter adds support for exporting Org outlines to formats
11162 that are not supported natively by Org. It also adds support to convert
11163 document from one format to another.  To use these features, you need to
11164 configure a command-line converter.
11166 @menu
11167 * Configuring a converter::     How to install a converter
11168 * Using the converter::         How to use the converter
11169 @end menu
11171 @node Configuring a converter, Using the converter, Exporting and Converting to Other formats, Advanced topics in @acronym{ODT} export
11172 @subsubheading Configuring a converter
11174 @subsubheading Pre-configured converters
11176 @cindex converter
11177 The @acronym{ODT} exporter supports two converters out of the box:
11179 @enumerate
11181 @cindex @file{unoconv}
11182 @item @file{unoconv}
11184 This converter is available as an installable package in your favorite
11185 distribution.
11187 @cindex @file{BasicODConverter}
11188 @item @file{BasicODConverter}
11190 @vindex org-odt-data-dir
11191 This converter is distributed as a LibreOffice extension and can be found in
11192 the your Org distribution. See the subdirectory pointed to by the variable
11193 @code{org-odt-data-dir}.
11195 @end enumerate
11197 @subsubheading Installing a new converter
11198 If you prefer to use a converter other than the two mentioned above, then you
11199 may have to do additional configuration.  You can proceed as follows:
11201 @enumerate
11202 @item Register the converter
11204 @vindex org-export-odt-convert-processes
11205 Name your converter and add it to the list of known converters by customizing
11206 the variable @code{org-export-odt-convert-processes}.  Also specify how the
11207 converter can be invoked via command-line to effect the conversion.
11209 @item Configure it's capabilities
11210 @vindex org-export-odt-convert-capabilities
11212 @anchor{x-odt-converter-capabilities}
11214 Specify the set of formats the converter can handle by customizing the
11215 variable @code{org-export-odt-convert-capabilities}.  Use the default value
11216 for this variable as a guide for configuring your converter.  As suggested by
11217 the default setting, you can specify full set of formats supported by the
11218 converter and not limit yourself to specifying formats that are related to
11219 just the OpenDocument Text format.
11221 @item Choose the converter
11223 @vindex org-export-odt-convert-process
11224 Select the newly added converter as the preferred one by customizing the
11225 variable @code{org-export-odt-convert-process}.
11226 @end enumerate
11228 @node Using the converter, Customizing Tables in @acronym{ODT} export, Configuring a converter, Advanced topics in @acronym{ODT} export
11229 @subsubheading Using the converter
11230 Once a command-line converter is configured you can use it to extend the list
11231 of formats to which Org can export
11232 to. @xref{x-export-to-other-formats,,Automatically Exporting to Other
11233 formats}.  You can also use it to perform one-off document conversion as
11234 detailed below.
11236 @vindex org-export-odt-convert
11237 @table @kbd
11239 @item M-x org-export-odt-convert
11240 Convert an existing document from one format to another format as determined
11241  by variable @code{org-export-odt-convert-capabilities}
11242  (@pxref{x-odt-converter-capabilities,,Configure converter capabilities}).
11244 Note that you can use this command to even convert documents that is produced
11245  outside of Org and in formats that is different from @acronym{ODT} format.
11246 @end table
11248 @node Customizing Tables in @acronym{ODT} export, A note on the internals of @acronym{ODT} exporter, Using the converter, Advanced topics in @acronym{ODT} export
11249 @subsubsection Customizing Tables in @acronym{ODT} export
11250 @cindex tables, in ODT export
11252 @cindex #+ATTR_ODT
11253 You can override the default formatting of the table by specifying a custom
11254 table style with the @code{#+ATTR_ODT} line.
11256 This feature closely mimics the way table templates are defined in the
11257 OpenDocument-v1.2
11258 specification@footnote{@url{http://docs.oasis-open.org/office/v1.2/OpenDocument-v1.2.html,
11259 OpenDocument-v1.2 Specification}}.
11261 To use this feature proceed as follows:
11263 @enumerate
11264 @item
11265 Create a table template@footnote{See @code{<table:table-template>} element of
11266 OpenDocument-v1.2 specification}
11268 A table template is nothing but a set of @samp{table-cell} and
11269 @samp{paragraph} style for each of the following table cell categories:
11271 @itemize @minus
11272 @item Body
11273 @item First column
11274 @item Last column
11275 @item First row
11276 @item Last row
11277 @item Even row
11278 @item Odd row
11279 @item Even column
11280 @item Odd Column
11281 @end itemize
11283 The names for the above styles must be chosen based on the name of the table
11284 template using a well-defined convention.
11286 The naming convention is better illustrated with an example.  For a table
11287 template with name @samp{Custom}, the needed style names are listed in the
11288 following table.
11290 @multitable  {Table cell type} {CustomEvenColumnTableCell} {CustomEvenColumnTableParagraph}
11291 @headitem Table cell type
11292 @tab @code{table-cell} style
11293 @tab @code{paragraph} style
11294 @item
11295 @tab
11296 @tab
11297 @item Body
11298 @tab @samp{CustomTableCell}
11299 @tab @samp{CustomTableParagraph}
11300 @item First column
11301 @tab @samp{CustomFirstColumnTableCell}
11302 @tab @samp{CustomFirstColumnTableParagraph}
11303 @item Last column
11304 @tab @samp{CustomLastColumnTableCell}
11305 @tab @samp{CustomLastColumnTableParagraph}
11306 @item First row
11307 @tab @samp{CustomFirstRowTableCell}
11308 @tab @samp{CustomFirstRowTableParagraph}
11309 @item Last row
11310 @tab @samp{CustomLastRowTableCell}
11311 @tab @samp{CustomLastRowTableParagraph}
11312 @item Even row
11313 @tab @samp{CustomEvenRowTableCell}
11314 @tab @samp{CustomEvenRowTableParagraph}
11315 @item Odd row
11316 @tab @samp{CustomOddRowTableCell}
11317 @tab @samp{CustomOddRowTableParagraph}
11318 @item Even column
11319 @tab @samp{CustomEvenColumnTableCell}
11320 @tab @samp{CustomEvenColumnTableParagraph}
11321 @item Odd column
11322 @tab @samp{CustomOddColumnTableCell}
11323 @tab @samp{CustomOddColumnTableParagraph}
11324 @end multitable
11326 To create a table template with name @samp{Custom}, define the above styles
11327 in the @code{<office:automatic-styles>}...@code{</office:automatic-styles>}
11328 element of the content template file (see docstring of variable
11329 @code{org-export-odt-content-template-file}).
11331 @item
11332 Define a table style@footnote{See attributes - @code{table:template-name},
11333 @code{table:use-first-row-styles}, @code{table:use-last-row-styles},
11334 @code{table:use-first-column-styles}, @code{table:use-last-column-styles},
11335 @code{table:use-banding-rows-styles}, @code{table:use-banding-column-styles}
11336 - of @code{<table:table>} element in OpenDocument-v1.2 specification}
11338 @vindex org-export-odt-table-styles
11339 To define a table style, create an entry for the style in the variable
11340 @code{org-export-odt-table-styles} and specify the following:
11342 @itemize @minus
11343 @item name of the table template created in step (1)
11344 @item set of cell styles in that template that are to be activated
11345 @end itemize
11347 For example, the entry below defines two different table styles
11348 @samp{TableWithHeaderRowsAndColumns} and @samp{TableWithHeaderColumns} based
11349 on the same template @samp{Custom}.  The styles achieve their intended effect
11350 by selectively activating the individual cell styles in that template.
11352 @lisp
11353 (setq org-export-odt-table-styles
11354       '(("TableWithHeaderRowsAndColumns"
11355          "Custom"
11356          ((use-first-row-styles . t)
11357           (use-first-column-styles . t)))
11358         ("TableWithHeaderColumns"
11359          "Custom" ((use-first-column-styles . t)))))
11360 @end lisp
11362 @item
11363 Associate a table with the table style
11365 To do this, specify the table style created in step (2) as part of
11366 @code{ATTR_ODT} line as show below.
11368 @example
11369 #+ATTR_ODT: TableWithHeaderColumns
11370 | Name  | Phone | Age |
11371 | Peter |  1234 |  17 |
11372 | Anna  |  4321 |  25 |
11373 @end example
11374 @end enumerate
11376 @node A note on the internals of @acronym{ODT} exporter,  , Customizing Tables in @acronym{ODT} export, Advanced topics in @acronym{ODT} export
11377 @subsubsection A note on the internals of @acronym{ODT} exporter
11378 @cindex styles, custom
11379 @cindex template, custom
11381 @vindex org-export-odt-styles-file
11383 @acronym{ODT} exporter relies on two files for generating it's output.  These
11384 files are bundled with the distribution under the directory pointed to by
11385 variable @code{org-odt-styles-dir}.  The two files are:
11387 @itemize
11388 @item
11389 @file{OrgOdtStyles.xml}
11391 This file contributes to @file{styles.xml} file of the final @samp{ODT}
11392 document.  This file gets modified for the following purposes:
11393 @enumerate
11395 @item
11396 To control outline numbering based on user settings.
11398 @item
11399 To add styles generated by the @file{htmlfontify.el} for fontification of
11400 code blocks.
11401 @end enumerate
11403 @item
11404 @file{OrgOdtContentTemplate.xml}
11406 This file contributes to the @file{content.xml} file of the final @samp{ODT}
11407 document.  The contents of the Org outline is inserted between the
11408 @samp{<office:text>}@dots{}@samp{</office:text>} elements of this file.
11410 Apart from serving as a template file for the final @file{content.xml}, the
11411 file serves the following purposes:
11412 @enumerate
11414 @item
11415 It contains Automatic Styles for formatting of tables which are referenced by
11416 the exporter.
11418 @item
11419 It contains @samp{<text:sequence-decl>}@dots{}@samp{</text:sequence-decl>}
11420 elements that control how various entities - Tables, Images, Equations etc -
11421 are numbered.
11422 @end enumerate
11423 @end itemize
11425 @c end opendocument
11427 @node  TaskJuggler export, Freemind export, OpenDocument Text export, Exporting
11428 @section TaskJuggler export
11429 @cindex TaskJuggler export
11430 @cindex Project management
11432 @uref{http://www.taskjuggler.org/, TaskJuggler} is a project management tool.
11433 It provides an optimizing scheduler that computes your project time lines and
11434 resource assignments based on the project outline and the constraints that
11435 you have provided.
11437 The TaskJuggler exporter is a bit different from other exporters, such as the
11438 HTML and LaTeX exporters for example, in that it does not export all the
11439 nodes of a document or strictly follow the order of the nodes in the
11440 document.
11442 Instead the TaskJuggler exporter looks for a tree that defines the tasks and
11443 a optionally tree that defines the resources for this project.  It then
11444 creates a TaskJuggler file based on these trees and the attributes defined in
11445 all the nodes.
11447 @subsection TaskJuggler export commands
11449 @table @kbd
11450 @orgcmd{C-c C-e j,org-export-as-taskjuggler}
11451 Export as TaskJuggler file.
11453 @orgcmd{C-c C-e J,org-export-as-taskjuggler-and-open}
11454 Export as TaskJuggler file and then open the file with TaskJugglerUI.
11455 @end table
11457 @subsection Tasks
11459 @vindex org-export-taskjuggler-project-tag
11460 Create your tasks as you usually do with Org-mode.  Assign efforts to each
11461 task using properties (it is easiest to do this in the column view).  You
11462 should end up with something similar to the example by Peter Jones in
11463 @url{http://www.contextualdevelopment.com/static/artifacts/articles/2008/project-planning/project-planning.org}.
11464 Now mark the top node of your tasks with a tag named
11465 @code{:taskjuggler_project:} (or whatever you customized
11466 @code{org-export-taskjuggler-project-tag} to).  You are now ready to export
11467 the project plan with @kbd{C-c C-e J} which will export the project plan and
11468 open a gantt chart in TaskJugglerUI.
11470 @subsection Resources
11472 @vindex org-export-taskjuggler-resource-tag
11473 Next you can define resources and assign those to work on specific tasks.  You
11474 can group your resources hierarchically.  Tag the top node of the resources
11475 with @code{:taskjuggler_resource:} (or whatever you customized
11476 @code{org-export-taskjuggler-resource-tag} to).  You can optionally assign an
11477 identifier (named @samp{resource_id}) to the resources (using the standard
11478 Org properties commands, @pxref{Property syntax}) or you can let the exporter
11479 generate identifiers automatically (the exporter picks the first word of the
11480 headline as the identifier as long as it is unique---see the documentation of
11481 @code{org-taskjuggler-get-unique-id}).  Using that identifier you can then
11482 allocate resources to tasks.  This is again done with the @samp{allocate}
11483 property on the tasks.  Do this in column view or when on the task type
11484 @kbd{C-c C-x p allocate @key{RET} <resource_id> @key{RET}}.
11486 Once the allocations are done you can again export to TaskJuggler and check
11487 in the Resource Allocation Graph which person is working on what task at what
11488 time.
11490 @subsection Export of properties
11492 The exporter also takes TODO state information into consideration, i.e.@: if a
11493 task is marked as done it will have the corresponding attribute in
11494 TaskJuggler (@samp{complete 100}).  Also it will export any property on a task
11495 resource or resource node which is known to TaskJuggler, such as
11496 @samp{limits}, @samp{vacation}, @samp{shift}, @samp{booking},
11497 @samp{efficiency}, @samp{journalentry}, @samp{rate} for resources or
11498 @samp{account}, @samp{start}, @samp{note}, @samp{duration}, @samp{end},
11499 @samp{journalentry}, @samp{milestone}, @samp{reference}, @samp{responsible},
11500 @samp{scheduling}, etc for tasks.
11502 @subsection Dependencies
11504 The exporter will handle dependencies that are defined in the tasks either
11505 with the @samp{ORDERED} attribute (@pxref{TODO dependencies}), with the
11506 @samp{BLOCKER} attribute (see @file{org-depend.el}) or alternatively with a
11507 @samp{depends} attribute.  Both the @samp{BLOCKER} and the @samp{depends}
11508 attribute can be either @samp{previous-sibling} or a reference to an
11509 identifier (named @samp{task_id}) which is defined for another task in the
11510 project.  @samp{BLOCKER} and the @samp{depends} attribute can define multiple
11511 dependencies separated by either space or comma.  You can also specify
11512 optional attributes on the dependency by simply appending it.  The following
11513 examples should illustrate this:
11515 @example
11516 * Preparation
11517   :PROPERTIES:
11518   :task_id:  preparation
11519   :ORDERED:  t
11520   :END:
11521 * Training material
11522   :PROPERTIES:
11523   :task_id:  training_material
11524   :ORDERED:  t
11525   :END:
11526 ** Markup Guidelines
11527    :PROPERTIES:
11528    :Effort:   2d
11529    :END:
11530 ** Workflow Guidelines
11531    :PROPERTIES:
11532    :Effort:   2d
11533    :END:
11534 * Presentation
11535   :PROPERTIES:
11536   :Effort:   2d
11537   :BLOCKER:  training_material @{ gapduration 1d @} preparation
11538   :END:
11539 @end example
11541 @subsection Reports
11543 @vindex org-export-taskjuggler-default-reports
11544 TaskJuggler can produce many kinds of reports (e.g.@: gantt chart, resource
11545 allocation, etc).  The user defines what kind of reports should be generated
11546 for a project in the TaskJuggler file.  The exporter will automatically insert
11547 some default reports in the file.  These defaults are defined in
11548 @code{org-export-taskjuggler-default-reports}.  They can be modified using
11549 customize along with a number of other options.  For a more complete list, see
11550 @kbd{M-x customize-group @key{RET} org-export-taskjuggler @key{RET}}.
11552 For more information and examples see the Org-taskjuggler tutorial at
11553 @uref{http://orgmode.org/worg/org-tutorials/org-taskjuggler.html}.
11555 @node Freemind export, XOXO export, TaskJuggler export, Exporting
11556 @section Freemind export
11557 @cindex Freemind export
11558 @cindex mind map
11560 The Freemind exporter was written by Lennart Borgman.
11562 @table @kbd
11563 @orgcmd{C-c C-e m,org-export-as-freemind}
11564 Export as Freemind mind map.  For an Org file @file{myfile.org}, the Freemind
11565 file will be @file{myfile.mm}.
11566 @end table
11568 @node XOXO export, iCalendar export, Freemind export, Exporting
11569 @section XOXO export
11570 @cindex XOXO export
11572 Org-mode contains an exporter that produces XOXO-style output.
11573 Currently, this exporter only handles the general outline structure and
11574 does not interpret any additional Org-mode features.
11576 @table @kbd
11577 @orgcmd{C-c C-e x,org-export-as-xoxo}
11578 Export as XOXO file.  For an Org file @file{myfile.org}, the XOXO file will be
11579 @file{myfile.html}.
11580 @orgkey{C-c C-e v x}
11581 Export only the visible part of the document.
11582 @end table
11584 @node iCalendar export,  , XOXO export, Exporting
11585 @section iCalendar export
11586 @cindex iCalendar export
11588 @vindex org-icalendar-include-todo
11589 @vindex org-icalendar-use-deadline
11590 @vindex org-icalendar-use-scheduled
11591 @vindex org-icalendar-categories
11592 @vindex org-icalendar-alarm-time
11593 Some people use Org-mode for keeping track of projects, but still prefer a
11594 standard calendar application for anniversaries and appointments.  In this
11595 case it can be useful to show deadlines and other time-stamped items in Org
11596 files in the calendar application.  Org-mode can export calendar information
11597 in the standard iCalendar format.  If you also want to have TODO entries
11598 included in the export, configure the variable
11599 @code{org-icalendar-include-todo}.  Plain timestamps are exported as VEVENT,
11600 and TODO items as VTODO.  It will also create events from deadlines that are
11601 in non-TODO items.  Deadlines and scheduling dates in TODO items will be used
11602 to set the start and due dates for the TODO entry@footnote{See the variables
11603 @code{org-icalendar-use-deadline} and @code{org-icalendar-use-scheduled}.}.
11604 As categories, it will use the tags locally defined in the heading, and the
11605 file/tree category@footnote{To add inherited tags or the TODO state,
11606 configure the variable @code{org-icalendar-categories}.}.  See the variable
11607 @code{org-icalendar-alarm-time} for a way to assign alarms to entries with a
11608 time.
11610 @vindex org-icalendar-store-UID
11611 @cindex property, ID
11612 The iCalendar standard requires each entry to have a globally unique
11613 identifier (UID).  Org creates these identifiers during export.  If you set
11614 the variable @code{org-icalendar-store-UID}, the UID will be stored in the
11615 @code{:ID:} property of the entry and re-used next time you report this
11616 entry.  Since a single entry can give rise to multiple iCalendar entries (as
11617 a timestamp, a deadline, a scheduled item, and as a TODO item), Org adds
11618 prefixes to the UID, depending on what triggered the inclusion of the entry.
11619 In this way the UID remains unique, but a synchronization program can still
11620 figure out from which entry all the different instances originate.
11622 @table @kbd
11623 @orgcmd{C-c C-e i,org-export-icalendar-this-file}
11624 Create iCalendar entries for the current file and store them in the same
11625 directory, using a file extension @file{.ics}.
11626 @orgcmd{C-c C-e I, org-export-icalendar-all-agenda-files}
11627 @vindex org-agenda-files
11628 Like @kbd{C-c C-e i}, but do this for all files in
11629 @code{org-agenda-files}.  For each of these files, a separate iCalendar
11630 file will be written.
11631 @orgcmd{C-c C-e c,org-export-icalendar-combine-agenda-files}
11632 @vindex org-combined-agenda-icalendar-file
11633 Create a single large iCalendar file from all files in
11634 @code{org-agenda-files} and write it to the file given by
11635 @code{org-combined-agenda-icalendar-file}.
11636 @end table
11638 @vindex org-use-property-inheritance
11639 @vindex org-icalendar-include-body
11640 @cindex property, SUMMARY
11641 @cindex property, DESCRIPTION
11642 @cindex property, LOCATION
11643 The export will honor SUMMARY, DESCRIPTION and LOCATION@footnote{The LOCATION
11644 property can be inherited from higher in the hierarchy if you configure
11645 @code{org-use-property-inheritance} accordingly.} properties if the selected
11646 entries have them.  If not, the summary will be derived from the headline,
11647 and the description from the body (limited to
11648 @code{org-icalendar-include-body} characters).
11650 How this calendar is best read and updated, depends on the application
11651 you are using.  The FAQ covers this issue.
11653 @node Publishing, Working With Source Code, Exporting, Top
11654 @chapter Publishing
11655 @cindex publishing
11657 Org includes a publishing management system that allows you to configure
11658 automatic HTML conversion of @emph{projects} composed of interlinked org
11659 files.  You can also configure Org to automatically upload your exported HTML
11660 pages and related attachments, such as images and source code files, to a web
11661 server.
11663 You can also use Org to convert files into PDF, or even combine HTML and PDF
11664 conversion so that files are available in both formats on the server.
11666 Publishing has been contributed to Org by David O'Toole.
11668 @menu
11669 * Configuration::               Defining projects
11670 * Uploading files::             How to get files up on the server
11671 * Sample configuration::        Example projects
11672 * Triggering publication::      Publication commands
11673 @end menu
11675 @node Configuration, Uploading files, Publishing, Publishing
11676 @section Configuration
11678 Publishing needs significant configuration to specify files, destination
11679 and many other properties of a project.
11681 @menu
11682 * Project alist::               The central configuration variable
11683 * Sources and destinations::    From here to there
11684 * Selecting files::             What files are part of the project?
11685 * Publishing action::           Setting the function doing the publishing
11686 * Publishing options::          Tweaking HTML/@LaTeX{} export
11687 * Publishing links::            Which links keep working after publishing?
11688 * Sitemap::                     Generating a list of all pages
11689 * Generating an index::         An index that reaches across pages
11690 @end menu
11692 @node Project alist, Sources and destinations, Configuration, Configuration
11693 @subsection The variable @code{org-publish-project-alist}
11694 @cindex org-publish-project-alist
11695 @cindex projects, for publishing
11697 @vindex org-publish-project-alist
11698 Publishing is configured almost entirely through setting the value of one
11699 variable, called @code{org-publish-project-alist}.  Each element of the list
11700 configures one project, and may be in one of the two following forms:
11702 @lisp
11703    ("project-name" :property value :property value ...)
11704      @r{i.e.@: a well-formed property list with alternating keys and values}
11705 @r{or}
11706    ("project-name" :components ("project-name" "project-name" ...))
11708 @end lisp
11710 In both cases, projects are configured by specifying property values.  A
11711 project defines the set of files that will be published, as well as the
11712 publishing configuration to use when publishing those files.  When a project
11713 takes the second form listed above, the individual members of the
11714 @code{:components} property are taken to be sub-projects, which group
11715 together files requiring different publishing options.  When you publish such
11716 a ``meta-project'', all the components will also be published, in the
11717 sequence given.
11719 @node Sources and destinations, Selecting files, Project alist, Configuration
11720 @subsection Sources and destinations for files
11721 @cindex directories, for publishing
11723 Most properties are optional, but some should always be set.  In
11724 particular, Org needs to know where to look for source files,
11725 and where to put published files.
11727 @multitable @columnfractions 0.3 0.7
11728 @item @code{:base-directory}
11729 @tab Directory containing publishing source files
11730 @item @code{:publishing-directory}
11731 @tab Directory where output files will be published.  You can directly
11732 publish to a webserver using a file name syntax appropriate for
11733 the Emacs @file{tramp} package.  Or you can publish to a local directory and
11734 use external tools to upload your website (@pxref{Uploading files}).
11735 @item @code{:preparation-function}
11736 @tab Function or list of functions to be called before starting the
11737 publishing process, for example, to run @code{make} for updating files to be
11738 published.  The project property list is scoped into this call as the
11739 variable @code{project-plist}.
11740 @item @code{:completion-function}
11741 @tab Function or list of functions called after finishing the publishing
11742 process, for example, to change permissions of the resulting files.  The
11743 project property list is scoped into this call as the variable
11744 @code{project-plist}.
11745 @end multitable
11746 @noindent
11748 @node Selecting files, Publishing action, Sources and destinations, Configuration
11749 @subsection Selecting files
11750 @cindex files, selecting for publishing
11752 By default, all files with extension @file{.org} in the base directory
11753 are considered part of the project.  This can be modified by setting the
11754 properties
11755 @multitable @columnfractions 0.25 0.75
11756 @item @code{:base-extension}
11757 @tab Extension (without the dot!) of source files.  This actually is a
11758 regular expression.  Set this to the symbol @code{any} if you want to get all
11759 files in @code{:base-directory}, even without extension.
11761 @item @code{:exclude}
11762 @tab Regular expression to match file names that should not be
11763 published, even though they have been selected on the basis of their
11764 extension.
11766 @item @code{:include}
11767 @tab List of files to be included regardless of @code{:base-extension}
11768 and @code{:exclude}.
11770 @item @code{:recursive}
11771 @tab Non-nil means, check base-directory recursively for files to publish.
11772 @end multitable
11774 @node Publishing action, Publishing options, Selecting files, Configuration
11775 @subsection Publishing action
11776 @cindex action, for publishing
11778 Publishing means that a file is copied to the destination directory and
11779 possibly transformed in the process.  The default transformation is to export
11780 Org files as HTML files, and this is done by the function
11781 @code{org-publish-org-to-html} which calls the HTML exporter (@pxref{HTML
11782 export}).  But you also can publish your content as PDF files using
11783 @code{org-publish-org-to-pdf}, or as @code{ascii}, @code{latin1} or
11784 @code{utf8} encoded files using the corresponding functions.  If you want to
11785 publish the Org file itself, but with @i{archived}, @i{commented}, and
11786 @i{tag-excluded} trees removed, use @code{org-publish-org-to-org} and set the
11787 parameters @code{:plain-source} and/or @code{:htmlized-source}.  This will
11788 produce @file{file.org} and @file{file.org.html} in the publishing
11789 directory@footnote{@file{file-source.org} and @file{file-source.org.html} if
11790 source and publishing directories are equal.  Note that with this kind of
11791 setup, you need to add @code{:exclude "-source\\.org"} to the project
11792 definition in @code{org-publish-project-alist} to prevent the published
11793 source files from being considered as new org files the next time the project
11794 is published.}.  Other files like images only need to be copied to the
11795 publishing destination; for this you may use @code{org-publish-attachment}.
11796 For non-Org files, you always need to specify the publishing function:
11798 @multitable @columnfractions 0.3 0.7
11799 @item @code{:publishing-function}
11800 @tab Function executing the publication of a file.  This may also be a
11801 list of functions, which will all be called in turn.
11802 @item @code{:plain-source}
11803 @tab Non-nil means, publish plain source.
11804 @item @code{:htmlized-source}
11805 @tab Non-nil means, publish htmlized source.
11806 @end multitable
11808 The function must accept three arguments: a property list containing at least
11809 a @code{:publishing-directory} property, the name of the file to be
11810 published, and the path to the publishing directory of the output file.  It
11811 should take the specified file, make the necessary transformation (if any)
11812 and place the result into the destination folder.
11814 @node Publishing options, Publishing links, Publishing action, Configuration
11815 @subsection Options for the HTML/@LaTeX{} exporters
11816 @cindex options, for publishing
11818 The property list can be used to set many export options for the HTML
11819 and @LaTeX{} exporters.  In most cases, these properties correspond to user
11820 variables in Org.  The table below lists these properties along
11821 with the variable they belong to.  See the documentation string for the
11822 respective variable for details.
11824 @vindex org-export-html-link-up
11825 @vindex org-export-html-link-home
11826 @vindex org-export-default-language
11827 @vindex org-display-custom-times
11828 @vindex org-export-headline-levels
11829 @vindex org-export-with-section-numbers
11830 @vindex org-export-section-number-format
11831 @vindex org-export-with-toc
11832 @vindex org-export-preserve-breaks
11833 @vindex org-export-with-archived-trees
11834 @vindex org-export-with-emphasize
11835 @vindex org-export-with-sub-superscripts
11836 @vindex org-export-with-special-strings
11837 @vindex org-export-with-footnotes
11838 @vindex org-export-with-drawers
11839 @vindex org-export-with-tags
11840 @vindex org-export-with-todo-keywords
11841 @vindex org-export-with-tasks
11842 @vindex org-export-with-done-tasks
11843 @vindex org-export-with-priority
11844 @vindex org-export-with-TeX-macros
11845 @vindex org-export-with-LaTeX-fragments
11846 @vindex org-export-skip-text-before-1st-heading
11847 @vindex org-export-with-fixed-width
11848 @vindex org-export-with-timestamps
11849 @vindex org-export-author-info
11850 @vindex org-export-email-info
11851 @vindex org-export-creator-info
11852 @vindex org-export-time-stamp-file
11853 @vindex org-export-with-tables
11854 @vindex org-export-highlight-first-table-line
11855 @vindex org-export-html-style-include-default
11856 @vindex org-export-html-style-include-scripts
11857 @vindex org-export-html-style
11858 @vindex org-export-html-style-extra
11859 @vindex org-export-html-link-org-files-as-html
11860 @vindex org-export-html-inline-images
11861 @vindex org-export-html-extension
11862 @vindex org-export-html-table-tag
11863 @vindex org-export-html-expand
11864 @vindex org-export-html-with-timestamp
11865 @vindex org-export-publishing-directory
11866 @vindex org-export-html-preamble
11867 @vindex org-export-html-postamble
11868 @vindex user-full-name
11869 @vindex user-mail-address
11870 @vindex org-export-select-tags
11871 @vindex org-export-exclude-tags
11873 @multitable @columnfractions 0.32 0.68
11874 @item @code{:link-up}               @tab @code{org-export-html-link-up}
11875 @item @code{:link-home}             @tab @code{org-export-html-link-home}
11876 @item @code{:language}              @tab @code{org-export-default-language}
11877 @item @code{:customtime}            @tab @code{org-display-custom-times}
11878 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
11879 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
11880 @item @code{:section-number-format} @tab @code{org-export-section-number-format}
11881 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
11882 @item @code{:preserve-breaks}       @tab @code{org-export-preserve-breaks}
11883 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
11884 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
11885 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
11886 @item @code{:special-strings}       @tab @code{org-export-with-special-strings}
11887 @item @code{:footnotes}             @tab @code{org-export-with-footnotes}
11888 @item @code{:drawers}               @tab @code{org-export-with-drawers}
11889 @item @code{:tags}                  @tab @code{org-export-with-tags}
11890 @item @code{:todo-keywords}         @tab @code{org-export-with-todo-keywords}
11891 @item @code{:tasks}                 @tab @code{org-export-with-tasks}
11892 @item @code{:priority}              @tab @code{org-export-with-priority}
11893 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
11894 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
11895 @item @code{:latex-listings}        @tab @code{org-export-latex-listings}
11896 @item @code{:skip-before-1st-heading} @tab @code{org-export-skip-text-before-1st-heading}
11897 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
11898 @item @code{:timestamps}            @tab @code{org-export-with-timestamps}
11899 @item @code{:author}                @tab @code{user-full-name}
11900 @item @code{:email}                 @tab @code{user-mail-address} : @code{addr;addr;..}
11901 @item @code{:author-info}           @tab @code{org-export-author-info}
11902 @item @code{:email-info}            @tab @code{org-export-email-info}
11903 @item @code{:creator-info}          @tab @code{org-export-creator-info}
11904 @item @code{:tables}                @tab @code{org-export-with-tables}
11905 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
11906 @item @code{:style-include-default} @tab @code{org-export-html-style-include-default}
11907 @item @code{:style-include-scripts} @tab @code{org-export-html-style-include-scripts}
11908 @item @code{:style}                 @tab @code{org-export-html-style}
11909 @item @code{:style-extra}           @tab @code{org-export-html-style-extra}
11910 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
11911 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
11912 @item @code{:html-extension}        @tab @code{org-export-html-extension}
11913 @item @code{:html-preamble}         @tab @code{org-export-html-preamble}
11914 @item @code{:html-postamble}        @tab @code{org-export-html-postamble}
11915 @item @code{:xml-declaration}       @tab @code{org-export-html-xml-declaration}
11916 @item @code{:html-table-tag}        @tab @code{org-export-html-table-tag}
11917 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
11918 @item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
11919 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
11920 @item @code{:select-tags}           @tab @code{org-export-select-tags}
11921 @item @code{:exclude-tags}          @tab @code{org-export-exclude-tags}
11922 @item @code{:latex-image-options}   @tab @code{org-export-latex-image-default-option}
11923 @end multitable
11925 Most of the @code{org-export-with-*} variables have the same effect in
11926 both HTML and @LaTeX{} exporters, except for @code{:TeX-macros} and
11927 @code{:LaTeX-fragments} options, respectively @code{nil} and @code{t} in the
11928 @LaTeX{} export.  See @code{org-export-plist-vars} to check this list of
11929 options.
11933 @vindex org-publish-project-alist
11934 When a property is given a value in @code{org-publish-project-alist},
11935 its setting overrides the value of the corresponding user variable (if
11936 any) during publishing.  Options set within a file (@pxref{Export
11937 options}), however, override everything.
11939 @node Publishing links, Sitemap, Publishing options, Configuration
11940 @subsection Links between published files
11941 @cindex links, publishing
11943 To create a link from one Org file to another, you would use
11944 something like @samp{[[file:foo.org][The foo]]} or simply
11945 @samp{file:foo.org.} (@pxref{Hyperlinks}).  When published, this link
11946 becomes a link to @file{foo.html}.  In this way, you can interlink the
11947 pages of your "org web" project and the links will work as expected when
11948 you publish them to HTML.  If you also publish the Org source file and want
11949 to link to that, use an @code{http:} link instead of a @code{file:} link,
11950 because @code{file:} links are converted to link to the corresponding
11951 @file{html} file.
11953 You may also link to related files, such as images.  Provided you are careful
11954 with relative file names, and provided you have also configured Org to upload
11955 the related files, these links will work too.  See @ref{Complex example}, for
11956 an example of this usage.
11958 Sometimes an Org file to be published may contain links that are
11959 only valid in your production environment, but not in the publishing
11960 location.  In this case, use the property
11962 @multitable @columnfractions 0.4 0.6
11963 @item @code{:link-validation-function}
11964 @tab Function to validate links
11965 @end multitable
11967 @noindent
11968 to define a function for checking link validity.  This function must
11969 accept two arguments, the file name and a directory relative to which
11970 the file name is interpreted in the production environment.  If this
11971 function returns @code{nil}, then the HTML generator will only insert a
11972 description into the HTML file, but no link.  One option for this
11973 function is @code{org-publish-validate-link} which checks if the given
11974 file is part of any project in @code{org-publish-project-alist}.
11976 @node Sitemap, Generating an index, Publishing links, Configuration
11977 @subsection Generating a sitemap
11978 @cindex sitemap, of published pages
11980 The following properties may be used to control publishing of
11981 a map of files for a given project.
11983 @multitable @columnfractions 0.35 0.65
11984 @item @code{:auto-sitemap}
11985 @tab When non-nil, publish a sitemap during @code{org-publish-current-project}
11986 or @code{org-publish-all}.
11988 @item @code{:sitemap-filename}
11989 @tab Filename for output of sitemap.  Defaults to @file{sitemap.org} (which
11990 becomes @file{sitemap.html}).
11992 @item @code{:sitemap-title}
11993 @tab Title of sitemap page.  Defaults to name of file.
11995 @item @code{:sitemap-function}
11996 @tab Plug-in function to use for generation of the sitemap.
11997 Defaults to @code{org-publish-org-sitemap}, which generates a plain list
11998 of links to all files in the project.
12000 @item @code{:sitemap-sort-folders}
12001 @tab Where folders should appear in the sitemap.  Set this to @code{first}
12002 (default) or @code{last} to display folders first or last,
12003 respectively.  Any other value will mix files and folders.
12005 @item @code{:sitemap-sort-files}
12006 @tab How the files are sorted in the site map.  Set this to
12007 @code{alphabetically} (default), @code{chronologically} or
12008 @code{anti-chronologically}.  @code{chronologically} sorts the files with
12009 older date first while @code{anti-chronologically} sorts the files with newer
12010 date first.  @code{alphabetically} sorts the files alphabetically.  The date of
12011 a file is retrieved with @code{org-publish-find-date}.
12013 @item @code{:sitemap-ignore-case}
12014 @tab Should sorting be case-sensitive?  Default @code{nil}.
12016 @item @code{:sitemap-file-entry-format}
12017 @tab With this option one can tell how a sitemap's entry is formatted in the
12018 sitemap.  This is a format string with some escape sequences: @code{%t} stands
12019 for the title of the file, @code{%a} stands for the author of the file and
12020 @code{%d} stands for the date of the file.  The date is retrieved with the
12021 @code{org-publish-find-date} function and formatted with
12022 @code{org-publish-sitemap-date-format}.  Default @code{%t}.
12024 @item @code{:sitemap-date-format}
12025 @tab Format string for the @code{format-time-string} function that tells how
12026 a sitemap entry's date is to be formatted.  This property bypasses
12027 @code{org-publish-sitemap-date-format} which defaults to @code{%Y-%m-%d}.
12029 @item @code{:sitemap-sans-extension}
12030 @tab When non-nil, remove filenames' extensions from the generated sitemap.
12031 Useful to have cool URIs (see @uref{http://www.w3.org/Provider/Style/URI}).
12032 Defaults to @code{nil}.
12034 @end multitable
12036 @node Generating an index,  , Sitemap, Configuration
12037 @subsection Generating an index
12038 @cindex index, in a publishing project
12040 Org-mode can generate an index across the files of a publishing project.
12042 @multitable @columnfractions 0.25 0.75
12043 @item @code{:makeindex}
12044 @tab When non-nil, generate in index in the file @file{theindex.org} and
12045 publish it as @file{theindex.html}.
12046 @end multitable
12048 The file will be created when first publishing a project with the
12049 @code{:makeindex} set.  The file only contains a statement @code{#+include:
12050 "theindex.inc"}.  You can then build around this include statement by adding
12051 a title, style information, etc.
12053 @node Uploading files, Sample configuration, Configuration, Publishing
12054 @section Uploading files
12055 @cindex rsync
12056 @cindex unison
12058 For those people already utilizing third party sync tools such as
12059 @command{rsync} or @command{unison}, it might be preferable not to use the built in
12060 @i{remote} publishing facilities of Org-mode which rely heavily on
12061 Tramp.  Tramp, while very useful and powerful, tends not to be
12062 so efficient for multiple file transfer and has been known to cause problems
12063 under heavy usage.
12065 Specialized synchronization utilities offer several advantages.  In addition
12066 to timestamp comparison, they also do content and permissions/attribute
12067 checks.  For this reason you might prefer to publish your web to a local
12068 directory (possibly even @i{in place} with your Org files) and then use
12069 @file{unison} or @file{rsync} to do the synchronization with the remote host.
12071 Since Unison (for example) can be configured as to which files to transfer to
12072 a certain remote destination, it can greatly simplify the project publishing
12073 definition.  Simply keep all files in the correct location, process your Org
12074 files with @code{org-publish} and let the synchronization tool do the rest.
12075 You do not need, in this scenario, to include attachments such as @file{jpg},
12076 @file{css} or @file{gif} files in the project definition since the 3rd party
12077 tool syncs them.
12079 Publishing to a local directory is also much faster than to a remote one, so
12080 that you can afford more easily to republish entire projects.  If you set
12081 @code{org-publish-use-timestamps-flag} to @code{nil}, you gain the main
12082 benefit of re-including any changed external files such as source example
12083 files you might include with @code{#+INCLUDE}.  The timestamp mechanism in
12084 Org is not smart enough to detect if included files have been modified.
12086 @node Sample configuration, Triggering publication, Uploading files, Publishing
12087 @section Sample configuration
12089 Below we provide two example configurations.  The first one is a simple
12090 project publishing only a set of Org files.  The second example is
12091 more complex, with a multi-component project.
12093 @menu
12094 * Simple example::              One-component publishing
12095 * Complex example::             A multi-component publishing example
12096 @end menu
12098 @node Simple example, Complex example, Sample configuration, Sample configuration
12099 @subsection Example: simple publishing configuration
12101 This example publishes a set of Org files to the @file{public_html}
12102 directory on the local machine.
12104 @lisp
12105 (setq org-publish-project-alist
12106       '(("org"
12107          :base-directory "~/org/"
12108          :publishing-directory "~/public_html"
12109          :section-numbers nil
12110          :table-of-contents nil
12111          :style "<link rel=\"stylesheet\"
12112                 href=\"../other/mystyle.css\"
12113                 type=\"text/css\"/>")))
12114 @end lisp
12116 @node Complex example,  , Simple example, Sample configuration
12117 @subsection Example: complex publishing configuration
12119 This more complicated example publishes an entire website, including
12120 Org files converted to HTML, image files, Emacs Lisp source code, and
12121 style sheets.  The publishing directory is remote and private files are
12122 excluded.
12124 To ensure that links are preserved, care should be taken to replicate
12125 your directory structure on the web server, and to use relative file
12126 paths.  For example, if your Org files are kept in @file{~/org} and your
12127 publishable images in @file{~/images}, you would link to an image with
12129 @example
12130 file:../images/myimage.png
12131 @end example
12133 On the web server, the relative path to the image should be the
12134 same.  You can accomplish this by setting up an "images" folder in the
12135 right place on the web server, and publishing images to it.
12137 @lisp
12138 (setq org-publish-project-alist
12139       '(("orgfiles"
12140           :base-directory "~/org/"
12141           :base-extension "org"
12142           :publishing-directory "/ssh:user@@host:~/html/notebook/"
12143           :publishing-function org-publish-org-to-html
12144           :exclude "PrivatePage.org"   ;; regexp
12145           :headline-levels 3
12146           :section-numbers nil
12147           :table-of-contents nil
12148           :style "<link rel=\"stylesheet\"
12149                   href=\"../other/mystyle.css\" type=\"text/css\"/>"
12150           :html-preamble t)
12152          ("images"
12153           :base-directory "~/images/"
12154           :base-extension "jpg\\|gif\\|png"
12155           :publishing-directory "/ssh:user@@host:~/html/images/"
12156           :publishing-function org-publish-attachment)
12158          ("other"
12159           :base-directory "~/other/"
12160           :base-extension "css\\|el"
12161           :publishing-directory "/ssh:user@@host:~/html/other/"
12162           :publishing-function org-publish-attachment)
12163          ("website" :components ("orgfiles" "images" "other"))))
12164 @end lisp
12166 @node Triggering publication,  , Sample configuration, Publishing
12167 @section Triggering publication
12169 Once properly configured, Org can publish with the following commands:
12171 @table @kbd
12172 @orgcmd{C-c C-e X,org-publish}
12173 Prompt for a specific project and publish all files that belong to it.
12174 @orgcmd{C-c C-e P,org-publish-current-project}
12175 Publish the project containing the current file.
12176 @orgcmd{C-c C-e F,org-publish-current-file}
12177 Publish only the current file.
12178 @orgcmd{C-c C-e E,org-publish-all}
12179 Publish every project.
12180 @end table
12182 @vindex org-publish-use-timestamps-flag
12183 Org uses timestamps to track when a file has changed.  The above functions
12184 normally only publish changed files.  You can override this and force
12185 publishing of all files by giving a prefix argument to any of the commands
12186 above, or by customizing the variable @code{org-publish-use-timestamps-flag}.
12187 This may be necessary in particular if files include other files via
12188 @code{#+SETUPFILE:} or @code{#+INCLUDE:}.
12190 @comment  node-name,  next,  previous,  up
12191 @comment Working With Source Code, Miscellaneous, Publishing, Top
12193 @node Working With Source Code, Miscellaneous, Publishing, Top
12194 @chapter Working with source code
12195 @cindex Schulte, Eric
12196 @cindex Davison, Dan
12197 @cindex source code, working with
12199 Source code can be included in Org-mode documents using a @samp{src} block,
12200 e.g.@:
12202 @example
12203 #+BEGIN_SRC emacs-lisp
12204   (defun org-xor (a b)
12205      "Exclusive or."
12206      (if a (not b) b))
12207 #+END_SRC
12208 @end example
12210 Org-mode provides a number of features for working with live source code,
12211 including editing of code blocks in their native major-mode, evaluation of
12212 code blocks, converting code blocks into source files (known as @dfn{tangling}
12213 in literate programming), and exporting code blocks and their
12214 results in several formats.  This functionality was contributed by Eric
12215 Schulte and Dan Davison, and was originally named Org-babel.
12217 The following sections describe Org-mode's code block handling facilities.
12219 @menu
12220 * Structure of code blocks::    Code block syntax described
12221 * Editing source code::         Language major-mode editing
12222 * Exporting code blocks::       Export contents and/or results
12223 * Extracting source code::      Create pure source code files
12224 * Evaluating code blocks::      Place results of evaluation in the Org-mode buffer
12225 * Library of Babel::            Use and contribute to a library of useful code blocks
12226 * Languages::                   List of supported code block languages
12227 * Header arguments::            Configure code block functionality
12228 * Results of evaluation::       How evaluation results are handled
12229 * Noweb reference syntax::      Literate programming in Org-mode
12230 * Key bindings and useful functions::  Work quickly with code blocks
12231 * Batch execution::             Call functions from the command line
12232 @end menu
12234 @comment  node-name,  next,  previous,  up
12235 @comment  Structure of code blocks, Editing source code, Working With Source Code, Working With Source Code
12237 @node Structure of code blocks, Editing source code, Working With Source Code, Working With Source Code
12238 @section Structure of code blocks
12239 @cindex code block, structure
12240 @cindex source code, block structure
12241 @cindex #+NAME
12242 @cindex #+BEGIN_SRC
12244 Live code blocks can be specified with a @samp{src} block or
12245 inline.@footnote{Note that @samp{src} blocks may be inserted using Org-mode's
12246 @ref{Easy Templates} system}  The structure of a @samp{src} block is
12248 @example
12249 #+NAME: <name>
12250 #+BEGIN_SRC <language> <switches> <header arguments>
12251   <body>
12252 #+END_SRC
12253 @end example
12255 The @code{#+NAME:} line is optional, and can be used to name the code
12256 block. Live code blocks require that a language be specified on the
12257 @code{#+BEGIN_SRC} line.  Switches and header arguments are optional.
12258 @cindex source code, inline
12260 Live code blocks can also be specified inline using
12262 @example
12263 src_<language>@{<body>@}
12264 @end example
12268 @example
12269 src_<language>[<header arguments>]@{<body>@}
12270 @end example
12272 @table @code
12273 @item <#+NAME: name>
12274 This line associates a name with the code block.  This is similar to the
12275 @code{#+TBLNAME: NAME} lines that can be used to name tables in Org-mode
12276 files.  Referencing the name of a code block makes it possible to evaluate
12277 the block from other places in the file, from other files, or from Org-mode
12278 table formulas (see @ref{The spreadsheet}).  Names are assumed to be unique
12279 and the behavior of Org-mode when two or more blocks share the same name is
12280 undefined.
12281 @cindex #+NAME
12282 @item <language>
12283 The language of the code in the block (see @ref{Languages}).
12284 @cindex source code, language
12285 @item <switches>
12286 Optional switches control code block export (see the discussion of switches in
12287 @ref{Literal examples})
12288 @cindex source code, switches
12289 @item <header arguments>
12290 Optional header arguments control many aspects of evaluation, export and
12291 tangling of code blocks (see @ref{Header arguments}).
12292 Header arguments can also be set on a per-buffer or per-subtree
12293 basis using properties.
12294 @item source code, header arguments
12295 @item <body>
12296 Source code in the specified language.
12297 @end table
12299 @comment  node-name,  next,  previous,  up
12300 @comment  Editing source code, Exporting code blocks, Structure of code blocks, Working With Source Code
12302 @node Editing source code, Exporting code blocks, Structure of code blocks, Working With Source Code
12303 @section Editing source code
12304 @cindex code block, editing
12305 @cindex source code, editing
12307 @kindex C-c '
12308 Use @kbd{C-c '} to edit the current code block.  This brings up
12309 a language major-mode edit buffer containing the body of the code
12310 block.  Saving this buffer will write the new contents back to the Org
12311 buffer.  Use @kbd{C-c '} again to exit.
12313 The @code{org-src-mode} minor mode will be active in the edit buffer.  The
12314 following variables can be used to configure the behavior of the edit
12315 buffer.  See also the customization group @code{org-edit-structure} for
12316 further configuration options.
12318 @table @code
12319 @item org-src-lang-modes
12320 If an Emacs major-mode named @code{<lang>-mode} exists, where
12321 @code{<lang>} is the language named in the header line of the code block,
12322 then the edit buffer will be placed in that major-mode.  This variable
12323 can be used to map arbitrary language names to existing major modes.
12324 @item org-src-window-setup
12325 Controls the way Emacs windows are rearranged when the edit buffer is created.
12326 @item org-src-preserve-indentation
12327 This variable is especially useful for tangling languages such as
12328 Python, in which whitespace indentation in the output is critical.
12329 @item org-src-ask-before-returning-to-edit-buffer
12330 By default, Org will ask before returning to an open edit buffer.  Set this
12331 variable to nil to switch without asking.
12332 @end table
12334 To turn on native code fontification in the @emph{Org} buffer, configure the
12335 variable @code{org-src-fontify-natively}.
12337 @comment  node-name,  next,  previous,  up
12338 @comment  Exporting code blocks, Extracting source code, Editing source code, Working With Source Code
12340 @node Exporting code blocks, Extracting source code, Editing source code, Working With Source Code
12341 @section Exporting code blocks
12342 @cindex code block, exporting
12343 @cindex source code, exporting
12345 It is possible to export the @emph{code} of code blocks, the @emph{results}
12346 of code block evaluation, @emph{both} the code and the results of code block
12347 evaluation, or @emph{none}.  For most languages, the default exports code.
12348 However, for some languages (e.g.@: @code{ditaa}) the default exports the
12349 results of code block evaluation.  For information on exporting code block
12350 bodies, see @ref{Literal examples}.
12352 The @code{:exports} header argument can be used to specify export
12353 behavior:
12355 @subsubheading Header arguments:
12356 @table @code
12357 @item :exports code
12358 The default in most languages.  The body of the code block is exported, as
12359 described in @ref{Literal examples}.
12360 @item :exports results
12361 The code block will be evaluated and the results will be placed in the
12362 Org-mode buffer for export, either updating previous results of the code
12363 block located anywhere in the buffer or, if no previous results exist,
12364 placing the results immediately after the code block.  The body of the code
12365 block will not be exported.
12366 @item :exports both
12367 Both the code block and its results will be exported.
12368 @item :exports none
12369 Neither the code block nor its results will be exported.
12370 @end table
12372 It is possible to inhibit the evaluation of code blocks during export.
12373 Setting the @code{org-export-babel-evaluate} variable to @code{nil} will
12374 ensure that no code blocks are evaluated as part of the export process.  This
12375 can be useful in situations where potentially untrusted Org-mode files are
12376 exported in an automated fashion, for example when Org-mode is used as the
12377 markup language for a wiki.
12379 @comment  node-name,  next,  previous,  up
12380 @comment  Extracting source code, Evaluating code blocks, Exporting code blocks, Working With Source Code
12381 @node Extracting source code, Evaluating code blocks, Exporting code blocks, Working With Source Code
12382 @section Extracting source code
12383 @cindex tangling
12384 @cindex source code, extracting
12385 @cindex code block, extracting source code
12387 Creating pure source code files by extracting code from source blocks is
12388 referred to as ``tangling''---a term adopted from the literate programming
12389 community.  During ``tangling'' of code blocks their bodies are expanded
12390 using @code{org-babel-expand-src-block} which can expand both variable and
12391 ``noweb'' style references  (see @ref{Noweb reference syntax}).
12393 @subsubheading Header arguments
12394 @table @code
12395 @item :tangle no
12396 The default.  The code block is not included in the tangled output.
12397 @item :tangle yes
12398 Include the code block in the tangled output.  The output file name is the
12399 name of the org file with the extension @samp{.org} replaced by the extension
12400 for the block language.
12401 @item :tangle filename
12402 Include the code block in the tangled output to file @samp{filename}.
12403 @end table
12405 @kindex  C-c C-v t
12406 @subsubheading Functions
12407 @table @code
12408 @item org-babel-tangle
12409 Tangle the current file.  Bound to @kbd{C-c C-v t}.
12410 @item org-babel-tangle-file
12411 Choose a file to tangle.  Bound to @kbd{C-c C-v f}.
12412 @end table
12414 @subsubheading Hooks
12415 @table @code
12416 @item org-babel-post-tangle-hook
12417 This hook is run from within code files tangled by @code{org-babel-tangle}.
12418 Example applications could include post-processing, compilation or evaluation
12419 of tangled code files.
12420 @end table
12422 @node Evaluating code blocks, Library of Babel, Extracting source code, Working With Source Code
12423 @section Evaluating code blocks
12424 @cindex code block, evaluating
12425 @cindex source code, evaluating
12427 Code blocks can be evaluated@footnote{Whenever code is evaluated there is a
12428 potential for that code to do harm.  Org-mode provides safeguards to ensure
12429 that code is only evaluated after explicit confirmation from the user.  For
12430 information on these safeguards (and on how to disable them) see @ref{Code
12431 evaluation security}.} and the results of evaluation optionally placed in the
12432 Org-mode buffer.  By default, the evaluation facility is only enabled for
12433 Lisp code blocks specified as @code{emacs-lisp}. However, souce code blocks
12434 in many languages can be evaluated within Org-mode (see @ref{Languages} for a
12435 list of supported languages and @ref{Structure of code blocks} for
12436 information on the syntax used to define a code block).
12438 @kindex C-c C-c
12439 There are a number of ways to evaluate code blocks.  The simplest is to press
12440 @kbd{C-c C-c} or @kbd{C-c C-v e} with the point on a code block@footnote{The
12441 @code{org-babel-no-eval-on-ctrl-c-ctrl-c} variable can be used to remove code
12442 evaluation from the @kbd{C-c C-c} key binding.}.  This will call the
12443 @code{org-babel-execute-src-block} function to evaluate the block and insert
12444 its results into the Org-mode buffer.
12445 @cindex #+CALL
12447 It is also possible to evaluate named code blocks from anywhere in an
12448 Org-mode buffer or an Org-mode table. Live code blocks located in the current
12449 Org-mode buffer or in the ``Library of Babel'' (see @ref{Library of Babel})
12450 can be executed.  Named code blocks can be executed with a separate
12451 @code{#+CALL:} line or inline within a block of text.
12453 The syntax of the @code{#+CALL:} line is
12455 @example
12456 #+CALL: <name>(<arguments>)
12457 #+CALL: <name>[<inside header arguments>](<arguments>) <end header arguments>
12458 @end example
12460 The syntax for inline evaluation of named code blocks is
12462 @example
12463 ... call_<name>(<arguments>) ...
12464 ... call_<name>[<inside header arguments>](<arguments>)[<end header arguments>] ...
12465 @end example
12467 @table @code
12468 @item <name>
12469 The name of the code block to be evaluated (see @ref{Structure of code blocks}).
12470 @item <arguments>
12471 Arguments specified in this section will be passed to the code block.  These
12472 arguments use standard function call syntax, rather than
12473 header argument syntax.  For example, a @code{#+CALL:} line that passes the
12474 number four to a code block named @code{double}, which declares the header
12475 argument @code{:var n=2}, would be written as @code{#+CALL: double(n=4)}.
12476 @item <inside header arguments>
12477 Inside header arguments are passed through and applied to the named code
12478 block.  These arguments use header argument syntax rather than standard
12479 function call syntax.  Inside header arguments affect how the code block is
12480 evaluated. For example, @code{[:results output]} will collect the results of
12481 everything printed to @code{STDOUT} during execution of the code block.
12482 @item <end header arguments>
12483 End header arguments are applied to the calling instance and do not affect
12484 evaluation of the named code block.  They affect how the results are
12485 incorporated into the Org-mode buffer and how the call line is exported.  For
12486 example, @code{:results html} will insert the results of the call line
12487 evaluation in the Org buffer, wrapped in a @code{BEGIN_HTML:} block.
12489 For more examples of passing header arguments to @code{#+CALL:} lines see
12490 @ref{Header arguments in function calls}.
12491 @end table
12493 @node Library of Babel, Languages, Evaluating code blocks, Working With Source Code
12494 @section Library of Babel
12495 @cindex babel, library of
12496 @cindex source code, library
12497 @cindex code block, library
12499 The ``Library of Babel'' consists of code blocks that can be called from any
12500 Org-mode file.  Code blocks defined in the ``Library of Babel'' can be called
12501 remotely as if they were in the current Org-mode buffer (see @ref{Evaluating
12502 code blocks} for information on the syntax of remote code block evaluation).
12505 The central repository of code blocks in the ``Library of Babel'' is housed
12506 in an Org-mode file located in the @samp{contrib} directory of Org-mode.
12508 Users can add code blocks they believe to be generally useful to their
12509 ``Library of Babel.''  The code blocks can be stored in any Org-mode file and
12510 then loaded into the library with @code{org-babel-lob-ingest}.
12513 @kindex C-c C-v i
12514 Code blocks located in any Org-mode file can be loaded into the ``Library of
12515 Babel'' with the @code{org-babel-lob-ingest} function, bound to @kbd{C-c C-v
12518 @node Languages, Header arguments, Library of Babel, Working With Source Code
12519 @section Languages
12520 @cindex babel, languages
12521 @cindex source code, languages
12522 @cindex code block, languages
12524 Code blocks in the following languages are supported.
12526 @multitable @columnfractions 0.28 0.3 0.22 0.2
12527 @item @b{Language} @tab @b{Identifier} @tab @b{Language} @tab @b{Identifier}
12528 @item Asymptote @tab asymptote @tab Awk @tab awk
12529 @item Emacs Calc @tab calc @tab C @tab C
12530 @item C++ @tab C++ @tab Clojure @tab clojure
12531 @item CSS @tab css @tab ditaa @tab ditaa
12532 @item Graphviz @tab dot @tab Emacs Lisp @tab emacs-lisp
12533 @item gnuplot @tab gnuplot @tab Haskell @tab haskell
12534 @item Java @tab java @tab @tab
12535 @item Javascript @tab js @tab LaTeX @tab latex
12536 @item Ledger @tab ledger @tab Lisp @tab lisp
12537 @item Lilypond @tab lilypond @tab MATLAB @tab matlab
12538 @item Mscgen @tab mscgen @tab Objective Caml @tab ocaml
12539 @item Octave @tab octave @tab Org-mode @tab org
12540 @item Oz @tab oz @tab Perl @tab perl
12541 @item Plantuml @tab plantuml @tab Python @tab python
12542 @item R @tab R @tab Ruby @tab ruby
12543 @item Sass @tab sass @tab Scheme @tab scheme
12544 @item GNU Screen @tab screen @tab shell @tab sh
12545 @item SQL @tab sql @tab SQLite @tab sqlite
12546 @end multitable
12548 Language-specific documentation is available for some languages.  If
12549 available, it can be found at
12550 @uref{http://orgmode.org/worg/org-contrib/babel/languages}.
12552 The @code{org-babel-load-languages} controls which languages are enabled for
12553 evaluation (by default only @code{emacs-lisp} is enabled).  This variable can
12554 be set using the customization interface or by adding code like the following
12555 to your emacs configuration.
12557 @quotation
12558 The following disables @code{emacs-lisp} evaluation and enables evaluation of
12559 @code{R} code blocks.
12560 @end quotation
12562 @lisp
12563 (org-babel-do-load-languages
12564  'org-babel-load-languages
12565  '((emacs-lisp . nil)
12566    (R . t)))
12567 @end lisp
12569 It is also possible to enable support for a language by loading the related
12570 elisp file with @code{require}.
12572 @quotation
12573 The following adds support for evaluating @code{clojure} code blocks.
12574 @end quotation
12576 @lisp
12577 (require 'ob-clojure)
12578 @end lisp
12580 @node Header arguments, Results of evaluation, Languages, Working With Source Code
12581 @section Header arguments
12582 @cindex code block, header arguments
12583 @cindex source code, block header arguments
12585 Code block functionality can be configured with header arguments.  This
12586 section provides an overview of the use of header arguments, and then
12587 describes each header argument in detail.
12589 @menu
12590 * Using header arguments::      Different ways to set header arguments
12591 * Specific header arguments::   List of header arguments
12592 @end menu
12594 @node Using header arguments, Specific header arguments, Header arguments, Header arguments
12595 @subsection Using header arguments
12597 The values of header arguments can be set in six different ways, each more
12598 specific (and having higher priority) than the last.
12599 @menu
12600 * System-wide header arguments::  Set global default values
12601 * Language-specific header arguments::  Set default values by language
12602 * Buffer-wide header arguments::  Set default values for a specific buffer
12603 * Header arguments in Org-mode properties::  Set default values for a buffer or heading
12604 * Code block specific header arguments::  The most common way to set values
12605 * Header arguments in function calls::  The most specific level
12606 @end menu
12609 @node System-wide header arguments, Language-specific header arguments, Using header arguments, Using header arguments
12610 @subsubheading System-wide header arguments
12611 @vindex org-babel-default-header-args
12612 System-wide values of header arguments can be specified by customizing the
12613 @code{org-babel-default-header-args} variable:
12615 @example
12616 :session    => "none"
12617 :results    => "replace"
12618 :exports    => "code"
12619 :cache      => "no"
12620 :noweb      => "no"
12621 @end example
12623 @c @example
12624 @c   org-babel-default-header-args is a variable defined in `org-babel.el'.
12625 @c   Its value is
12626 @c   ((:session . "none")
12627 @c    (:results . "replace")
12628 @c    (:exports . "code")
12629 @c    (:cache . "no")
12630 @c    (:noweb . "no"))
12633 @c   Documentation:
12634 @c   Default arguments to use when evaluating a code block.
12635 @c @end example
12637 For example, the following example could be used to set the default value of
12638 @code{:noweb} header arguments to @code{yes}.  This would have the effect of
12639 expanding @code{:noweb} references by default when evaluating source code
12640 blocks.
12642 @lisp
12643 (setq org-babel-default-header-args
12644 (cons '(:noweb . "yes")
12645 (assq-delete-all :noweb org-babel-default-header-args)))
12646 @end lisp
12648 @node Language-specific header arguments, Buffer-wide header arguments, System-wide header arguments, Using header arguments
12649 @subsubheading Language-specific header arguments
12650 Each language can define its own set of default header arguments.  See the
12651 language-specific documentation available online at
12652 @uref{http://orgmode.org/worg/org-contrib/babel}.
12654 @node Buffer-wide header arguments, Header arguments in Org-mode properties, Language-specific header arguments, Using header arguments
12655 @subsubheading Buffer-wide header arguments
12656 Buffer-wide header arguments may be specified as properties through the use
12657 of @code{#+PROPERTY:} lines placed anywhere in an Org-mode file (see
12658 @ref{Property syntax}).
12660 For example the following would set @code{session} to @code{*R*}, and
12661 @code{results} to @code{silent} for every code block in the buffer, ensuring
12662 that all execution took place in the same session, and no results would be
12663 inserted into the buffer.
12665 @example
12666 #+PROPERTY: session *R*
12667 #+PROPERTY: results silent
12668 @end example
12670 @node Header arguments in Org-mode properties, Code block specific header arguments, Buffer-wide header arguments, Using header arguments
12671 @subsubheading Header arguments in Org-mode properties
12673 Header arguments are also read from Org-mode properties (see @ref{Property
12674 syntax}), which can be set on a buffer-wide or per-heading basis.  An example
12675 of setting a header argument for all code blocks in a buffer is
12677 @example
12678 #+PROPERTY: tangle yes
12679 @end example
12681 @vindex org-use-property-inheritance
12682 When properties are used to set default header arguments, they are looked up
12683 with inheritance, regardless of the value of
12684 @code{org-use-property-inheritance}.  In the following example the value of
12685 the @code{:cache} header argument will default to @code{yes} in all code
12686 blocks in the subtree rooted at the following heading:
12688 @example
12689 * outline header
12690 :PROPERTIES:
12691 :cache:    yes
12692 :END:
12693 @end example
12695 @kindex C-c C-x p
12696 @vindex org-babel-default-header-args
12697 Properties defined in this way override the properties set in
12698 @code{org-babel-default-header-args}.  It is convenient to use the
12699 @code{org-set-property} function bound to @kbd{C-c C-x p} to set properties
12700 in Org-mode documents.
12702 @node Code block specific header arguments, Header arguments in function calls, Header arguments in Org-mode properties, Using header arguments
12703 @subsubheading Code block specific header arguments
12705 The most common way to assign values to header arguments is at the
12706 code block level.  This can be done by listing a sequence of header
12707 arguments and their values as part of the @code{#+BEGIN_SRC} line.
12708 Properties set in this way override both the values of
12709 @code{org-babel-default-header-args} and header arguments specified as
12710 properties.  In the following example, the @code{:results} header argument
12711 is set to @code{silent}, meaning the results of execution will not be
12712 inserted in the buffer, and the @code{:exports} header argument is set to
12713 @code{code}, meaning only the body of the code block will be
12714 preserved on export to HTML or LaTeX.
12716 @example
12717 #+NAME: factorial
12718 #+BEGIN_SRC haskell :results silent :exports code :var n=0
12719 fac 0 = 1
12720 fac n = n * fac (n-1)
12721 #+END_SRC
12722 @end example
12723 Similarly, it is possible to set header arguments for inline code blocks
12725 @example
12726 src_haskell[:exports both]@{fac 5@}
12727 @end example
12729 Code block header arguments can span multiple lines using @code{#+HEADER:} or
12730 @code{#+HEADERS:} lines preceding a code block or nested between the
12731 @code{#+NAME:} line and the @code{#+BEGIN_SRC} line of a named code block.
12732 @cindex #+HEADER:
12733 @cindex #+HEADERS:
12735 Multi-line header arguments on an un-named code block:
12736 @example
12737  #+HEADERS: :var data1=1
12738  #+BEGIN_SRC emacs-lisp :var data2=2
12739    (message "data1:%S, data2:%S" data1 data2)
12740  #+END_SRC
12742  #+results:
12743  : data1:1, data2:2
12744 @end example
12746 Multi-line header arguments on a named code block:
12747 @example
12748    #+NAME: named-block
12749    #+HEADER: :var data=2
12750    #+BEGIN_SRC emacs-lisp
12751      (message "data:%S" data)
12752    #+END_SRC
12754    #+results: named-block
12755    : data:2
12756 @end example
12758 @node Header arguments in function calls,  , Code block specific header arguments, Using header arguments
12759 @comment  node-name,  next,  previous,  up
12760 @subsubheading Header arguments in function calls
12762 At the most specific level, header arguments for ``Library of Babel'' or
12763 @code{#+CALL:} lines can be set as shown in the two examples below.  For more
12764 information on the structure of @code{#+CALL:} lines see @ref{Evaluating code
12765 blocks}.
12767 The following will apply the @code{:exports results} header argument to the
12768 evaluation of the @code{#+CALL:} line.
12769 @example
12770 #+CALL: factorial(n=5) :exports results
12771 @end example
12773 The following will apply the @code{:session special} header argument to the
12774 evaluation of the @code{factorial} code block.
12775 @example
12776 #+CALL: factorial[:session special](n=5)
12777 @end example
12779 @node Specific header arguments,  , Using header arguments, Header arguments
12780 @subsection Specific header arguments
12781 Header arguments consist of an initial colon followed by the name of the
12782 argument in lowercase letters.  The following header arguments are defined:
12784 @menu
12785 * var::                         Pass arguments to code blocks
12786 * results::                     Specify the type of results and how they will
12787                                 be collected and handled
12788 * file::                        Specify a path for file output
12789 * dir::                         Specify the default (possibly remote)
12790                                 directory for code block execution
12791 * exports::                     Export code and/or results
12792 * tangle::                      Toggle tangling and specify file name
12793 * mkdirp::                      Toggle creation of parent directories of target
12794                                 files during tangling
12795 * comments::                    Toggle insertion of comments in tangled
12796                                 code files
12797 * padline::                     Control insertion of padding lines in tangled
12798                                 code files
12799 * no-expand::                   Turn off variable assignment and noweb
12800                                 expansion during tangling
12801 * session::                     Preserve the state of code evaluation
12802 * noweb::                       Toggle expansion of noweb references
12803 * noweb-ref::                   Specify block's noweb reference resolution target
12804 * cache::                       Avoid re-evaluating unchanged code blocks
12805 * sep::                         Delimiter for writing tabular results outside Org
12806 * hlines::                      Handle horizontal lines in tables
12807 * colnames::                    Handle column names in tables
12808 * rownames::                    Handle row names in tables
12809 * shebang::                     Make tangled files executable
12810 * eval::                        Limit evaluation of specific code blocks
12811 @end menu
12813 Additional header arguments are defined on a language-specific basis, see
12814 @ref{Languages}.
12816 @node var, results, Specific header arguments, Specific header arguments
12817 @subsubsection @code{:var}
12818 The @code{:var} header argument is used to pass arguments to code blocks.
12819 The specifics of how arguments are included in a code block vary by language;
12820 these are addressed in the language-specific documentation.  However, the
12821 syntax used to specify arguments is the same across all languages.  In every
12822 case, variables require a default value when they are declared.
12824 The values passed to arguments can either be literal values, references, or
12825 Emacs Lisp code (see @ref{var, Emacs Lisp evaluation of variables}). References
12826 include anything in the Org-mode file that takes a @code{#+NAME:},
12827 @code{#+TBLNAME:}, or @code{#+RESULTS:} line.  This includes tables, lists,
12828 @code{#+BEGIN_EXAMPLE} blocks, other code blocks, and the results of other
12829 code blocks.
12831 Argument values can be indexed in a manner similar to arrays (see @ref{var,
12832 Indexable variable values}).
12834 The following syntax is used to pass arguments to code blocks using the
12835 @code{:var} header argument.
12837 @example
12838 :var name=assign
12839 @end example
12841 The argument, @code{assign}, can either be a literal value, such as a string
12842 @samp{"string"} or a number @samp{9}, or a reference to a table, a list, a
12843 literal example, another code block (with or without arguments), or the
12844 results of evaluating another code block.
12846 Here are examples of passing values by reference:
12848 @table @dfn
12850 @item table
12851 an Org mode table named with either a @code{#+NAME:} or @code{#+TBLNAME:} line
12852 @example
12853 #+TBLNAME: example-table
12854 | 1 |
12855 | 2 |
12856 | 3 |
12857 | 4 |
12859 #+NAME: table-length
12860 #+BEGIN_SRC emacs-lisp :var table=example-table
12861 (length table)
12862 #+END_SRC
12864 #+results: table-length
12865 : 4
12866 @end example
12868 @item list
12869 a simple list named with a @code{#+NAME:} line (note that nesting is not
12870 carried through to the source code block)
12872 @example
12873 #+NAME: example-list
12874   - simple
12875     - not
12876     - nested
12877   - list
12879 #+BEGIN_SRC emacs-lisp :var x=example-list
12880   (print x)
12881 #+END_SRC
12883 #+results:
12884 | simple | list |
12885 @end example
12887 @item code block without arguments
12888 a code block name (from the example above), as assigned by @code{#+NAME:},
12889 optionally followed by parentheses
12891 @example
12892 #+BEGIN_SRC emacs-lisp :var length=table-length()
12893 (* 2 length)
12894 #+END_SRC
12896 #+results:
12897 : 8
12898 @end example
12900 @item code block with arguments
12901 a code block name, as assigned by @code{#+NAME:}, followed by parentheses and
12902 optional arguments passed within the parentheses following the
12903 code block name using standard function call syntax
12905 @example
12906 #+NAME: double
12907 #+BEGIN_SRC emacs-lisp :var input=8
12908 (* 2 input)
12909 #+END_SRC
12911 #+results: double
12912 : 16
12914 #+NAME: squared
12915 #+BEGIN_SRC emacs-lisp :var input=double(input=1)
12916 (* input input)
12917 #+END_SRC
12919 #+results: squared
12920 : 4
12921 @end example
12923 @item literal example
12924 a literal example block named with a @code{#+NAME:} line
12926 @example
12927 #+NAME: literal-example
12928 #+BEGIN_EXAMPLE
12929 A literal example
12930 on two lines
12931 #+END_EXAMPLE
12933 #+NAME: read-literal-example
12934 #+BEGIN_SRC emacs-lisp :var x=literal-example
12935   (concatenate 'string x " for you.")
12936 #+END_SRC
12938 #+results: read-literal-example
12939 : A literal example
12940 : on two lines for you.
12942 @end example
12944 @end table
12946 @subsubheading Alternate argument syntax
12947 It is also possible to specify arguments in a potentially more natural way
12948 using the @code{#+NAME:} line of a code block.  As in the following
12949 example, arguments can be packed inside of parentheses, separated by commas,
12950 following the source name.
12952 @example
12953 #+NAME: double(input=0, x=2)
12954 #+BEGIN_SRC emacs-lisp
12955 (* 2 (+ input x))
12956 #+END_SRC
12957 @end example
12959 @subsubheading Indexable variable values
12960 It is possible to reference portions of variable values by ``indexing'' into
12961 the variables.  Indexes are 0 based with negative values counting back from
12962 the end.  If an index is separated by @code{,}s then each subsequent section
12963 will index into the next deepest nesting or dimension of the value.  Note
12964 that this indexing occurs @emph{before} other table related header arguments
12965 like @code{:hlines}, @code{:colnames} and @code{:rownames} are applied.  The
12966 following example assigns the last cell of the first row the table
12967 @code{example-table} to the variable @code{data}:
12969 @example
12970 #+NAME: example-table
12971 | 1 | a |
12972 | 2 | b |
12973 | 3 | c |
12974 | 4 | d |
12976 #+BEGIN_SRC emacs-lisp :var data=example-table[0,-1]
12977   data
12978 #+END_SRC
12980 #+results:
12981 : a
12982 @end example
12984 Ranges of variable values can be referenced using two integers separated by a
12985 @code{:}, in which case the entire inclusive range is referenced.  For
12986 example the following assigns the middle three rows of @code{example-table}
12987 to @code{data}.
12989 @example
12990 #+NAME: example-table
12991 | 1 | a |
12992 | 2 | b |
12993 | 3 | c |
12994 | 4 | d |
12995 | 5 | 3 |
12997 #+BEGIN_SRC emacs-lisp :var data=example-table[1:3]
12998   data
12999 #+END_SRC
13001 #+results:
13002 | 2 | b |
13003 | 3 | c |
13004 | 4 | d |
13005 @end example
13007 Additionally, an empty index, or the single character @code{*}, are both
13008 interpreted to mean the entire range and as such are equivalent to
13009 @code{0:-1}, as shown in the following example in which the entire first
13010 column is referenced.
13012 @example
13013 #+NAME: example-table
13014 | 1 | a |
13015 | 2 | b |
13016 | 3 | c |
13017 | 4 | d |
13019 #+BEGIN_SRC emacs-lisp :var data=example-table[,0]
13020   data
13021 #+END_SRC
13023 #+results:
13024 | 1 | 2 | 3 | 4 |
13025 @end example
13027 It is possible to index into the results of code blocks as well as tables.
13028 Any number of dimensions can be indexed.  Dimensions are separated from one
13029 another by commas, as shown in the following example.
13031 @example
13032 #+NAME: 3D
13033 #+BEGIN_SRC emacs-lisp
13034   '(((1  2  3)  (4  5  6)  (7  8  9))
13035     ((10 11 12) (13 14 15) (16 17 18))
13036     ((19 20 21) (22 23 24) (25 26 27)))
13037 #+END_SRC
13039 #+BEGIN_SRC emacs-lisp :var data=3D[1,,1]
13040   data
13041 #+END_SRC
13043 #+results:
13044 | 11 | 14 | 17 |
13045 @end example
13047 @subsubheading Emacs Lisp evaluation of variables
13049 Emacs lisp code can be used to initialize variable values.  When a variable
13050 value starts with @code{(}, @code{[}, @code{'} or @code{`} it will be
13051 evaluated as Emacs Lisp and the result of the evaluation will be assigned as
13052 the variable value.  The following example demonstrates use of this
13053 evaluation to reliably pass the file-name of the org-mode buffer to a code
13054 block---note that evaluation of header arguments is guaranteed to take place
13055 in the original Org-mode file, while there is no such guarantee for
13056 evaluation of the code block body.
13058 @example
13059 #+BEGIN_SRC sh :var filename=(buffer-file-name) :exports both
13060   wc -w $filename
13061 #+END_SRC
13062 @end example
13064 Note that values read from tables and lists will not be evaluated as
13065 Emacs Lisp, as shown in the following example.
13067 @example
13068 #+NAME: table
13069 | (a b c) |
13071 #+HEADERS: :var data=table[0,0]
13072 #+BEGIN_SRC perl
13073   $data
13074 #+END_SRC
13076 #+results:
13077 : (a b c)
13078 @end example
13080 @node results, file, var, Specific header arguments
13081 @subsubsection @code{:results}
13083 There are three classes of @code{:results} header argument.  Only one option
13084 per class may be supplied per code block.
13086 @itemize @bullet
13087 @item
13088 @b{collection} header arguments specify how the results should be collected
13089 from the code block
13090 @item
13091 @b{type} header arguments specify what type of result the code block will
13092 return---which has implications for how they will be inserted into the
13093 Org-mode buffer
13094 @item
13095 @b{handling} header arguments specify how the results of evaluating the code
13096 block should be handled.
13097 @end itemize
13099 @subsubheading Collection
13100 The following options are mutually exclusive, and specify how the results
13101 should be collected from the code block.
13103 @itemize @bullet
13104 @item @code{value}
13105 This is the default.  The result is the value of the last statement in the
13106 code block.  This header argument places the evaluation in functional
13107 mode.  Note that in some languages, e.g., Python, use of this result type
13108 requires that a @code{return} statement be included in the body of the source
13109 code block.  E.g., @code{:results value}.
13110 @item @code{output}
13111 The result is the collection of everything printed to STDOUT during the
13112 execution of the code block.  This header argument places the
13113 evaluation in scripting mode.  E.g., @code{:results output}.
13114 @end itemize
13116 @subsubheading Type
13118 The following options are mutually exclusive and specify what type of results
13119 the code block will return.  By default, results are inserted as either a
13120 table or scalar depending on their value.
13122 @itemize @bullet
13123 @item @code{table}, @code{vector}
13124 The results should be interpreted as an Org-mode table.  If a single value is
13125 returned, it will be converted into a table with one row and one column.
13126 E.g., @code{:results value table}.
13127 @item @code{list}
13128 The results should be interpreted as an Org-mode list.  If a single scalar
13129 value is returned it will be converted into a list with only one element.
13130 @item @code{scalar}, @code{verbatim}
13131 The results should be interpreted literally---they will not be
13132 converted into a table.  The results will be inserted into the Org-mode
13133 buffer as quoted text.  E.g., @code{:results value verbatim}.
13134 @item @code{file}
13135 The results will be interpreted as the path to a file, and will be inserted
13136 into the Org-mode buffer as a file link.  E.g., @code{:results value file}.
13137 @item @code{raw}, @code{org}
13138 The results are interpreted as raw Org-mode code and are inserted directly
13139 into the buffer.  If the results look like a table they will be aligned as
13140 such by Org-mode.  E.g., @code{:results value raw}.
13141 @item @code{html}
13142 Results are assumed to be HTML and will be enclosed in a @code{begin_html}
13143 block.  E.g., @code{:results value html}.
13144 @item @code{latex}
13145 Results assumed to be LaTeX and are enclosed in a @code{begin_latex} block.
13146 E.g., @code{:results value latex}.
13147 @item @code{code}
13148 Result are assumed to be parseable code and are enclosed in a code block.
13149 E.g., @code{:results value code}.
13150 @item @code{pp}
13151 The result is converted to pretty-printed code and is enclosed in a code
13152 block.  This option currently supports Emacs Lisp, Python, and Ruby.  E.g.,
13153 @code{:results value pp}.
13154 @item @code{wrap}
13155 The result is wrapped in a @code{begin_result} block.  This can be useful for
13156 inserting @code{raw} or @code{org} syntax results in such a way that their
13157 extend is known and they can be automatically removed or replaced.
13158 @end itemize
13160 @subsubheading Handling
13161 The following results options indicate what happens with the
13162 results once they are collected.
13164 @itemize @bullet
13165 @item @code{silent}
13166 The results will be echoed in the minibuffer but will not be inserted into
13167 the Org-mode buffer.  E.g., @code{:results output silent}.
13168 @item @code{replace}
13169 The default value.  Any existing results will be removed, and the new results
13170 will be inserted into the Org-mode buffer in their place.  E.g.,
13171 @code{:results output replace}.
13172 @item @code{append}
13173 If there are pre-existing results of the code block then the new results will
13174 be appended to the existing results.  Otherwise the new results will be
13175 inserted as with @code{replace}.
13176 @item @code{prepend}
13177 If there are pre-existing results of the code block then the new results will
13178 be prepended to the existing results.  Otherwise the new results will be
13179 inserted as with @code{replace}.
13180 @end itemize
13182 @node file, dir, results, Specific header arguments
13183 @subsubsection @code{:file}
13185 The header argument @code{:file} is used to specify an external file in which
13186 to save code block results.  After code block evaluation an Org-mode style
13187 @code{[[file:]]} link (see @ref{Link format}) to the file will be inserted
13188 into the Org-mode buffer.  Some languages including R, gnuplot, dot, and
13189 ditaa provide special handling of the @code{:file} header argument
13190 automatically wrapping the code block body in the boilerplate code required
13191 to save output to the specified file.  This is often useful for saving
13192 graphical output of a code block to the specified file.
13194 The argument to @code{:file} should be either a string specifying the path to
13195 a file, or a list of two strings in which case the first element of the list
13196 should be the path to a file and the second a description for the link.
13198 @node dir, exports, file, Specific header arguments
13199 @subsubsection @code{:dir} and remote execution
13201 While the @code{:file} header argument can be used to specify the path to the
13202 output file, @code{:dir} specifies the default directory during code block
13203 execution.  If it is absent, then the directory associated with the current
13204 buffer is used.  In other words, supplying @code{:dir path} temporarily has
13205 the same effect as changing the current directory with @kbd{M-x cd path}, and
13206 then not supplying @code{:dir}.  Under the surface, @code{:dir} simply sets
13207 the value of the Emacs variable @code{default-directory}.
13209 When using @code{:dir}, you should supply a relative path for file output
13210 (e.g.@: @code{:file myfile.jpg} or @code{:file results/myfile.jpg}) in which
13211 case that path will be interpreted relative to the default directory.
13213 In other words, if you want your plot to go into a folder called @file{Work}
13214 in your home directory, you could use
13216 @example
13217 #+BEGIN_SRC R :file myplot.png :dir ~/Work
13218 matplot(matrix(rnorm(100), 10), type="l")
13219 #+END_SRC
13220 @end example
13222 @subsubheading Remote execution
13223 A directory on a remote machine can be specified using tramp file syntax, in
13224 which case the code will be evaluated on the remote machine.  An example is
13226 @example
13227 #+BEGIN_SRC R :file plot.png :dir /dand@@yakuba.princeton.edu:
13228 plot(1:10, main=system("hostname", intern=TRUE))
13229 #+END_SRC
13230 @end example
13232 Text results will be returned to the local Org-mode buffer as usual, and file
13233 output will be created on the remote machine with relative paths interpreted
13234 relative to the remote directory.  An Org-mode link to the remote file will be
13235 created.
13237 So, in the above example a plot will be created on the remote machine,
13238 and a link of the following form will be inserted in the org buffer:
13240 @example
13241 [[file:/scp:dand@@yakuba.princeton.edu:/home/dand/plot.png][plot.png]]
13242 @end example
13244 Most of this functionality follows immediately from the fact that @code{:dir}
13245 sets the value of the Emacs variable @code{default-directory}, thanks to
13246 tramp.  Those using XEmacs, or GNU Emacs prior to version 23 may need to
13247 install tramp separately in order for these features to work correctly.
13249 @subsubheading Further points
13251 @itemize @bullet
13252 @item
13253 If @code{:dir} is used in conjunction with @code{:session}, although it will
13254 determine the starting directory for a new session as expected, no attempt is
13255 currently made to alter the directory associated with an existing session.
13256 @item
13257 @code{:dir} should typically not be used to create files during export with
13258 @code{:exports results} or @code{:exports both}.  The reason is that, in order
13259 to retain portability of exported material between machines, during export
13260 links inserted into the buffer will @emph{not} be expanded against @code{default
13261 directory}.  Therefore, if @code{default-directory} is altered using
13262 @code{:dir}, it is probable that the file will be created in a location to
13263 which the link does not point.
13264 @end itemize
13266 @node exports, tangle, dir, Specific header arguments
13267 @subsubsection @code{:exports}
13269 The @code{:exports} header argument specifies what should be included in HTML
13270 or LaTeX exports of the Org-mode file.
13272 @itemize @bullet
13273 @item @code{code}
13274 The default.  The body of code is included into the exported file.  E.g.,
13275 @code{:exports code}.
13276 @item @code{results}
13277 The result of evaluating the code is included in the exported file.  E.g.,
13278 @code{:exports results}.
13279 @item @code{both}
13280 Both the code and results are included in the exported file.  E.g.,
13281 @code{:exports both}.
13282 @item @code{none}
13283 Nothing is included in the exported file.  E.g., @code{:exports none}.
13284 @end itemize
13286 @node tangle, mkdirp, exports, Specific header arguments
13287 @subsubsection @code{:tangle}
13289 The @code{:tangle} header argument specifies whether or not the code
13290 block should be included in tangled extraction of source code files.
13292 @itemize @bullet
13293 @item @code{tangle}
13294 The code block is exported to a source code file named after the full path
13295 (including the directory) and file name (w/o extension) of the Org-mode file.
13296 E.g., @code{:tangle yes}.
13297 @item @code{no}
13298 The default.  The code block is not exported to a source code file.
13299 E.g., @code{:tangle no}.
13300 @item other
13301 Any other string passed to the @code{:tangle} header argument is interpreted
13302 as a path (directory and file name relative to the directory of the Org-mode
13303 file) to which the block will be exported.  E.g., @code{:tangle path}.
13304 @end itemize
13306 @node mkdirp, comments, tangle, Specific header arguments
13307 @subsubsection @code{:mkdirp}
13309 The @code{:mkdirp} header argument can be used to create parent directories
13310 of tangled files when missing.  This can be set to @code{yes} to enable
13311 directory creation or to @code{no} to inhibit directory creation.
13313 @node comments, padline, mkdirp, Specific header arguments
13314 @subsubsection @code{:comments}
13315 By default code blocks are tangled to source-code files without any insertion
13316 of comments beyond those which may already exist in the body of the code
13317 block.  The @code{:comments} header argument can be set as follows to control
13318 the insertion of extra comments into the tangled code file.
13320 @itemize @bullet
13321 @item @code{no}
13322 The default.  No extra comments are inserted during tangling.
13323 @item @code{link}
13324 The code block is wrapped in comments which contain pointers back to the
13325 original Org file from which the code was tangled.
13326 @item @code{yes}
13327 A synonym for ``link'' to maintain backwards compatibility.
13328 @item @code{org}
13329 Include text from the org-mode file as a comment.
13331 The text is picked from the leading context of the tangled code and is
13332 limited by the nearest headline or source block as the case may be.
13333 @item @code{both}
13334 Turns on both the ``link'' and ``org'' comment options.
13335 @item @code{noweb}
13336 Turns on the ``link'' comment option, and additionally wraps expanded noweb
13337 references in the code block body in link comments.
13338 @end itemize
13340 @node padline, no-expand, comments, Specific header arguments
13341 @subsubsection @code{:padline}
13342 Control in insertion of padding lines around code block bodies in tangled
13343 code files.  The default value is @code{yes} which results in insertion of
13344 newlines before and after each tangled code block.  The following arguments
13345 are accepted.
13347 @itemize @bullet
13348 @item @code{yes}
13349 Insert newlines before and after each code block body in tangled code files.
13350 @item @code{no}
13351 Do not insert any newline padding in tangled output.
13352 @end itemize
13354 @node no-expand, session, padline, Specific header arguments
13355 @subsubsection @code{:no-expand}
13357 By default, code blocks are expanded with @code{org-babel-expand-src-block}
13358 during tangling.  This has the effect of assigning values to variables
13359 specified with @code{:var} (see @ref{var}), and of replacing ``noweb''
13360 references (see @ref{Noweb reference syntax}) with their targets.  The
13361 @code{:no-expand} header argument can be used to turn off this behavior.
13363 @node session, noweb, no-expand, Specific header arguments
13364 @subsubsection @code{:session}
13366 The @code{:session} header argument starts a session for an interpreted
13367 language where state is preserved.
13369 By default, a session is not started.
13371 A string passed to the @code{:session} header argument will give the session
13372 a name.  This makes it possible to run concurrent sessions for each
13373 interpreted language.
13375 @node noweb, noweb-ref, session, Specific header arguments
13376 @subsubsection @code{:noweb}
13378 The @code{:noweb} header argument controls expansion of ``noweb'' style (see
13379 @ref{Noweb reference syntax}) references in a code block.  This header
13380 argument can have one of three values: @code{yes}, @code{no}, or @code{tangle}.
13382 @itemize @bullet
13383 @item @code{yes}
13384 All ``noweb'' syntax references in the body of the code block will be
13385 expanded before the block is evaluated, tangled or exported.
13386 @item @code{no}
13387 The default.  No ``noweb'' syntax specific action is taken on evaluating
13388 code blocks, However, noweb references will still be expanded during
13389 tangling.
13390 @item @code{tangle}
13391 All ``noweb'' syntax references in the body of the code block will be
13392 expanded before the block is tangled, however ``noweb'' references will not
13393 be expanded when the block is evaluated or exported.
13394 @end itemize
13396 @subsubheading Noweb prefix lines
13397 Noweb insertions are now placed behind the line prefix of the
13398 @code{<<reference>>}.
13399 This behavior is illustrated in the following example.  Because the
13400 @code{<<example>>} noweb reference appears behind the SQL comment syntax,
13401 each line of the expanded noweb reference will be commented.
13403 This code block:
13405 @example
13406 -- <<example>>
13407 @end example
13410 expands to:
13412 @example
13413 -- this is the
13414 -- multi-line body of example
13415 @end example
13417 Note that noweb replacement text that does not contain any newlines will not
13418 be affected by this change, so it is still possible to use inline noweb
13419 references.
13421 @node noweb-ref, cache, noweb, Specific header arguments
13422 @subsubsection @code{:noweb-ref}
13423 When expanding ``noweb'' style references the bodies of all code block with
13424 @emph{either} a block name matching the reference name @emph{or} a
13425 @code{:noweb-ref} header argument matching the reference name will be
13426 concatenated together to form the replacement text.
13428 By setting this header argument at the sub-tree or file level, simple code
13429 block concatenation may be achieved.  For example, when tangling the
13430 following Org-mode file, the bodies of code blocks will be concatenated into
13431 the resulting pure code file.
13433 @example
13434  #+BEGIN_SRC sh :tangle yes :noweb yes :shebang #!/bin/sh
13435    <<fullest-disk>>
13436  #+END_SRC
13437  * the mount point of the fullest disk
13438    :PROPERTIES:
13439    :noweb-ref: fullest-disk
13440    :END:
13442  ** query all mounted disks
13443  #+BEGIN_SRC sh
13444    df \
13445  #+END_SRC
13447  ** strip the header row
13448  #+BEGIN_SRC sh
13449    |sed '1d' \
13450  #+END_SRC
13452  ** sort by the percent full
13453  #+BEGIN_SRC sh
13454    |awk '@{print $5 " " $6@}'|sort -n |tail -1 \
13455  #+END_SRC
13457  ** extract the mount point
13458  #+BEGIN_SRC sh
13459    |awk '@{print $2@}'
13460  #+END_SRC
13461 @end example
13463 @node cache, sep, noweb-ref, Specific header arguments
13464 @subsubsection @code{:cache}
13466 The @code{:cache} header argument controls the use of in-buffer caching of
13467 the results of evaluating code blocks.  It can be used to avoid re-evaluating
13468 unchanged code blocks.  This header argument can have one of two
13469 values: @code{yes} or @code{no}.
13471 @itemize @bullet
13472 @item @code{no}
13473 The default.  No caching takes place, and the code block will be evaluated
13474 every time it is called.
13475 @item @code{yes}
13476 Every time the code block is run a SHA1 hash of the code and arguments
13477 passed to the block will be generated.  This hash is packed into the
13478 @code{#+results:} line and will be checked on subsequent
13479 executions of the code block.  If the code block has not
13480 changed since the last time it was evaluated, it will not be re-evaluated.
13481 @end itemize
13483 Code block caches notice if the value of a variable argument
13484 to the code block has changed.  If this is the case, the cache is
13485 invalidated and the code block is re-run.  In the following example,
13486 @code{caller} will not be re-run unless the results of @code{random} have
13487 changed since it was last run.
13489 @example
13490  #+NAME: random
13491  #+BEGIN_SRC R :cache yes
13492  runif(1)
13493  #+END_SRC
13495  #+results[a2a72cd647ad44515fab62e144796432793d68e1]: random
13496  0.4659510825295
13498  #+NAME: caller
13499  #+BEGIN_SRC emacs-lisp :var x=random :cache yes
13501  #+END_SRC
13503  #+results[bec9c8724e397d5df3b696502df3ed7892fc4f5f]: caller
13504  0.254227238707244
13505 @end example
13507 @node sep, hlines, cache, Specific header arguments
13508 @subsubsection @code{:sep}
13510 The @code{:sep} header argument can be used to control the delimiter used
13511 when writing tabular results out to files external to Org-mode.  This is used
13512 either when opening tabular results of a code block by calling the
13513 @code{org-open-at-point} function bound to @kbd{C-c C-o} on the code block,
13514 or when writing code block results to an external file (see @ref{file})
13515 header argument.
13517 By default, when @code{:sep} is not specified output tables are tab
13518 delimited.
13520 @node hlines, colnames, sep, Specific header arguments
13521 @subsubsection @code{:hlines}
13523 Tables are frequently represented with one or more horizontal lines, or
13524 hlines.  The @code{:hlines} argument to a code block accepts the
13525 values @code{yes} or @code{no}, with a default value of @code{no}.
13527 @itemize @bullet
13528 @item @code{no}
13529 Strips horizontal lines from the input table.  In most languages this is the
13530 desired effect because an @code{hline} symbol is interpreted as an unbound
13531 variable and raises an error.  Setting @code{:hlines no} or relying on the
13532 default value yields the following results.
13534 @example
13535 #+TBLNAME: many-cols
13536 | a | b | c |
13537 |---+---+---|
13538 | d | e | f |
13539 |---+---+---|
13540 | g | h | i |
13542 #+NAME: echo-table
13543 #+BEGIN_SRC python :var tab=many-cols
13544   return tab
13545 #+END_SRC
13547 #+results: echo-table
13548 | a | b | c |
13549 | d | e | f |
13550 | g | h | i |
13551 @end example
13553 @item @code{yes}
13554 Leaves hlines in the table.  Setting @code{:hlines yes} has this effect.
13556 @example
13557 #+TBLNAME: many-cols
13558 | a | b | c |
13559 |---+---+---|
13560 | d | e | f |
13561 |---+---+---|
13562 | g | h | i |
13564 #+NAME: echo-table
13565 #+BEGIN_SRC python :var tab=many-cols :hlines yes
13566   return tab
13567 #+END_SRC
13569 #+results: echo-table
13570 | a | b | c |
13571 |---+---+---|
13572 | d | e | f |
13573 |---+---+---|
13574 | g | h | i |
13575 @end example
13576 @end itemize
13578 @node colnames, rownames, hlines, Specific header arguments
13579 @subsubsection @code{:colnames}
13581 The @code{:colnames} header argument accepts the values @code{yes},
13582 @code{no}, or @code{nil} for unassigned.  The default value is @code{nil}.
13583 Note that the behavior of the @code{:colnames} header argument may differ
13584 across languages.  For example Emacs Lisp code blocks ignore the
13585 @code{:colnames} header argument entirely given the ease with which tables
13586 with column names may be handled directly in Emacs Lisp.
13588 @itemize @bullet
13589 @item @code{nil}
13590 If an input table looks like it has column names
13591 (because its second row is an hline), then the column
13592 names will be removed from the table before
13593 processing, then reapplied to the results.
13595 @example
13596 #+TBLNAME: less-cols
13597 | a |
13598 |---|
13599 | b |
13600 | c |
13602 #+NAME: echo-table-again
13603 #+BEGIN_SRC python :var tab=less-cols
13604   return [[val + '*' for val in row] for row in tab]
13605 #+END_SRC
13607 #+results: echo-table-again
13608 | a  |
13609 |----|
13610 | b* |
13611 | c* |
13612 @end example
13614 Please note that column names are not removed before the table is indexed
13615 using variable indexing @xref{var, Indexable variable values}.
13617 @item @code{no}
13618 No column name pre-processing takes place
13620 @item @code{yes}
13621 Column names are removed and reapplied as with @code{nil} even if the table
13622 does not ``look like'' it has column names (i.e.@: the second row is not an
13623 hline)
13624 @end itemize
13626 @node rownames, shebang, colnames, Specific header arguments
13627 @subsubsection @code{:rownames}
13629 The @code{:rownames} header argument can take on the values @code{yes}
13630 or @code{no}, with a default value of @code{no}.
13632 @itemize @bullet
13633 @item @code{no}
13634 No row name pre-processing will take place.
13636 @item @code{yes}
13637 The first column of the table is removed from the table before processing,
13638 and is then reapplied to the results.
13640 @example
13641 #+TBLNAME: with-rownames
13642 | one | 1 | 2 | 3 | 4 |  5 |
13643 | two | 6 | 7 | 8 | 9 | 10 |
13645 #+NAME: echo-table-once-again
13646 #+BEGIN_SRC python :var tab=with-rownames :rownames yes
13647   return [[val + 10 for val in row] for row in tab]
13648 #+END_SRC
13650 #+results: echo-table-once-again
13651 | one | 11 | 12 | 13 | 14 | 15 |
13652 | two | 16 | 17 | 18 | 19 | 20 |
13653 @end example
13655 Please note that row names are not removed before the table is indexed using
13656 variable indexing @xref{var, Indexable variable values}.
13658 @end itemize
13660 @node shebang, eval, rownames, Specific header arguments
13661 @subsubsection @code{:shebang}
13663 Setting the @code{:shebang} header argument to a string value
13664 (e.g.@: @code{:shebang "#!/bin/bash"}) causes the string to be inserted as the
13665 first line of any tangled file holding the code block, and the file
13666 permissions of the tangled file are set to make it executable.
13668 @node eval,  , shebang, Specific header arguments
13669 @subsubsection @code{:eval}
13670 The @code{:eval} header argument can be used to limit the evaluation of
13671 specific code blocks.  The @code{:eval} header argument can be useful for
13672 protecting against the evaluation of dangerous code blocks or to ensure that
13673 evaluation will require a query regardless of the value of the
13674 @code{org-confirm-babel-evaluate} variable.  The possible values of
13675 @code{:eval} and their effects are shown below.
13677 @table @code
13678 @item never or no
13679 The code block will not be evaluated under any circumstances.
13680 @item query
13681 Evaluation of the code block will require a query.
13682 @item never-export or no-export
13683 The code block will not be evaluated during export but may still be called
13684 interactively.
13685 @item query-export
13686 Evaluation of the code block during export will require a query.
13687 @end table
13689 If this header argument is not set then evaluation is determined by the value
13690 of the @code{org-confirm-babel-evaluate} variable see @ref{Code evaluation
13691 security}.
13693 @node Results of evaluation, Noweb reference syntax, Header arguments, Working With Source Code
13694 @section Results of evaluation
13695 @cindex code block, results of evaluation
13696 @cindex source code, results of evaluation
13698 The way in which results are handled depends on whether a session is invoked,
13699 as well as on whether @code{:results value} or @code{:results output} is
13700 used.  The following table shows the table possibilities.  For a full listing
13701 of the possible results header arguments see @ref{results}.
13703 @multitable @columnfractions 0.26 0.33 0.41
13704 @item @tab @b{Non-session} @tab @b{Session}
13705 @item @code{:results value} @tab value of last expression @tab value of last expression
13706 @item @code{:results output} @tab contents of STDOUT @tab concatenation of interpreter output
13707 @end multitable
13709 Note: With @code{:results value}, the result in both @code{:session} and
13710 non-session is returned to Org-mode as a table (a one- or two-dimensional
13711 vector of strings or numbers) when appropriate.
13713 @subsection Non-session
13714 @subsubsection @code{:results value}
13715 This is the default.  Internally, the value is obtained by wrapping the code
13716 in a function definition in the external language, and evaluating that
13717 function.  Therefore, code should be written as if it were the body of such a
13718 function.  In particular, note that Python does not automatically return a
13719 value from a function unless a @code{return} statement is present, and so a
13720 @samp{return} statement will usually be required in Python.
13722 This is the only one of the four evaluation contexts in which the code is
13723 automatically wrapped in a function definition.
13725 @subsubsection @code{:results output}
13726 The code is passed to the interpreter as an external process, and the
13727 contents of the standard output stream are returned as text.  (In certain
13728 languages this also contains the error output stream; this is an area for
13729 future work.)
13731 @subsection Session
13732 @subsubsection @code{:results value}
13733 The code is passed to an interpreter running as an interactive Emacs inferior
13734 process.  Only languages which provide tools for interactive evaluation of
13735 code have session support, so some language (e.g., C and ditaa) do not
13736 support the @code{:session} header argument, and in other languages (e.g.,
13737 Python and Haskell) which have limitations on the code which may be entered
13738 into interactive sessions, those limitations apply to the code in code blocks
13739 using the @code{:session} header argument as well.
13741 Unless the @code{:results output} option is supplied (see below) the result
13742 returned is the result of the last evaluation performed by the
13743 interpreter.  (This is obtained in a language-specific manner: the value of
13744 the variable @code{_} in Python and Ruby, and the value of @code{.Last.value}
13745 in R).
13747 @subsubsection @code{:results output}
13748 The code is passed to the interpreter running as an interactive Emacs
13749 inferior process.  The result returned is the concatenation of the sequence of
13750 (text) output from the interactive interpreter.  Notice that this is not
13751 necessarily the same as what would be sent to @code{STDOUT} if the same code
13752 were passed to a non-interactive interpreter running as an external
13753 process.  For example, compare the following two blocks:
13755 @example
13756 #+BEGIN_SRC python :results output
13757  print "hello"
13759  print "bye"
13760 #+END_SRC
13762 #+results:
13763 : hello
13764 : bye
13765 @end example
13767 In non-session mode, the `2' is not printed and does not appear.
13768 @example
13769 #+BEGIN_SRC python :results output :session
13770  print "hello"
13772  print "bye"
13773 #+END_SRC
13775 #+results:
13776 : hello
13777 : 2
13778 : bye
13779 @end example
13781 But in @code{:session} mode, the interactive interpreter receives input `2'
13782 and prints out its value, `2'.  (Indeed, the other print statements are
13783 unnecessary here).
13785 @node Noweb reference syntax, Key bindings and useful functions, Results of evaluation, Working With Source Code
13786 @section Noweb reference syntax
13787 @cindex code block, noweb reference
13788 @cindex syntax, noweb
13789 @cindex source code, noweb reference
13791 The ``noweb'' (see @uref{http://www.cs.tufts.edu/~nr/noweb/}) Literate
13792 Programming system allows named blocks of code to be referenced by using the
13793 familiar Noweb syntax:
13795 @example
13796 <<code-block-name>>
13797 @end example
13799 When a code block is tangled or evaluated, whether or not ``noweb''
13800 references are expanded depends upon the value of the @code{:noweb} header
13801 argument.  If @code{:noweb yes}, then a Noweb reference is expanded before
13802 evaluation.  If @code{:noweb no}, the default, then the reference is not
13803 expanded before evaluation.
13805 Note: the default value, @code{:noweb no}, was chosen to ensure that
13806 correct code is not broken in a language, such as Ruby, where
13807 @code{<<arg>>} is a syntactically valid construct.  If @code{<<arg>>} is not
13808 syntactically valid in languages that you use, then please consider setting
13809 the default value.
13811 @node Key bindings and useful functions, Batch execution, Noweb reference syntax, Working With Source Code
13812 @section Key bindings and useful functions
13813 @cindex code block, key bindings
13815 Many common Org-mode key sequences are re-bound depending on
13816 the context.
13818 Within a code block, the following key bindings
13819 are active:
13821 @multitable @columnfractions 0.25 0.75
13822 @kindex C-c C-c
13823 @item @kbd{C-c C-c} @tab @code{org-babel-execute-src-block}
13824 @kindex C-c C-o
13825 @item @kbd{C-c C-o} @tab @code{org-babel-open-src-block-result}
13826 @kindex C-up
13827 @item @kbd{C-@key{up}}    @tab @code{org-babel-load-in-session}
13828 @kindex M-down
13829 @item @kbd{M-@key{down}}  @tab @code{org-babel-pop-to-session}
13830 @end multitable
13832 In an Org-mode buffer, the following key bindings are active:
13834 @multitable @columnfractions 0.45 0.55
13835 @kindex C-c C-v a
13836 @kindex C-c C-v C-a
13837 @item @kbd{C-c C-v a} @ @ @r{or} @ @ @kbd{C-c C-v C-a} @tab @code{org-babel-sha1-hash}
13838 @kindex C-c C-v b
13839 @kindex C-c C-v C-b
13840 @item @kbd{C-c C-v b} @ @ @r{or} @ @ @kbd{C-c C-v C-b} @tab @code{org-babel-execute-buffer}
13841 @kindex C-c C-v f
13842 @kindex C-c C-v C-f
13843 @item @kbd{C-c C-v f} @ @ @r{or} @ @ @kbd{C-c C-v C-f} @tab @code{org-babel-tangle-file}
13844 @kindex C-c C-v g
13845 @item @kbd{C-c C-v g} @tab @code{org-babel-goto-named-source-block}
13846 @kindex C-c C-v h
13847 @item @kbd{C-c C-v h} @tab @code{org-babel-describe-bindings}
13848 @kindex C-c C-v l
13849 @kindex C-c C-v C-l
13850 @item @kbd{C-c C-v l} @ @ @r{or} @ @ @kbd{C-c C-v C-l} @tab @code{org-babel-lob-ingest}
13851 @kindex C-c C-v p
13852 @kindex C-c C-v C-p
13853 @item @kbd{C-c C-v p} @ @ @r{or} @ @ @kbd{C-c C-v C-p} @tab @code{org-babel-expand-src-block}
13854 @kindex C-c C-v s
13855 @kindex C-c C-v C-s
13856 @item @kbd{C-c C-v s} @ @ @r{or} @ @ @kbd{C-c C-v C-s} @tab @code{org-babel-execute-subtree}
13857 @kindex C-c C-v t
13858 @kindex C-c C-v C-t
13859 @item @kbd{C-c C-v t} @ @ @r{or} @ @ @kbd{C-c C-v C-t} @tab @code{org-babel-tangle}
13860 @kindex C-c C-v z
13861 @kindex C-c C-v C-z
13862 @item @kbd{C-c C-v z} @ @ @r{or} @ @ @kbd{C-c C-v C-z} @tab @code{org-babel-switch-to-session}
13863 @end multitable
13865 @c When possible these keybindings were extended to work when the control key is
13866 @c kept pressed, resulting in the following additional keybindings.
13868 @c @multitable @columnfractions 0.25 0.75
13869 @c @item @kbd{C-c C-v C-a} @tab @code{org-babel-sha1-hash}
13870 @c @item @kbd{C-c C-v C-b} @tab @code{org-babel-execute-buffer}
13871 @c @item @kbd{C-c C-v C-f} @tab @code{org-babel-tangle-file}
13872 @c @item @kbd{C-c C-v C-l} @tab @code{org-babel-lob-ingest}
13873 @c @item @kbd{C-c C-v C-p} @tab @code{org-babel-expand-src-block}
13874 @c @item @kbd{C-c C-v C-s} @tab @code{org-babel-execute-subtree}
13875 @c @item @kbd{C-c C-v C-t} @tab @code{org-babel-tangle}
13876 @c @item @kbd{C-c C-v C-z} @tab @code{org-babel-switch-to-session}
13877 @c @end multitable
13879 @node Batch execution,  , Key bindings and useful functions, Working With Source Code
13880 @section Batch execution
13881 @cindex code block, batch execution
13882 @cindex source code, batch execution
13884 It is possible to call functions from the command line.  This shell
13885 script calls @code{org-babel-tangle} on every one of its arguments.
13887 Be sure to adjust the paths to fit your system.
13889 @example
13890 #!/bin/sh
13891 # -*- mode: shell-script -*-
13893 # tangle files with org-mode
13895 DIR=`pwd`
13896 FILES=""
13897 ORGINSTALL="~/src/org/lisp/org-install.el"
13899 # wrap each argument in the code required to call tangle on it
13900 for i in $@@; do
13901     FILES="$FILES \"$i\""
13902 done
13904 emacs -Q --batch -l $ORGINSTALL \
13905 --eval "(progn
13906 (add-to-list 'load-path (expand-file-name \"~/src/org/lisp/\"))
13907 (add-to-list 'load-path (expand-file-name \"~/src/org/contrib/lisp/\"))
13908 (require 'org)(require 'org-exp)(require 'ob)(require 'ob-tangle)
13909 (mapc (lambda (file)
13910        (find-file (expand-file-name file \"$DIR\"))
13911        (org-babel-tangle)
13912        (kill-buffer)) '($FILES)))" 2>&1 |grep tangled
13913 @end example
13915 @node Miscellaneous, Hacking, Working With Source Code, Top
13916 @chapter Miscellaneous
13918 @menu
13919 * Completion::                  M-TAB knows what you need
13920 * Easy Templates::              Quick insertion of structural elements
13921 * Speed keys::                  Electric commands at the beginning of a headline
13922 * Code evaluation security::    Org mode files evaluate inline code
13923 * Customization::               Adapting Org to your taste
13924 * In-buffer settings::          Overview of the #+KEYWORDS
13925 * The very busy C-c C-c key::   When in doubt, press C-c C-c
13926 * Clean view::                  Getting rid of leading stars in the outline
13927 * TTY keys::                    Using Org on a tty
13928 * Interaction::                 Other Emacs packages
13929 * org-crypt.el::                Encrypting Org files
13930 @end menu
13933 @node Completion, Easy Templates, Miscellaneous, Miscellaneous
13934 @section Completion
13935 @cindex completion, of @TeX{} symbols
13936 @cindex completion, of TODO keywords
13937 @cindex completion, of dictionary words
13938 @cindex completion, of option keywords
13939 @cindex completion, of tags
13940 @cindex completion, of property keys
13941 @cindex completion, of link abbreviations
13942 @cindex @TeX{} symbol completion
13943 @cindex TODO keywords completion
13944 @cindex dictionary word completion
13945 @cindex option keyword completion
13946 @cindex tag completion
13947 @cindex link abbreviations, completion of
13949 Emacs would not be Emacs without completion, and Org-mode uses it whenever it
13950 makes sense.  If you prefer an @i{iswitchb}- or @i{ido}-like interface for
13951 some of the completion prompts, you can specify your preference by setting at
13952 most one of the variables @code{org-completion-use-iswitchb}
13953 @code{org-completion-use-ido}.
13955 Org supports in-buffer completion.  This type of completion does
13956 not make use of the minibuffer.  You simply type a few letters into
13957 the buffer and use the key to complete text right there.
13959 @table @kbd
13960 @kindex M-@key{TAB}
13961 @item M-@key{TAB}
13962 Complete word at point
13963 @itemize @bullet
13964 @item
13965 At the beginning of a headline, complete TODO keywords.
13966 @item
13967 After @samp{\}, complete @TeX{} symbols supported by the exporter.
13968 @item
13969 After @samp{*}, complete headlines in the current buffer so that they
13970 can be used in search links like @samp{[[*find this headline]]}.
13971 @item
13972 After @samp{:} in a headline, complete tags.  The list of tags is taken
13973 from the variable @code{org-tag-alist} (possibly set through the
13974 @samp{#+TAGS} in-buffer option, @pxref{Setting tags}), or it is created
13975 dynamically from all tags used in the current buffer.
13976 @item
13977 After @samp{:} and not in a headline, complete property keys.  The list
13978 of keys is constructed dynamically from all keys used in the current
13979 buffer.
13980 @item
13981 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
13982 @item
13983 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
13984 @samp{OPTIONS} which set file-specific options for Org-mode.  When the
13985 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
13986 will insert example settings for this keyword.
13987 @item
13988 In the line after @samp{#+STARTUP: }, complete startup keywords,
13989 i.e.@: valid keys for this line.
13990 @item
13991 Elsewhere, complete dictionary words using Ispell.
13992 @end itemize
13993 @end table
13995 @node Easy Templates, Speed keys, Completion, Miscellaneous
13996 @section Easy Templates
13997 @cindex template insertion
13998 @cindex insertion, of templates
14000 Org-mode supports insertion of empty structural elements (like
14001 @code{#+BEGIN_SRC} and @code{#+END_SRC} pairs) with just a few key
14002 strokes.  This is achieved through a native template expansion mechanism.
14003 Note that Emacs has several other template mechanisms which could be used in
14004 a similar way, for example @file{yasnippet}.
14006 To insert a structural element, type a @samp{<}, followed by a template
14007 selector and @kbd{@key{TAB}}.  Completion takes effect only when the above
14008 keystrokes are typed on a line by itself.
14010 The following template selectors are currently supported.
14012 @multitable @columnfractions 0.1 0.9
14013 @item @kbd{s} @tab @code{#+begin_src     ... #+end_src}
14014 @item @kbd{e} @tab @code{#+begin_example ... #+end_example}
14015 @item @kbd{q} @tab @code{#+begin_quote   ... #+end_quote}
14016 @item @kbd{v} @tab @code{#+begin_verse   ... #+end_verse}
14017 @item @kbd{c} @tab @code{#+begin_center  ... #+end_center}
14018 @item @kbd{l} @tab @code{#+begin_latex   ... #+end_latex}
14019 @item @kbd{L} @tab @code{#+latex:}
14020 @item @kbd{h} @tab @code{#+begin_html    ... #+end_html}
14021 @item @kbd{H} @tab @code{#+html:}
14022 @item @kbd{a} @tab @code{#+begin_ascii   ... #+end_ascii}
14023 @item @kbd{A} @tab @code{#+ascii:}
14024 @item @kbd{i} @tab @code{#+index:} line
14025 @item @kbd{I} @tab @code{#+include:} line
14026 @end multitable
14028 For example, on an empty line, typing "<e" and then pressing TAB, will expand
14029 into a complete EXAMPLE template.
14031 You can install additional templates by customizing the variable
14032 @code{org-structure-template-alist}.  See the docstring of the variable for
14033 additional details.
14035 @node Speed keys, Code evaluation security, Easy Templates, Miscellaneous
14036 @section Speed keys
14037 @cindex speed keys
14038 @vindex org-use-speed-commands
14039 @vindex org-speed-commands-user
14041 Single keys can be made to execute commands when the cursor is at the
14042 beginning of a headline, i.e.@: before the first star.  Configure the variable
14043 @code{org-use-speed-commands} to activate this feature.  There is a
14044 pre-defined list of commands, and you can add more such commands using the
14045 variable @code{org-speed-commands-user}.  Speed keys do not only speed up
14046 navigation and other commands, but they also provide an alternative way to
14047 execute commands bound to keys that are not or not easily available on a TTY,
14048 or on a small mobile device with a limited keyboard.
14050 To see which commands are available, activate the feature and press @kbd{?}
14051 with the cursor at the beginning of a headline.
14053 @node Code evaluation security, Customization, Speed keys, Miscellaneous
14054 @section Code evaluation and security issues
14056 Org provides tools to work with the code snippets, including evaluating them.
14058 Running code on your machine always comes with a security risk.  Badly
14059 written or malicious code can be executed on purpose or by accident.  Org has
14060 default settings which will only evaluate such code if you give explicit
14061 permission to do so, and as a casual user of these features you should leave
14062 these precautions intact.
14064 For people who regularly work with such code, the confirmation prompts can
14065 become annoying, and you might want to turn them off.  This can be done, but
14066 you must be aware of the risks that are involved.
14068 Code evaluation can happen under the following circumstances:
14070 @table @i
14071 @item Source code blocks
14072 Source code blocks can be evaluated during export, or when pressing @kbd{C-c
14073 C-c} in the block.  The most important thing to realize here is that Org mode
14074 files which contain code snippets are, in a certain sense, like executable
14075 files.  So you should accept them and load them into Emacs only from trusted
14076 sources---just like you would do with a program you install on your computer.
14078 Make sure you know what you are doing before customizing the variables
14079 which take off the default security brakes.
14081 @defopt org-confirm-babel-evaluate
14082 When t (the default), the user is asked before every code block evaluation.
14083 When nil, the user is not asked.  When set to a function, it is called with
14084 two arguments (language and body of the code block) and should return t to
14085 ask and nil not to ask.
14086 @end defopt
14088 For example, here is how to execute "ditaa" code (which is considered safe)
14089 without asking:
14090 @example
14091 (defun my-org-confirm-babel-evaluate (lang body)
14092   (not (string= lang "ditaa")))  ; don't ask for ditaa
14093 (setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate)
14094 @end example
14096 @item Following @code{shell} and @code{elisp} links
14097 Org has two link types that can directly evaluate code (@pxref{External
14098 links}).  These links can be problematic because the code to be evaluated is
14099 not visible.
14101 @defopt org-confirm-shell-link-function
14102 Function to queries user about shell link execution.
14103 @end defopt
14104 @defopt org-confirm-elisp-link-function
14105 Functions to query user for Emacs Lisp link execution.
14106 @end defopt
14108 @item Formulas in tables
14109 Formulas in tables (@pxref{The spreadsheet}) are code that is evaluated
14110 either by the @i{calc} interpreter, or by the @i{Emacs Lisp} interpreter.
14111 @end table
14113 @node Customization, In-buffer settings, Code evaluation security, Miscellaneous
14114 @section Customization
14115 @cindex customization
14116 @cindex options, for customization
14117 @cindex variables, for customization
14119 There are more than 180 variables that can be used to customize
14120 Org.  For the sake of compactness of the manual, I am not
14121 describing the variables here.  A structured overview of customization
14122 variables is available with @kbd{M-x org-customize}.  Or select
14123 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
14124 settings can also be activated on a per-file basis, by putting special
14125 lines into the buffer (@pxref{In-buffer settings}).
14127 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
14128 @section Summary of in-buffer settings
14129 @cindex in-buffer settings
14130 @cindex special keywords
14132 Org-mode uses special lines in the buffer to define settings on a
14133 per-file basis.  These lines start with a @samp{#+} followed by a
14134 keyword, a colon, and then individual words defining a setting.  Several
14135 setting words can be in the same line, but you can also have multiple
14136 lines for the keyword.  While these settings are described throughout
14137 the manual, here is a summary.  After changing any of those lines in the
14138 buffer, press @kbd{C-c C-c} with the cursor still in the line to
14139 activate the changes immediately.  Otherwise they become effective only
14140 when the file is visited again in a new Emacs session.
14142 @vindex org-archive-location
14143 @table @kbd
14144 @item #+ARCHIVE: %s_done::
14145 This line sets the archive location for the agenda file.  It applies for
14146 all subsequent lines until the next @samp{#+ARCHIVE} line, or the end
14147 of the file.  The first such line also applies to any entries before it.
14148 The corresponding variable is @code{org-archive-location}.
14149 @item #+CATEGORY:
14150 This line sets the category for the agenda file.  The category applies
14151 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
14152 end of the file.  The first such line also applies to any entries before it.
14153 @item #+COLUMNS: %25ITEM .....
14154 @cindex property, COLUMNS
14155 Set the default format for columns view.  This format applies when
14156 columns view is invoked in locations where no @code{COLUMNS} property
14157 applies.
14158 @item #+CONSTANTS: name1=value1 ...
14159 @vindex org-table-formula-constants
14160 @vindex org-table-formula
14161 Set file-local values for constants to be used in table formulas.  This
14162 line sets the local variable @code{org-table-formula-constants-local}.
14163 The global version of this variable is
14164 @code{org-table-formula-constants}.
14165 @item #+FILETAGS: :tag1:tag2:tag3:
14166 Set tags that can be inherited by any entry in the file, including the
14167 top-level entries.
14168 @item #+DRAWERS: NAME1 .....
14169 @vindex org-drawers
14170 Set the file-local set of drawers.  The corresponding global variable is
14171 @code{org-drawers}.
14172 @item #+LINK:  linkword replace
14173 @vindex org-link-abbrev-alist
14174 These lines (several are allowed) specify link abbreviations.
14175 @xref{Link abbreviations}.  The corresponding variable is
14176 @code{org-link-abbrev-alist}.
14177 @item #+PRIORITIES: highest lowest default
14178 @vindex org-highest-priority
14179 @vindex org-lowest-priority
14180 @vindex org-default-priority
14181 This line sets the limits and the default for the priorities.  All three
14182 must be either letters A-Z or numbers 0-9.  The highest priority must
14183 have a lower ASCII number than the lowest priority.
14184 @item #+PROPERTY: Property_Name Value
14185 This line sets a default inheritance value for entries in the current
14186 buffer, most useful for specifying the allowed values of a property.
14187 @cindex #+SETUPFILE
14188 @item #+SETUPFILE: file
14189 This line defines a file that holds more in-buffer setup.  Normally this is
14190 entirely ignored.  Only when the buffer is parsed for option-setting lines
14191 (i.e.@: when starting Org-mode for a file, when pressing @kbd{C-c C-c} in a
14192 settings line, or when exporting), then the contents of this file are parsed
14193 as if they had been included in the buffer.  In particular, the file can be
14194 any other Org-mode file with internal setup.  You can visit the file the
14195 cursor is in the line with @kbd{C-c '}.
14196 @item #+STARTUP:
14197 @cindex #+STARTUP:
14198 This line sets options to be used at startup of Org-mode, when an
14199 Org file is being visited.
14201 The first set of options deals with the initial visibility of the outline
14202 tree.  The corresponding variable for global default settings is
14203 @code{org-startup-folded}, with a default value @code{t}, which means
14204 @code{overview}.
14205 @vindex org-startup-folded
14206 @cindex @code{overview}, STARTUP keyword
14207 @cindex @code{content}, STARTUP keyword
14208 @cindex @code{showall}, STARTUP keyword
14209 @cindex @code{showeverything}, STARTUP keyword
14210 @example
14211 overview         @r{top-level headlines only}
14212 content          @r{all headlines}
14213 showall          @r{no folding of any entries}
14214 showeverything   @r{show even drawer contents}
14215 @end example
14217 @vindex org-startup-indented
14218 @cindex @code{indent}, STARTUP keyword
14219 @cindex @code{noindent}, STARTUP keyword
14220 Dynamic virtual indentation is controlled by the variable
14221 @code{org-startup-indented}@footnote{Emacs 23 and Org-mode 6.29 are required}
14222 @example
14223 indent     @r{start with @code{org-indent-mode} turned on}
14224 noindent   @r{start with @code{org-indent-mode} turned off}
14225 @end example
14227 @vindex org-startup-align-all-tables
14228 Then there are options for aligning tables upon visiting a file.  This
14229 is useful in files containing narrowed table columns.  The corresponding
14230 variable is @code{org-startup-align-all-tables}, with a default value
14231 @code{nil}.
14232 @cindex @code{align}, STARTUP keyword
14233 @cindex @code{noalign}, STARTUP keyword
14234 @example
14235 align      @r{align all tables}
14236 noalign    @r{don't align tables on startup}
14237 @end example
14239 @vindex org-startup-with-inline-images
14240 When visiting a file, inline images can be automatically displayed.  The
14241 corresponding variable is @code{org-startup-with-inline-images}, with a
14242 default value @code{nil} to avoid delays when visiting a file.
14243 @cindex @code{inlineimages}, STARTUP keyword
14244 @cindex @code{noinlineimages}, STARTUP keyword
14245 @example
14246 inlineimages   @r{show inline images}
14247 noinlineimages @r{don't show inline images on startup}
14248 @end example
14250 @vindex org-log-done
14251 @vindex org-log-note-clock-out
14252 @vindex org-log-repeat
14253 Logging the closing and reopening of TODO items and clock intervals can be
14254 configured using these options (see variables @code{org-log-done},
14255 @code{org-log-note-clock-out} and @code{org-log-repeat})
14256 @cindex @code{logdone}, STARTUP keyword
14257 @cindex @code{lognotedone}, STARTUP keyword
14258 @cindex @code{nologdone}, STARTUP keyword
14259 @cindex @code{lognoteclock-out}, STARTUP keyword
14260 @cindex @code{nolognoteclock-out}, STARTUP keyword
14261 @cindex @code{logrepeat}, STARTUP keyword
14262 @cindex @code{lognoterepeat}, STARTUP keyword
14263 @cindex @code{nologrepeat}, STARTUP keyword
14264 @cindex @code{logreschedule}, STARTUP keyword
14265 @cindex @code{lognotereschedule}, STARTUP keyword
14266 @cindex @code{nologreschedule}, STARTUP keyword
14267 @cindex @code{logredeadline}, STARTUP keyword
14268 @cindex @code{lognoteredeadline}, STARTUP keyword
14269 @cindex @code{nologredeadline}, STARTUP keyword
14270 @cindex @code{logrefile}, STARTUP keyword
14271 @cindex @code{lognoterefile}, STARTUP keyword
14272 @cindex @code{nologrefile}, STARTUP keyword
14273 @example
14274 logdone            @r{record a timestamp when an item is marked DONE}
14275 lognotedone        @r{record timestamp and a note when DONE}
14276 nologdone          @r{don't record when items are marked DONE}
14277 logrepeat          @r{record a time when reinstating a repeating item}
14278 lognoterepeat      @r{record a note when reinstating a repeating item}
14279 nologrepeat        @r{do not record when reinstating repeating item}
14280 lognoteclock-out   @r{record a note when clocking out}
14281 nolognoteclock-out @r{don't record a note when clocking out}
14282 logreschedule      @r{record a timestamp when scheduling time changes}
14283 lognotereschedule  @r{record a note when scheduling time changes}
14284 nologreschedule    @r{do not record when a scheduling date changes}
14285 logredeadline      @r{record a timestamp when deadline changes}
14286 lognoteredeadline  @r{record a note when deadline changes}
14287 nologredeadline    @r{do not record when a deadline date changes}
14288 logrefile          @r{record a timestamp when refiling}
14289 lognoterefile      @r{record a note when refiling}
14290 nologrefile        @r{do not record when refiling}
14291 @end example
14292 @vindex org-hide-leading-stars
14293 @vindex org-odd-levels-only
14294 Here are the options for hiding leading stars in outline headings, and for
14295 indenting outlines.  The corresponding variables are
14296 @code{org-hide-leading-stars} and @code{org-odd-levels-only}, both with a
14297 default setting @code{nil} (meaning @code{showstars} and @code{oddeven}).
14298 @cindex @code{hidestars}, STARTUP keyword
14299 @cindex @code{showstars}, STARTUP keyword
14300 @cindex @code{odd}, STARTUP keyword
14301 @cindex @code{even}, STARTUP keyword
14302 @example
14303 hidestars  @r{make all but one of the stars starting a headline invisible.}
14304 showstars  @r{show all stars starting a headline}
14305 indent     @r{virtual indentation according to outline level}
14306 noindent   @r{no virtual indentation according to outline level}
14307 odd        @r{allow only odd outline levels (1,3,...)}
14308 oddeven    @r{allow all outline levels}
14309 @end example
14310 @vindex org-put-time-stamp-overlays
14311 @vindex org-time-stamp-overlay-formats
14312 To turn on custom format overlays over timestamps (variables
14313 @code{org-put-time-stamp-overlays} and
14314 @code{org-time-stamp-overlay-formats}), use
14315 @cindex @code{customtime}, STARTUP keyword
14316 @example
14317 customtime @r{overlay custom time format}
14318 @end example
14319 @vindex constants-unit-system
14320 The following options influence the table spreadsheet (variable
14321 @code{constants-unit-system}).
14322 @cindex @code{constcgs}, STARTUP keyword
14323 @cindex @code{constSI}, STARTUP keyword
14324 @example
14325 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
14326 constSI    @r{@file{constants.el} should use the SI unit system}
14327 @end example
14328 @vindex org-footnote-define-inline
14329 @vindex org-footnote-auto-label
14330 @vindex org-footnote-auto-adjust
14331 To influence footnote settings, use the following keywords.  The
14332 corresponding variables are @code{org-footnote-define-inline},
14333 @code{org-footnote-auto-label}, and @code{org-footnote-auto-adjust}.
14334 @cindex @code{fninline}, STARTUP keyword
14335 @cindex @code{nofninline}, STARTUP keyword
14336 @cindex @code{fnlocal}, STARTUP keyword
14337 @cindex @code{fnprompt}, STARTUP keyword
14338 @cindex @code{fnauto}, STARTUP keyword
14339 @cindex @code{fnconfirm}, STARTUP keyword
14340 @cindex @code{fnplain}, STARTUP keyword
14341 @cindex @code{fnadjust}, STARTUP keyword
14342 @cindex @code{nofnadjust}, STARTUP keyword
14343 @example
14344 fninline    @r{define footnotes inline}
14345 fnnoinline  @r{define footnotes in separate section}
14346 fnlocal     @r{define footnotes near first reference, but not inline}
14347 fnprompt    @r{prompt for footnote labels}
14348 fnauto      @r{create @code{[fn:1]}-like labels automatically (default)}
14349 fnconfirm   @r{offer automatic label for editing or confirmation}
14350 fnplain     @r{create @code{[1]}-like labels automatically}
14351 fnadjust    @r{automatically renumber and sort footnotes}
14352 nofnadjust  @r{do not renumber and sort automatically}
14353 @end example
14354 @cindex org-hide-block-startup
14355 To hide blocks on startup, use these keywords.  The corresponding variable is
14356 @code{org-hide-block-startup}.
14357 @cindex @code{hideblocks}, STARTUP keyword
14358 @cindex @code{nohideblocks}, STARTUP keyword
14359 @example
14360 hideblocks   @r{Hide all begin/end blocks on startup}
14361 nohideblocks @r{Do not hide blocks on startup}
14362 @end example
14363 @cindex org-pretty-entities
14364 The display of entities as UTF-8 characters is governed by the variable
14365 @code{org-pretty-entities} and the keywords
14366 @cindex @code{entitiespretty}, STARTUP keyword
14367 @cindex @code{entitiesplain}, STARTUP keyword
14368 @example
14369 entitiespretty  @r{Show entities as UTF-8 characters where possible}
14370 entitiesplain   @r{Leave entities plain}
14371 @end example
14372 @item #+TAGS:  TAG1(c1) TAG2(c2)
14373 @vindex org-tag-alist
14374 These lines (several such lines are allowed) specify the valid tags in
14375 this file, and (potentially) the corresponding @emph{fast tag selection}
14376 keys.  The corresponding variable is @code{org-tag-alist}.
14377 @item #+TBLFM:
14378 This line contains the formulas for the table directly above the line.
14379 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+DATE:,
14380 @itemx #+OPTIONS:, #+BIND:, #+XSLT:,
14381 @itemx #+DESCRIPTION:, #+KEYWORDS:,
14382 @itemx #+LATEX_HEADER:, #+STYLE:, #+LINK_UP:, #+LINK_HOME:,
14383 @itemx #+EXPORT_SELECT_TAGS:, #+EXPORT_EXCLUDE_TAGS:
14384 These lines provide settings for exporting files.  For more details see
14385 @ref{Export options}.
14386 @item #+TODO:    #+SEQ_TODO:   #+TYP_TODO:
14387 @vindex org-todo-keywords
14388 These lines set the TODO keywords and their interpretation in the
14389 current file.  The corresponding variable is @code{org-todo-keywords}.
14390 @end table
14392 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
14393 @section The very busy C-c C-c key
14394 @kindex C-c C-c
14395 @cindex C-c C-c, overview
14397 The key @kbd{C-c C-c} has many purposes in Org, which are all
14398 mentioned scattered throughout this manual.  One specific function of
14399 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
14400 other circumstances it means something like @emph{``Hey Org, look
14401 here and update according to what you see here''}.  Here is a summary of
14402 what this means in different contexts.
14404 @itemize @minus
14405 @item
14406 If there are highlights in the buffer from the creation of a sparse
14407 tree, or from clock display, remove these highlights.
14408 @item
14409 If the cursor is in one of the special @code{#+KEYWORD} lines, this
14410 triggers scanning the buffer for these lines and updating the
14411 information.
14412 @item
14413 If the cursor is inside a table, realign the table.  This command
14414 works even if the automatic table editor has been turned off.
14415 @item
14416 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
14417 the entire table.
14418 @item
14419 If the current buffer is a capture buffer, close the note and file it.
14420 With a prefix argument, file it, without further interaction, to the
14421 default location.
14422 @item
14423 If the cursor is on a @code{<<<target>>>}, update radio targets and
14424 corresponding links in this buffer.
14425 @item
14426 If the cursor is in a property line or at the start or end of a property
14427 drawer, offer property commands.
14428 @item
14429 If the cursor is at a footnote reference, go to the corresponding
14430 definition, and vice versa.
14431 @item
14432 If the cursor is on a statistics cookie, update it.
14433 @item
14434 If the cursor is in a plain list item with a checkbox, toggle the status
14435 of the checkbox.
14436 @item
14437 If the cursor is on a numbered item in a plain list, renumber the
14438 ordered list.
14439 @item
14440 If the cursor is on the @code{#+BEGIN} line of a dynamic block, the
14441 block is updated.
14442 @item
14443 If the cursor is at a timestamp, fix the day name in the timestamp.
14444 @end itemize
14446 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
14447 @section A cleaner outline view
14448 @cindex hiding leading stars
14449 @cindex dynamic indentation
14450 @cindex odd-levels-only outlines
14451 @cindex clean outline view
14453 Some people find it noisy and distracting that the Org headlines start with a
14454 potentially large number of stars, and that text below the headlines is not
14455 indented.  While this is no problem when writing a @emph{book-like} document
14456 where the outline headings are really section headings, in a more
14457 @emph{list-oriented} outline, indented structure is a lot cleaner:
14459 @example
14460 @group
14461 * Top level headline             |    * Top level headline
14462 ** Second level                  |      * Second level
14463 *** 3rd level                    |        * 3rd level
14464 some text                        |          some text
14465 *** 3rd level                    |        * 3rd level
14466 more text                        |          more text
14467 * Another top level headline     |    * Another top level headline
14468 @end group
14469 @end example
14471 @noindent
14473 If you are using at least Emacs 23.2@footnote{Emacs 23.1 can actually crash
14474 with @code{org-indent-mode}} and version 6.29 of Org, this kind of view can
14475 be achieved dynamically at display time using @code{org-indent-mode}.  In
14476 this minor mode, all lines are prefixed for display with the necessary amount
14477 of space@footnote{@code{org-indent-mode} also sets the @code{wrap-prefix}
14478 property, such that @code{visual-line-mode} (or purely setting
14479 @code{word-wrap}) wraps long lines (including headlines) correctly indented.
14480 }.  Also headlines are prefixed with additional stars, so that the amount of
14481 indentation shifts by two@footnote{See the variable
14482 @code{org-indent-indentation-per-level}.}  spaces per level.  All headline
14483 stars but the last one are made invisible using the @code{org-hide}
14484 face@footnote{Turning on @code{org-indent-mode} sets
14485 @code{org-hide-leading-stars} to @code{t} and @code{org-adapt-indentation} to
14486 @code{nil}.} - see below under @samp{2.} for more information on how this
14487 works.  You can turn on @code{org-indent-mode} for all files by customizing
14488 the variable @code{org-startup-indented}, or you can turn it on for
14489 individual files using
14491 @example
14492 #+STARTUP: indent
14493 @end example
14495 If you want a similar effect in an earlier version of Emacs and/or Org, or if
14496 you want the indentation to be hard space characters so that the plain text
14497 file looks as similar as possible to the Emacs display, Org supports you in
14498 the following way:
14500 @enumerate
14501 @item
14502 @emph{Indentation of text below headlines}@*
14503 You may indent text below each headline to make the left boundary line up
14504 with the headline, like
14506 @example
14507 *** 3rd level
14508     more text, now indented
14509 @end example
14511 @vindex org-adapt-indentation
14512 Org supports this with paragraph filling, line wrapping, and structure
14513 editing@footnote{See also the variable @code{org-adapt-indentation}.},
14514 preserving or adapting the indentation as appropriate.
14516 @item
14517 @vindex org-hide-leading-stars
14518 @emph{Hiding leading stars}@* You can modify the display in such a way that
14519 all leading stars become invisible.  To do this in a global way, configure
14520 the variable @code{org-hide-leading-stars} or change this on a per-file basis
14521 with
14523 @example
14524 #+STARTUP: hidestars
14525 #+STARTUP: showstars
14526 @end example
14528 With hidden stars, the tree becomes:
14530 @example
14531 @group
14532 * Top level headline
14533  * Second level
14534   * 3rd level
14535   ...
14536 @end group
14537 @end example
14539 @noindent
14540 @vindex org-hide @r{(face)}
14541 The leading stars are not truly replaced by whitespace, they are only
14542 fontified with the face @code{org-hide} that uses the background color as
14543 font color.  If you are not using either white or black background, you may
14544 have to customize this face to get the wanted effect.  Another possibility is
14545 to set this font such that the extra stars are @i{almost} invisible, for
14546 example using the color @code{grey90} on a white background.
14548 @item
14549 @vindex org-odd-levels-only
14550 Things become cleaner still if you skip all the even levels and use only odd
14551 levels 1, 3, 5..., effectively adding two stars to go from one outline level
14552 to the next@footnote{When you need to specify a level for a property search
14553 or refile targets, @samp{LEVEL=2} will correspond to 3 stars, etc@.}.  In this
14554 way we get the outline view shown at the beginning of this section.  In order
14555 to make the structure editing and export commands handle this convention
14556 correctly, configure the variable @code{org-odd-levels-only}, or set this on
14557 a per-file basis with one of the following lines:
14559 @example
14560 #+STARTUP: odd
14561 #+STARTUP: oddeven
14562 @end example
14564 You can convert an Org file from single-star-per-level to the
14565 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
14566 RET} in that file.  The reverse operation is @kbd{M-x
14567 org-convert-to-oddeven-levels}.
14568 @end enumerate
14570 @node TTY keys, Interaction, Clean view, Miscellaneous
14571 @section Using Org on a tty
14572 @cindex tty key bindings
14574 Because Org contains a large number of commands, by default many of
14575 Org's core commands are bound to keys that are generally not
14576 accessible on a tty, such as the cursor keys (@key{left}, @key{right},
14577 @key{up}, @key{down}), @key{TAB} and @key{RET}, in particular when used
14578 together with modifiers like @key{Meta} and/or @key{Shift}.  To access
14579 these commands on a tty when special keys are unavailable, the following
14580 alternative bindings can be used.  The tty bindings below will likely be
14581 more cumbersome; you may find for some of the bindings below that a
14582 customized workaround suits you better.  For example, changing a timestamp
14583 is really only fun with @kbd{S-@key{cursor}} keys, whereas on a
14584 tty you would rather use @kbd{C-c .} to re-insert the timestamp.
14586 @multitable @columnfractions 0.15 0.2 0.1 0.2
14587 @item @b{Default} @tab @b{Alternative 1} @tab @b{Speed key} @tab @b{Alternative 2}
14588 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab @kbd{C} @tab
14589 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{l} @tab @kbd{@key{Esc} @key{left}}
14590 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab @kbd{L} @tab
14591 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{r} @tab @kbd{@key{Esc} @key{right}}
14592 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab @kbd{R} @tab
14593 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{ } @tab @kbd{@key{Esc} @key{up}}
14594 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab @kbd{U} @tab
14595 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{ } @tab @kbd{@key{Esc} @key{down}}
14596 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab @kbd{D} @tab
14597 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab @kbd{ } @tab
14598 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{ } @tab @kbd{@key{Esc} @key{RET}}
14599 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab @kbd{ } @tab
14600 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab @kbd{ } @tab
14601 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab @kbd{ } @tab
14602 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab @kbd{ } @tab
14603 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab @kbd{ } @tab
14604 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab @kbd{ } @tab
14605 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab @kbd{ } @tab
14606 @end multitable
14609 @node Interaction, org-crypt.el, TTY keys, Miscellaneous
14610 @section Interaction with other packages
14611 @cindex packages, interaction with other
14612 Org lives in the world of GNU Emacs and interacts in various ways
14613 with other code out there.
14615 @menu
14616 * Cooperation::                 Packages Org cooperates with
14617 * Conflicts::                   Packages that lead to conflicts
14618 @end menu
14620 @node Cooperation, Conflicts, Interaction, Interaction
14621 @subsection Packages that Org cooperates with
14623 @table @asis
14624 @cindex @file{calc.el}
14625 @cindex Gillespie, Dave
14626 @item @file{calc.el} by Dave Gillespie
14627 Org uses the Calc package for implementing spreadsheet
14628 functionality in its tables (@pxref{The spreadsheet}).  Org
14629 checks for the availability of Calc by looking for the function
14630 @code{calc-eval} which will have been autoloaded during setup if Calc has
14631 been installed properly.  As of Emacs 22, Calc is part of the Emacs
14632 distribution.  Another possibility for interaction between the two
14633 packages is using Calc for embedded calculations.  @xref{Embedded Mode,
14634 , Embedded Mode, Calc, GNU Emacs Calc Manual}.
14635 @item @file{constants.el} by Carsten Dominik
14636 @cindex @file{constants.el}
14637 @cindex Dominik, Carsten
14638 @vindex org-table-formula-constants
14639 In a table formula (@pxref{The spreadsheet}), it is possible to use
14640 names for natural constants or units.  Instead of defining your own
14641 constants in the variable @code{org-table-formula-constants}, install
14642 the @file{constants} package which defines a large number of constants
14643 and units, and lets you use unit prefixes like @samp{M} for
14644 @samp{Mega}, etc@.  You will need version 2.0 of this package, available
14645 at @url{http://www.astro.uva.nl/~dominik/Tools}.  Org checks for
14646 the function @code{constants-get}, which has to be autoloaded in your
14647 setup.  See the installation instructions in the file
14648 @file{constants.el}.
14649 @item @file{cdlatex.el} by Carsten Dominik
14650 @cindex @file{cdlatex.el}
14651 @cindex Dominik, Carsten
14652 Org-mode can make use of the CDLa@TeX{} package to efficiently enter
14653 @LaTeX{} fragments into Org files.  See @ref{CDLaTeX mode}.
14654 @item @file{imenu.el} by Ake Stenhoff and Lars Lindberg
14655 @cindex @file{imenu.el}
14656 Imenu allows menu access to an index of items in a file.  Org-mode
14657 supports Imenu---all you need to do to get the index is the following:
14658 @lisp
14659 (add-hook 'org-mode-hook
14660           (lambda () (imenu-add-to-menubar "Imenu")))
14661 @end lisp
14662 @vindex org-imenu-depth
14663 By default the index is two levels deep---you can modify the depth using
14664 the option @code{org-imenu-depth}.
14665 @item @file{remember.el} by John Wiegley
14666 @cindex @file{remember.el}
14667 @cindex Wiegley, John
14668 Org used to use this package for capture, but no longer does.
14669 @item @file{speedbar.el} by Eric M. Ludlam
14670 @cindex @file{speedbar.el}
14671 @cindex Ludlam, Eric M.
14672 Speedbar is a package that creates a special frame displaying files and
14673 index items in files.  Org-mode supports Speedbar and allows you to
14674 drill into Org files directly from the Speedbar.  It also allows you to
14675 restrict the scope of agenda commands to a file or a subtree by using
14676 the command @kbd{<} in the Speedbar frame.
14677 @cindex @file{table.el}
14678 @item @file{table.el} by Takaaki Ota
14679 @kindex C-c C-c
14680 @cindex table editor, @file{table.el}
14681 @cindex @file{table.el}
14682 @cindex Ota, Takaaki
14684 Complex ASCII tables with automatic line wrapping, column- and row-spanning,
14685 and alignment can be created using the Emacs table package by Takaaki Ota
14686 (@uref{http://sourceforge.net/projects/table}, and also part of Emacs 22).
14687 Org-mode will recognize these tables and export them properly.  Because of
14688 interference with other Org-mode functionality, you unfortunately cannot edit
14689 these tables directly in the buffer.  Instead, you need to use the command
14690 @kbd{C-c '} to edit them, similar to source code snippets.
14692 @table @kbd
14693 @orgcmd{C-c ',org-edit-special}
14694 Edit a @file{table.el} table.  Works when the cursor is in a table.el table.
14696 @orgcmd{C-c ~,org-table-create-with-table.el}
14697 Insert a @file{table.el} table.  If there is already a table at point, this
14698 command converts it between the @file{table.el} format and the Org-mode
14699 format.  See the documentation string of the command
14700 @code{org-convert-table} for the restrictions under which this is
14701 possible.
14702 @end table
14703 @file{table.el} is part of Emacs since Emacs 22.
14704 @item @file{footnote.el} by Steven L. Baur
14705 @cindex @file{footnote.el}
14706 @cindex Baur, Steven L.
14707 Org-mode recognizes numerical footnotes as provided by this package.
14708 However, Org-mode also has its own footnote support (@pxref{Footnotes}),
14709 which makes using @file{footnote.el} unnecessary.
14710 @end table
14712 @node Conflicts,  , Cooperation, Interaction
14713 @subsection Packages that lead to conflicts with Org-mode
14715 @table @asis
14717 @cindex @code{shift-selection-mode}
14718 @vindex org-support-shift-select
14719 In Emacs 23, @code{shift-selection-mode} is on by default, meaning that
14720 cursor motions combined with the shift key should start or enlarge regions.
14721 This conflicts with the use of @kbd{S-@key{cursor}} commands in Org to change
14722 timestamps, TODO keywords, priorities, and item bullet types if the cursor is
14723 at such a location.  By default, @kbd{S-@key{cursor}} commands outside
14724 special contexts don't do anything, but you can customize the variable
14725 @code{org-support-shift-select}.  Org-mode then tries to accommodate shift
14726 selection by (i) using it outside of the special contexts where special
14727 commands apply, and by (ii) extending an existing active region even if the
14728 cursor moves across a special context.
14730 @item @file{CUA.el} by Kim. F. Storm
14731 @cindex @file{CUA.el}
14732 @cindex Storm, Kim. F.
14733 @vindex org-replace-disputed-keys
14734 Key bindings in Org conflict with the @kbd{S-<cursor>} keys used by CUA mode
14735 (as well as @code{pc-select-mode} and @code{s-region-mode}) to select and extend the
14736 region.  In fact, Emacs 23 has this built-in in the form of
14737 @code{shift-selection-mode}, see previous paragraph.  If you are using Emacs
14738 23, you probably don't want to use another package for this purpose.  However,
14739 if you prefer to leave these keys to a different package while working in
14740 Org-mode, configure the variable @code{org-replace-disputed-keys}.  When set,
14741 Org will move the following key bindings in Org files, and in the agenda
14742 buffer (but not during date selection).
14744 @example
14745 S-UP      @result{}  M-p             S-DOWN     @result{}  M-n
14746 S-LEFT    @result{}  M--             S-RIGHT    @result{}  M-+
14747 C-S-LEFT  @result{}  M-S--           C-S-RIGHT  @result{}  M-S-+
14748 @end example
14750 @vindex org-disputed-keys
14751 Yes, these are unfortunately more difficult to remember.  If you want
14752 to have other replacement keys, look at the variable
14753 @code{org-disputed-keys}.
14755 @item @file{yasnippet.el}
14756 @cindex @file{yasnippet.el}
14757 The way Org mode binds the TAB key (binding to @code{[tab]} instead of
14758 @code{"\t"}) overrules YASnippet's access to this key.  The following code
14759 fixed this problem:
14761 @lisp
14762 (add-hook 'org-mode-hook
14763           (lambda ()
14764             (org-set-local 'yas/trigger-key [tab])
14765             (define-key yas/keymap [tab] 'yas/next-field-or-maybe-expand)))
14766 @end lisp
14768 The latest version of yasnippet doesn't play well with Org mode.  If the
14769 above code does not fix the conflict, start by defining the following
14770 function:
14772 @lisp
14773 (defun yas/org-very-safe-expand ()
14774        (let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
14775 @end lisp
14777 Then, tell Org mode what to do with the new function:
14779 @lisp
14780 (add-hook 'org-mode-hook
14781           (lambda ()
14782               (make-variable-buffer-local 'yas/trigger-key)
14783               (setq yas/trigger-key [tab])
14784               (add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
14785               (define-key yas/keymap [tab] 'yas/next-field)))
14786 @end lisp
14788 @item @file{windmove.el} by Hovav Shacham
14789 @cindex @file{windmove.el}
14790 This package also uses the @kbd{S-<cursor>} keys, so everything written
14791 in the paragraph above about CUA mode also applies here.  If you want make
14792 the windmove function active in locations where Org-mode does not have
14793 special functionality on @kbd{S-@key{cursor}}, add this to your
14794 configuration:
14796 @lisp
14797 ;; Make windmove work in org-mode:
14798 (add-hook 'org-shiftup-final-hook 'windmove-up)
14799 (add-hook 'org-shiftleft-final-hook 'windmove-left)
14800 (add-hook 'org-shiftdown-final-hook 'windmove-down)
14801 (add-hook 'org-shiftright-final-hook 'windmove-right)
14802 @end lisp
14804 @item @file{viper.el} by Michael Kifer
14805 @cindex @file{viper.el}
14806 @kindex C-c /
14807 Viper uses @kbd{C-c /} and therefore makes this key not access the
14808 corresponding Org-mode command @code{org-sparse-tree}.  You need to find
14809 another key for this command, or override the key in
14810 @code{viper-vi-global-user-map} with
14812 @lisp
14813 (define-key viper-vi-global-user-map "C-c /" 'org-sparse-tree)
14814 @end lisp
14816 @end table
14818 @node org-crypt.el,  , Interaction, Miscellaneous
14819 @section org-crypt.el
14820 @cindex @file{org-crypt.el}
14821 @cindex @code{org-decrypt-entry}
14823 Org-crypt will encrypt the text of an entry, but not the headline, or
14824 properties.  Org-crypt uses the Emacs EasyPG library to encrypt and decrypt
14825 files.
14827 Any text below a headline that has a @samp{:crypt:} tag will be automatically
14828 be encrypted when the file is saved.  If you want to use a different tag just
14829 customize the @code{org-crypt-tag-matcher} setting.
14831 To use org-crypt it is suggested that you have the following in your
14832 @file{.emacs}:
14834 @example
14835 (require 'org-crypt)
14836 (org-crypt-use-before-save-magic)
14837 (setq org-tags-exclude-from-inheritance (quote ("crypt")))
14839 (setq org-crypt-key nil)
14840   ;; GPG key to use for encryption
14841   ;; Either the Key ID or set to nil to use symmetric encryption.
14843 (setq auto-save-default nil)
14844   ;; Auto-saving does not cooperate with org-crypt.el: so you need
14845   ;; to turn it off if you plan to use org-crypt.el quite often.
14846   ;; Otherwise, you'll get an (annoying) message each time you
14847   ;; start Org.
14849   ;; To turn it off only locally, you can insert this:
14850   ;;
14851   ;; # -*- buffer-auto-save-file-name: nil; -*-
14852 @end example
14854 Excluding the crypt tag from inheritance prevents already encrypted text
14855 being encrypted again.
14857 @node Hacking, MobileOrg, Miscellaneous, Top
14858 @appendix Hacking
14859 @cindex hacking
14861 This appendix covers some aspects where users can extend the functionality of
14862 Org.
14864 @menu
14865 * Hooks::                       Who to reach into Org's internals
14866 * Add-on packages::             Available extensions
14867 * Adding hyperlink types::      New custom link types
14868 * Context-sensitive commands::  How to add functionality to such commands
14869 * Tables in arbitrary syntax::  Orgtbl for @LaTeX{} and other programs
14870 * Dynamic blocks::              Automatically filled blocks
14871 * Special agenda views::        Customized views
14872 * Extracting agenda information::  Postprocessing of agenda information
14873 * Using the property API::      Writing programs that use entry properties
14874 * Using the mapping API::       Mapping over all or selected entries
14875 @end menu
14877 @node Hooks, Add-on packages, Hacking, Hacking
14878 @section Hooks
14879 @cindex hooks
14881 Org has a large number of hook variables that can be used to add
14882 functionality.  This appendix about hacking is going to illustrate the
14883 use of some of them.  A complete list of all hooks with documentation is
14884 maintained by the Worg project and can be found at
14885 @uref{http://orgmode.org/worg/org-configs/org-hooks.php}.
14887 @node Add-on packages, Adding hyperlink types, Hooks, Hacking
14888 @section Add-on packages
14889 @cindex add-on packages
14891 A large number of add-on packages have been written by various authors.
14892 These packages are not part of Emacs, but they are distributed as contributed
14893 packages with the separate release available at the Org-mode home page at
14894 @uref{http://orgmode.org}.  The list of contributed packages, along with
14895 documentation about each package, is maintained by the Worg project at
14896 @uref{http://orgmode.org/worg/org-contrib/}.
14900 @node Adding hyperlink types, Context-sensitive commands, Add-on packages, Hacking
14901 @section Adding hyperlink types
14902 @cindex hyperlinks, adding new types
14904 Org has a large number of hyperlink types built-in
14905 (@pxref{Hyperlinks}).  If you would like to add new link types, Org
14906 provides an interface for doing so.  Let's look at an example file,
14907 @file{org-man.el}, that will add support for creating links like
14908 @samp{[[man:printf][The printf manpage]]} to show Unix manual pages inside
14909 Emacs:
14911 @lisp
14912 ;;; org-man.el - Support for links to manpages in Org
14914 (require 'org)
14916 (org-add-link-type "man" 'org-man-open)
14917 (add-hook 'org-store-link-functions 'org-man-store-link)
14919 (defcustom org-man-command 'man
14920   "The Emacs command to be used to display a man page."
14921   :group 'org-link
14922   :type '(choice (const man) (const woman)))
14924 (defun org-man-open (path)
14925   "Visit the manpage on PATH.
14926 PATH should be a topic that can be thrown at the man command."
14927   (funcall org-man-command path))
14929 (defun org-man-store-link ()
14930   "Store a link to a manpage."
14931   (when (memq major-mode '(Man-mode woman-mode))
14932     ;; This is a man page, we do make this link
14933     (let* ((page (org-man-get-page-name))
14934            (link (concat "man:" page))
14935            (description (format "Manpage for %s" page)))
14936       (org-store-link-props
14937        :type "man"
14938        :link link
14939        :description description))))
14941 (defun org-man-get-page-name ()
14942   "Extract the page name from the buffer name."
14943   ;; This works for both `Man-mode' and `woman-mode'.
14944   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
14945       (match-string 1 (buffer-name))
14946     (error "Cannot create link to this man page")))
14948 (provide 'org-man)
14950 ;;; org-man.el ends here
14951 @end lisp
14953 @noindent
14954 You would activate this new link type in @file{.emacs} with
14956 @lisp
14957 (require 'org-man)
14958 @end lisp
14960 @noindent
14961 Let's go through the file and see what it does.
14962 @enumerate
14963 @item
14964 It does @code{(require 'org)} to make sure that @file{org.el} has been
14965 loaded.
14966 @item
14967 The next line calls @code{org-add-link-type} to define a new link type
14968 with prefix @samp{man}.  The call also contains the name of a function
14969 that will be called to follow such a link.
14970 @item
14971 @vindex org-store-link-functions
14972 The next line adds a function to @code{org-store-link-functions}, in
14973 order to allow the command @kbd{C-c l} to record a useful link in a
14974 buffer displaying a man page.
14975 @end enumerate
14977 The rest of the file defines the necessary variables and functions.
14978 First there is a customization variable that determines which Emacs
14979 command should be used to display man pages.  There are two options,
14980 @code{man} and @code{woman}.  Then the function to follow a link is
14981 defined.  It gets the link path as an argument---in this case the link
14982 path is just a topic for the manual command.  The function calls the
14983 value of @code{org-man-command} to display the man page.
14985 Finally the function @code{org-man-store-link} is defined.  When you try
14986 to store a link with @kbd{C-c l}, this function will be called to
14987 try to make a link.  The function must first decide if it is supposed to
14988 create the link for this buffer type; we do this by checking the value
14989 of the variable @code{major-mode}.  If not, the function must exit and
14990 return the value @code{nil}.  If yes, the link is created by getting the
14991 manual topic from the buffer name and prefixing it with the string
14992 @samp{man:}.  Then it must call the command @code{org-store-link-props}
14993 and set the @code{:type} and @code{:link} properties.  Optionally you
14994 can also set the @code{:description} property to provide a default for
14995 the link description when the link is later inserted into an Org
14996 buffer with @kbd{C-c C-l}.
14998 When it makes sense for your new link type, you may also define a function
14999 @code{org-PREFIX-complete-link} that implements special (e.g.@: completion)
15000 support for inserting such a link with @kbd{C-c C-l}.  Such a function should
15001 not accept any arguments, and return the full link with prefix.
15003 @node Context-sensitive commands, Tables in arbitrary syntax, Adding hyperlink types, Hacking
15004 @section Context-sensitive commands
15005 @cindex context-sensitive commands, hooks
15006 @cindex add-ons, context-sensitive commands
15007 @vindex org-ctrl-c-ctrl-c-hook
15009 Org has several commands that act differently depending on context.  The most
15010 important example it the @kbd{C-c C-c} (@pxref{The very busy C-c C-c key}).
15011 Also the @kbd{M-cursor} and @kbd{M-S-cursor} keys have this property.
15013 Add-ons can tap into this functionality by providing a function that detects
15014 special context for that add-on and executes functionality appropriate for
15015 the context.  Here is an example from Dan Davison's @file{org-R.el} which
15016 allows you to evaluate commands based on the @file{R} programming language
15017 @footnote{@file{org-R.el} has been replaced by the org-mode functionality
15018 described in @ref{Working With Source Code} and is now obsolete.}.  For this
15019 package, special contexts are lines that start with @code{#+R:} or
15020 @code{#+RR:}.
15022 @lisp
15023 (defun org-R-apply-maybe ()
15024   "Detect if this is context for org-R and execute R commands."
15025   (if (save-excursion
15026         (beginning-of-line 1)
15027         (looking-at "#\\+RR?:"))
15028       (progn (call-interactively 'org-R-apply)
15029              t) ;; to signal that we took action
15030     nil)) ;; to signal that we did not
15032 (add-hook 'org-ctrl-c-ctrl-c-hook 'org-R-apply-maybe)
15033 @end lisp
15035 The function first checks if the cursor is in such a line.  If that is the
15036 case, @code{org-R-apply} is called and the function returns @code{t} to
15037 signal that action was taken, and @kbd{C-c C-c} will stop looking for other
15038 contexts.  If the function finds it should do nothing locally, it returns
15039 @code{nil} so that other, similar functions can have a try.
15042 @node Tables in arbitrary syntax, Dynamic blocks, Context-sensitive commands, Hacking
15043 @section Tables and lists in arbitrary syntax
15044 @cindex tables, in other modes
15045 @cindex lists, in other modes
15046 @cindex Orgtbl mode
15048 Since Orgtbl mode can be used as a minor mode in arbitrary buffers, a
15049 frequent feature request has been to make it work with native tables in
15050 specific languages, for example @LaTeX{}.  However, this is extremely
15051 hard to do in a general way, would lead to a customization nightmare,
15052 and would take away much of the simplicity of the Orgtbl mode table
15053 editor.
15055 This appendix describes a different approach.  We keep the Orgtbl mode
15056 table in its native format (the @i{source table}), and use a custom
15057 function to @i{translate} the table to the correct syntax, and to
15058 @i{install} it in the right location (the @i{target table}).  This puts
15059 the burden of writing conversion functions on the user, but it allows
15060 for a very flexible system.
15062 Bastien added the ability to do the same with lists, in Orgstruct mode.  You
15063 can use Org's facilities to edit and structure lists by turning
15064 @code{orgstruct-mode} on, then locally exporting such lists in another format
15065 (HTML, @LaTeX{} or Texinfo.)
15068 @menu
15069 * Radio tables::                Sending and receiving radio tables
15070 * A LaTeX example::             Step by step, almost a tutorial
15071 * Translator functions::        Copy and modify
15072 * Radio lists::                 Doing the same for lists
15073 @end menu
15075 @node Radio tables, A LaTeX example, Tables in arbitrary syntax, Tables in arbitrary syntax
15076 @subsection Radio tables
15077 @cindex radio tables
15079 To define the location of the target table, you first need to create two
15080 lines that are comments in the current mode, but contain magic words for
15081 Orgtbl mode to find.  Orgtbl mode will insert the translated table
15082 between these lines, replacing whatever was there before.  For example:
15084 @example
15085 /* BEGIN RECEIVE ORGTBL table_name */
15086 /* END RECEIVE ORGTBL table_name */
15087 @end example
15089 @noindent
15090 Just above the source table, we put a special line that tells
15091 Orgtbl mode how to translate this table and where to install it.  For
15092 example:
15093 @cindex #+ORGTBL
15094 @example
15095 #+ORGTBL: SEND table_name translation_function arguments....
15096 @end example
15098 @noindent
15099 @code{table_name} is the reference name for the table that is also used
15100 in the receiver lines.  @code{translation_function} is the Lisp function
15101 that does the translation.  Furthermore, the line can contain a list of
15102 arguments (alternating key and value) at the end.  The arguments will be
15103 passed as a property list to the translation function for
15104 interpretation.  A few standard parameters are already recognized and
15105 acted upon before the translation function is called:
15107 @table @code
15108 @item :skip N
15109 Skip the first N lines of the table.  Hlines do count as separate lines for
15110 this parameter!
15112 @item :skipcols (n1 n2 ...)
15113 List of columns that should be skipped.  If the table has a column with
15114 calculation marks, that column is automatically discarded as well.
15115 Please note that the translator function sees the table @emph{after} the
15116 removal of these columns, the function never knows that there have been
15117 additional columns.
15118 @end table
15120 @noindent
15121 The one problem remaining is how to keep the source table in the buffer
15122 without disturbing the normal workings of the file, for example during
15123 compilation of a C file or processing of a @LaTeX{} file.  There are a
15124 number of different solutions:
15126 @itemize @bullet
15127 @item
15128 The table could be placed in a block comment if that is supported by the
15129 language.  For example, in C mode you could wrap the table between
15130 @samp{/*} and @samp{*/} lines.
15131 @item
15132 Sometimes it is possible to put the table after some kind of @i{END}
15133 statement, for example @samp{\bye} in @TeX{} and @samp{\end@{document@}}
15134 in @LaTeX{}.
15135 @item
15136 You can just comment the table line-by-line whenever you want to process
15137 the file, and uncomment it whenever you need to edit the table.  This
15138 only sounds tedious---the command @kbd{M-x orgtbl-toggle-comment}
15139 makes this comment-toggling very easy, in particular if you bind it to a
15140 key.
15141 @end itemize
15143 @node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
15144 @subsection A @LaTeX{} example of radio tables
15145 @cindex @LaTeX{}, and Orgtbl mode
15147 The best way to wrap the source table in @LaTeX{} is to use the
15148 @code{comment} environment provided by @file{comment.sty}.  It has to be
15149 activated by placing @code{\usepackage@{comment@}} into the document
15150 header.  Orgtbl mode can insert a radio table skeleton@footnote{By
15151 default this works only for @LaTeX{}, HTML, and Texinfo.  Configure the
15152 variable @code{orgtbl-radio-tables} to install templates for other
15153 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
15154 be prompted for a table name, let's say we use @samp{salesfigures}.  You
15155 will then get the following template:
15157 @cindex #+ORGTBL, SEND
15158 @example
15159 % BEGIN RECEIVE ORGTBL salesfigures
15160 % END RECEIVE ORGTBL salesfigures
15161 \begin@{comment@}
15162 #+ORGTBL: SEND salesfigures orgtbl-to-latex
15163 | | |
15164 \end@{comment@}
15165 @end example
15167 @noindent
15168 @vindex @LaTeX{}-verbatim-environments
15169 The @code{#+ORGTBL: SEND} line tells Orgtbl mode to use the function
15170 @code{orgtbl-to-latex} to convert the table into @LaTeX{} and to put it
15171 into the receiver location with name @code{salesfigures}.  You may now
15172 fill in the table---feel free to use the spreadsheet features@footnote{If
15173 the @samp{#+TBLFM} line contains an odd number of dollar characters,
15174 this may cause problems with font-lock in @LaTeX{} mode.  As shown in the
15175 example you can fix this by adding an extra line inside the
15176 @code{comment} environment that is used to balance the dollar
15177 expressions.  If you are using AUC@TeX{} with the font-latex library, a
15178 much better solution is to add the @code{comment} environment to the
15179 variable @code{LaTeX-verbatim-environments}.}:
15181 @example
15182 % BEGIN RECEIVE ORGTBL salesfigures
15183 % END RECEIVE ORGTBL salesfigures
15184 \begin@{comment@}
15185 #+ORGTBL: SEND salesfigures orgtbl-to-latex
15186 | Month | Days | Nr sold | per day |
15187 |-------+------+---------+---------|
15188 | Jan   |   23 |      55 |     2.4 |
15189 | Feb   |   21 |      16 |     0.8 |
15190 | March |   22 |     278 |    12.6 |
15191 #+TBLFM: $4=$3/$2;%.1f
15192 % $ (optional extra dollar to keep font-lock happy, see footnote)
15193 \end@{comment@}
15194 @end example
15196 @noindent
15197 When you are done, press @kbd{C-c C-c} in the table to get the converted
15198 table inserted between the two marker lines.
15200 Now let's assume you want to make the table header by hand, because you
15201 want to control how columns are aligned, etc@.  In this case we make sure
15202 that the table translator skips the first 2 lines of the source
15203 table, and tell the command to work as a @i{splice}, i.e.@: to not produce
15204 header and footer commands of the target table:
15206 @example
15207 \begin@{tabular@}@{lrrr@}
15208 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
15209 % BEGIN RECEIVE ORGTBL salesfigures
15210 % END RECEIVE ORGTBL salesfigures
15211 \end@{tabular@}
15213 \begin@{comment@}
15214 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
15215 | Month | Days | Nr sold | per day |
15216 |-------+------+---------+---------|
15217 | Jan   |   23 |      55 |     2.4 |
15218 | Feb   |   21 |      16 |     0.8 |
15219 | March |   22 |     278 |    12.6 |
15220 #+TBLFM: $4=$3/$2;%.1f
15221 \end@{comment@}
15222 @end example
15224 The @LaTeX{} translator function @code{orgtbl-to-latex} is already part of
15225 Orgtbl mode.  It uses a @code{tabular} environment to typeset the table
15226 and marks horizontal lines with @code{\hline}.  Furthermore, it
15227 interprets the following parameters (see also @pxref{Translator functions}):
15229 @table @code
15230 @item :splice nil/t
15231 When set to t, return only table body lines, don't wrap them into a
15232 tabular environment.  Default is nil.
15234 @item :fmt fmt
15235 A format to be used to wrap each field, it should contain @code{%s} for the
15236 original field value.  For example, to wrap each field value in dollars,
15237 you could use @code{:fmt "$%s$"}.  This may also be a property list with
15238 column numbers and formats, for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
15239 A function of one argument can be used in place of the strings; the
15240 function must return a formatted string.
15242 @item :efmt efmt
15243 Use this format to print numbers with exponentials.  The format should
15244 have @code{%s} twice for inserting mantissa and exponent, for example
15245 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
15246 may also be a property list with column numbers and formats, for example
15247 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
15248 @code{efmt} has been applied to a value, @code{fmt} will also be
15249 applied.  Similar to @code{fmt}, functions of two arguments can be
15250 supplied instead of strings.
15251 @end table
15253 @node Translator functions, Radio lists, A LaTeX example, Tables in arbitrary syntax
15254 @subsection Translator functions
15255 @cindex HTML, and Orgtbl mode
15256 @cindex translator function
15258 Orgtbl mode has several translator functions built-in: @code{orgtbl-to-csv}
15259 (comma-separated values), @code{orgtbl-to-tsv} (TAB-separated values)
15260 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and @code{orgtbl-to-texinfo}.
15261 Except for @code{orgtbl-to-html}@footnote{The HTML translator uses the same
15262 code that produces tables during HTML export.}, these all use a generic
15263 translator, @code{orgtbl-to-generic}.  For example, @code{orgtbl-to-latex}
15264 itself is a very short function that computes the column definitions for the
15265 @code{tabular} environment, defines a few field and line separators and then
15266 hands processing over to the generic translator.  Here is the entire code:
15268 @lisp
15269 @group
15270 (defun orgtbl-to-latex (table params)
15271   "Convert the Orgtbl mode TABLE to LaTeX."
15272   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
15273                                org-table-last-alignment ""))
15274          (params2
15275           (list
15276            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
15277            :tend "\\end@{tabular@}"
15278            :lstart "" :lend " \\\\" :sep " & "
15279            :efmt "%s\\,(%s)" :hline "\\hline")))
15280     (orgtbl-to-generic table (org-combine-plists params2 params))))
15281 @end group
15282 @end lisp
15284 As you can see, the properties passed into the function (variable
15285 @var{PARAMS}) are combined with the ones newly defined in the function
15286 (variable @var{PARAMS2}).  The ones passed into the function (i.e.@: the
15287 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
15288 would like to use the @LaTeX{} translator, but wanted the line endings to
15289 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
15290 overrule the default with
15292 @example
15293 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
15294 @end example
15296 For a new language, you can either write your own converter function in
15297 analogy with the @LaTeX{} translator, or you can use the generic function
15298 directly.  For example, if you have a language where a table is started
15299 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
15300 started with @samp{!BL!}, ended with @samp{!EL!}, and where the field
15301 separator is a TAB, you could call the generic translator like this (on
15302 a single line!):
15304 @example
15305 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
15306                               :lstart "!BL! " :lend " !EL!" :sep "\t"
15307 @end example
15309 @noindent
15310 Please check the documentation string of the function
15311 @code{orgtbl-to-generic} for a full list of parameters understood by
15312 that function, and remember that you can pass each of them into
15313 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
15314 using the generic function.
15316 Of course you can also write a completely new function doing complicated
15317 things the generic translator cannot do.  A translator function takes
15318 two arguments.  The first argument is the table, a list of lines, each
15319 line either the symbol @code{hline} or a list of fields.  The second
15320 argument is the property list containing all parameters specified in the
15321 @samp{#+ORGTBL: SEND} line.  The function must return a single string
15322 containing the formatted table.  If you write a generally useful
15323 translator, please post it on @email{emacs-orgmode@@gnu.org} so that
15324 others can benefit from your work.
15326 @node Radio lists,  , Translator functions, Tables in arbitrary syntax
15327 @subsection Radio lists
15328 @cindex radio lists
15329 @cindex org-list-insert-radio-list
15331 Sending and receiving radio lists works exactly the same way as sending and
15332 receiving radio tables (@pxref{Radio tables}).  As for radio tables, you can
15333 insert radio list templates in HTML, @LaTeX{} and Texinfo modes by calling
15334 @code{org-list-insert-radio-list}.
15336 Here are the differences with radio tables:
15338 @itemize @minus
15339 @item
15340 Orgstruct mode must be active.
15341 @item
15342 Use the @code{ORGLST} keyword instead of @code{ORGTBL}.
15343 @item
15344 The available translation functions for radio lists don't take
15345 parameters.
15346 @item
15347 @kbd{C-c C-c} will work when pressed on the first item of the list.
15348 @end itemize
15350 Here is a @LaTeX{} example.  Let's say that you have this in your
15351 @LaTeX{} file:
15353 @cindex #+ORGLST
15354 @example
15355 % BEGIN RECEIVE ORGLST to-buy
15356 % END RECEIVE ORGLST to-buy
15357 \begin@{comment@}
15358 #+ORGLST: SEND to-buy org-list-to-latex
15359 - a new house
15360 - a new computer
15361   + a new keyboard
15362   + a new mouse
15363 - a new life
15364 \end@{comment@}
15365 @end example
15367 Pressing `C-c C-c' on @code{a new house} and will insert the converted
15368 @LaTeX{} list between the two marker lines.
15370 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Hacking
15371 @section Dynamic blocks
15372 @cindex dynamic blocks
15374 Org documents can contain @emph{dynamic blocks}.  These are
15375 specially marked regions that are updated by some user-written function.
15376 A good example for such a block is the clock table inserted by the
15377 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
15379 Dynamic blocks are enclosed by a BEGIN-END structure that assigns a name
15380 to the block and can also specify parameters for the function producing
15381 the content of the block.
15383 @cindex #+BEGIN:dynamic block
15384 @example
15385 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
15387 #+END:
15388 @end example
15390 Dynamic blocks are updated with the following commands
15392 @table @kbd
15393 @orgcmd{C-c C-x C-u,org-dblock-update}
15394 Update dynamic block at point.
15395 @orgkey{C-u C-c C-x C-u}
15396 Update all dynamic blocks in the current file.
15397 @end table
15399 Updating a dynamic block means to remove all the text between BEGIN and
15400 END, parse the BEGIN line for parameters and then call the specific
15401 writer function for this block to insert the new content.  If you want
15402 to use the original content in the writer function, you can use the
15403 extra parameter @code{:content}.
15405 For a block with name @code{myblock}, the writer function is
15406 @code{org-dblock-write:myblock} with as only parameter a property list
15407 with the parameters given in the begin line.  Here is a trivial example
15408 of a block that keeps track of when the block update function was last
15409 run:
15411 @example
15412 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
15414 #+END:
15415 @end example
15417 @noindent
15418 The corresponding block writer function could look like this:
15420 @lisp
15421 (defun org-dblock-write:block-update-time (params)
15422    (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
15423      (insert "Last block update at: "
15424              (format-time-string fmt (current-time)))))
15425 @end lisp
15427 If you want to make sure that all dynamic blocks are always up-to-date,
15428 you could add the function @code{org-update-all-dblocks} to a hook, for
15429 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
15430 written in a way such that it does nothing in buffers that are not in
15431 @code{org-mode}.
15433 You can narrow the current buffer to the current dynamic block (like any
15434 other block) with @code{org-narrow-to-block}.
15436 @node Special agenda views, Extracting agenda information, Dynamic blocks, Hacking
15437 @section Special agenda views
15438 @cindex agenda views, user-defined
15440 @vindex org-agenda-skip-function
15441 @vindex org-agenda-skip-function-global
15442 Org provides a special hook that can be used to narrow down the selection
15443 made by these agenda views: @code{agenda}, @code{todo}, @code{alltodo},
15444 @code{tags}, @code{tags-todo}, @code{tags-tree}.  You may specify a function
15445 that is used at each match to verify if the match should indeed be part of
15446 the agenda view, and if not, how much should be skipped.  You can specify a
15447 global condition that will be applied to all agenda views, this condition
15448 would be stored in the variable @code{org-agenda-skip-function-global}.  More
15449 commonly, such a definition is applied only to specific custom searches,
15450 using @code{org-agenda-skip-function}.
15452 Let's say you want to produce a list of projects that contain a WAITING
15453 tag anywhere in the project tree.  Let's further assume that you have
15454 marked all tree headings that define a project with the TODO keyword
15455 PROJECT.  In this case you would run a TODO search for the keyword
15456 PROJECT, but skip the match unless there is a WAITING tag anywhere in
15457 the subtree belonging to the project line.
15459 To achieve this, you must write a function that searches the subtree for
15460 the tag.  If the tag is found, the function must return @code{nil} to
15461 indicate that this match should not be skipped.  If there is no such
15462 tag, return the location of the end of the subtree, to indicate that
15463 search should continue from there.
15465 @lisp
15466 (defun my-skip-unless-waiting ()
15467   "Skip trees that are not waiting"
15468   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
15469     (if (re-search-forward ":waiting:" subtree-end t)
15470         nil          ; tag found, do not skip
15471       subtree-end))) ; tag not found, continue after end of subtree
15472 @end lisp
15474 Now you may use this function in an agenda custom command, for example
15475 like this:
15477 @lisp
15478 (org-add-agenda-custom-command
15479  '("b" todo "PROJECT"
15480    ((org-agenda-skip-function 'my-skip-unless-waiting)
15481     (org-agenda-overriding-header "Projects waiting for something: "))))
15482 @end lisp
15484 @vindex org-agenda-overriding-header
15485 Note that this also binds @code{org-agenda-overriding-header} to get a
15486 meaningful header in the agenda view.
15488 @vindex org-odd-levels-only
15489 @vindex org-agenda-skip-function
15490 A general way to create custom searches is to base them on a search for
15491 entries with a certain level limit.  If you want to study all entries with
15492 your custom search function, simply do a search for
15493 @samp{LEVEL>0}@footnote{Note that, when using @code{org-odd-levels-only}, a
15494 level number corresponds to order in the hierarchy, not to the number of
15495 stars.}, and then use @code{org-agenda-skip-function} to select the entries
15496 you really want to have.
15498 You may also put a Lisp form into @code{org-agenda-skip-function}.  In
15499 particular, you may use the functions @code{org-agenda-skip-entry-if}
15500 and @code{org-agenda-skip-subtree-if} in this form, for example:
15502 @table @code
15503 @item (org-agenda-skip-entry-if 'scheduled)
15504 Skip current entry if it has been scheduled.
15505 @item (org-agenda-skip-entry-if 'notscheduled)
15506 Skip current entry if it has not been scheduled.
15507 @item (org-agenda-skip-entry-if 'deadline)
15508 Skip current entry if it has a deadline.
15509 @item (org-agenda-skip-entry-if 'scheduled 'deadline)
15510 Skip current entry if it has a deadline, or if it is scheduled.
15511 @item (org-agenda-skip-entry-if 'todo '("TODO" "WAITING"))
15512 Skip current entry if the TODO keyword is TODO or WAITING.
15513 @item (org-agenda-skip-entry-if 'todo 'done)
15514 Skip current entry if the TODO keyword marks a DONE state.
15515 @item (org-agenda-skip-entry-if 'timestamp)
15516 Skip current entry if it has any timestamp, may also be deadline or scheduled.
15517 @item (org-agenda-skip-entry 'regexp "regular expression")
15518 Skip current entry if the regular expression matches in the entry.
15519 @item (org-agenda-skip-entry 'notregexp "regular expression")
15520 Skip current entry unless the regular expression matches.
15521 @item (org-agenda-skip-subtree-if 'regexp "regular expression")
15522 Same as above, but check and skip the entire subtree.
15523 @end table
15525 Therefore we could also have written the search for WAITING projects
15526 like this, even without defining a special function:
15528 @lisp
15529 (org-add-agenda-custom-command
15530  '("b" todo "PROJECT"
15531    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
15532                                 'regexp ":waiting:"))
15533     (org-agenda-overriding-header "Projects waiting for something: "))))
15534 @end lisp
15536 @node Extracting agenda information, Using the property API, Special agenda views, Hacking
15537 @section Extracting agenda information
15538 @cindex agenda, pipe
15539 @cindex Scripts, for agenda processing
15541 @vindex org-agenda-custom-commands
15542 Org provides commands to access agenda information for the command
15543 line in Emacs batch mode.  This extracted information can be sent
15544 directly to a printer, or it can be read by a program that does further
15545 processing of the data.  The first of these commands is the function
15546 @code{org-batch-agenda}, that produces an agenda view and sends it as
15547 ASCII text to STDOUT.  The command takes a single string as parameter.
15548 If the string has length 1, it is used as a key to one of the commands
15549 you have configured in @code{org-agenda-custom-commands}, basically any
15550 key you can use after @kbd{C-c a}.  For example, to directly print the
15551 current TODO list, you could use
15553 @example
15554 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
15555 @end example
15557 If the parameter is a string with 2 or more characters, it is used as a
15558 tags/TODO match string.  For example, to print your local shopping list
15559 (all items with the tag @samp{shop}, but excluding the tag
15560 @samp{NewYork}), you could use
15562 @example
15563 emacs -batch -l ~/.emacs                                      \
15564       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
15565 @end example
15567 @noindent
15568 You may also modify parameters on the fly like this:
15570 @example
15571 emacs -batch -l ~/.emacs                                      \
15572    -eval '(org-batch-agenda "a"                               \
15573             org-agenda-span (quote month)                     \
15574             org-agenda-include-diary nil                      \
15575             org-agenda-files (quote ("~/org/project.org")))'  \
15576    | lpr
15577 @end example
15579 @noindent
15580 which will produce a 30-day agenda, fully restricted to the Org file
15581 @file{~/org/projects.org}, not even including the diary.
15583 If you want to process the agenda data in more sophisticated ways, you
15584 can use the command @code{org-batch-agenda-csv} to get a comma-separated
15585 list of values for each agenda item.  Each line in the output will
15586 contain a number of fields separated by commas.  The fields in a line
15587 are:
15589 @example
15590 category     @r{The category of the item}
15591 head         @r{The headline, without TODO keyword, TAGS and PRIORITY}
15592 type         @r{The type of the agenda entry, can be}
15593                 todo               @r{selected in TODO match}
15594                 tagsmatch          @r{selected in tags match}
15595                 diary              @r{imported from diary}
15596                 deadline           @r{a deadline}
15597                 scheduled          @r{scheduled}
15598                 timestamp          @r{appointment, selected by timestamp}
15599                 closed             @r{entry was closed on date}
15600                 upcoming-deadline  @r{warning about nearing deadline}
15601                 past-scheduled     @r{forwarded scheduled item}
15602                 block              @r{entry has date block including date}
15603 todo         @r{The TODO keyword, if any}
15604 tags         @r{All tags including inherited ones, separated by colons}
15605 date         @r{The relevant date, like 2007-2-14}
15606 time         @r{The time, like 15:00-16:50}
15607 extra        @r{String with extra planning info}
15608 priority-l   @r{The priority letter if any was given}
15609 priority-n   @r{The computed numerical priority}
15610 @end example
15612 @noindent
15613 Time and date will only be given if a timestamp (or deadline/scheduled)
15614 led to the selection of the item.
15616 A CSV list like this is very easy to use in a post-processing script.
15617 For example, here is a Perl program that gets the TODO list from
15618 Emacs/Org and prints all the items, preceded by a checkbox:
15620 @example
15621 #!/usr/bin/perl
15623 # define the Emacs command to run
15624 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
15626 # run it and capture the output
15627 $agenda = qx@{$cmd 2>/dev/null@};
15629 # loop over all lines
15630 foreach $line (split(/\n/,$agenda)) @{
15631   # get the individual values
15632   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
15633    $priority_l,$priority_n) = split(/,/,$line);
15634   # process and print
15635   print "[ ] $head\n";
15637 @end example
15639 @node Using the property API, Using the mapping API, Extracting agenda information, Hacking
15640 @section Using the property API
15641 @cindex API, for properties
15642 @cindex properties, API
15644 Here is a description of the functions that can be used to work with
15645 properties.
15647 @defun org-entry-properties &optional pom which
15648 Get all properties of the entry at point-or-marker POM.@*
15649 This includes the TODO keyword, the tags, time strings for deadline,
15650 scheduled, and clocking, and any additional properties defined in the
15651 entry.  The return value is an alist.  Keys may occur multiple times
15652 if the property key was used several times.@*
15653 POM may also be nil, in which case the current entry is used.
15654 If WHICH is nil or `all', get all properties.  If WHICH is
15655 `special' or `standard', only get that subclass.
15656 @end defun
15657 @vindex org-use-property-inheritance
15658 @defun org-entry-get pom property &optional inherit
15659 Get value of PROPERTY for entry at point-or-marker POM.  By default,
15660 this only looks at properties defined locally in the entry.  If INHERIT
15661 is non-nil and the entry does not have the property, then also check
15662 higher levels of the hierarchy.  If INHERIT is the symbol
15663 @code{selective}, use inheritance if and only if the setting of
15664 @code{org-use-property-inheritance} selects PROPERTY for inheritance.
15665 @end defun
15667 @defun org-entry-delete pom property
15668 Delete the property PROPERTY from entry at point-or-marker POM.
15669 @end defun
15671 @defun org-entry-put pom property value
15672 Set PROPERTY to VALUE for entry at point-or-marker POM.
15673 @end defun
15675 @defun org-buffer-property-keys &optional include-specials
15676 Get all property keys in the current buffer.
15677 @end defun
15679 @defun org-insert-property-drawer
15680 Insert a property drawer at point.
15681 @end defun
15683 @defun org-entry-put-multivalued-property pom property &rest values
15684 Set PROPERTY at point-or-marker POM to VALUES.  VALUES should be a list of
15685 strings.  They will be concatenated, with spaces as separators.
15686 @end defun
15688 @defun org-entry-get-multivalued-property pom property
15689 Treat the value of the property PROPERTY as a whitespace-separated list of
15690 values and return the values as a list of strings.
15691 @end defun
15693 @defun org-entry-add-to-multivalued-property pom property value
15694 Treat the value of the property PROPERTY as a whitespace-separated list of
15695 values and make sure that VALUE is in this list.
15696 @end defun
15698 @defun org-entry-remove-from-multivalued-property pom property value
15699 Treat the value of the property PROPERTY as a whitespace-separated list of
15700 values and make sure that VALUE is @emph{not} in this list.
15701 @end defun
15703 @defun org-entry-member-in-multivalued-property pom property value
15704 Treat the value of the property PROPERTY as a whitespace-separated list of
15705 values and check if VALUE is in this list.
15706 @end defun
15708 @defopt org-property-allowed-value-functions
15709 Hook for functions supplying allowed values for a specific property.
15710 The functions must take a single argument, the name of the property, and
15711 return a flat list of allowed values.  If @samp{:ETC} is one of
15712 the values, use the values as completion help, but allow also other values
15713 to be entered.  The functions must return @code{nil} if they are not
15714 responsible for this property.
15715 @end defopt
15717 @node Using the mapping API,  , Using the property API, Hacking
15718 @section Using the mapping API
15719 @cindex API, for mapping
15720 @cindex mapping entries, API
15722 Org has sophisticated mapping capabilities to find all entries satisfying
15723 certain criteria.  Internally, this functionality is used to produce agenda
15724 views, but there is also an API that can be used to execute arbitrary
15725 functions for each or selected entries.  The main entry point for this API
15728 @defun org-map-entries func &optional match scope &rest skip
15729 Call FUNC at each headline selected by MATCH in SCOPE.
15731 FUNC is a function or a Lisp form.  The function will be called without
15732 arguments, with the cursor positioned at the beginning of the headline.
15733 The return values of all calls to the function will be collected and
15734 returned as a list.
15736 The call to FUNC will be wrapped into a save-excursion form, so FUNC
15737 does not need to preserve point.  After evaluation, the cursor will be
15738 moved to the end of the line (presumably of the headline of the
15739 processed entry) and search continues from there.  Under some
15740 circumstances, this may not produce the wanted results.  For example,
15741 if you have removed (e.g.@: archived) the current (sub)tree it could
15742 mean that the next entry will be skipped entirely.  In such cases, you
15743 can specify the position from where search should continue by making
15744 FUNC set the variable `org-map-continue-from' to the desired buffer
15745 position.
15747 MATCH is a tags/property/todo match as it is used in the agenda match view.
15748 Only headlines that are matched by this query will be considered during
15749 the iteration.  When MATCH is nil or t, all headlines will be
15750 visited by the iteration.
15752 SCOPE determines the scope of this command.  It can be any of:
15754 @example
15755 nil     @r{the current buffer, respecting the restriction if any}
15756 tree    @r{the subtree started with the entry at point}
15757 region  @r{The entries within the active region, if any}
15758 file    @r{the current buffer, without restriction}
15759 file-with-archives
15760         @r{the current buffer, and any archives associated with it}
15761 agenda  @r{all agenda files}
15762 agenda-with-archives
15763         @r{all agenda files with any archive files associated with them}
15764 (file1 file2 ...)
15765         @r{if this is a list, all files in the list will be scanned}
15766 @end example
15767 @noindent
15768 The remaining args are treated as settings for the skipping facilities of
15769 the scanner.  The following items can be given here:
15771 @vindex org-agenda-skip-function
15772 @example
15773 archive   @r{skip trees with the archive tag}
15774 comment   @r{skip trees with the COMMENT keyword}
15775 function or Lisp form
15776           @r{will be used as value for @code{org-agenda-skip-function},}
15777           @r{so whenever the function returns t, FUNC}
15778           @r{will not be called for that entry and search will}
15779           @r{continue from the point where the function leaves it}
15780 @end example
15781 @end defun
15783 The function given to that mapping routine can really do anything you like.
15784 It can use the property API (@pxref{Using the property API}) to gather more
15785 information about the entry, or in order to change metadata in the entry.
15786 Here are a couple of functions that might be handy:
15788 @defun org-todo &optional arg
15789 Change the TODO state of the entry.  See the docstring of the functions for
15790 the many possible values for the argument ARG.
15791 @end defun
15793 @defun org-priority &optional action
15794 Change the priority of the entry.  See the docstring of this function for the
15795 possible values for ACTION.
15796 @end defun
15798 @defun org-toggle-tag tag &optional onoff
15799 Toggle the tag TAG in the current entry.  Setting ONOFF to either @code{on}
15800 or @code{off} will not toggle tag, but ensure that it is either on or off.
15801 @end defun
15803 @defun org-promote
15804 Promote the current entry.
15805 @end defun
15807 @defun org-demote
15808 Demote the current entry.
15809 @end defun
15811 Here is a simple example that will turn all entries in the current file with
15812 a tag @code{TOMORROW} into TODO entries with the keyword @code{UPCOMING}.
15813 Entries in comment trees and in archive trees will be ignored.
15815 @lisp
15816 (org-map-entries
15817    '(org-todo "UPCOMING")
15818    "+TOMORROW" 'file 'archive 'comment)
15819 @end lisp
15821 The following example counts the number of entries with TODO keyword
15822 @code{WAITING}, in all agenda files.
15824 @lisp
15825 (length (org-map-entries t "/+WAITING" 'agenda))
15826 @end lisp
15828 @node MobileOrg, History and Acknowledgments, Hacking, Top
15829 @appendix MobileOrg
15830 @cindex iPhone
15831 @cindex MobileOrg
15833 @uref{http://mobileorg.ncogni.to/, MobileOrg} is an application for the
15834 @i{iPhone/iPod Touch} series of devices, developed by Richard Moreland.
15835 @i{MobileOrg} offers offline viewing and capture support for an Org-mode
15836 system rooted on a ``real'' computer.  It does also allow you to record
15837 changes to existing entries.  Android users should check out
15838 @uref{http://wiki.github.com/matburt/mobileorg-android/, MobileOrg Android}
15839 by Matt Jones.
15841 This appendix describes the support Org has for creating agenda views in a
15842 format that can be displayed by @i{MobileOrg}, and for integrating notes
15843 captured and changes made by @i{MobileOrg} into the main system.
15845 For changing tags and TODO states in MobileOrg, you should have set up the
15846 customization variables @code{org-todo-keywords} and @code{org-tags-alist} to
15847 cover all important tags and TODO keywords, even if individual files use only
15848 part of these.  MobileOrg will also offer you states and tags set up with
15849 in-buffer settings, but it will understand the logistics of TODO state
15850 @i{sets} (@pxref{Per-file keywords}) and @i{mutually exclusive} tags
15851 (@pxref{Setting tags}) only for those set in these variables.
15853 @menu
15854 * Setting up the staging area::  Where to interact with the mobile device
15855 * Pushing to MobileOrg::        Uploading Org files and agendas
15856 * Pulling from MobileOrg::      Integrating captured and flagged items
15857 @end menu
15859 @node Setting up the staging area, Pushing to MobileOrg, MobileOrg, MobileOrg
15860 @section Setting up the staging area
15862 MobileOrg needs to interact with Emacs through a directory on a server.  If you
15863 are using a public server, you should consider to encrypt the files that are
15864 uploaded to the server.  This can be done with Org-mode 7.02 and with
15865 @i{MobileOrg 1.5} (iPhone version), and you need an @file{openssl}
15866 installation on your system.  To turn on encryption, set a password in
15867 @i{MobileOrg} and, on the Emacs side, configure the variable
15868 @code{org-mobile-use-encryption}@footnote{If you can safely store the
15869 password in your Emacs setup, you might also want to configure
15870 @code{org-mobile-encryption-password}.  Please read the docstring of that
15871 variable.  Note that encryption will apply only to the contents of the
15872 @file{.org} files.  The file names themselves will remain visible.}.
15874 The easiest way to create that directory is to use a free
15875 @uref{http://dropbox.com,Dropbox.com} account@footnote{If you cannot use
15876 Dropbox, or if your version of MobileOrg does not support it, you can use a
15877 webdav server.  For more information, check out the documentation of MobileOrg and also this
15878 @uref{http://orgmode.org/worg/org-faq.html#mobileorg_webdav, FAQ entry}.}.
15879 When MobileOrg first connects to your Dropbox, it will create a directory
15880 @i{MobileOrg} inside the Dropbox.  After the directory has been created, tell
15881 Emacs about it:
15883 @lisp
15884 (setq org-mobile-directory "~/Dropbox/MobileOrg")
15885 @end lisp
15887 Org-mode has commands to put files for @i{MobileOrg} into that directory,
15888 and to read captured notes from there.
15890 @node Pushing to MobileOrg, Pulling from MobileOrg, Setting up the staging area, MobileOrg
15891 @section Pushing to MobileOrg
15893 This operation copies all files currently listed in @code{org-mobile-files}
15894 to the directory @code{org-mobile-directory}.  By default this list contains
15895 all agenda files (as listed in @code{org-agenda-files}), but additional files
15896 can be included by customizing @code{org-mobile-files}.  File names will be
15897 staged with paths relative to @code{org-directory}, so all files should be
15898 inside this directory.  The push operation also creates a special Org file
15899 @file{agendas.org} with all custom agenda view defined by the
15900 user@footnote{While creating the agendas, Org-mode will force ID properties
15901 on all referenced entries, so that these entries can be uniquely identified
15902 if @i{MobileOrg} flags them for further action.  If you do not want to get
15903 these properties in so many entries, you can set the variable
15904 @code{org-mobile-force-id-on-agenda-items} to @code{nil}.  Org mode will then
15905 rely on outline paths, in the hope that these will be unique enough.}.
15906 Finally, Org writes the file @file{index.org}, containing links to all other
15907 files.  @i{MobileOrg} first reads this file from the server, and then
15908 downloads all agendas and Org files listed in it.  To speed up the download,
15909 MobileOrg will only read files whose checksums@footnote{stored automatically
15910 in the file @file{checksums.dat}} have changed.
15912 @node Pulling from MobileOrg,  , Pushing to MobileOrg, MobileOrg
15913 @section Pulling from MobileOrg
15915 When @i{MobileOrg} synchronizes with the server, it not only pulls the Org
15916 files for viewing.  It also appends captured entries and pointers to flagged
15917 and changed entries to the file @file{mobileorg.org} on the server.  Org has
15918 a @emph{pull} operation that integrates this information into an inbox file
15919 and operates on the pointers to flagged entries.  Here is how it works:
15921 @enumerate
15922 @item
15923 Org moves all entries found in
15924 @file{mobileorg.org}@footnote{@file{mobileorg.org} will be empty after this
15925 operation.} and appends them to the file pointed to by the variable
15926 @code{org-mobile-inbox-for-pull}.  Each captured entry and each editing event
15927 will be a top-level entry in the inbox file.
15928 @item
15929 After moving the entries, Org will attempt to implement the changes made in
15930 @i{MobileOrg}.  Some changes are applied directly and without user
15931 interaction.  Examples are all changes to tags, TODO state, headline and body
15932 text that can be cleanly applied.  Entries that have been flagged for further
15933 action will receive a tag @code{:FLAGGED:}, so that they can be easily found
15934 again.  When there is a problem finding an entry or applying the change, the
15935 pointer entry will remain in the inbox and will be marked with an error
15936 message.  You need to later resolve these issues by hand.
15937 @item
15938 Org will then generate an agenda view with all flagged entries.  The user
15939 should then go through these entries and do whatever actions are necessary.
15940 If a note has been stored while flagging an entry in @i{MobileOrg}, that note
15941 will be displayed in the echo area when the cursor is on the corresponding
15942 agenda line.
15943 @table @kbd
15944 @kindex ?
15945 @item ?
15946 Pressing @kbd{?} in that special agenda will display the full flagging note in
15947 another window and also push it onto the kill ring.  So you could use @kbd{?
15948 z C-y C-c C-c} to store that flagging note as a normal note in the entry.
15949 Pressing @kbd{?} twice in succession will offer to remove the
15950 @code{:FLAGGED:} tag along with the recorded flagging note (which is stored
15951 in a property).  In this way you indicate that the intended processing for
15952 this flagged entry is finished.
15953 @end table
15954 @end enumerate
15956 @kindex C-c a ?
15957 If you are not able to process all flagged entries directly, you can always
15958 return to this agenda view@footnote{Note, however, that there is a subtle
15959 difference.  The view created automatically by @kbd{M-x org-mobile-pull
15960 @key{RET}} is guaranteed to search all files that have been addressed by the
15961 last pull.  This might include a file that is not currently in your list of
15962 agenda files.  If you later use @kbd{C-c a ?} to regenerate the view, only
15963 the current agenda files will be searched.} using @kbd{C-c a ?}.
15965 @node History and Acknowledgments, Main Index, MobileOrg, Top
15966 @appendix History and acknowledgments
15967 @cindex acknowledgments
15968 @cindex history
15969 @cindex thanks
15971 Org was born in 2003, out of frustration over the user interface of the Emacs
15972 Outline mode.  I was trying to organize my notes and projects, and using
15973 Emacs seemed to be the natural way to go.  However, having to remember eleven
15974 different commands with two or three keys per command, only to hide and show
15975 parts of the outline tree, that seemed entirely unacceptable to me.  Also,
15976 when using outlines to take notes, I constantly wanted to restructure the
15977 tree, organizing it parallel to my thoughts and plans.  @emph{Visibility
15978 cycling} and @emph{structure editing} were originally implemented in the
15979 package @file{outline-magic.el}, but quickly moved to the more general
15980 @file{org.el}.  As this environment became comfortable for project planning,
15981 the next step was adding @emph{TODO entries}, basic @emph{timestamps}, and
15982 @emph{table support}.  These areas highlighted the two main goals that Org
15983 still has today: to be a new, outline-based, plain text mode with innovative
15984 and intuitive editing features, and to incorporate project planning
15985 functionality directly into a notes file.
15987 Since the first release, literally thousands of emails to me or to
15988 @email{emacs-orgmode@@gnu.org} have provided a constant stream of bug
15989 reports, feedback, new ideas, and sometimes patches and add-on code.
15990 Many thanks to everyone who has helped to improve this package.  I am
15991 trying to keep here a list of the people who had significant influence
15992 in shaping one or more aspects of Org.  The list may not be
15993 complete, if I have forgotten someone, please accept my apologies and
15994 let me know.
15996 Before I get to this list, a few special mentions are in order:
15998 @table @i
15999 @item Bastien Guerry
16000 Bastien has written a large number of extensions to Org (most of them
16001 integrated into the core by now), including the LaTeX exporter and the plain
16002 list parser.  His support during the early days, when he basically acted as
16003 co-maintainer, was central to the success of this project.  Bastien also
16004 invented Worg, helped establishing the Web presence of Org, and sponsors
16005 hosting costs for the orgmode.org website.
16006 @item Eric Schulte and Dan Davison
16007 Eric and Dan are jointly responsible for the Org-babel system, which turns
16008 Org into a multi-language environment for evaluating code and doing literate
16009 programming and reproducible research.
16010 @item John Wiegley
16011 John has contributed a number of great ideas and patches directly to Org,
16012 including the attachment system (@file{org-attach.el}), integration with
16013 Apple Mail (@file{org-mac-message.el}), hierarchical dependencies of TODO
16014 items, habit tracking (@file{org-habits.el}), and encryption
16015 (@file{org-crypt.el}).  Also, the capture system is really an extended copy
16016 of his great @file{remember.el}.
16017 @item Sebastian Rose
16018 Without Sebastian, the HTML/XHTML publishing of Org would be the pitiful work
16019 of an ignorant amateur.  Sebastian has pushed this part of Org onto a much
16020 higher level.  He also wrote @file{org-info.js}, a Java script for displaying
16021 webpages derived from Org using an Info-like or a folding interface with
16022 single-key navigation.
16023 @end table
16025 @noindent OK, now to the full list of contributions!  Again, please let me
16026 know what I am missing here!
16028 @itemize @bullet
16030 @item
16031 @i{Russel Adams} came up with the idea for drawers.
16032 @item
16033 @i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}.
16034 @item
16035 @i{Christophe Bataillon} created the great unicorn logo that we use on the
16036 Org-mode website.
16037 @item
16038 @i{Alex Bochannek} provided a patch for rounding timestamps.
16039 @item
16040 @i{Jan Böcker} wrote @file{org-docview.el}.
16041 @item
16042 @i{Brad Bozarth} showed how to pull RSS feed data into Org-mode files.
16043 @item
16044 @i{Tom Breton} wrote @file{org-choose.el}.
16045 @item
16046 @i{Charles Cave}'s suggestion sparked the implementation of templates
16047 for Remember, which are now templates for capture.
16048 @item
16049 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
16050 specified time.
16051 @item
16052 @i{Gregory Chernov} patched support for Lisp forms into table
16053 calculations and improved XEmacs compatibility, in particular by porting
16054 @file{nouline.el} to XEmacs.
16055 @item
16056 @i{Sacha Chua} suggested copying some linking code from Planner.
16057 @item
16058 @i{Baoqiu Cui} contributed the DocBook exporter.
16059 @item
16060 @i{Eddward DeVilla} proposed and tested checkbox statistics.  He also
16061 came up with the idea of properties, and that there should be an API for
16062 them.
16063 @item
16064 @i{Nick Dokos} tracked down several nasty bugs.
16065 @item
16066 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
16067 inspired some of the early development, including HTML export.  He also
16068 asked for a way to narrow wide table columns.
16069 @item
16070 @i{Thomas S. Dye} contributed documentation on Worg and helped integrating
16071 the Org-Babel documentation into the manual.
16072 @item
16073 @i{Christian Egli} converted the documentation into Texinfo format, inspired
16074 the agenda, patched CSS formatting into the HTML exporter, and wrote
16075 @file{org-taskjuggler.el}.
16076 @item
16077 @i{David Emery} provided a patch for custom CSS support in exported
16078 HTML agendas.
16079 @item
16080 @i{Nic Ferrier} contributed mailcap and XOXO support.
16081 @item
16082 @i{Miguel A. Figueroa-Villanueva} implemented hierarchical checkboxes.
16083 @item
16084 @i{John Foerch} figured out how to make incremental search show context
16085 around a match in a hidden outline tree.
16086 @item
16087 @i{Raimar Finken} wrote @file{org-git-line.el}.
16088 @item
16089 @i{Mikael Fornius} works as a mailing list moderator.
16090 @item
16091 @i{Austin Frank} works as a mailing list moderator.
16092 @item
16093 @i{Eric Fraga} drove the development of BEAMER export with ideas and
16094 testing.
16095 @item
16096 @i{Barry Gidden} did proofreading the manual in preparation for the book
16097 publication through Network Theory Ltd.
16098 @item
16099 @i{Niels Giesen} had the idea to automatically archive DONE trees.
16100 @item
16101 @i{Nicolas Goaziou} rewrote much of the plain list code.
16102 @item
16103 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
16104 @item
16105 @i{Brian Gough} of Network Theory Ltd publishes the Org mode manual as a
16106 book.
16107 @item
16108 @i{Bernt Hansen} has driven much of the support for auto-repeating tasks,
16109 task state change logging, and the clocktable.  His clear explanations have
16110 been critical when we started to adopt the Git version control system.
16111 @item
16112 @i{Manuel Hermenegildo} has contributed various ideas, small fixes and
16113 patches.
16114 @item
16115 @i{Phil Jackson} wrote @file{org-irc.el}.
16116 @item
16117 @i{Scott Jaderholm} proposed footnotes, control over whitespace between
16118 folded entries, and column view for properties.
16119 @item
16120 @i{Matt Jones} wrote @i{MobileOrg Android}.
16121 @item
16122 @i{Tokuya Kameshima} wrote @file{org-wl.el} and @file{org-mew.el}.
16123 @item
16124 @i{Shidai Liu} ("Leo") asked for embedded @LaTeX{} and tested it.  He also
16125 provided frequent feedback and some patches.
16126 @item
16127 @i{Matt Lundin} has proposed last-row references for table formulas and named
16128 invisible anchors.  He has also worked a lot on the FAQ.
16129 @item
16130 @i{David Maus} wrote @file{org-atom.el}, maintains the issues file for Org,
16131 and is a prolific contributor on the mailing list with competent replies,
16132 small fixes and patches.
16133 @item
16134 @i{Jason F. McBrayer} suggested agenda export to CSV format.
16135 @item
16136 @i{Max Mikhanosha} came up with the idea of refiling.
16137 @item
16138 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
16139 basis.
16140 @item
16141 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
16142 happy.
16143 @item
16144 @i{Richard Moreland} wrote @i{MobileOrg} for the iPhone.
16145 @item
16146 @i{Rick Moynihan} proposed allowing multiple TODO sequences in a file
16147 and being able to quickly restrict the agenda to a subtree.
16148 @item
16149 @i{Todd Neal} provided patches for links to Info files and Elisp forms.
16150 @item
16151 @i{Greg Newman} refreshed the unicorn logo into its current form.
16152 @item
16153 @i{Tim O'Callaghan} suggested in-file links, search options for general
16154 file links, and TAGS.
16155 @item
16156 @i{Osamu Okano} wrote @file{orgcard2ref.pl}, a Perl program to create a text
16157 version of the reference card.
16158 @item
16159 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
16160 into Japanese.
16161 @item
16162 @i{Oliver Oppitz} suggested multi-state TODO items.
16163 @item
16164 @i{Scott Otterson} sparked the introduction of descriptive text for
16165 links, among other things.
16166 @item
16167 @i{Pete Phillips} helped during the development of the TAGS feature, and
16168 provided frequent feedback.
16169 @item
16170 @i{Martin Pohlack} provided the code snippet to bundle character insertion
16171 into bundles of 20 for undo.
16172 @item
16173 @i{T.V. Raman} reported bugs and suggested improvements.
16174 @item
16175 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
16176 control.
16177 @item
16178 @i{Paul Rivier} provided the basic implementation of named footnotes.  He
16179 also acted as mailing list moderator for some time.
16180 @item
16181 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
16182 @item
16183 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
16184 conflict with @file{allout.el}.
16185 @item
16186 @i{Jason Riedy} generalized the send-receive mechanism for Orgtbl tables with
16187 extensive patches.
16188 @item
16189 @i{Philip Rooke} created the Org reference card, provided lots
16190 of feedback, developed and applied standards to the Org documentation.
16191 @item
16192 @i{Christian Schlauer} proposed angular brackets around links, among
16193 other things.
16194 @item
16195 @i{Paul Sexton} wrote @file{org-ctags.el}.
16196 @item
16197 Linking to VM/BBDB/Gnus was first inspired by @i{Tom Shannon}'s
16198 @file{organizer-mode.el}.
16199 @item
16200 @i{Ilya Shlyakhter} proposed the Archive Sibling, line numbering in literal
16201 examples, and remote highlighting for referenced code lines.
16202 @item
16203 @i{Stathis Sideris} wrote the @file{ditaa.jar} ASCII to PNG converter that is
16204 now packaged into Org's @file{contrib} directory.
16205 @item
16206 @i{Daniel Sinder} came up with the idea of internal archiving by locking
16207 subtrees.
16208 @item
16209 @i{Dale Smith} proposed link abbreviations.
16210 @item
16211 @i{James TD Smith} has contributed a large number of patches for useful
16212 tweaks and features.
16213 @item
16214 @i{Adam Spiers} asked for global linking commands, inspired the link
16215 extension system, added support for mairix, and proposed the mapping API.
16216 @item
16217 @i{Ulf Stegemann} created the table to translate special symbols to HTML,
16218 LaTeX, UTF-8, Latin-1 and ASCII.
16219 @item
16220 @i{Andy Stewart} contributed code to @file{org-w3m.el}, to copy HTML content
16221 with links transformation to Org syntax.
16222 @item
16223 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
16224 chapter about publishing.
16225 @item
16226 @i{Jambunathan K} contributed the @acronym{ODT} exporter.
16227 @item
16228 @i{Sebastien Vauban} reported many issues with LaTeX and BEAMER export and
16229 enabled source code highlighling in Gnus.
16230 @item
16231 @i{Stefan Vollmar} organized a video-recorded talk at the
16232 Max-Planck-Institute for Neurology.  He also inspired the creation of a
16233 concept index for HTML export.
16234 @item
16235 @i{J@"urgen Vollmer} contributed code generating the table of contents
16236 in HTML output.
16237 @item
16238 @i{Samuel Wales} has provided important feedback and bug reports.
16239 @item
16240 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
16241 keyword.
16242 @item
16243 @i{David Wainberg} suggested archiving, and improvements to the linking
16244 system.
16245 @item
16246 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
16247 linking to Gnus.
16248 @item
16249 @i{Roland Winkler} requested additional key bindings to make Org
16250 work on a tty.
16251 @item
16252 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
16253 and contributed various ideas and code snippets.
16254 @item
16255 @end itemize
16258 @node Main Index, Key Index, History and Acknowledgments, Top
16259 @unnumbered Concept index
16261 @printindex cp
16263 @node Key Index, Command and Function Index, Main Index, Top
16264 @unnumbered Key index
16266 @printindex ky
16268 @node Command and Function Index, Variable Index, Key Index, Top
16269 @unnumbered Command and function index
16271 @printindex fn
16273 @node Variable Index,  , Command and Function Index, Top
16274 @unnumbered Variable index
16276 This is not a complete index of variables and faces, only the ones that are
16277 mentioned in the manual.  For a more complete list, use @kbd{M-x
16278 org-customize @key{RET}} and then click yourself through the tree.
16280 @printindex vr
16282 @bye
16284 @c Local variables:
16285 @c fill-column: 77
16286 @c indent-tabs-mode: nil
16287 @c paragraph-start:    "\b\\|^@[a-zA-Z]*[ \n]\\|^@x?org\\(key\\|cmd\\)\\|\f\\|[  ]*$"
16288 @c paragraph-separate: "\b\\|^@[a-zA-Z]*[ \n]\\|^@x?org\\(key\\|cmd\\)\\|[       \f]*$"
16289 @c End:
16292 @c  LocalWords:  webdavhost pre