Fix typos
[org-mode.git] / doc / org.texi
blob4ce32ce47e0572ce914ef23a609c7e9ece059224
2 \input texinfo
3 @c %**start of header
4 @setfilename ../../info/org
5 @settitle The Org Manual
7 @set VERSION 7.01trans
8 @set DATE July 2010
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
24 @c Macro definitions
25 @macro orgcmd{key,command}
26 @iftex
27 @kindex \key\
28 @findex \command\
29 @item @kbd{\key\} @hskip 0pt plus 1filll @code{\command\}
30 @end iftex
31 @ifnottex
32 @kindex \key\
33 @findex \command\
34 @item @kbd{\key\} @tie{}@tie{}@tie{}@tie{}(@code{\command\})
35 @end ifnottex
36 @end macro
38 @macro orgkey{key}
39 @kindex \key\
40 @item @kbd{\key\}
41 @end macro
43 @iftex
44 @c @hyphenation{time-stamp time-stamps time-stamp-ing time-stamp-ed}
45 @end iftex
46 @macro Ie {}
47 I.e.,
48 @end macro
49 @macro ie {}
50 i.e.,
51 @end macro
52 @macro Eg {}
53 E.g.,
54 @end macro
55 @macro eg {}
56 e.g.,
57 @end macro
59 @c Subheadings inside a table.
60 @macro tsubheading{text}
61 @ifinfo
62 @subsubheading \text\
63 @end ifinfo
64 @ifnotinfo
65 @item @b{\text\}
66 @end ifnotinfo
67 @end macro
69 @copying
70 This manual is for Org version @value{VERSION}.
72 Copyright @copyright{} 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation
74 @quotation
75 Permission is granted to copy, distribute and/or modify this document
76 under the terms of the GNU Free Documentation License, Version 1.3 or
77 any later version published by the Free Software Foundation; with no
78 Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
79 and with the Back-Cover Texts as in (a) below.  A copy of the license
80 is included in the section entitled ``GNU Free Documentation License.''
82 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
83 modify this GNU manual.  Buying copies from the FSF supports it in
84 developing GNU and promoting software freedom.''
86 This document is part of a collection distributed under the GNU Free
87 Documentation License.  If you want to distribute this document
88 separately from the collection, you can do so by adding a copy of the
89 license to the document, as described in section 6 of the license.
90 @end quotation
91 @end copying
93 @dircategory Emacs
94 @direntry
95 * Org Mode: (org).      Outline-based notes management and organizer
96 @end direntry
98 @titlepage
99 @title The Org Manual
101 @subtitle Release @value{VERSION}
102 @author by Carsten Dominik
103 with contributions by David O'Toole, Bastien Guerry, Philip Rooke, Dan Davison, Eric Schulte, and Thomas Dye
105 @c The following two commands start the copyright page.
106 @page
107 @vskip 0pt plus 1filll
108 @insertcopying
109 @end titlepage
111 @c Output the table of contents at the beginning.
112 @contents
114 @ifnottex
115 @node Top, Introduction, (dir), (dir)
116 @top Org Mode Manual
118 @insertcopying
119 @end ifnottex
121 @menu
122 * Introduction::                Getting started
123 * Document Structure::          A tree works like your brain
124 * Tables::                      Pure magic for quick formatting
125 * Hyperlinks::                  Notes in context
126 * TODO Items::                  Every tree branch can be a TODO item
127 * Tags::                        Tagging headlines and matching sets of tags
128 * Properties and Columns::      Storing information about an entry
129 * Dates and Times::             Making items useful for planning
130 * Capture - Refile - Archive::  The ins and outs for projects
131 * Agenda Views::                Collecting information into views
132 * Markup::                      Prepare text for rich export
133 * Exporting::                   Sharing and publishing of notes
134 * Publishing::                  Create a web site of linked Org files
135 * Working With Source Code::    Export, evaluate, and tangle code blocks
136 * Miscellaneous::               All the rest which did not fit elsewhere
137 * Hacking::                     How to hack your way around
138 * MobileOrg::                   Viewing and capture on a mobile device
139 * History and Acknowledgments::  How Org came into being
140 * Main Index::                  An index of Org's concepts and features
141 * Key Index::                   Key bindings and where they are described
142 * Command and Function Index::  Command names and some internal functions
143 * Variable Index::              Variables mentioned in the manual
145 @detailmenu
146  --- The Detailed Node Listing ---
148 Introduction
150 * Summary::                     Brief summary of what Org does
151 * Installation::                How to install a downloaded version of Org
152 * Activation::                  How to activate Org for certain buffers
153 * Feedback::                    Bug reports, ideas, patches etc.
154 * Conventions::                 Type-setting conventions in the manual
156 Document structure
158 * Outlines::                    Org is based on Outline mode
159 * Headlines::                   How to typeset Org tree headlines
160 * Visibility cycling::          Show and hide, much simplified
161 * Motion::                      Jumping to other headlines
162 * Structure editing::           Changing sequence and level of headlines
163 * Sparse trees::                Matches embedded in context
164 * Plain lists::                 Additional structure within an entry
165 * Drawers::                     Tucking stuff away
166 * Blocks::                      Folding blocks
167 * Footnotes::                   How footnotes are defined in Org's syntax
168 * Orgstruct mode::              Structure editing outside Org
170 Tables
172 * Built-in table editor::       Simple tables
173 * Column width and alignment::  Overrule the automatic settings
174 * Column groups::               Grouping to trigger vertical lines
175 * Orgtbl mode::                 The table editor as minor mode
176 * The spreadsheet::             The table editor has spreadsheet capabilities
177 * Org-Plot::                    Plotting from org tables
179 The spreadsheet
181 * References::                  How to refer to another field or range
182 * Formula syntax for Calc::     Using Calc to compute stuff
183 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
184 * Field formulas::              Formulas valid for a single field
185 * Column formulas::             Formulas valid for an entire column
186 * Editing and debugging formulas::  Fixing formulas
187 * Updating the table::          Recomputing all dependent fields
188 * Advanced features::           Field names, parameters and automatic recalc
190 Hyperlinks
192 * Link format::                 How links in Org are formatted
193 * Internal links::              Links to other places in the current file
194 * External links::              URL-like links to the world
195 * Handling links::              Creating, inserting and following
196 * Using links outside Org::     Linking from my C source code?
197 * Link abbreviations::          Shortcuts for writing complex links
198 * Search options::              Linking to a specific location
199 * Custom searches::             When the default search is not enough
201 Internal links
203 * Radio targets::               Make targets trigger links in plain text
205 TODO items
207 * TODO basics::                 Marking and displaying TODO entries
208 * TODO extensions::             Workflow and assignments
209 * Progress logging::            Dates and notes for progress
210 * Priorities::                  Some things are more important than others
211 * Breaking down tasks::         Splitting a task into manageable pieces
212 * Checkboxes::                  Tick-off lists
214 Extended use of TODO keywords
216 * Workflow states::             From TODO to DONE in steps
217 * TODO types::                  I do this, Fred does the rest
218 * Multiple sets in one file::   Mixing it all, and still finding your way
219 * Fast access to TODO states::  Single letter selection of a state
220 * Per-file keywords::           Different files, different requirements
221 * Faces for TODO keywords::     Highlighting states
222 * TODO dependencies::           When one task needs to wait for others
224 Progress logging
226 * Closing items::               When was this entry marked DONE?
227 * Tracking TODO state changes::  When did the status change?
228 * Tracking your habits::        How consistent have you been?
230 Tags
232 * Tag inheritance::             Tags use the tree structure of the outline
233 * Setting tags::                How to assign tags to a headline
234 * Tag searches::                Searching for combinations of tags
236 Properties and columns
238 * Property syntax::             How properties are spelled out
239 * Special properties::          Access to other Org-mode features
240 * Property searches::           Matching property values
241 * Property inheritance::        Passing values down the tree
242 * Column view::                 Tabular viewing and editing
243 * Property API::                Properties for Lisp programmers
245 Column view
247 * Defining columns::            The COLUMNS format property
248 * Using column view::           How to create and use column view
249 * Capturing column view::       A dynamic block for column view
251 Defining columns
253 * Scope of column definitions::  Where defined, where valid?
254 * Column attributes::           Appearance and content of a column
256 Dates and times
258 * Timestamps::                  Assigning a time to a tree entry
259 * Creating timestamps::         Commands which insert timestamps
260 * Deadlines and scheduling::    Planning your work
261 * Clocking work time::          Tracking how long you spend on a task
262 * Resolving idle time::         Resolving time if you've been idle
263 * Effort estimates::            Planning work effort in advance
264 * Relative timer::              Notes with a running timer
266 Creating timestamps
268 * The date/time prompt::        How Org-mode helps you entering date and time
269 * Custom time format::          Making dates look different
271 Deadlines and scheduling
273 * Inserting deadline/schedule::  Planning items
274 * Repeated tasks::              Items that show up again and again
276 Capture - Refile - Archive
278 * Capture::                     Capturing new stuff
279 * Attachments::                 Add files to tasks
280 * RSS Feeds::                   Getting input from RSS feeds
281 * Protocols::                   External (e.g. Browser) access to Emacs and Org
282 * Refiling notes::              Moving a tree from one place to another
283 * Archiving::                   What to do with finished projects
285 Capture
287 * Setting up capture::          Where notes will be stored
288 * Using capture::               Commands to invoke and terminate capture
289 * Capture templates::           Define the outline of different note types
291 Capture templates
293 * Template elements::           What is needed for a complete template entry
294 * Template expansion::          Filling in information about time and context
296 Archiving
298 * Moving subtrees::             Moving a tree to an archive file
299 * Internal archiving::          Switch off a tree but keep it in the file
301 Agenda views
303 * Agenda files::                Files being searched for agenda information
304 * Agenda dispatcher::           Keyboard access to agenda views
305 * Built-in agenda views::       What is available out of the box?
306 * Presentation and sorting::    How agenda items are prepared for display
307 * Agenda commands::             Remote editing of Org trees
308 * Custom agenda views::         Defining special searches and views
309 * Exporting Agenda Views::      Writing a view to a file
310 * Agenda column view::          Using column view for collected entries
312 The built-in agenda views
314 * Weekly/daily agenda::         The calendar page with current tasks
315 * Global TODO list::            All unfinished action items
316 * Matching tags and properties::  Structured information with fine-tuned search
317 * Timeline::                    Time-sorted view for single file
318 * Search view::                 Find entries by searching for text
319 * Stuck projects::              Find projects you need to review
321 Presentation and sorting
323 * Categories::                  Not all tasks are equal
324 * Time-of-day specifications::  How the agenda knows the time
325 * Sorting of agenda items::     The order of things
327 Custom agenda views
329 * Storing searches::            Type once, use often
330 * Block agenda::                All the stuff you need in a single buffer
331 * Setting Options::             Changing the rules
333 Markup for rich export
335 * Structural markup elements::  The basic structure as seen by the exporter
336 * Images and tables::           Tables and Images will be included
337 * Literal examples::            Source code examples with special formatting
338 * Include files::               Include additional files into a document
339 * Index entries::               Making an index
340 * Macro replacement::           Use macros to create complex output
341 * Embedded LaTeX::              LaTeX can be freely used inside Org documents
343 Structural markup elements
345 * Document title::              Where the title is taken from
346 * Headings and sections::       The document structure as seen by the exporter
347 * Table of contents::           The if and where of the table of contents
348 * Initial text::                Text before the first heading?
349 * Lists::                       Lists
350 * Paragraphs::                  Paragraphs
351 * Footnote markup::             Footnotes
352 * Emphasis and monospace::      Bold, italic, etc.
353 * Horizontal rules::            Make a line
354 * Comment lines::               What will *not* be exported
356 Embedded La@TeX{}
358 * Special symbols::             Greek letters and other symbols
359 * Subscripts and superscripts::  Simple syntax for raising/lowering text
360 * LaTeX fragments::             Complex formulas made easy
361 * Previewing LaTeX fragments::  What will this snippet look like?
362 * CDLaTeX mode::                Speed up entering of formulas
364 Exporting
366 * Selective export::            Using tags to select and exclude trees
367 * Export options::              Per-file export settings
368 * The export dispatcher::       How to access exporter commands
369 * ASCII/Latin-1/UTF-8 export::  Exporting to flat files with encoding
370 * HTML export::                 Exporting to HTML
371 * LaTeX and PDF export::        Exporting to La@TeX{}, and processing to PDF
372 * DocBook export::              Exporting to DocBook
373 * TaskJuggler export::          Exporting to TaskJuggler
374 * Freemind export::             Exporting to Freemind mind maps
375 * XOXO export::                 Exporting to XOXO
376 * iCalendar export::            Exporting in iCalendar format
378 HTML export
380 * HTML Export commands::        How to invoke HTML export
381 * Quoting HTML tags::           Using direct HTML in Org-mode
382 * Links in HTML export::        How links will be interpreted and formatted
383 * Tables in HTML export::       How to modify the formatting of tables
384 * Images in HTML export::       How to insert figures into HTML output
385 * Math formatting in HTML export::  Beautiful math also on the web
386 * Text areas in HTML export::   An alternative way to show an example
387 * CSS support::                 Changing the appearance of the output
388 * JavaScript support::          Info and Folding in a web browser
390 La@TeX{} and PDF export
392 * LaTeX/PDF export commands::   Which key invokes which commands
393 * Header and sectioning::       Setting up the export file structure
394 * Quoting LaTeX code::          Incorporating literal La@TeX{} code
395 * Tables in LaTeX export::      Options for exporting tables to La@TeX{}
396 * Images in LaTeX export::      How to insert figures into La@TeX{} output
397 * Beamer class export::         Turning the file into a presentation
399 DocBook export
401 * DocBook export commands::     How to invoke DocBook export
402 * Quoting DocBook code::        Incorporating DocBook code in Org files
403 * Recursive sections::          Recursive sections in DocBook
404 * Tables in DocBook export::    Tables are exported as HTML tables
405 * Images in DocBook export::    How to insert figures into DocBook output
406 * Special characters::          How to handle special characters
408 Publishing
410 * Configuration::               Defining projects
411 * Uploading files::             How to get files up on the server
412 * Sample configuration::        Example projects
413 * Triggering publication::      Publication commands
415 Configuration
417 * Project alist::               The central configuration variable
418 * Sources and destinations::    From here to there
419 * Selecting files::             What files are part of the project?
420 * Publishing action::           Setting the function doing the publishing
421 * Publishing options::          Tweaking HTML export
422 * Publishing links::            Which links keep working after publishing?
423 * Sitemap::                     Generating a list of all pages
424 * Generating an index::         An index that reaches across pages
426 Sample configuration
428 * Simple example::              One-component publishing
429 * Complex example::             A multi-component publishing example
431 Working with source code
433 * Structure of code blocks::    Code block syntax described
434 * Editing source code::         Language major-mode editing
435 * Exporting code blocks::       Export contents and/or results
436 * Extracting source code::      Create pure source code files
437 * Evaluating code blocks::      Place results of evaluation in the Org-mode buffer
438 * Library of Babel::            Use and contribute to a library of useful code blocks
439 * Languages::                   List of supported code block languages
440 * Header arguments::            Configure code block functionality
441 * Results of evaluation::       How evaluation results are handled
442 * Noweb reference syntax::      Literate programming in Org-mode
443 * Key bindings and useful functions::  Work quickly with code blocks
444 * Batch execution::             Call functions from the command line
446 Header arguments
448 * Using header arguments::      Different ways to set header arguments
449 * Specific header arguments::   List of header arguments
451 Using header arguments
453 * System-wide header arguments::  Set global default values
454 * Language-specific header arguments::  Set default values by language
455 * Buffer-wide header arguments::  Set default values for a specific buffer
456 * Header arguments in Org-mode properties::  Set default values for a buffer or heading
457 * Code block specific header arguments::  The most common way to set values
459 Specific header arguments
461 * var::                         Pass arguments to code blocks
462 * results::                     Specify the type of results and how they will
463                                 be collected and handled
464 * file::                        Specify a path for file output
465 * dir::                         Specify the default (possibly remote)
466                                 directory for code block execution
467 * exports::                     Export code and/or results
468 * tangle::                      Toggle tangling and specify file name
469 * comments::                    Toggle insertion of comments in tangled
470                                 code files
471 * no-expand::                   Turn off variable assignment and noweb
472                                 expansion during tangling
473 * session::                     Preserve the state of code evaluation
474 * noweb::                       Toggle expansion of noweb references
475 * cache::                       Avoid re-evaluating unchanged code blocks
476 * hlines::                      Handle horizontal lines in tables
477 * colnames::                    Handle column names in tables
478 * rownames::                    Handle row names in tables
479 * shebang::                     Make tangled files executable
480 * eval::                        Limit evaluation of specific code blocks
482 Miscellaneous
484 * Completion::                  M-TAB knows what you need
485 * Easy Templates::              Quick insertion of structural elements
486 * Speed keys::                  Electric commands at the beginning of a headline
487 * Code evaluation security::    Org mode files evaluate inline code
488 * Customization::               Adapting Org to your taste
489 * In-buffer settings::          Overview of the #+KEYWORDS
490 * The very busy C-c C-c key::   When in doubt, press C-c C-c
491 * Clean view::                  Getting rid of leading stars in the outline
492 * TTY keys::                    Using Org on a tty
493 * Interaction::                 Other Emacs packages
495 Interaction with other packages
497 * Cooperation::                 Packages Org cooperates with
498 * Conflicts::                   Packages that lead to conflicts
500 Hacking
502 * Hooks::                       Who to reach into Org's internals
503 * Add-on packages::             Available extensions
504 * Adding hyperlink types::      New custom link types
505 * Context-sensitive commands::  How to add functionality to such commands
506 * Tables in arbitrary syntax::  Orgtbl for La@TeX{} and other programs
507 * Dynamic blocks::              Automatically filled blocks
508 * Special agenda views::        Customized views
509 * Extracting agenda information::  Postprocessing of agenda information
510 * Using the property API::      Writing programs that use entry properties
511 * Using the mapping API::       Mapping over all or selected entries
513 Tables and lists in arbitrary syntax
515 * Radio tables::                Sending and receiving radio tables
516 * A LaTeX example::             Step by step, almost a tutorial
517 * Translator functions::        Copy and modify
518 * Radio lists::                 Doing the same for lists
520 MobileOrg
522 * Setting up the staging area::  Where to interact with the mobile device
523 * Pushing to MobileOrg::        Uploading Org files and agendas
524 * Pulling from MobileOrg::      Integrating captured and flagged items
526 @end detailmenu
527 @end menu
529 @node Introduction, Document Structure, Top, Top
530 @chapter Introduction
531 @cindex introduction
533 @menu
534 * Summary::                     Brief summary of what Org does
535 * Installation::                How to install a downloaded version of Org
536 * Activation::                  How to activate Org for certain buffers
537 * Feedback::                    Bug reports, ideas, patches etc.
538 * Conventions::                 Type-setting conventions in the manual
539 @end menu
541 @node Summary, Installation, Introduction, Introduction
542 @section Summary
543 @cindex summary
545 Org is a mode for keeping notes, maintaining TODO lists, and doing
546 project planning with a fast and effective plain-text system.
548 Org develops organizational tasks around NOTES files that contain
549 lists or information about projects as plain text.  Org is
550 implemented on top of Outline mode, which makes it possible to keep the
551 content of large files well structured.  Visibility cycling and
552 structure editing help to work with the tree.  Tables are easily created
553 with a built-in table editor.  Org supports TODO items, deadlines,
554 timestamps, and scheduling.  It dynamically compiles entries into an
555 agenda that utilizes and smoothly integrates much of the Emacs calendar
556 and diary.  Plain text URL-like links connect to websites, emails,
557 Usenet messages, BBDB entries, and any files related to the projects.
558 For printing and sharing of notes, an Org file can be exported as a
559 structured ASCII file, as HTML, or (TODO and agenda items only) as an
560 iCalendar file.  It can also serve as a publishing tool for a set of
561 linked web pages.
563 As a project planning environment, Org works by adding metadata to outline
564 nodes.  Based on this data, specific entries can be extracted in queries and
565 create dynamic @i{agenda views}.
567 Org mode contains the Org Babel environment which allows to work with
568 embedded source code block in a file, to facilitate code evaluation,
569 documentation, and tangling.
571 Org's automatic, context-sensitive table editor with spreadsheet
572 capabilities can be integrated into any major mode by activating the
573 minor Orgtbl mode.  Using a translation step, it can be used to maintain
574 tables in arbitrary file types, for example in La@TeX{}.  The structure
575 editing and list creation capabilities can be used outside Org with
576 the minor Orgstruct mode.
578 Org keeps simple things simple.  When first fired up, it should
579 feel like a straightforward, easy to use outliner.  Complexity is not
580 imposed, but a large amount of functionality is available when you need
581 it.  Org is a toolbox and can be used in different ways and for different
582 ends, for example:
584 @example
585 @r{@bullet{} an outline extension with visibility cycling and structure editing}
586 @r{@bullet{} an ASCII system and table editor for taking structured notes}
587 @r{@bullet{} a TODO list editor}
588 @r{@bullet{} a full agenda and planner with deadlines and work scheduling}
589 @pindex GTD, Getting Things Done
590 @r{@bullet{} an environment in which to implement David Allen's GTD system}
591 @r{@bullet{} a simple hypertext system, with HTML and La@TeX{} export}
592 @r{@bullet{} a publishing tool to create a set of interlinked webpages}
593 @r{@bullet{} an environment for literate programming}
594 @end example
597 @cindex FAQ
598 There is a website for Org which provides links to the newest
599 version of Org, as well as additional information, frequently asked
600 questions (FAQ), links to tutorials, etc@.  This page is located at
601 @uref{http://orgmode.org}.
603 @page
606 @node Installation, Activation, Summary, Introduction
607 @section Installation
608 @cindex installation
609 @cindex XEmacs
611 @b{Important:} @i{If you are using a version of Org that is part of the Emacs
612 distribution or an XEmacs package, please skip this section and go directly
613 to @ref{Activation}.}
615 If you have downloaded Org from the Web, either as a distribution @file{.zip}
616 or @file{.tar} file, or as a Git archive, you must take the following steps
617 to install it: go into the unpacked Org distribution directory and edit the
618 top section of the file @file{Makefile}.  You must set the name of the Emacs
619 binary (likely either @file{emacs} or @file{xemacs}), and the paths to the
620 directories where local Lisp and Info files are kept.  If you don't have
621 access to the system-wide directories, you can simply run Org directly from
622 the distribution directory by adding the @file{lisp} subdirectory to the
623 Emacs load path.  To do this, add the following line to @file{.emacs}:
625 @example
626 (setq load-path (cons "~/path/to/orgdir/lisp" load-path))
627 @end example
629 @noindent
630 If you plan to use code from the @file{contrib} subdirectory, do a similar
631 step for this directory:
633 @example
634 (setq load-path (cons "~/path/to/orgdir/contrib/lisp" load-path))
635 @end example
637 @noindent Now byte-compile the Lisp files with the shell command:
639 @example
640 make
641 @end example
643 @noindent If you are running Org from the distribution directory, this is
644 all.  If you want to install Org into the system directories, use (as
645 administrator)
647 @example
648 make install
649 @end example
651 Installing Info files is system dependent, because of differences in the
652 @file{install-info} program.  In Debian it copies the info files into the
653 correct directory and modifies the info directory file.  In many other
654 systems, the files need to be copied to the correct directory separately, and
655 @file{install-info} then only modifies the directory file.  Check your system
656 documentation to find out which of the following commands you need:
658 @example
659 make install-info
660 make install-info-debian
661 @end example
663 Then add the following line to @file{.emacs}.  It is needed so that
664 Emacs can autoload functions that are located in files not immediately loaded
665 when Org-mode starts.
666 @lisp
667 (require 'org-install)
668 @end lisp
670 Do not forget to activate Org as described in the following section.
671 @page
673 @node Activation, Feedback, Installation, Introduction
674 @section Activation
675 @cindex activation
676 @cindex autoload
677 @cindex global key bindings
678 @cindex key bindings, global
680 Add the following lines to your @file{.emacs} file.  The last three lines
681 define @emph{global} keys for the commands @command{org-store-link},
682 @command{org-agenda}, and @command{org-iswitchb}---please choose suitable
683 keys yourself.
685 @lisp
686 ;; The following lines are always needed.  Choose your own keys.
687 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
688 (global-set-key "\C-cl" 'org-store-link)
689 (global-set-key "\C-ca" 'org-agenda)
690 (global-set-key "\C-cb" 'org-iswitchb)
691 @end lisp
693 Furthermore, you must activate @code{font-lock-mode} in Org
694 buffers, because significant functionality depends on font-locking being
695 active.  You can do this with either one of the following two lines
696 (XEmacs users must use the second option):
697 @lisp
698 (global-font-lock-mode 1)                     ; for all buffers
699 (add-hook 'org-mode-hook 'turn-on-font-lock)  ; Org buffers only
700 @end lisp
702 @cindex Org-mode, turning on
703 With this setup, all files with extension @samp{.org} will be put
704 into Org-mode.  As an alternative, make the first line of a file look
705 like this:
707 @example
708 MY PROJECTS    -*- mode: org; -*-
709 @end example
711 @vindex org-insert-mode-line-in-empty-file
712 @noindent which will select Org-mode for this buffer no matter what
713 the file's name is.  See also the variable
714 @code{org-insert-mode-line-in-empty-file}.
716 Many commands in Org work on the region if the region is @i{active}.  To make
717 use of this, you need to have @code{transient-mark-mode}
718 (@code{zmacs-regions} in XEmacs) turned on.  In Emacs 23 this is the default,
719 in Emacs 22 you need to do this yourself with
720 @lisp
721 (transient-mark-mode 1)
722 @end lisp
723 @noindent If you do not like @code{transient-mark-mode}, you can create an
724 active region by using the mouse to select a region, or pressing
725 @kbd{C-@key{SPC}} twice before moving the cursor.
727 @node Feedback, Conventions, Activation, Introduction
728 @section Feedback
729 @cindex feedback
730 @cindex bug reports
731 @cindex maintainer
732 @cindex author
734 If you find problems with Org, or if you have questions, remarks, or ideas
735 about it, please mail to the Org mailing list @email{emacs-orgmode@@gnu.org}.
736 If you are not a member of the mailing list, your mail will be passed to the
737 list after a moderator has approved it@footnote{Please consider subscribing
738 to the mailing list, in order to minimize the work the mailing list
739 moderators have to do.}.
741 For bug reports, please first try to reproduce the bug with the latest
742 version of Org available - if you are running an outdated version, it is
743 quite possible that the bug has been fixed already.  If the bug persists,
744 prepare a report and provide as much information as possible, including the
745 version information of Emacs (@kbd{M-x emacs-version @key{RET}}) and Org
746 (@kbd{M-x org-version @key{RET}}), as well as the Org related setup in
747 @file{.emacs}.  The easiest way to do this is to use the command
748 @example
749 @kbd{M-x org-submit-bug-report}
750 @end example
751 @noindent which will put all this information into an Emacs mail buffer so
752 that you only need to add your description.  If you re not sending the Email
753 from within Emacs, please copy and paste the content into your Email program.
755 If an error occurs, a backtrace can be very useful (see below on how to
756 create one).  Often a small example file helps, along with clear information
757 about:
759 @enumerate
760 @item What exactly did you do?
761 @item What did you expect to happen?
762 @item What happened instead?
763 @end enumerate
764 @noindent Thank you for helping to improve this program.
766 @subsubheading How to create a useful backtrace
768 @cindex backtrace of an error
769 If working with Org produces an error with a message you don't
770 understand, you may have hit a bug.  The best way to report this is by
771 providing, in addition to what was mentioned above, a @emph{backtrace}.
772 This is information from the built-in debugger about where and how the
773 error occurred.  Here is how to produce a useful backtrace:
775 @enumerate
776 @item
777 Reload uncompiled versions of all Org-mode Lisp files.  The backtrace
778 contains much more information if it is produced with uncompiled code.
779 To do this, use
780 @example
781 C-u M-x org-reload RET
782 @end example
783 @noindent
784 or select @code{Org -> Refresh/Reload -> Reload Org uncompiled} from the
785 menu.
786 @item
787 Go to the @code{Options} menu and select @code{Enter Debugger on Error}
788 (XEmacs has this option in the @code{Troubleshooting} sub-menu).
789 @item
790 Do whatever you have to do to hit the error.  Don't forget to
791 document the steps you take.
792 @item
793 When you hit the error, a @file{*Backtrace*} buffer will appear on the
794 screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
795 attach it to your bug report.
796 @end enumerate
798 @node Conventions,  , Feedback, Introduction
799 @section Typesetting conventions used in this manual
801 Org uses three types of keywords: TODO keywords, tags, and property
802 names.  In this manual we use the following conventions:
804 @table @code
805 @item TODO
806 @itemx WAITING
807 TODO keywords are written with all capitals, even if they are
808 user-defined.
809 @item boss
810 @itemx ARCHIVE
811 User-defined tags are written in lowercase; built-in tags with special
812 meaning are written with all capitals.
813 @item Release
814 @itemx PRIORITY
815 User-defined properties are capitalized; built-in properties with
816 special meaning are written with all capitals.
817 @end table
819 @node Document Structure, Tables, Introduction, Top
820 @chapter Document structure
821 @cindex document structure
822 @cindex structure of document
824 Org is based on Outline mode and provides flexible commands to
825 edit the structure of the document.
827 @menu
828 * Outlines::                    Org is based on Outline mode
829 * Headlines::                   How to typeset Org tree headlines
830 * Visibility cycling::          Show and hide, much simplified
831 * Motion::                      Jumping to other headlines
832 * Structure editing::           Changing sequence and level of headlines
833 * Sparse trees::                Matches embedded in context
834 * Plain lists::                 Additional structure within an entry
835 * Drawers::                     Tucking stuff away
836 * Blocks::                      Folding blocks
837 * Footnotes::                   How footnotes are defined in Org's syntax
838 * Orgstruct mode::              Structure editing outside Org
839 @end menu
841 @node Outlines, Headlines, Document Structure, Document Structure
842 @section Outlines
843 @cindex outlines
844 @cindex Outline mode
846 Org is implemented on top of Outline mode.  Outlines allow a
847 document to be organized in a hierarchical structure, which (at least
848 for me) is the best representation of notes and thoughts.  An overview
849 of this structure is achieved by folding (hiding) large parts of the
850 document to show only the general document structure and the parts
851 currently being worked on.  Org greatly simplifies the use of
852 outlines by compressing the entire show/hide functionality into a single
853 command, @command{org-cycle}, which is bound to the @key{TAB} key.
855 @node Headlines, Visibility cycling, Outlines, Document Structure
856 @section Headlines
857 @cindex headlines
858 @cindex outline tree
859 @vindex org-special-ctrl-a/e
860 @vindex org-special-ctrl-k
861 @vindex org-ctrl-k-protect-subtree
863 Headlines define the structure of an outline tree.  The headlines in Org
864 start with one or more stars, on the left margin@footnote{See the variables
865 @code{org-special-ctrl-a/e}, @code{org-special-ctrl-k}, and
866 @code{org-ctrl-k-protect-subtree} to configure special behavior of @kbd{C-a},
867 @kbd{C-e}, and @kbd{C-k} in headlines.}.  For example:
869 @example
870 * Top level headline
871 ** Second level
872 *** 3rd level
873     some text
874 *** 3rd level
875     more text
877 * Another top level headline
878 @end example
880 @noindent Some people find the many stars too noisy and would prefer an
881 outline that has whitespace followed by a single star as headline
882 starters.  @ref{Clean view}, describes a setup to realize this.
884 @vindex org-cycle-separator-lines
885 An empty line after the end of a subtree is considered part of it and
886 will be hidden when the subtree is folded.  However, if you leave at
887 least two empty lines, one empty line will remain visible after folding
888 the subtree, in order to structure the collapsed view.  See the
889 variable @code{org-cycle-separator-lines} to modify this behavior.
891 @node Visibility cycling, Motion, Headlines, Document Structure
892 @section Visibility cycling
893 @cindex cycling, visibility
894 @cindex visibility cycling
895 @cindex trees, visibility
896 @cindex show hidden text
897 @cindex hide text
899 Outlines make it possible to hide parts of the text in the buffer.
900 Org uses just two commands, bound to @key{TAB} and
901 @kbd{S-@key{TAB}} to change the visibility in the buffer.
903 @cindex subtree visibility states
904 @cindex subtree cycling
905 @cindex folded, subtree visibility state
906 @cindex children, subtree visibility state
907 @cindex subtree, subtree visibility state
908 @table @asis
909 @orgcmd{@key{TAB},org-cycle}
910 @emph{Subtree cycling}: Rotate current subtree among the states
912 @example
913 ,-> FOLDED -> CHILDREN -> SUBTREE --.
914 '-----------------------------------'
915 @end example
917 @vindex org-cycle-emulate-tab
918 @vindex org-cycle-global-at-bob
919 The cursor must be on a headline for this to work@footnote{see, however,
920 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
921 beginning of the buffer and the first line is not a headline, then
922 @key{TAB} actually runs global cycling (see below)@footnote{see the
923 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
924 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
926 @cindex global visibility states
927 @cindex global cycling
928 @cindex overview, global visibility state
929 @cindex contents, global visibility state
930 @cindex show all, global visibility state
931 @orgcmd{S-@key{TAB},org-global-cycle}
932 @itemx C-u @key{TAB}
933 @emph{Global cycling}: Rotate the entire buffer among the states
935 @example
936 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
937 '--------------------------------------'
938 @end example
940 When @kbd{S-@key{TAB}} is called with a numeric prefix argument N, the
941 CONTENTS view up to headlines of level N will be shown.  Note that inside
942 tables, @kbd{S-@key{TAB}} jumps to the previous field.
944 @cindex show all, command
945 @orgcmd{C-u C-u C-u @key{TAB},show-all}
946 Show all, including drawers.
947 @orgcmd{C-c C-r,org-reveal}
948 Reveal context around point, showing the current entry, the following heading
949 and the hierarchy above.  Useful for working near a location that has been
950 exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda command
951 (@pxref{Agenda commands}).  With a prefix argument show, on each
952 level, all sibling headings.  With double prefix arg, also show the entire
953 subtree of the parent.
954 @orgcmd{C-c C-k,show-branches}
955 Expose all the headings of the subtree, CONTENT view for just one subtree.
956 @orgcmd{C-c C-x b,org-tree-to-indirect-buffer}
957 Show the current subtree in an indirect buffer@footnote{The indirect
958 buffer
959 @ifinfo
960 (@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
961 @end ifinfo
962 @ifnotinfo
963 (see the Emacs manual for more information about indirect buffers)
964 @end ifnotinfo
965 will contain the entire buffer, but will be narrowed to the current
966 tree.  Editing the indirect buffer will also change the original buffer,
967 but without affecting visibility in that buffer.}.  With a numeric
968 prefix argument N, go up to level N and then take that tree.  If N is
969 negative then go up that many levels.  With a @kbd{C-u} prefix, do not remove
970 the previously used indirect buffer.
971 @end table
973 @vindex org-startup-folded
974 @cindex @code{overview}, STARTUP keyword
975 @cindex @code{content}, STARTUP keyword
976 @cindex @code{showall}, STARTUP keyword
977 @cindex @code{showeverything}, STARTUP keyword
979 When Emacs first visits an Org file, the global state is set to
980 OVERVIEW, i.e. only the top level headlines are visible.  This can be
981 configured through the variable @code{org-startup-folded}, or on a
982 per-file basis by adding one of the following lines anywhere in the
983 buffer:
985 @example
986 #+STARTUP: overview
987 #+STARTUP: content
988 #+STARTUP: showall
989 #+STARTUP: showeverything
990 @end example
992 @cindex property, VISIBILITY
993 @noindent
994 Furthermore, any entries with a @samp{VISIBILITY} property (@pxref{Properties
995 and Columns}) will get their visibility adapted accordingly.  Allowed values
996 for this property are @code{folded}, @code{children}, @code{content}, and
997 @code{all}.
998 @table @asis
999 @orgcmd{C-u C-u @key{TAB},org-set-startup-visibility}
1000 Switch back to the startup visibility of the buffer, i.e. whatever is
1001 requested by startup options and @samp{VISIBILITY} properties in individual
1002 entries.
1003 @end table
1005 @node Motion, Structure editing, Visibility cycling, Document Structure
1006 @section Motion
1007 @cindex motion, between headlines
1008 @cindex jumping, to headlines
1009 @cindex headline navigation
1010 The following commands jump to other headlines in the buffer.
1012 @table @asis
1013 @orgcmd{C-c C-n,outline-next-visible-heading}
1014 Next heading.
1015 @orgcmd{C-c C-p,outline-previous-visible-heading}
1016 Previous heading.
1017 @orgcmd{C-c C-f,org-forward-same-level}
1018 Next heading same level.
1019 @orgcmd{C-c C-b,org-backward-same-level}
1020 Previous heading same level.
1021 @orgcmd{C-c C-u,outline-up-heading}
1022 Backward to higher level heading.
1023 @orgcmd{C-c C-j,org-goto}
1024 Jump to a different place without changing the current outline
1025 visibility.  Shows the document structure in a temporary buffer, where
1026 you can use the following keys to find your destination:
1027 @vindex org-goto-auto-isearch
1028 @example
1029 @key{TAB}         @r{Cycle visibility.}
1030 @key{down} / @key{up}   @r{Next/previous visible headline.}
1031 @key{RET}         @r{Select this location.}
1032 @kbd{/}           @r{Do a Sparse-tree search}
1033 @r{The following keys work if you turn off @code{org-goto-auto-isearch}}
1034 n / p        @r{Next/previous visible headline.}
1035 f / b        @r{Next/previous headline same level.}
1036 u            @r{One level up.}
1037 0-9          @r{Digit argument.}
1038 q            @r{Quit}
1039 @end example
1040 @vindex org-goto-interface
1041 @noindent
1042 See also the variable @code{org-goto-interface}.
1043 @end table
1045 @node Structure editing, Sparse trees, Motion, Document Structure
1046 @section Structure editing
1047 @cindex structure editing
1048 @cindex headline, promotion and demotion
1049 @cindex promotion, of subtrees
1050 @cindex demotion, of subtrees
1051 @cindex subtree, cut and paste
1052 @cindex pasting, of subtrees
1053 @cindex cutting, of subtrees
1054 @cindex copying, of subtrees
1055 @cindex sorting, of subtrees
1056 @cindex subtrees, cut and paste
1058 @table @asis
1059 @orgcmd{M-@key{RET},org-insert-heading}
1060 @vindex org-M-RET-may-split-line
1061 Insert new heading with same level as current.  If the cursor is in a
1062 plain list item, a new item is created (@pxref{Plain lists}).  To force
1063 creation of a new headline, use a prefix argument, or first press @key{RET}
1064 to get to the beginning of the next line.  When this command is used in
1065 the middle of a line, the line is split and the rest of the line becomes
1066 the new headline@footnote{If you do not want the line to be split,
1067 customize the variable @code{org-M-RET-may-split-line}.}.  If the
1068 command is used at the beginning of a headline, the new headline is
1069 created before the current line.  If at the beginning of any other line,
1070 the content of that line is made the new heading.  If the command is
1071 used at the end of a folded subtree (i.e. behind the ellipses at the end
1072 of a headline), then a headline like the current one will be inserted
1073 after the end of the subtree.
1074 @kindex C-@key{RET}
1075 @item C-@key{RET}
1076 Just like @kbd{M-@key{RET}}, except when adding a new heading below the
1077 current heading, the new heading is placed after the body instead of before
1078 it.  This command works from anywhere in the entry.
1079 @kindex M-S-@key{RET}
1080 @item M-S-@key{RET}
1081 @vindex org-treat-insert-todo-heading-as-state-change
1082 Insert new TODO entry with same level as current heading.  See also the
1083 variable @code{org-treat-insert-todo-heading-as-state-change}.
1084 @kindex C-S-@key{RET}
1085 @item C-S-@key{RET}
1086 Insert new TODO entry with same level as current heading.  Like
1087 @kbd{C-@key{RET}}, the new headline will be inserted after the current
1088 subtree.
1089 @orgcmd{@key{TAB},org-cycle}
1090 In a new entry with no text yet, the first @key{TAB} demotes the entry to
1091 become a child of the previous one.  The next @key{TAB} makes it a parent,
1092 and so on, all the way to top level.  Yet another @key{TAB}, and you are back
1093 to the initial level.
1094 @orgcmd{M-@key{left},org-do-promote}
1095 Promote current heading by one level.
1096 @orgcmd{M-@key{right},org-do-demote}
1097 Demote current heading by one level.
1098 @orgcmd{M-S-@key{left},org-promote-subtree}
1099 Promote the current subtree by one level.
1100 @orgcmd{M-S-@key{right},org-demote-subtree}
1101 Demote the current subtree by one level.
1102 @orgcmd{M-S-@key{up},org-move-subtree-up}
1103 Move subtree up (swap with previous subtree of same
1104 level).
1105 @orgcmd{M-S-@key{down},org-move-subtree-down}
1106 Move subtree down (swap with next subtree of same level).
1107 @orgcmd{C-c C-x C-w,org-cut-subtree}
1108 Kill subtree, i.e. remove it from buffer but save in kill ring.
1109 With a numeric prefix argument N, kill N sequential subtrees.
1110 @orgcmd{C-c C-x M-w,org-copy-subtree}
1111 Copy subtree to kill ring.  With a numeric prefix argument N, copy the N
1112 sequential subtrees.
1113 @orgcmd{C-c C-x C-y,org-paste-subtree}
1114 Yank subtree from kill ring.  This does modify the level of the subtree to
1115 make sure the tree fits in nicely at the yank position.  The yank level can
1116 also be specified with a numeric prefix argument, or by yanking after a
1117 headline marker like @samp{****}.
1118 @orgcmd{C-y,org-yank}
1119 @vindex org-yank-adjusted-subtrees
1120 @vindex org-yank-folded-subtrees
1121 Depending on the variables @code{org-yank-adjusted-subtrees} and
1122 @code{org-yank-folded-subtrees}, Org's internal @code{yank} command will
1123 paste subtrees folded and in a clever way, using the same command as @kbd{C-c
1124 C-x C-y}.  With the default settings, no level adjustment will take place,
1125 but the yanked tree will be folded unless doing so would swallow text
1126 previously visible.  Any prefix argument to this command will force a normal
1127 @code{yank} to be executed, with the prefix passed along.  A good way to
1128 force a normal yank is @kbd{C-u C-y}.  If you use @code{yank-pop} after a
1129 yank, it will yank previous kill items plainly, without adjustment and
1130 folding.
1131 @orgcmd{C-c C-x c,org-clone-subtree-with-time-shift}
1132 Clone a subtree by making a number of sibling copies of it.  You will be
1133 prompted for the number of copies to make, and you can also specify if any
1134 timestamps in the entry should be shifted.  This can be useful, for example,
1135 to create a number of tasks related to a series of lectures to prepare.  For
1136 more details, see the docstring of the command
1137 @code{org-clone-subtree-with-time-shift}.
1138 @orgcmd{C-c C-w,org-refile}
1139 Refile entry or region to a different location.  @xref{Refiling notes}.
1140 @orgcmd{C-c ^,org-sort-entries-or-items}
1141 Sort same-level entries.  When there is an active region, all entries in the
1142 region will be sorted.  Otherwise the children of the current headline are
1143 sorted.  The command prompts for the sorting method, which can be
1144 alphabetically, numerically, by time (first timestamp with active preferred,
1145 creation time, scheduled time, deadline time), by priority, by TODO keyword
1146 (in the sequence the keywords have been defined in the setup) or by the value
1147 of a property.  Reverse sorting is possible as well.  You can also supply
1148 your own function to extract the sorting key.  With a @kbd{C-u} prefix,
1149 sorting will be case-sensitive.  With two @kbd{C-u C-u} prefixes, duplicate
1150 entries will also be removed.
1151 @orgcmd{C-x n s,org-narrow-to-subtree}
1152 Narrow buffer to current subtree.
1153 @orgcmd{C-x n w,widen}
1154 Widen buffer to remove narrowing.
1155 @orgcmd{C-c *,org-toggle-heading}
1156 Turn a normal line or plain list item into a headline (so that it becomes a
1157 subheading at its location).  Also turn a headline into a normal line by
1158 removing the stars.  If there is an active region, turn all lines in the
1159 region into headlines.  If the first line in the region was an item, turn
1160 only the item lines into headlines.  Finally, if the first line is a
1161 headline, remove the stars from all headlines in the region.
1162 @end table
1164 @cindex region, active
1165 @cindex active region
1166 @cindex transient mark mode
1167 When there is an active region (Transient Mark mode), promotion and
1168 demotion work on all headlines in the region.  To select a region of
1169 headlines, it is best to place both point and mark at the beginning of a
1170 line, mark at the beginning of the first headline, and point at the line
1171 just after the last headline to change.  Note that when the cursor is
1172 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
1173 functionality.
1176 @node Sparse trees, Plain lists, Structure editing, Document Structure
1177 @section Sparse trees
1178 @cindex sparse trees
1179 @cindex trees, sparse
1180 @cindex folding, sparse trees
1181 @cindex occur, command
1183 @vindex org-show-hierarchy-above
1184 @vindex org-show-following-heading
1185 @vindex org-show-siblings
1186 @vindex org-show-entry-below
1187 An important feature of Org-mode is the ability to construct @emph{sparse
1188 trees} for selected information in an outline tree, so that the entire
1189 document is folded as much as possible, but the selected information is made
1190 visible along with the headline structure above it@footnote{See also the
1191 variables @code{org-show-hierarchy-above}, @code{org-show-following-heading},
1192 @code{org-show-siblings}, and @code{org-show-entry-below} for detailed
1193 control on how much context is shown around each match.}.  Just try it out
1194 and you will see immediately how it works.
1196 Org-mode contains several commands creating such trees, all these
1197 commands can be accessed through a dispatcher:
1199 @table @asis
1200 @orgcmd{C-c /,org-sparse-tree}
1201 This prompts for an extra key to select a sparse-tree creating command.
1202 @kindex C-c / r
1203 @item C-c / r
1204 @vindex org-remove-highlights-with-change
1205 Occur.  Prompts for a regexp and shows a sparse tree with all matches.  If
1206 the match is in a headline, the headline is made visible.  If the match is in
1207 the body of an entry, headline and body are made visible.  In order to
1208 provide minimal context, also the full hierarchy of headlines above the match
1209 is shown, as well as the headline following the match.  Each match is also
1210 highlighted; the highlights disappear when the buffer is changed by an
1211 editing command@footnote{This depends on the option
1212 @code{org-remove-highlights-with-change}}, or by pressing @kbd{C-c C-c}.
1213 When called with a @kbd{C-u} prefix argument, previous highlights are kept,
1214 so several calls to this command can be stacked.
1215 @end table
1217 @noindent
1218 @vindex org-agenda-custom-commands
1219 For frequently used sparse trees of specific search strings, you can
1220 use the variable @code{org-agenda-custom-commands} to define fast
1221 keyboard access to specific sparse trees.  These commands will then be
1222 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
1223 For example:
1225 @lisp
1226 (setq org-agenda-custom-commands
1227       '(("f" occur-tree "FIXME")))
1228 @end lisp
1230 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
1231 a sparse tree matching the string @samp{FIXME}.
1233 The other sparse tree commands select headings based on TODO keywords,
1234 tags, or properties and will be discussed later in this manual.
1236 @kindex C-c C-e v
1237 @cindex printing sparse trees
1238 @cindex visible text, printing
1239 To print a sparse tree, you can use the Emacs command
1240 @code{ps-print-buffer-with-faces} which does not print invisible parts
1241 of the document @footnote{This does not work under XEmacs, because
1242 XEmacs uses selective display for outlining, not text properties.}.
1243 Or you can use the command @kbd{C-c C-e v} to export only the visible
1244 part of the document and print the resulting file.
1246 @node Plain lists, Drawers, Sparse trees, Document Structure
1247 @section Plain lists
1248 @cindex plain lists
1249 @cindex lists, plain
1250 @cindex lists, ordered
1251 @cindex ordered lists
1253 Within an entry of the outline tree, hand-formatted lists can provide
1254 additional structure.  They also provide a way to create lists of
1255 checkboxes (@pxref{Checkboxes}).  Org supports editing such lists,
1256 and the HTML exporter (@pxref{Exporting}) parses and formats them.
1258 Org knows ordered lists, unordered lists, and description lists.
1259 @itemize @bullet
1260 @item
1261 @emph{Unordered} list items start with @samp{-}, @samp{+}, or
1262 @samp{*}@footnote{When using @samp{*} as a bullet, lines must be indented or
1263 they will be seen as top-level headlines.  Also, when you are hiding leading
1264 stars to get a clean outline view, plain list items starting with a star are
1265 visually indistinguishable from true headlines.  In short: even though
1266 @samp{*} is supported, it may be better to not use it for plain list items.}
1267 as bullets.
1268 @item
1269 @emph{Ordered} list items start with a numeral followed by either a period or
1270 a right parenthesis, such as @samp{1.} or @samp{1)}.  If you want a list to
1271 start a different value (e.g. 20), start the text of the item with
1272 @code{[@@start:20]}.
1273 @item
1274 @emph{Description} list items are unordered list items, and contain the
1275 separator @samp{ :: } to separate the description @emph{term} from the
1276 description.
1277 @end itemize
1279 @vindex org-empty-line-terminates-plain-lists
1280 Items belonging to the same list must have the same indentation on the first
1281 line.  In particular, if an ordered list reaches number @samp{10.}, then the
1282 2--digit numbers must be written left-aligned with the other numbers in the
1283 list.  Indentation also determines the end of a list item.  It ends before
1284 the next line that is indented like the bullet/number, or less.  Empty lines
1285 are part of the previous item, so you can have several paragraphs in one
1286 item.  If you would like an empty line to terminate all currently open plain
1287 lists, configure the variable @code{org-empty-line-terminates-plain-lists}.
1288 Here is an example:
1290 @example
1291 @group
1292 ** Lord of the Rings
1293    My favorite scenes are (in this order)
1294    1. The attack of the Rohirrim
1295    2. Eowyn's fight with the witch king
1296       + this was already my favorite scene in the book
1297       + I really like Miranda Otto.
1298    3. Peter Jackson being shot by Legolas
1299        - on DVD only
1300       He makes a really funny face when it happens.
1301    But in the end, no individual scenes matter but the film as a whole.
1302    Important actors in this film are:
1303    - @b{Elijah Wood} :: He plays Frodo
1304    - @b{Sean Austin} :: He plays Sam, Frodo's friend.  I still remember
1305      him very well from his role as Mikey Walsh in @i{The Goonies}.
1306 @end group
1307 @end example
1309 Org supports these lists by tuning filling and wrapping commands to deal with
1310 them correctly@footnote{Org only changes the filling settings for Emacs.  For
1311 XEmacs, you should use Kyle E. Jones' @file{filladapt.el}.  To turn this on,
1312 put into @file{.emacs}: @code{(require 'filladapt)}}, and by exporting them
1313 properly (@pxref{Exporting}).  Since indentation is what governs the
1314 structure of these lists, many structural constructs like @code{#+BEGIN_...}
1315 blocks can be indented to signal that they should be part of a list item.
1317 @vindex org-list-demote-modify-bullet
1318 If you find that using a different bullet for a sub-list (than that used for
1319 the current list-level) improves readability, customize the variable
1320 @code{org-list-demote-modify-bullet}.
1322 The following commands act on items when the cursor is in the first line
1323 of an item (the line with the bullet or number).
1325 @table @asis
1326 @orgcmd{@key{TAB},org-cycle}
1327 @vindex org-cycle-include-plain-lists
1328 Items can be folded just like headline levels.  Normally this works only if
1329 the cursor is on a plain list item.  For more details, see the variable
1330 @code{org-cycle-include-plain-lists}. to @code{integrate}, plain list items
1331 will be treated like low-level.  The level of an item is then given by the
1332 indentation of the bullet/number.  Items are always subordinate to real
1333 headlines, however; the hierarchies remain completely separated.
1335 If @code{org-cycle-include-plain-lists} has not been set, @key{TAB}
1336 fixes the indentation of the current line in a heuristic way.
1337 @orgcmd{M-@key{RET},org-insert-heading}
1338 @vindex org-M-RET-may-split-line
1339 Insert new item at current level.  With a prefix argument, force a new
1340 heading (@pxref{Structure editing}).  If this command is used in the middle
1341 of a line, the line is @emph{split} and the rest of the line becomes the new
1342 item@footnote{If you do not want the line to be split, customize the variable
1343 @code{org-M-RET-may-split-line}.}.  If this command is executed in the
1344 @emph{whitespace before a bullet or number}, the new item is created
1345 @emph{before} the current item.  If the command is executed in the white
1346 space before the text that is part of an item but does not contain the
1347 bullet, a bullet is added to the current line.
1348 @kindex M-S-@key{RET}
1349 @item M-S-@key{RET}
1350 Insert a new item with a checkbox (@pxref{Checkboxes}).
1351 @orgcmd{@key{TAB},org-cycle}
1352 In a new item with no text yet, the first @key{TAB} demotes the item to
1353 become a child of the previous one.  The next @key{TAB} makes it a parent,
1354 and so on, all the way to the left margin.  Yet another @key{TAB}, and you
1355 are back to the initial level.
1356 @kindex S-@key{down}
1357 @item S-@key{up}
1358 @itemx S-@key{down}
1359 @cindex shift-selection-mode
1360 @vindex org-support-shift-select
1361 Jump to the previous/next item in the current list, but only if
1362 @code{org-support-shift-select} is off.  If not, you can still use paragraph
1363 jumping commands like @kbd{C-@key{up}} and @kbd{C-@key{down}} to quite
1364 similar effect.
1365 @kindex M-S-@key{up}
1366 @kindex M-S-@key{down}
1367 @item M-S-@key{up}
1368 @itemx M-S-@key{down}
1369 Move the item including subitems up/down (swap with previous/next item
1370 of same indentation).  If the list is ordered, renumbering is
1371 automatic.
1372 @kindex M-@key{left}
1373 @kindex M-@key{right}
1374 @item M-@key{left}
1375 @itemx M-@key{right}
1376 Decrease/increase the indentation of an item, leaving children alone.
1377 @kindex M-S-@key{left}
1378 @kindex M-S-@key{right}
1379 @item M-S-@key{left}
1380 @itemx M-S-@key{right}
1381 Decrease/increase the indentation of the item, including subitems.
1382 Initially, the item tree is selected based on current indentation.
1383 When these commands are executed several times in direct succession,
1384 the initially selected region is used, even if the new indentation
1385 would imply a different hierarchy.  To use the new hierarchy, break
1386 the command chain with a cursor motion or so.
1387 @kindex C-c C-c
1388 @item C-c C-c
1389 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1390 state of the checkbox.  If not, this command makes sure that all the
1391 items on this list level use the same bullet.  Furthermore, if this is
1392 an ordered list, make sure the numbering is OK.
1393 @kindex C-c -
1394 @item C-c -
1395 Cycle the entire list level through the different itemize/enumerate bullets
1396 (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}).  With a numeric prefix
1397 argument N, select the Nth bullet from this list.  If there is an active
1398 region when calling this, all lines will be converted to list items.  If the
1399 first line already was a list item, any item markers will be removed from the
1400 list.  Finally, even without an active region, a normal line will be
1401 converted into a list item.
1402 @kindex C-c *
1403 @item C-c *
1404 Turn a plain list item into a headline (so that it becomes a subheading at
1405 its location). @xref{Structure editing}, for a detailed explanation.
1406 @kindex S-@key{left}
1407 @kindex S-@key{right}
1408 @item S-@key{left}/@key{right}
1409 @vindex org-support-shift-select
1410 This command also cycles bullet styles when the cursor in on the bullet or
1411 anywhere in an item line, details depending on
1412 @code{org-support-shift-select}.
1413 @kindex C-c ^
1414 @item C-c ^
1415 Sort the plain list.  You will be prompted for the sorting method:
1416 numerically, alphabetically, by time, or by custom function.
1417 @end table
1419 @node Drawers, Blocks, Plain lists, Document Structure
1420 @section Drawers
1421 @cindex drawers
1422 @cindex #+DRAWERS
1423 @cindex visibility cycling, drawers
1425 @vindex org-drawers
1426 Sometimes you want to keep information associated with an entry, but you
1427 normally don't want to see it.  For this, Org-mode has @emph{drawers}.
1428 Drawers need to be configured with the variable
1429 @code{org-drawers}@footnote{You can define drawers on a per-file basis
1430 with a line like @code{#+DRAWERS: HIDDEN PROPERTIES STATE}}.  Drawers
1431 look like this:
1433 @example
1434 ** This is a headline
1435    Still outside the drawer
1436    :DRAWERNAME:
1437       This is inside the drawer.
1438    :END:
1439    After the drawer.
1440 @end example
1442 Visibility cycling (@pxref{Visibility cycling}) on the headline will hide and
1443 show the entry, but keep the drawer collapsed to a single line.  In order to
1444 look inside the drawer, you need to move the cursor to the drawer line and
1445 press @key{TAB} there.  Org-mode uses the @code{PROPERTIES} drawer for
1446 storing properties (@pxref{Properties and Columns}), and you can also arrange
1447 for state change notes (@pxref{Tracking TODO state changes}) and clock times
1448 (@pxref{Clocking work time}) to be stored in a drawer @code{LOGBOOK}.  If you
1449 want to store a quick note in the LOGBOOK drawer, in a similar way as this is
1450 done by state changes, use
1452 @table @kbd
1453 @kindex C-c C-z
1454 @item C-c C-z
1455 Add a time-stamped note to the LOGBOOK drawer.
1456 @end table
1458 @node Blocks, Footnotes, Drawers, Document Structure
1459 @section Blocks
1461 @vindex org-hide-block-startup
1462 @cindex blocks, folding
1463 Org-mode uses begin...end blocks for various purposes from including source
1464 code examples (@pxref{Literal examples}) to capturing time logging
1465 information (@pxref{Clocking work time}).  These blocks can be folded and
1466 unfolded by pressing TAB in the begin line.  You can also get all blocks
1467 folded at startup by configuring the variable @code{org-hide-block-startup}
1468 or on a per-file basis by using
1470 @cindex @code{hideblocks}, STARTUP keyword
1471 @cindex @code{nohideblocks}, STARTUP keyword
1472 @example
1473 #+STARTUP: hideblocks
1474 #+STARTUP: nohideblocks
1475 @end example
1477 @node Footnotes, Orgstruct mode, Blocks, Document Structure
1478 @section Footnotes
1479 @cindex footnotes
1481 Org-mode supports the creation of footnotes.  In contrast to the
1482 @file{footnote.el} package, Org-mode's footnotes are designed for work on a
1483 larger document, not only for one-off documents like emails.  The basic
1484 syntax is similar to the one used by @file{footnote.el}, i.e. a footnote is
1485 defined in a paragraph that is started by a footnote marker in square
1486 brackets in column 0, no indentation allowed.  If you need a paragraph break
1487 inside a footnote, use the La@TeX{} idiom @samp{\par}.  The footnote reference
1488 is simply the marker in square brackets, inside text.  For example:
1490 @example
1491 The Org homepage[fn:1] now looks a lot better than it used to.
1493 [fn:1] The link is: http://orgmode.org
1494 @end example
1496 Org-mode extends the number-based syntax to @emph{named} footnotes and
1497 optional inline definition.  Using plain numbers as markers (as
1498 @file{footnote.el} does) is supported for backward compatibility, but not
1499 encouraged because of possible conflicts with La@TeX{} snippets (@pxref{Embedded
1500 LaTeX}).  Here are the valid references:
1502 @table @code
1503 @item [1]
1504 A plain numeric footnote marker.  Compatible with @file{footnote.el}, but not
1505 recommended because something like @samp{[1]} could easily be part of a code
1506 snippet.
1507 @item [fn:name]
1508 A named footnote reference, where @code{name} is a unique label word, or, for
1509 simplicity of automatic creation, a number.
1510 @item [fn:: This is the inline definition of this footnote]
1511 A La@TeX{}-like anonymous footnote where the definition is given directly at the
1512 reference point.
1513 @item [fn:name: a definition]
1514 An inline definition of a footnote, which also specifies a name for the note.
1515 Since Org allows multiple references to the same note, you can then use
1516 @code{[fn:name]} to create additional references.
1517 @end table
1519 @vindex org-footnote-auto-label
1520 Footnote labels can be created automatically, or you can create names yourself.
1521 This is handled by the variable @code{org-footnote-auto-label} and its
1522 corresponding @code{#+STARTUP} keywords, see the docstring of that variable
1523 for details.
1525 @noindent The following command handles footnotes:
1527 @table @kbd
1528 @kindex C-c C-x f
1529 @item C-c C-x f
1530 The footnote action command.
1532 When the cursor is on a footnote reference, jump to the definition.  When it
1533 is at a definition, jump to the (first) reference.
1535 @vindex org-footnote-define-inline
1536 @vindex org-footnote-section
1537 @vindex org-footnote-auto-adjust
1538 Otherwise, create a new footnote.  Depending on the variable
1539 @code{org-footnote-define-inline}@footnote{The corresponding in-buffer
1540 setting is: @code{#+STARTUP: fninline} or @code{#+STARTUP: nofninline}}, the
1541 definition will be placed right into the text as part of the reference, or
1542 separately into the location determined by the variable
1543 @code{org-footnote-section}.
1545 When this command is called with a prefix argument, a menu of additional
1546 options is offered:
1547 @example
1548 s   @r{Sort the footnote definitions by reference sequence.  During editing,}
1549     @r{Org makes no effort to sort footnote definitions into a particular}
1550     @r{sequence.  If you want them sorted, use this command, which will}
1551     @r{also move entries according to @code{org-footnote-section}.  Automatic}
1552     @r{sorting after each insertion/deletion can be configured using the}
1553     @r{variable @code{org-footnote-auto-adjust}.}
1554 r   @r{Renumber the simple @code{fn:N} footnotes.  Automatic renumbering}
1555     @r{after each insertion/deletion can be configured using the variable}
1556     @r{@code{org-footnote-auto-adjust}.}
1557 S   @r{Short for first @code{r}, then @code{s} action.}
1558 n   @r{Normalize the footnotes by collecting all definitions (including}
1559     @r{inline definitions) into a special section, and then numbering them}
1560     @r{in sequence.  The references will then also be numbers.  This is}
1561     @r{meant to be the final step before finishing a document (e.g. sending}
1562     @r{off an email).  The exporters do this automatically, and so could}
1563     @r{something like @code{message-send-hook}.}
1564 d   @r{Delete the footnote at point, and all definitions of and references}
1565     @r{to it.}
1566 @end example
1567 Depending on the variable @code{org-footnote-auto-adjust}@footnote{the
1568 corresponding in-buffer options are @code{fnadjust} and @code{nofnadjust}.},
1569 renumbering and sorting footnotes can be automatic after each insertion or
1570 deletion.
1572 @kindex C-c C-c
1573 @item C-c C-c
1574 If the cursor is on a footnote reference, jump to the definition.  If it is a
1575 the definition, jump back to the reference.  When called at a footnote
1576 location with a prefix argument, offer the same menu as @kbd{C-c C-x f}.
1577 @kindex C-c C-o
1578 @kindex mouse-1
1579 @kindex mouse-2
1580 @item C-c C-o  @r{or} mouse-1/2
1581 Footnote labels are also links to the corresponding definition/reference, and
1582 you can use the usual commands to follow these links.
1583 @end table
1585 @node Orgstruct mode,  , Footnotes, Document Structure
1586 @section The Orgstruct minor mode
1587 @cindex Orgstruct mode
1588 @cindex minor mode for structure editing
1590 If you like the intuitive way the Org-mode structure editing and list
1591 formatting works, you might want to use these commands in other modes like
1592 Text mode or Mail mode as well.  The minor mode @code{orgstruct-mode} makes
1593 this possible.   Toggle the mode with @kbd{M-x orgstruct-mode}, or
1594 turn it on by default, for example in Mail mode, with one of:
1596 @lisp
1597 (add-hook 'mail-mode-hook 'turn-on-orgstruct)
1598 (add-hook 'mail-mode-hook 'turn-on-orgstruct++)
1599 @end lisp
1601 When this mode is active and the cursor is on a line that looks to Org like a
1602 headline or the first line of a list item, most structure editing commands
1603 will work, even if the same keys normally have different functionality in the
1604 major mode you are using.  If the cursor is not in one of those special
1605 lines, Orgstruct mode lurks silently in the shadow.  When you use
1606 @code{orgstruct++-mode}, Org will also export indentation and autofill
1607 settings into that mode, and detect item context after the first line of an
1608 item.
1610 @node Tables, Hyperlinks, Document Structure, Top
1611 @chapter Tables
1612 @cindex tables
1613 @cindex editing tables
1615 Org comes with a fast and intuitive table editor.  Spreadsheet-like
1616 calculations are supported in connection with the Emacs @file{calc}
1617 package
1618 @ifinfo
1619 (@pxref{Top,Calc,,Calc,Gnu Emacs Calculator Manual}).
1620 @end ifinfo
1621 @ifnotinfo
1622 (see the Emacs Calculator manual for more information about the Emacs
1623 calculator).
1624 @end ifnotinfo
1626 @menu
1627 * Built-in table editor::       Simple tables
1628 * Column width and alignment::  Overrule the automatic settings
1629 * Column groups::               Grouping to trigger vertical lines
1630 * Orgtbl mode::                 The table editor as minor mode
1631 * The spreadsheet::             The table editor has spreadsheet capabilities
1632 * Org-Plot::                    Plotting from org tables
1633 @end menu
1635 @node Built-in table editor, Column width and alignment, Tables, Tables
1636 @section The built-in table editor
1637 @cindex table editor, built-in
1639 Org makes it easy to format tables in plain ASCII.  Any line with
1640 @samp{|} as the first non-whitespace character is considered part of a
1641 table.  @samp{|} is also the column separator.  A table might look like
1642 this:
1644 @example
1645 | Name  | Phone | Age |
1646 |-------+-------+-----|
1647 | Peter |  1234 |  17 |
1648 | Anna  |  4321 |  25 |
1649 @end example
1651 A table is re-aligned automatically each time you press @key{TAB} or
1652 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
1653 the next field (@key{RET} to the next row) and creates new table rows
1654 at the end of the table or before horizontal lines.  The indentation
1655 of the table is set by the first line.  Any line starting with
1656 @samp{|-} is considered as a horizontal separator line and will be
1657 expanded on the next re-align to span the whole table width.  So, to
1658 create the above table, you would only type
1660 @example
1661 |Name|Phone|Age|
1663 @end example
1665 @noindent and then press @key{TAB} to align the table and start filling in
1666 fields.  Even faster would be to type @code{|Name|Phone|Age} followed by
1667 @kbd{C-c @key{RET}}.
1669 @vindex org-enable-table-editor
1670 @vindex org-table-auto-blank-field
1671 When typing text into a field, Org treats @key{DEL},
1672 @key{Backspace}, and all character keys in a special way, so that
1673 inserting and deleting avoids shifting other fields.  Also, when
1674 typing @emph{immediately after the cursor was moved into a new field
1675 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
1676 field is automatically made blank.  If this behavior is too
1677 unpredictable for you, configure the variables
1678 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
1680 @table @kbd
1681 @tsubheading{Creation and conversion}
1682 @kindex C-c |
1683 @item C-c |
1684 Convert the active region to table. If every line contains at least one
1685 TAB character, the function assumes that the material is tab separated.
1686 If every line contains a comma, comma-separated values (CSV) are assumed.
1687 If not, lines are split at whitespace into fields.  You can use a prefix
1688 argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
1689 C-u} forces TAB, and a numeric argument N indicates that at least N
1690 consecutive spaces, or alternatively a TAB will be the separator.
1692 If there is no active region, this command creates an empty Org
1693 table.  But it's easier just to start typing, like
1694 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
1696 @tsubheading{Re-aligning and field motion}
1697 @kindex C-c C-c
1698 @item C-c C-c
1699 Re-align the table without moving the cursor.
1701 @kindex @key{TAB}
1702 @item @key{TAB}
1703 Re-align the table, move to the next field.  Creates a new row if
1704 necessary.
1706 @kindex S-@key{TAB}
1707 @item S-@key{TAB}
1708 Re-align, move to previous field.
1710 @kindex @key{RET}
1711 @item @key{RET}
1712 Re-align the table and move down to next row.  Creates a new row if
1713 necessary.  At the beginning or end of a line, @key{RET} still does
1714 NEWLINE, so it can be used to split a table.
1716 @kindex M-a
1717 @item M-a
1718 Move to beginning of the current table field, or on to the previous field.
1719 @kindex M-e
1720 @item M-e
1721 Move to end of the current table field, or on to the next field.
1723 @tsubheading{Column and row editing}
1724 @kindex M-@key{left}
1725 @kindex M-@key{right}
1726 @item M-@key{left}
1727 @itemx M-@key{right}
1728 Move the current column left/right.
1730 @kindex M-S-@key{left}
1731 @item M-S-@key{left}
1732 Kill the current column.
1734 @kindex M-S-@key{right}
1735 @item M-S-@key{right}
1736 Insert a new column to the left of the cursor position.
1738 @kindex M-@key{up}
1739 @kindex M-@key{down}
1740 @item M-@key{up}
1741 @itemx M-@key{down}
1742 Move the current row up/down.
1744 @kindex M-S-@key{up}
1745 @item M-S-@key{up}
1746 Kill the current row or horizontal line.
1748 @kindex M-S-@key{down}
1749 @item M-S-@key{down}
1750 Insert a new row above the current row.  With a prefix argument, the line is
1751 created below the current one.
1753 @kindex C-c -
1754 @item C-c -
1755 Insert a horizontal line below current row.  With a prefix argument, the line
1756 is created above the current line.
1758 @kindex C-c @key{RET}
1759 @item C-c @key{RET}
1760 Insert a horizontal line below current row, and move the cursor into the row
1761 below that line.
1763 @kindex C-c ^
1764 @item C-c ^
1765 Sort the table lines in the region.  The position of point indicates the
1766 column to be used for sorting, and the range of lines is the range
1767 between the nearest horizontal separator lines, or the entire table.  If
1768 point is before the first column, you will be prompted for the sorting
1769 column.  If there is an active region, the mark specifies the first line
1770 and the sorting column, while point should be in the last line to be
1771 included into the sorting.  The command prompts for the sorting type
1772 (alphabetically, numerically, or by time).  When called with a prefix
1773 argument, alphabetic sorting will be case-sensitive.
1775 @tsubheading{Regions}
1776 @kindex C-c C-x M-w
1777 @item C-c C-x M-w
1778 Copy a rectangular region from a table to a special clipboard.  Point and
1779 mark determine edge fields of the rectangle.  If there is no active region,
1780 copy just the current field.  The process ignores horizontal separator lines.
1782 @kindex C-c C-x C-w
1783 @item C-c C-x C-w
1784 Copy a rectangular region from a table to a special clipboard, and
1785 blank all fields in the rectangle.  So this is the ``cut'' operation.
1787 @kindex C-c C-x C-y
1788 @item C-c C-x C-y
1789 Paste a rectangular region into a table.
1790 The upper left corner ends up in the current field.  All involved fields
1791 will be overwritten.  If the rectangle does not fit into the present table,
1792 the table is enlarged as needed.  The process ignores horizontal separator
1793 lines.
1795 @kindex M-@key{RET}
1796 @itemx M-@kbd{RET}
1797 Wrap several fields in a column like a paragraph.  If there is an active
1798 region, and both point and mark are in the same column, the text in the
1799 column is wrapped to minimum width for the given number of lines.  A numeric
1800 prefix argument may be used to change the number of desired lines.  If there
1801 is no region, the current field is split at the cursor position and the text
1802 fragment to the right of the cursor is prepended to the field one line
1803 down. If there is no region, but you specify a prefix argument, the current
1804 field is made blank, and the content is appended to the field above.
1806 @tsubheading{Calculations}
1807 @cindex formula, in tables
1808 @cindex calculations, in tables
1809 @cindex region, active
1810 @cindex active region
1811 @cindex transient mark mode
1812 @kindex C-c +
1813 @item C-c +
1814 Sum the numbers in the current column, or in the rectangle defined by
1815 the active region.  The result is shown in the echo area and can
1816 be inserted with @kbd{C-y}.
1818 @kindex S-@key{RET}
1819 @item S-@key{RET}
1820 @vindex org-table-copy-increment
1821 When current field is empty, copy from first non-empty field above.  When not
1822 empty, copy current field down to next row and move cursor along with it.
1823 Depending on the variable @code{org-table-copy-increment}, integer field
1824 values will be incremented during copy.  Integers that are too large will not
1825 be incremented.  Also, a @code{0} prefix argument temporarily disables the
1826 increment.  This key is also used by shift-selection and related modes
1827 (@pxref{Conflicts}).
1829 @tsubheading{Miscellaneous}
1830 @kindex C-c `
1831 @item C-c `
1832 Edit the current field in a separate window.  This is useful for fields that
1833 are not fully visible (@pxref{Column width and alignment}).  When called with
1834 a @kbd{C-u} prefix, just make the full field visible, so that it can be
1835 edited in place.
1837 @item M-x org-table-import
1838 Import a file as a table.  The table should be TAB or whitespace
1839 separated.  Use, for example, to import a spreadsheet table or data
1840 from a database, because these programs generally can write
1841 TAB-separated text files.  This command works by inserting the file into
1842 the buffer and then converting the region to a table.  Any prefix
1843 argument is passed on to the converter, which uses it to determine the
1844 separator.
1845 @item C-c |
1846 Tables can also be imported by pasting tabular text into the Org
1847 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
1848 @kbd{C-c |} command (see above under @i{Creation and conversion}).
1850 @item M-x org-table-export
1851 @vindex org-table-export-default-format
1852 Export the table, by default as a TAB-separated file.  Use for data
1853 exchange with, for example, spreadsheet or database programs.  The format
1854 used to export the file can be configured in the variable
1855 @code{org-table-export-default-format}.  You may also use properties
1856 @code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
1857 name and the format for table export in a subtree.  Org supports quite
1858 general formats for exported tables.  The exporter format is the same as the
1859 format used by Orgtbl radio tables, see @ref{Translator functions}, for a
1860 detailed description.
1861 @end table
1863 If you don't like the automatic table editor because it gets in your
1864 way on lines which you would like to start with @samp{|}, you can turn
1865 it off with
1867 @lisp
1868 (setq org-enable-table-editor nil)
1869 @end lisp
1871 @noindent Then the only table command that still works is
1872 @kbd{C-c C-c} to do a manual re-align.
1874 @node Column width and alignment, Column groups, Built-in table editor, Tables
1875 @section Column width and alignment
1876 @cindex narrow columns in tables
1877 @cindex alignment in tables
1879 The width of columns is automatically determined by the table editor.  And
1880 also the alignment of a column is determined automatically from the fraction
1881 of number-like versus non-number fields in the column.
1883 Sometimes a single field or a few fields need to carry more text, leading to
1884 inconveniently wide columns.  Or maybe you want to make a table with several
1885 columns having a fixed width, regardless of content.  To set@footnote{This
1886 feature does not work on XEmacs.} the width of a column, one field anywhere
1887 in the column may contain just the string @samp{<N>} where @samp{N} is an
1888 integer specifying the width of the column in characters.  The next re-align
1889 will then set the width of this column to this value.
1891 @example
1892 @group
1893 |---+------------------------------|               |---+--------|
1894 |   |                              |               |   | <6>    |
1895 | 1 | one                          |               | 1 | one    |
1896 | 2 | two                          |     ----\     | 2 | two    |
1897 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
1898 | 4 | four                         |               | 4 | four   |
1899 |---+------------------------------|               |---+--------|
1900 @end group
1901 @end example
1903 @noindent
1904 Fields that are wider become clipped and end in the string @samp{=>}.
1905 Note that the full text is still in the buffer, it is only invisible.
1906 To see the full text, hold the mouse over the field---a tool-tip window
1907 will show the full content.  To edit such a field, use the command
1908 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
1909 open a new window with the full field.  Edit it and finish with @kbd{C-c
1910 C-c}.
1912 @vindex org-startup-align-all-tables
1913 When visiting a file containing a table with narrowed columns, the
1914 necessary character hiding has not yet happened, and the table needs to
1915 be aligned before it looks nice.  Setting the option
1916 @code{org-startup-align-all-tables} will realign all tables in a file
1917 upon visiting, but also slow down startup.  You can also set this option
1918 on a per-file basis with:
1920 @example
1921 #+STARTUP: align
1922 #+STARTUP: noalign
1923 @end example
1925 If you would like to overrule the automatic alignment of number-rich columns
1926 to the right and of string-rich column to the left, you and use @samp{<r>} or
1927 @samp{<l>} in a similar fashion.  You may also combine alignment and field
1928 width like this: @samp{<l10>}.
1930 Lines which only contain these formatting cookies will be removed
1931 automatically when exporting the document.
1933 @node Column groups, Orgtbl mode, Column width and alignment, Tables
1934 @section Column groups
1935 @cindex grouping columns in tables
1937 When Org exports tables, it does so by default without vertical
1938 lines because that is visually more satisfying in general.  Occasionally
1939 however, vertical lines can be useful to structure a table into groups
1940 of columns, much like horizontal lines can do for groups of rows.  In
1941 order to specify column groups, you can use a special row where the
1942 first field contains only @samp{/}.  The further fields can either
1943 contain @samp{<} to indicate that this column should start a group,
1944 @samp{>} to indicate the end of a column, or @samp{<>} to make a column
1945 a group of its own.  Boundaries between column groups will upon export be
1946 marked with vertical lines.  Here is an example:
1948 @example
1949 | N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1950 |---+-----+-----+-----+---------+------------|
1951 | / |   < |     |   > |       < |          > |
1952 | 1 |   1 |   1 |   1 |       1 |          1 |
1953 | 2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
1954 | 3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
1955 |---+-----+-----+-----+---------+------------|
1956 #+TBLFM: $2=$1^2::$3=$1^3::$4=$1^4::$5=sqrt($1)::$6=sqrt(sqrt(($1)))
1957 @end example
1959 It is also sufficient to just insert the column group starters after
1960 every vertical line you would like to have:
1962 @example
1963 |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1964 |----+-----+-----+-----+---------+------------|
1965 | /  | <   |     |     | <       |            |
1966 @end example
1968 @node Orgtbl mode, The spreadsheet, Column groups, Tables
1969 @section The Orgtbl minor mode
1970 @cindex Orgtbl mode
1971 @cindex minor mode for tables
1973 If you like the intuitive way the Org table editor works, you
1974 might also want to use it in other modes like Text mode or Mail mode.
1975 The minor mode Orgtbl mode makes this possible.  You can always toggle
1976 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
1977 example in mail mode, use
1979 @lisp
1980 (add-hook 'mail-mode-hook 'turn-on-orgtbl)
1981 @end lisp
1983 Furthermore, with some special setup, it is possible to maintain tables
1984 in arbitrary syntax with Orgtbl mode.  For example, it is possible to
1985 construct La@TeX{} tables with the underlying ease and power of
1986 Orgtbl mode, including spreadsheet capabilities.  For details, see
1987 @ref{Tables in arbitrary syntax}.
1989 @node The spreadsheet, Org-Plot, Orgtbl mode, Tables
1990 @section The spreadsheet
1991 @cindex calculations, in tables
1992 @cindex spreadsheet capabilities
1993 @cindex @file{calc} package
1995 The table editor makes use of the Emacs @file{calc} package to implement
1996 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
1997 derive fields from other fields.  While fully featured, Org's implementation
1998 is not identical to other spreadsheets.  For example, Org knows the concept
1999 of a @emph{column formula} that will be applied to all non-header fields in a
2000 column without having to copy the formula to each relevant field.  There is
2001 also a formula debugger, and a formula editor with features for highlighting
2002 fields in the table corresponding to the references at the point in the
2003 formula, moving these references by arrow keys
2005 @menu
2006 * References::                  How to refer to another field or range
2007 * Formula syntax for Calc::     Using Calc to compute stuff
2008 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
2009 * Field formulas::              Formulas valid for a single field
2010 * Column formulas::             Formulas valid for an entire column
2011 * Editing and debugging formulas::  Fixing formulas
2012 * Updating the table::          Recomputing all dependent fields
2013 * Advanced features::           Field names, parameters and automatic recalc
2014 @end menu
2016 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
2017 @subsection References
2018 @cindex references
2020 To compute fields in the table from other fields, formulas must
2021 reference other fields or ranges.  In Org, fields can be referenced
2022 by name, by absolute coordinates, and by relative coordinates.  To find
2023 out what the coordinates of a field are, press @kbd{C-c ?} in that
2024 field, or press @kbd{C-c @}} to toggle the display of a grid.
2026 @subsubheading Field references
2027 @cindex field references
2028 @cindex references, to fields
2030 Formulas can reference the value of another field in two ways.  Like in
2031 any other spreadsheet, you may reference fields with a letter/number
2032 combination like @code{B3}, meaning the 2nd field in the 3rd row.
2033 @c Such references are always fixed to that field, they don't change
2034 @c when you copy and paste a formula to a different field.  So
2035 @c Org's @code{B3} behaves like @code{$B$3} in other spreadsheets.
2037 @noindent
2038 Org also uses another, more general operator that looks like this:
2039 @example
2040 @@@var{row}$@var{column}
2041 @end example
2043 @noindent
2044 Column references can be absolute like @samp{1}, @samp{2},...@samp{@var{N}},
2045 or relative to the current column like @samp{+1} or @samp{-2}.
2047 The row specification only counts data lines and ignores horizontal
2048 separator lines (hlines).  You can use absolute row numbers
2049 @samp{1}...@samp{@var{N}}, and row numbers relative to the current row like
2050 @samp{+3} or @samp{-1}.  Or specify the row relative to one of the
2051 hlines: @samp{I} refers to the first hline@footnote{Note that only
2052 hlines are counted that @emph{separate} table lines.  If the table
2053 starts with a hline above the header, it does not count.}, @samp{II} to
2054 the second, etc@.  @samp{-I} refers to the first such line above the
2055 current line, @samp{+I} to the first such line below the current line.
2056 You can also write @samp{III+2} which is the second data line after the
2057 third hline in the table.
2059 @samp{0} refers to the current row and column.  Also, if you omit
2060 either the column or the row part of the reference, the current
2061 row/column is implied.
2063 Org's references with @emph{unsigned} numbers are fixed references
2064 in the sense that if you use the same reference in the formula for two
2065 different fields, the same field will be referenced each time.
2066 Org's references with @emph{signed} numbers are floating
2067 references because the same reference operator can reference different
2068 fields depending on the field being calculated by the formula.
2070 As a special case, references like @samp{$LR5} and @samp{$LR12} can be used
2071 to refer in a stable way to the 5th and 12th field in the last row of the
2072 table.
2074 Here are a few examples:
2076 @example
2077 @@2$3      @r{2nd row, 3rd column}
2078 C2        @r{same as previous}
2079 $5        @r{column 5 in the current row}
2080 E&        @r{same as previous}
2081 @@2        @r{current column, row 2}
2082 @@-1$-3    @r{the field one row up, three columns to the left}
2083 @@-I$2     @r{field just under hline above current row, column 2}
2084 @end example
2086 @subsubheading Range references
2087 @cindex range references
2088 @cindex references, to ranges
2090 You may reference a rectangular range of fields by specifying two field
2091 references connected by two dots @samp{..}.  If both fields are in the
2092 current row, you may simply use @samp{$2..$7}, but if at least one field
2093 is in a different row, you need to use the general @code{@@row$column}
2094 format at least for the first field (i.e the reference must start with
2095 @samp{@@} in order to be interpreted correctly).  Examples:
2097 @example
2098 $1..$3        @r{First three fields in the current row.}
2099 $P..$Q        @r{Range, using column names (see under Advanced)}
2100 @@2$1..@@4$3    @r{6 fields between these two fields.}
2101 A2..C4        @r{Same as above.}
2102 @@-1$-2..@@-1   @r{3 numbers from the column to the left, 2 up to current row}
2103 @end example
2105 @noindent Range references return a vector of values that can be fed
2106 into Calc vector functions.  Empty fields in ranges are normally
2107 suppressed, so that the vector contains only the non-empty fields (but
2108 see the @samp{E} mode switch below).  If there are no non-empty fields,
2109 @samp{[0]} is returned to avoid syntax errors in formulas.
2111 @subsubheading Field coordinates in formulas
2112 @cindex field coordinates
2113 @cindex coordinates, of field
2114 @cindex row, of field coordinates
2115 @cindex column, of field coordinates
2117 For Calc formulas and Lisp formulas @code{@@#} and @code{$#} can be used to
2118 get the row or column number of the field where the formula result goes.
2119 The traditional Lisp formula equivalents are @code{org-table-current-dline}
2120 and @code{org-table-current-column}.  Examples:
2122 @example
2123 if(@@# % 2, $#, string(""))   @r{column number on odd lines only}
2124 $3 = remote(FOO, @@@@#$2)      @r{copy column 2 from table FOO into}
2125                              @r{column 3 of the current table}
2126 @end example
2128 @noindent For the second example, table FOO must have at least as many rows
2129 as the current table.  Inefficient@footnote{The computation time scales as
2130 O(N^2) because table FOO is parsed for each field to be copied.} for large
2131 number of rows.
2133 @subsubheading Named references
2134 @cindex named references
2135 @cindex references, named
2136 @cindex name, of column or field
2137 @cindex constants, in calculations
2138 @cindex #+CONSTANTS
2140 @vindex org-table-formula-constants
2141 @samp{$name} is interpreted as the name of a column, parameter or
2142 constant.  Constants are defined globally through the variable
2143 @code{org-table-formula-constants}, and locally (for the file) through a
2144 line like
2146 @example
2147 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
2148 @end example
2150 @noindent
2151 @vindex constants-unit-system
2152 @pindex constants.el
2153 Also properties (@pxref{Properties and Columns}) can be used as
2154 constants in table formulas: for a property @samp{:Xyz:} use the name
2155 @samp{$PROP_Xyz}, and the property will be searched in the current
2156 outline entry and in the hierarchy above it.  If you have the
2157 @file{constants.el} package, it will also be used to resolve constants,
2158 including natural constants like @samp{$h} for Planck's constant, and
2159 units like @samp{$km} for kilometers@footnote{@file{constants.el} can
2160 supply the values of constants in two different unit systems, @code{SI}
2161 and @code{cgs}.  Which one is used depends on the value of the variable
2162 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
2163 @code{constSI} and @code{constcgs} to set this value for the current
2164 buffer.}.  Column names and parameters can be specified in special table
2165 lines.  These are described below, see @ref{Advanced features}.  All
2166 names must start with a letter, and further consist of letters and
2167 numbers.
2169 @subsubheading Remote references
2170 @cindex remote references
2171 @cindex references, remote
2172 @cindex references, to a different table
2173 @cindex name, of column or field
2174 @cindex constants, in calculations
2175 @cindex #+TBLNAME
2177 You may also reference constants, fields and ranges from a different table,
2178 either in the current file or even in a different file.  The syntax is
2180 @example
2181 remote(NAME-OR-ID,REF)
2182 @end example
2184 @noindent
2185 where NAME can be the name of a table in the current file as set by a
2186 @code{#+TBLNAME: NAME} line before the table.  It can also be the ID of an
2187 entry, even in a different file, and the reference then refers to the first
2188 table in that entry.  REF is an absolute field or range reference as
2189 described above for example @code{@@3$3} or @code{$somename}, valid in the
2190 referenced table.
2192 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
2193 @subsection Formula syntax for Calc
2194 @cindex formula syntax, Calc
2195 @cindex syntax, of formulas
2197 A formula can be any algebraic expression understood by the Emacs
2198 @file{Calc} package.  @b{Note that @file{calc} has the
2199 non-standard convention that @samp{/} has lower precedence than
2200 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
2201 evaluation by @code{calc-eval} (@pxref{Calling Calc from
2202 Your Programs,calc-eval,Calling Calc from Your Lisp Programs,Calc,GNU
2203 Emacs Calc Manual}),
2204 @c FIXME:  The link to the Calc manual in HTML does not work.
2205 variable substitution takes place according to the rules described above.
2206 @cindex vectors, in table calculations
2207 The range vectors can be directly fed into the Calc vector functions
2208 like @samp{vmean} and @samp{vsum}.
2210 @cindex format specifier
2211 @cindex mode, for @file{calc}
2212 @vindex org-calc-default-modes
2213 A formula can contain an optional mode string after a semicolon.  This
2214 string consists of flags to influence Calc and other modes during
2215 execution.  By default, Org uses the standard Calc modes (precision
2216 12, angular units degrees, fraction and symbolic modes off).  The display
2217 format, however, has been changed to @code{(float 8)} to keep tables
2218 compact.  The default settings can be configured using the variable
2219 @code{org-calc-default-modes}.
2221 @example
2222 p20           @r{set the internal Calc calculation precision to 20 digits}
2223 n3 s3 e2 f4   @r{Normal, scientific, engineering, or fixed}
2224               @r{format of the result of Calc passed back to Org.}
2225               @r{Calc formatting is unlimited in precision as}
2226               @r{long as the Calc calculation precision is greater.}
2227 D R           @r{angle modes: degrees, radians}
2228 F S           @r{fraction and symbolic modes}
2229 N             @r{interpret all fields as numbers, use 0 for non-numbers}
2230 T             @r{force text interpretation}
2231 E             @r{keep empty fields in ranges}
2232 L             @r{literal}
2233 @end example
2235 @noindent
2236 Unless you use large integer numbers or high-precision-calculation
2237 and -display for floating point numbers you may alternatively provide a
2238 @code{printf} format specifier to reformat the Calc result after it has been
2239 passed back to Org instead of letting Calc already do the
2240 formatting@footnote{The @code{printf} reformatting is limited in precision
2241 because the value passed to it is converted into an @code{integer} or
2242 @code{double}.  The @code{integer} is limited in size by truncating the
2243 signed value to 32 bits.  The @code{double} is limited in precision to 64
2244 bits overall which leaves approximately 16 significant decimal digits.}.
2245 A few examples:
2247 @example
2248 $1+$2                @r{Sum of first and second field}
2249 $1+$2;%.2f           @r{Same, format result to two decimals}
2250 exp($2)+exp($1)      @r{Math functions can be used}
2251 $0;%.1f              @r{Reformat current cell to 1 decimal}
2252 ($3-32)*5/9          @r{Degrees F -> C conversion}
2253 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
2254 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
2255 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
2256 vmean($2..$7)        @r{Compute column range mean, using vector function}
2257 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
2258 taylor($3,x=7,2)     @r{taylor series of $3, at x=7, second degree}
2259 @end example
2261 Calc also contains a complete set of logical operations.  For example
2263 @example
2264 if($1<20,teen,string(""))  @r{``teen'' if age $1 less than 20, else empty}
2265 @end example
2267 @node Formula syntax for Lisp, Field formulas, Formula syntax for Calc, The spreadsheet
2268 @subsection Emacs Lisp forms as formulas
2269 @cindex Lisp forms, as table formulas
2271 It is also possible to write a formula in Emacs Lisp; this can be useful
2272 for string manipulation and control structures, if Calc's
2273 functionality is not enough.  If a formula starts with a single-quote
2274 followed by an opening parenthesis, then it is evaluated as a Lisp form.
2275 The evaluation should return either a string or a number.  Just as with
2276 @file{calc} formulas, you can specify modes and a printf format after a
2277 semicolon.  With Emacs Lisp forms, you need to be conscious about the way
2278 field references are interpolated into the form.  By default, a
2279 reference will be interpolated as a Lisp string (in double-quotes)
2280 containing the field.  If you provide the @samp{N} mode switch, all
2281 referenced elements will be numbers (non-number fields will be zero) and
2282 interpolated as Lisp numbers, without quotes.  If you provide the
2283 @samp{L} flag, all fields will be interpolated literally, without quotes.
2284 I.e., if you want a reference to be interpreted as a string by the Lisp
2285 form, enclose the reference operator itself in double-quotes, like
2286 @code{"$3"}.  Ranges are inserted as space-separated fields, so you can
2287 embed them in list or vector syntax.  A few examples, note how the
2288 @samp{N} mode is used when we do computations in Lisp.
2290 @example
2291 @r{Swap the first two characters of the content of column 1}
2292   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
2293 @r{Add columns 1 and 2, equivalent to Calc's @code{$1+$2}}
2294   '(+ $1 $2);N
2295 @r{Compute the sum of columns 1-4, like Calc's @code{vsum($1..$4)}}
2296   '(apply '+ '($1..$4));N
2297 @end example
2299 @node Field formulas, Column formulas, Formula syntax for Lisp, The spreadsheet
2300 @subsection Field formulas
2301 @cindex field formula
2302 @cindex formula, for individual table field
2304 To assign a formula to a particular field, type it directly into the
2305 field, preceded by @samp{:=}, for example @samp{:=$1+$2}.  When you
2306 press @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in
2307 the field, the formula will be stored as the formula for this field,
2308 evaluated, and the current field replaced with the result.
2310 @cindex #+TBLFM
2311 Formulas are stored in a special line starting with @samp{#+TBLFM:}
2312 directly below the table.  If you typed the equation in the 4th field of
2313 the 3rd data line in the table, the formula will look like
2314 @samp{@@3$4=$1+$2}.  When inserting/deleting/swapping column and rows
2315 with the appropriate commands, @i{absolute references} (but not relative
2316 ones) in stored formulas are modified in order to still reference the
2317 same field.  Of course this is not true if you edit the table structure
2318 with normal editing commands---then you must fix the equations yourself.
2319 The left-hand side of a formula may also be a named field (@pxref{Advanced
2320 features}), or a last-row reference like @samp{$LR3}.
2322 Instead of typing an equation into the field, you may also use the
2323 following command
2325 @table @kbd
2326 @kindex C-u C-c =
2327 @item C-u C-c =
2328 Install a new formula for the current field.  The command prompts for a
2329 formula with default taken from the @samp{#+TBLFM:} line, applies
2330 it to the current field, and stores it.
2331 @end table
2333 @node Column formulas, Editing and debugging formulas, Field formulas, The spreadsheet
2334 @subsection Column formulas
2335 @cindex column formula
2336 @cindex formula, for table column
2338 Often in a table, the same formula should be used for all fields in a
2339 particular column.  Instead of having to copy the formula to all fields
2340 in that column, Org allows you to assign a single formula to an entire
2341 column.  If the table contains horizontal separator hlines, everything
2342 before the first such line is considered part of the table @emph{header}
2343 and will not be modified by column formulas.
2345 To assign a formula to a column, type it directly into any field in the
2346 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
2347 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the field,
2348 the formula will be stored as the formula for the current column, evaluated
2349 and the current field replaced with the result.  If the field contains only
2350 @samp{=}, the previously stored formula for this column is used.  For each
2351 column, Org will only remember the most recently used formula.  In the
2352 @samp{#+TBLFM:} line, column formulas will look like @samp{$4=$1+$2}.  The left-hand
2353 side of a column formula cannot currently be the name of column, it
2354 must be the numeric column reference.
2356 Instead of typing an equation into the field, you may also use the
2357 following command:
2359 @table @kbd
2360 @kindex C-c =
2361 @item C-c =
2362 Install a new formula for the current column and replace current field with
2363 the result of the formula.  The command prompts for a formula, with default
2364 taken from the @samp{#+TBLFM} line, applies it to the current field and
2365 stores it.  With a numeric prefix argument(e.g. @kbd{C-5 C-c =}) the command
2366 will apply it to that many consecutive fields in the current column.
2367 @end table
2369 @node Editing and debugging formulas, Updating the table, Column formulas, The spreadsheet
2370 @subsection Editing and debugging formulas
2371 @cindex formula editing
2372 @cindex editing, of table formulas
2374 @vindex org-table-use-standard-references
2375 You can edit individual formulas in the minibuffer or directly in the
2376 field.  Org can also prepare a special buffer with all active
2377 formulas of a table.  When offering a formula for editing, Org
2378 converts references to the standard format (like @code{B3} or @code{D&})
2379 if possible.  If you prefer to only work with the internal format (like
2380 @code{@@3$2} or @code{$4}), configure the variable
2381 @code{org-table-use-standard-references}.
2383 @table @kbd
2384 @kindex C-c =
2385 @kindex C-u C-c =
2386 @item C-c =
2387 @itemx C-u C-c =
2388 Edit the formula associated with the current column/field in the
2389 minibuffer.  See @ref{Column formulas}, and @ref{Field formulas}.
2390 @kindex C-u C-u C-c =
2391 @item C-u C-u C-c =
2392 Re-insert the active formula (either a
2393 field formula, or a column formula) into the current field, so that you
2394 can edit it directly in the field.  The advantage over editing in the
2395 minibuffer is that you can use the command @kbd{C-c ?}.
2396 @kindex C-c ?
2397 @item C-c ?
2398 While editing a formula in a table field, highlight the field(s)
2399 referenced by the reference at the cursor position in the formula.
2400 @kindex C-c @}
2401 @item C-c @}
2402 Toggle the display of row and column numbers for a table, using
2403 overlays.  These are updated each time the table is aligned; you can
2404 force it with @kbd{C-c C-c}.
2405 @kindex C-c @{
2406 @item C-c @{
2407 Toggle the formula debugger on and off.  See below.
2408 @kindex C-c '
2409 @item C-c '
2410 Edit all formulas for the current table in a special buffer, where the
2411 formulas will be displayed one per line.  If the current field has an
2412 active formula, the cursor in the formula editor will mark it.
2413 While inside the special buffer, Org will automatically highlight
2414 any field or range reference at the cursor position.  You may edit,
2415 remove and add formulas, and use the following commands:
2416 @table @kbd
2417 @kindex C-c C-c
2418 @kindex C-x C-s
2419 @item C-c C-c
2420 @itemx C-x C-s
2421 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
2422 prefix, also apply the new formulas to the entire table.
2423 @kindex C-c C-q
2424 @item C-c C-q
2425 Exit the formula editor without installing changes.
2426 @kindex C-c C-r
2427 @item C-c C-r
2428 Toggle all references in the formula editor between standard (like
2429 @code{B3}) and internal (like @code{@@3$2}).
2430 @kindex @key{TAB}
2431 @item @key{TAB}
2432 Pretty-print or indent Lisp formula at point.  When in a line containing
2433 a Lisp formula, format the formula according to Emacs Lisp rules.
2434 Another @key{TAB} collapses the formula back again.  In the open
2435 formula, @key{TAB} re-indents just like in Emacs Lisp mode.
2436 @kindex M-@key{TAB}
2437 @item M-@key{TAB}
2438 Complete Lisp symbols, just like in Emacs Lisp mode.
2439 @kindex S-@key{up}
2440 @kindex S-@key{down}
2441 @kindex S-@key{left}
2442 @kindex S-@key{right}
2443 @item S-@key{up}/@key{down}/@key{left}/@key{right}
2444 Shift the reference at point.  For example, if the reference is
2445 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
2446 This also works for relative references and for hline references.
2447 @kindex M-S-@key{up}
2448 @kindex M-S-@key{down}
2449 @item M-S-@key{up}/@key{down}
2450 Move the test line for column formulas in the Org buffer up and
2451 down.
2452 @kindex M-@key{up}
2453 @kindex M-@key{down}
2454 @item M-@key{up}/@key{down}
2455 Scroll the window displaying the table.
2456 @kindex C-c @}
2457 @item C-c @}
2458 Turn the coordinate grid in the table on and off.
2459 @end table
2460 @end table
2462 Making a table field blank does not remove the formula associated with
2463 the field, because that is stored in a different line (the @samp{#+TBLFM}
2464 line)---during the next recalculation the field will be filled again.
2465 To remove a formula from a field, you have to give an empty reply when
2466 prompted for the formula, or to edit the @samp{#+TBLFM} line.
2468 @kindex C-c C-c
2469 You may edit the @samp{#+TBLFM} directly and re-apply the changed
2470 equations with @kbd{C-c C-c} in that line or with the normal
2471 recalculation commands in the table.
2473 @subsubheading Debugging formulas
2474 @cindex formula debugging
2475 @cindex debugging, of table formulas
2476 When the evaluation of a formula leads to an error, the field content
2477 becomes the string @samp{#ERROR}.  If you would like see what is going
2478 on during variable substitution and calculation in order to find a bug,
2479 turn on formula debugging in the @code{Tbl} menu and repeat the
2480 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
2481 field.  Detailed information will be displayed.
2483 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
2484 @subsection Updating the table
2485 @cindex recomputing table fields
2486 @cindex updating, table
2488 Recalculation of a table is normally not automatic, but needs to be
2489 triggered by a command.  See @ref{Advanced features}, for a way to make
2490 recalculation at least semi-automatic.
2492 In order to recalculate a line of a table or the entire table, use the
2493 following commands:
2495 @table @kbd
2496 @kindex C-c *
2497 @item C-c *
2498 Recalculate the current row by first applying the stored column formulas
2499 from left to right, and all field formulas in the current row.
2501 @kindex C-u C-c *
2502 @item C-u C-c *
2503 @kindex C-u C-c C-c
2504 @itemx C-u C-c C-c
2505 Recompute the entire table, line by line.  Any lines before the first
2506 hline are left alone, assuming that these are part of the table header.
2508 @kindex C-u C-u C-c *
2509 @kindex C-u C-u C-c C-c
2510 @item C-u C-u C-c *
2511 @itemx C-u C-u C-c C-c
2512 Iterate the table by recomputing it until no further changes occur.
2513 This may be necessary if some computed fields use the value of other
2514 fields that are computed @i{later} in the calculation sequence.
2515 @item M-x org-table-recalculate-buffer-tables
2516 Recompute all tables in the current buffer.
2517 @item M-x org-table-iterate-buffer-tables
2518 Iterate all tables in the current buffer, in order to converge table-to-table
2519 dependencies.
2520 @end table
2522 @node Advanced features,  , Updating the table, The spreadsheet
2523 @subsection Advanced features
2525 If you want the recalculation of fields to happen automatically, or if
2526 you want to be able to assign @i{names} to fields and columns, you need
2527 to reserve the first column of the table for special marking characters.
2528 @table @kbd
2529 @kindex C-#
2530 @item C-#
2531 Rotate the calculation mark in first column through the states @samp{ },
2532 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  When there is an active region,
2533 change all marks in the region.
2534 @end table
2536 Here is an example of a table that collects exam results of students and
2537 makes use of these features:
2539 @example
2540 @group
2541 |---+---------+--------+--------+--------+-------+------|
2542 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2543 |---+---------+--------+--------+--------+-------+------|
2544 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2545 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2546 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2547 |---+---------+--------+--------+--------+-------+------|
2548 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
2549 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
2550 |---+---------+--------+--------+--------+-------+------|
2551 |   | Average |        |        |        |  29.7 |      |
2552 | ^ |         |        |        |        |    at |      |
2553 | $ | max=50  |        |        |        |       |      |
2554 |---+---------+--------+--------+--------+-------+------|
2555 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
2556 @end group
2557 @end example
2559 @noindent @b{Important}: please note that for these special tables,
2560 recalculating the table with @kbd{C-u C-c *} will only affect rows that
2561 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
2562 to the field itself.  The column formulas are not applied in rows with
2563 empty first field.
2565 @cindex marking characters, tables
2566 The marking characters have the following meaning:
2567 @table @samp
2568 @item !
2569 The fields in this line define names for the columns, so that you may
2570 refer to a column as @samp{$Tot} instead of @samp{$6}.
2571 @item ^
2572 This row defines names for the fields @emph{above} the row.  With such
2573 a definition, any formula in the table may use @samp{$m1} to refer to
2574 the value @samp{10}.  Also, if you assign a formula to a names field, it
2575 will be stored as @samp{$name=...}.
2576 @item _
2577 Similar to @samp{^}, but defines names for the fields in the row
2578 @emph{below}.
2579 @item $
2580 Fields in this row can define @emph{parameters} for formulas.  For
2581 example, if a field in a @samp{$} row contains @samp{max=50}, then
2582 formulas in this table can refer to the value 50 using @samp{$max}.
2583 Parameters work exactly like constants, only that they can be defined on
2584 a per-table basis.
2585 @item #
2586 Fields in this row are automatically recalculated when pressing
2587 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
2588 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
2589 lines will be left alone by this command.
2590 @item *
2591 Selects this line for global recalculation with @kbd{C-u C-c *}, but
2592 not for automatic recalculation.  Use this when automatic
2593 recalculation slows down editing too much.
2594 @item
2595 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
2596 All lines that should be recalculated should be marked with @samp{#}
2597 or @samp{*}.
2598 @item /
2599 Do not export this line.  Useful for lines that contain the narrowing
2600 @samp{<N>} markers or column group markers.
2601 @end table
2603 Finally, just to whet your appetite for what can be done with the
2604 fantastic @file{calc.el} package, here is a table that computes the Taylor
2605 series of degree @code{n} at location @code{x} for a couple of
2606 functions.
2608 @example
2609 @group
2610 |---+-------------+---+-----+--------------------------------------|
2611 |   | Func        | n | x   | Result                               |
2612 |---+-------------+---+-----+--------------------------------------|
2613 | # | exp(x)      | 1 | x   | 1 + x                                |
2614 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
2615 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
2616 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
2617 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
2618 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
2619 |---+-------------+---+-----+--------------------------------------|
2620 #+TBLFM: $5=taylor($2,$4,$3);n3
2621 @end group
2622 @end example
2624 @node Org-Plot,  , The spreadsheet, Tables
2625 @section Org-Plot
2626 @cindex graph, in tables
2627 @cindex plot tables using Gnuplot
2628 @cindex #+PLOT
2630 Org-Plot can produce 2D and 3D graphs of information stored in org tables
2631 using @file{Gnuplot} @uref{http://www.gnuplot.info/} and @file{gnuplot-mode}
2632 @uref{http://cars9.uchicago.edu/~ravel/software/gnuplot-mode.html}.  To see
2633 this in action, ensure that you have both Gnuplot and Gnuplot mode installed
2634 on your system, then call @code{org-plot/gnuplot} on the following table.
2636 @example
2637 @group
2638 #+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
2639 | Sede      | Max cites | H-index |
2640 |-----------+-----------+---------|
2641 | Chile     |    257.72 |   21.39 |
2642 | Leeds     |    165.77 |   19.68 |
2643 | Sao Paolo |     71.00 |   11.50 |
2644 | Stockholm |    134.19 |   14.33 |
2645 | Morelia   |    257.56 |   17.67 |
2646 @end group
2647 @end example
2649 Notice that Org Plot is smart enough to apply the table's headers as labels.
2650 Further control over the labels, type, content, and appearance of plots can
2651 be exercised through the @code{#+PLOT:} lines preceding a table.  See below
2652 for a complete list of Org-plot options.  For more information and examples
2653 see the Org-plot tutorial at
2654 @uref{http://orgmode.org/worg/org-tutorials/org-plot.php}.
2656 @subsubheading Plot Options
2658 @table @code
2659 @item set
2660 Specify any @command{gnuplot} option to be set when graphing.
2662 @item title
2663 Specify the title of the plot.
2665 @item ind
2666 Specify which column of the table to use as the @code{x} axis.
2668 @item deps
2669 Specify the columns to graph as a Lisp style list, surrounded by parentheses
2670 and separated by spaces for example @code{dep:(3 4)} to graph the third and
2671 fourth columns (defaults to graphing all other columns aside from the @code{ind}
2672 column).
2674 @item type
2675 Specify whether the plot will be @code{2d}, @code{3d}, or @code{grid}.
2677 @item with
2678 Specify a @code{with} option to be inserted for every col being plotted
2679 (e.g. @code{lines}, @code{points}, @code{boxes}, @code{impulses}, etc...).
2680 Defaults to @code{lines}.
2682 @item file
2683 If you want to plot to a file, specify @code{"@var{path/to/desired/output-file}"}.
2685 @item labels
2686 List of labels to be used for the deps (defaults to the column headers if
2687 they exist).
2689 @item line
2690 Specify an entire line to be inserted in the Gnuplot script.
2692 @item map
2693 When plotting @code{3d} or @code{grid} types, set this to @code{t} to graph a
2694 flat mapping rather than a @code{3d} slope.
2696 @item timefmt
2697 Specify format of Org-mode timestamps as they will be parsed by Gnuplot.
2698 Defaults to @samp{%Y-%m-%d-%H:%M:%S}.
2700 @item script
2701 If you want total control, you can specify a script file (place the file name
2702 between double-quotes) which will be used to plot.  Before plotting, every
2703 instance of @code{$datafile} in the specified script will be replaced with
2704 the path to the generated data file.  Note: even if you set this option, you
2705 may still want to specify the plot type, as that can impact the content of
2706 the data file.
2707 @end table
2709 @node Hyperlinks, TODO Items, Tables, Top
2710 @chapter Hyperlinks
2711 @cindex hyperlinks
2713 Like HTML, Org provides links inside a file, external links to
2714 other files, Usenet articles, emails, and much more.
2716 @menu
2717 * Link format::                 How links in Org are formatted
2718 * Internal links::              Links to other places in the current file
2719 * External links::              URL-like links to the world
2720 * Handling links::              Creating, inserting and following
2721 * Using links outside Org::     Linking from my C source code?
2722 * Link abbreviations::          Shortcuts for writing complex links
2723 * Search options::              Linking to a specific location
2724 * Custom searches::             When the default search is not enough
2725 @end menu
2727 @node Link format, Internal links, Hyperlinks, Hyperlinks
2728 @section Link format
2729 @cindex link format
2730 @cindex format, of links
2732 Org will recognize plain URL-like links and activate them as
2733 clickable links.  The general link format, however, looks like this:
2735 @example
2736 [[link][description]]       @r{or alternatively}           [[link]]
2737 @end example
2739 @noindent
2740 Once a link in the buffer is complete (all brackets present), Org
2741 will change the display so that @samp{description} is displayed instead
2742 of @samp{[[link][description]]} and @samp{link} is displayed instead of
2743 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
2744 which by default is an underlined face.  You can directly edit the
2745 visible part of a link.  Note that this can be either the @samp{link}
2746 part (if there is no description) or the @samp{description} part.  To
2747 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
2748 cursor on the link.
2750 If you place the cursor at the beginning or just behind the end of the
2751 displayed text and press @key{BACKSPACE}, you will remove the
2752 (invisible) bracket at that location.  This makes the link incomplete
2753 and the internals are again displayed as plain text.  Inserting the
2754 missing bracket hides the link internals again.  To show the
2755 internal structure of all links, use the menu entry
2756 @code{Org->Hyperlinks->Literal links}.
2758 @node Internal links, External links, Link format, Hyperlinks
2759 @section Internal links
2760 @cindex internal links
2761 @cindex links, internal
2762 @cindex targets, for links
2764 @cindex property, CUSTOM_ID
2765 If the link does not look like a URL, it is considered to be internal in the
2766 current file.  The most important case is a link like
2767 @samp{[[#my-custom-id]]} which will link to the entry with the
2768 @code{CUSTOM_ID} property @samp{my-custom-id}.  Such custom IDs are very good
2769 for HTML export (@pxref{HTML export}) where they produce pretty section
2770 links.  You are responsible yourself to make sure these custom IDs are unique
2771 in a file.
2773 Links such as @samp{[[My Target]]} or @samp{[[My Target][Find my target]]}
2774 lead to a text search in the current file.
2776 The link can be followed with @kbd{C-c C-o} when the cursor is on the link,
2777 or with a mouse click (@pxref{Handling links}).  Links to custom IDs will
2778 point to the corresponding headline.  The preferred match for a text link is
2779 a @i{dedicated target}: the same string in double angular brackets.  Targets
2780 may be located anywhere; sometimes it is convenient to put them into a
2781 comment line. For example
2783 @example
2784 # <<My Target>>
2785 @end example
2787 @noindent In HTML export (@pxref{HTML export}), such targets will become
2788 named anchors for direct access through @samp{http} links@footnote{Note that
2789 text before the first headline is usually not exported, so the first such
2790 target should be after the first headline, or in the line directly before the
2791 first headline.}.
2793 If no dedicated target exists, Org will search for a headline that is exactly
2794 the link text but may also include a TODO keyword and tags@footnote{To insert
2795 a link targeting a headline, in-buffer completion can be used.  Just type a
2796 star followed by a few optional letters into the buffer and press
2797 @kbd{M-@key{TAB}}.  All headlines in the current buffer will be offered as
2798 completions.}.  In non-Org files, the search will look for the words in the
2799 link text, in the above example the search would be for @samp{my target}.
2801 Following a link pushes a mark onto Org's own mark ring.  You can
2802 return to the previous position with @kbd{C-c &}.  Using this command
2803 several times in direct succession goes back to positions recorded
2804 earlier.
2806 @menu
2807 * Radio targets::               Make targets trigger links in plain text
2808 @end menu
2810 @node Radio targets,  , Internal links, Internal links
2811 @subsection Radio targets
2812 @cindex radio targets
2813 @cindex targets, radio
2814 @cindex links, radio targets
2816 Org can automatically turn any occurrences of certain target names
2817 in normal text into a link.  So without explicitly creating a link, the
2818 text connects to the target radioing its position.  Radio targets are
2819 enclosed by triple angular brackets.  For example, a target @samp{<<<My
2820 Target>>>} causes each occurrence of @samp{my target} in normal text to
2821 become activated as a link.  The Org file is scanned automatically
2822 for radio targets only when the file is first loaded into Emacs.  To
2823 update the target list during editing, press @kbd{C-c C-c} with the
2824 cursor on or at a target.
2826 @node External links, Handling links, Internal links, Hyperlinks
2827 @section External links
2828 @cindex links, external
2829 @cindex external links
2830 @cindex links, external
2831 @cindex Gnus links
2832 @cindex BBDB links
2833 @cindex IRC links
2834 @cindex URL links
2835 @cindex file links
2836 @cindex VM links
2837 @cindex RMAIL links
2838 @cindex WANDERLUST links
2839 @cindex MH-E links
2840 @cindex USENET links
2841 @cindex SHELL links
2842 @cindex Info links
2843 @cindex Elisp links
2845 Org supports links to files, websites, Usenet and email messages,
2846 BBDB database entries and links to both IRC conversations and their
2847 logs.  External links are URL-like locators.  They start with a short
2848 identifying string followed by a colon.  There can be no space after
2849 the colon.  The following list shows examples for each link type.
2851 @example
2852 http://www.astro.uva.nl/~dominik          @r{on the web}
2853 doi:10.1000/182                           @r{DOI for an electronic resource}
2854 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
2855 /home/dominik/images/jupiter.jpg          @r{same as above}
2856 file:papers/last.pdf                      @r{file, relative path}
2857 ./papers/last.pdf                         @r{same as above}
2858 file:/myself@@some.where:papers/last.pdf   @r{file, path on remote machine}
2859 /myself@@some.where:papers/last.pdf        @r{same as above}
2860 file:sometextfile::NNN                    @r{file with line number to jump to}
2861 file:projects.org                         @r{another Org file}
2862 file:projects.org::some words             @r{text search in Org file}
2863 file:projects.org::*task title            @r{heading search in Org file}
2864 docview:papers/last.pdf::NNN              @r{open file in doc-view mode at page NNN}
2865 id:B7423F4D-2E8A-471B-8810-C40F074717E9   @r{Link to heading by ID}
2866 news:comp.emacs                           @r{Usenet link}
2867 mailto:adent@@galaxy.net                   @r{Mail link}
2868 vm:folder                                 @r{VM folder link}
2869 vm:folder#id                              @r{VM message link}
2870 vm://myself@@some.where.org/folder#id      @r{VM on remote machine}
2871 wl:folder                                 @r{WANDERLUST folder link}
2872 wl:folder#id                              @r{WANDERLUST message link}
2873 mhe:folder                                @r{MH-E folder link}
2874 mhe:folder#id                             @r{MH-E message link}
2875 rmail:folder                              @r{RMAIL folder link}
2876 rmail:folder#id                           @r{RMAIL message link}
2877 gnus:group                                @r{Gnus group link}
2878 gnus:group#id                             @r{Gnus article link}
2879 bbdb:R.*Stallman                          @r{BBDB link (with regexp)}
2880 irc:/irc.com/#emacs/bob                   @r{IRC link}
2881 info:org:External%20links                 @r{Info node link (with encoded space)}
2882 shell:ls *.org                            @r{A shell command}
2883 elisp:org-agenda                          @r{Interactive Elisp command}
2884 elisp:(find-file-other-frame "Elisp.org") @r{Elisp form to evaluate}
2885 @end example
2887 A link should be enclosed in double brackets and may contain a
2888 descriptive text to be displayed instead of the URL (@pxref{Link
2889 format}), for example:
2891 @example
2892 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
2893 @end example
2895 @noindent
2896 If the description is a file name or URL that points to an image, HTML
2897 export (@pxref{HTML export}) will inline the image as a clickable
2898 button.  If there is no description at all and the link points to an
2899 image,
2900 that image will be inlined into the exported HTML file.
2902 @cindex square brackets, around links
2903 @cindex plain text external links
2904 Org also finds external links in the normal text and activates them
2905 as links.  If spaces must be part of the link (for example in
2906 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
2907 about the end of the link, enclose them in square brackets.
2909 @node Handling links, Using links outside Org, External links, Hyperlinks
2910 @section Handling links
2911 @cindex links, handling
2913 Org provides methods to create a link in the correct syntax, to
2914 insert it into an Org file, and to follow the link.
2916 @table @kbd
2917 @kindex C-c l
2918 @cindex storing links
2919 @item C-c l
2920 Store a link to the current location.  This is a @emph{global} command (you
2921 must create the key binding yourself) which can be used in any buffer to
2922 create a link.  The link will be stored for later insertion into an Org
2923 buffer (see below).  What kind of link will be created depends on the current
2924 buffer:
2926 @b{Org-mode buffers}@*
2927 For Org files, if there is a @samp{<<target>>} at the cursor, the link points
2928 to the target.  Otherwise it points to the current headline, which will also
2929 be the description.
2931 @vindex org-link-to-org-use-id
2932 @cindex property, CUSTOM_ID
2933 @cindex property, ID
2934 If the headline has a @code{CUSTOM_ID} property, a link to this custom ID
2935 will be stored.  In addition or alternatively (depending on the value of
2936 @code{org-link-to-org-use-id}), a globally unique @code{ID} property will be
2937 created and/or used to construct a link.  So using this command in Org
2938 buffers will potentially create two links: a human-readable from the custom
2939 ID, and one that is globally unique and works even if the entry is moved from
2940 file to file.  Later, when inserting the link, you need to decide which one
2941 to use.
2943 @b{Email/News clients: VM, Rmail, Wanderlust, MH-E, Gnus}@*
2944 Pretty much all Emacs mail clients are supported.  The link will point to the
2945 current article, or, in some GNUS buffers, to the group.  The description is
2946 constructed from the author and the subject.
2948 @b{Web browsers: W3 and W3M}@*
2949 Here the link will be the current URL, with the page title as description.
2951 @b{Contacts: BBDB}@*
2952 Links created in a BBDB buffer will point to the current entry.
2954 @b{Chat: IRC}@*
2955 @vindex org-irc-link-to-logs
2956 For IRC links, if you set the variable @code{org-irc-link-to-logs} to
2957 @code{t}, a @samp{file:/} style link to the relevant point in the logs for
2958 the current conversation is created.  Otherwise an @samp{irc:/} style link to
2959 the user/channel/server under the point will be stored.
2961 @b{Other files}@*
2962 For any other files, the link will point to the file, with a search string
2963 (@pxref{Search options}) pointing to the contents of the current line.  If
2964 there is an active region, the selected words will form the basis of the
2965 search string.  If the automatically created link is not working correctly or
2966 accurately enough, you can write custom functions to select the search string
2967 and to do the search for particular file types---see @ref{Custom searches}.
2968 The key binding @kbd{C-c l} is only a suggestion---see @ref{Installation}.
2970 @b{Agenda view}@*
2971 When the cursor is in an agenda view, the created link points to the
2972 entry referenced by the current line.
2975 @kindex C-c C-l
2976 @cindex link completion
2977 @cindex completion, of links
2978 @cindex inserting links
2979 @item C-c C-l
2980 @vindex org-keep-stored-link-after-insertion
2981 Insert a link@footnote{ Note that you don't have to use this command to
2982 insert a link.  Links in Org are plain text, and you can type or paste them
2983 straight into the buffer.  By using this command, the links are automatically
2984 enclosed in double brackets, and you will be asked for the optional
2985 descriptive text.}.  This prompts for a link to be inserted into the buffer.
2986 You can just type a link, using text for an internal link, or one of the link
2987 type prefixes mentioned in the examples above.  The link will be inserted
2988 into the buffer@footnote{After insertion of a stored link, the link will be
2989 removed from the list of stored links.  To keep it in the list later use, use
2990 a triple @kbd{C-u} prefix argument to @kbd{C-c C-l}, or configure the option
2991 @code{org-keep-stored-link-after-insertion}.}, along with a descriptive text.
2992 If some text was selected when this command is called, the selected text
2993 becomes the default description.
2995 @b{Inserting stored links}@*
2996 All links stored during the
2997 current session are part of the history for this prompt, so you can access
2998 them with @key{up} and @key{down} (or @kbd{M-p/n}).
3000 @b{Completion support}@* Completion with @key{TAB} will help you to insert
3001 valid link prefixes like @samp{http:} or @samp{ftp:}, including the prefixes
3002 defined through link abbreviations (@pxref{Link abbreviations}).  If you
3003 press @key{RET} after inserting only the @var{prefix}, Org will offer
3004 specific completion support for some link types@footnote{This works by
3005 calling a special function @code{org-PREFIX-complete-link}.}  For
3006 example, if you type @kbd{file @key{RET}}, file name completion (alternative
3007 access: @kbd{C-u C-c C-l}, see below) will be offered, and after @kbd{bbdb
3008 @key{RET}} you can complete contact names.
3009 @kindex C-u C-c C-l
3010 @cindex file name completion
3011 @cindex completion, of file names
3012 @item C-u C-c C-l
3013 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
3014 a file will be inserted and you may use file name completion to select
3015 the name of the file.  The path to the file is inserted relative to the
3016 directory of the current Org file, if the linked file is in the current
3017 directory or in a sub-directory of it, or if the path is written relative
3018 to the current directory using @samp{../}.  Otherwise an absolute path
3019 is used, if possible with @samp{~/} for your home directory.  You can
3020 force an absolute path with two @kbd{C-u} prefixes.
3022 @item C-c C-l @ @r{(with cursor on existing link)}
3023 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
3024 link and description parts of the link.
3026 @cindex following links
3027 @kindex C-c C-o
3028 @kindex @key{RET}
3029 @item C-c C-o @ @r{(or, if @code{org-return-follows-link} is set, also} @key{RET}
3030 @vindex org-file-apps
3031 Open link at point.  This will launch a web browser for URLs (using
3032 @command{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB for
3033 the corresponding links, and execute the command in a shell link.  When the
3034 cursor is on an internal link, this command runs the corresponding search.
3035 When the cursor is on a TAG list in a headline, it creates the corresponding
3036 TAGS view.  If the cursor is on a timestamp, it compiles the agenda for that
3037 date.  Furthermore, it will visit text and remote files in @samp{file:} links
3038 with Emacs and select a suitable application for local non-text files.
3039 Classification of files is based on file extension only.  See option
3040 @code{org-file-apps}.  If you want to override the default application and
3041 visit the file with Emacs, use a @kbd{C-u} prefix.  If you want to avoid
3042 opening in Emacs, use a @kbd{C-u C-u} prefix.@*
3043 If the cursor is on a headline, but not on a link, offer all links in the
3044 headline and entry text.
3046 @kindex mouse-2
3047 @kindex mouse-1
3048 @item mouse-2
3049 @itemx mouse-1
3050 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
3051 would.  Under Emacs 22, @kbd{mouse-1} will also follow a link.
3053 @kindex mouse-3
3054 @item mouse-3
3055 @vindex org-display-internal-link-with-indirect-buffer
3056 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
3057 internal links to be displayed in another window@footnote{See the
3058 variable @code{org-display-internal-link-with-indirect-buffer}}.
3060 @cindex inlining images
3061 @cindex images, inlining
3062 @kindex C-c C-x C-v
3063 @item C-c C-x C-v
3064 Toggle the inline display of linked images.  Normally this will only inline
3065 images that have no description part in the link, i.e. images that will also
3066 be inlined during export.  When called with a prefix argument, also display
3067 images that do have a link description.
3068 @cindex mark ring
3069 @kindex C-c %
3070 @item C-c %
3071 Push the current position onto the mark ring, to be able to return
3072 easily. Commands following an internal link do this automatically.
3074 @cindex links, returning to
3075 @kindex C-c &
3076 @item C-c &
3077 Jump back to a recorded position.  A position is recorded by the
3078 commands following internal links, and by @kbd{C-c %}.  Using this
3079 command several times in direct succession moves through a ring of
3080 previously recorded positions.
3082 @kindex C-c C-x C-n
3083 @kindex C-c C-x C-p
3084 @cindex links, finding next/previous
3085 @item C-c C-x C-n
3086 @itemx C-c C-x C-p
3087 Move forward/backward to the next link in the buffer.  At the limit of
3088 the buffer, the search fails once, and then wraps around.  The key
3089 bindings for this are really too long, you might want to bind this also
3090 to @kbd{C-n} and @kbd{C-p}
3091 @lisp
3092 (add-hook 'org-load-hook
3093   (lambda ()
3094     (define-key 'org-mode-map "\C-n" 'org-next-link)
3095     (define-key 'org-mode-map "\C-p" 'org-previous-link)))
3096 @end lisp
3097 @end table
3099 @node Using links outside Org, Link abbreviations, Handling links, Hyperlinks
3100 @section Using links outside Org
3102 You can insert and follow links that have Org syntax not only in
3103 Org, but in any Emacs buffer.  For this, you should create two
3104 global commands, like this (please select suitable global keys
3105 yourself):
3107 @lisp
3108 (global-set-key "\C-c L" 'org-insert-link-global)
3109 (global-set-key "\C-c o" 'org-open-at-point-global)
3110 @end lisp
3112 @node Link abbreviations, Search options, Using links outside Org, Hyperlinks
3113 @section Link abbreviations
3114 @cindex link abbreviations
3115 @cindex abbreviation, links
3117 Long URLs can be cumbersome to type, and often many similar links are
3118 needed in a document.  For this you can use link abbreviations.  An
3119 abbreviated link looks like this
3121 @example
3122 [[linkword:tag][description]]
3123 @end example
3125 @noindent
3126 @vindex org-link-abbrev-alist
3127 where the tag is optional.
3128 The @i{linkword} must be a word, starting with a letter, followed by
3129 letters, numbers, @samp{-}, and @samp{_}.  Abbreviations are resolved
3130 according to the information in the variable @code{org-link-abbrev-alist}
3131 that relates the linkwords to replacement text.  Here is an example:
3133 @lisp
3134 @group
3135 (setq org-link-abbrev-alist
3136   '(("bugzilla" . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
3137     ("google"   . "http://www.google.com/search?q=")
3138     ("ads"      . "http://adsabs.harvard.edu/cgi-bin/
3139                    nph-abs_connect?author=%s&db_key=AST")))
3140 @end group
3141 @end lisp
3143 If the replacement text contains the string @samp{%s}, it will be
3144 replaced with the tag.  Otherwise the tag will be appended to the string
3145 in order to create the link.  You may also specify a function that will
3146 be called with the tag as the only argument to create the link.
3148 With the above setting, you could link to a specific bug with
3149 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
3150 @code{[[google:OrgMode]]} and find out what the Org author is
3151 doing besides Emacs hacking with @code{[[ads:Dominik,C]]}.
3153 If you need special abbreviations just for a single Org buffer, you
3154 can define them in the file with
3156 @cindex #+LINK
3157 @example
3158 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
3159 #+LINK: google    http://www.google.com/search?q=%s
3160 @end example
3162 @noindent
3163 In-buffer completion (@pxref{Completion}) can be used after @samp{[} to
3164 complete link abbreviations.  You may also define a function
3165 @code{org-PREFIX-complete-link} that implements special (e.g. completion)
3166 support for inserting such a link with @kbd{C-c C-l}.  Such a function should
3167 not accept any arguments, and return the full link with prefix.
3169 @node Search options, Custom searches, Link abbreviations, Hyperlinks
3170 @section Search options in file links
3171 @cindex search option in file links
3172 @cindex file links, searching
3174 File links can contain additional information to make Emacs jump to a
3175 particular location in the file when following a link.  This can be a
3176 line number or a search option after a double@footnote{For backward
3177 compatibility, line numbers can also follow a single colon.} colon. For
3178 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
3179 links}) to a file, it encodes the words in the current line as a search
3180 string that can be used to find this line back later when following the
3181 link with @kbd{C-c C-o}.
3183 Here is the syntax of the different ways to attach a search to a file
3184 link, together with an explanation:
3186 @example
3187 [[file:~/code/main.c::255]]
3188 [[file:~/xx.org::My Target]]
3189 [[file:~/xx.org::*My Target]]
3190 [[file:~/xx.org::#my-custom-id]]
3191 [[file:~/xx.org::/regexp/]]
3192 @end example
3194 @table @code
3195 @item 255
3196 Jump to line 255.
3197 @item My Target
3198 Search for a link target @samp{<<My Target>>}, or do a text search for
3199 @samp{my target}, similar to the search in internal links, see
3200 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
3201 link will become an HTML reference to the corresponding named anchor in
3202 the linked file.
3203 @item *My Target
3204 In an Org file, restrict search to headlines.
3205 @item #my-custom-id
3206 Link to a heading with a @code{CUSTOM_ID} property
3207 @item /regexp/
3208 Do a regular expression search for @code{regexp}.  This uses the Emacs
3209 command @code{occur} to list all matches in a separate window.  If the
3210 target file is in Org-mode, @code{org-occur} is used to create a
3211 sparse tree with the matches.
3212 @c If the target file is a directory,
3213 @c @code{grep} will be used to search all files in the directory.
3214 @end table
3216 As a degenerate case, a file link with an empty file name can be used
3217 to search the current file.  For example, @code{[[file:::find me]]} does
3218 a search for @samp{find me} in the current file, just as
3219 @samp{[[find me]]} would.
3221 @node Custom searches,  , Search options, Hyperlinks
3222 @section Custom Searches
3223 @cindex custom search strings
3224 @cindex search strings, custom
3226 The default mechanism for creating search strings and for doing the
3227 actual search related to a file link may not work correctly in all
3228 cases.  For example, Bib@TeX{} database files have many entries like
3229 @samp{year="1993"} which would not result in good search strings,
3230 because the only unique identification for a Bib@TeX{} entry is the
3231 citation key.
3233 @vindex org-create-file-search-functions
3234 @vindex org-execute-file-search-functions
3235 If you come across such a problem, you can write custom functions to set
3236 the right search string for a particular file type, and to do the search
3237 for the string in the file.  Using @code{add-hook}, these functions need
3238 to be added to the hook variables
3239 @code{org-create-file-search-functions} and
3240 @code{org-execute-file-search-functions}.  See the docstring for these
3241 variables for more information.  Org actually uses this mechanism
3242 for Bib@TeX{} database files, and you can use the corresponding code as
3243 an implementation example.  See the file @file{org-bibtex.el}.
3245 @node TODO Items, Tags, Hyperlinks, Top
3246 @chapter TODO items
3247 @cindex TODO items
3249 Org-mode does not maintain TODO lists as separate documents@footnote{Of
3250 course, you can make a document that contains only long lists of TODO items,
3251 but this is not required.}.  Instead, TODO items are an integral part of the
3252 notes file, because TODO items usually come up while taking notes!  With Org
3253 mode, simply mark any entry in a tree as being a TODO item.  In this way,
3254 information is not duplicated, and the entire context from which the TODO
3255 item emerged is always present.
3257 Of course, this technique for managing TODO items scatters them
3258 throughout your notes file.  Org-mode compensates for this by providing
3259 methods to give you an overview of all the things that you have to do.
3261 @menu
3262 * TODO basics::                 Marking and displaying TODO entries
3263 * TODO extensions::             Workflow and assignments
3264 * Progress logging::            Dates and notes for progress
3265 * Priorities::                  Some things are more important than others
3266 * Breaking down tasks::         Splitting a task into manageable pieces
3267 * Checkboxes::                  Tick-off lists
3268 @end menu
3270 @node TODO basics, TODO extensions, TODO Items, TODO Items
3271 @section Basic TODO functionality
3273 Any headline becomes a TODO item when it starts with the word
3274 @samp{TODO}, for example:
3276 @example
3277 *** TODO Write letter to Sam Fortune
3278 @end example
3280 @noindent
3281 The most important commands to work with TODO entries are:
3283 @table @kbd
3284 @kindex C-c C-t
3285 @cindex cycling, of TODO states
3286 @item C-c C-t
3287 Rotate the TODO state of the current item among
3289 @example
3290 ,-> (unmarked) -> TODO -> DONE --.
3291 '--------------------------------'
3292 @end example
3294 The same rotation can also be done ``remotely'' from the timeline and
3295 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
3297 @kindex C-u C-c C-t
3298 @item C-u C-c C-t
3299 Select a specific keyword using completion or (if it has been set up)
3300 the fast selection interface.  For the latter, you need to assign keys
3301 to TODO states, see @ref{Per-file keywords}, and @ref{Setting tags}, for
3302 more information.
3304 @kindex S-@key{right}
3305 @kindex S-@key{left}
3306 @vindex org-treat-S-cursor-todo-selection-as-state-change
3307 @item S-@key{right}
3308 @itemx S-@key{left}
3309 Select the following/preceding TODO state, similar to cycling.  Useful
3310 mostly if more than two TODO states are possible (@pxref{TODO
3311 extensions}).  See also @ref{Conflicts}, for a discussion of the interaction
3312 with @code{shift-selection-mode}.  See also the variable
3313 @code{org-treat-S-cursor-todo-selection-as-state-change}.
3314 @kindex C-c / t
3315 @cindex sparse tree, for TODO
3316 @itemx C-c / t
3317 @vindex org-todo-keywords
3318 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds the
3319 entire buffer, but shows all TODO items (with not-DONE state) and the
3320 headings hierarchy above them.  With a prefix argument (or by using @kbd{C-c
3321 / T}), search for a specific TODO.  You will be prompted for the keyword, and
3322 you can also give a list of keywords like @code{KWD1|KWD2|...} to list
3323 entries that match any one of these keywords.  With numeric prefix argument
3324 N, show the tree for the Nth keyword in the variable
3325 @code{org-todo-keywords}.  With two prefix arguments, find all TODO states,
3326 both un-done and done.
3327 @kindex C-c a t
3328 @item C-c a t
3329 Show the global TODO list.  Collects the TODO items (with not-DONE states)
3330 from all agenda files (@pxref{Agenda Views}) into a single buffer.  The new
3331 buffer will be in @code{agenda-mode}, which provides commands to examine and
3332 manipulate the TODO entries from the new buffer (@pxref{Agenda commands}).
3333 @xref{Global TODO list}, for more information.
3334 @kindex S-M-@key{RET}
3335 @item S-M-@key{RET}
3336 Insert a new TODO entry below the current one.
3337 @end table
3339 @noindent
3340 @vindex org-todo-state-tags-triggers
3341 Changing a TODO state can also trigger tag changes.  See the docstring of the
3342 option @code{org-todo-state-tags-triggers} for details.
3344 @node TODO extensions, Progress logging, TODO basics, TODO Items
3345 @section Extended use of TODO keywords
3346 @cindex extended TODO keywords
3348 @vindex org-todo-keywords
3349 By default, marked TODO entries have one of only two states: TODO and
3350 DONE.  Org-mode allows you to classify TODO items in more complex ways
3351 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With
3352 special setup, the TODO keyword system can work differently in different
3353 files.
3355 Note that @i{tags} are another way to classify headlines in general and
3356 TODO items in particular (@pxref{Tags}).
3358 @menu
3359 * Workflow states::             From TODO to DONE in steps
3360 * TODO types::                  I do this, Fred does the rest
3361 * Multiple sets in one file::   Mixing it all, and still finding your way
3362 * Fast access to TODO states::  Single letter selection of a state
3363 * Per-file keywords::           Different files, different requirements
3364 * Faces for TODO keywords::     Highlighting states
3365 * TODO dependencies::           When one task needs to wait for others
3366 @end menu
3368 @node Workflow states, TODO types, TODO extensions, TODO extensions
3369 @subsection TODO keywords as workflow states
3370 @cindex TODO workflow
3371 @cindex workflow states as TODO keywords
3373 You can use TODO keywords to indicate different @emph{sequential} states
3374 in the process of working on an item, for example@footnote{Changing
3375 this variable only becomes effective after restarting Org-mode in a
3376 buffer.}:
3378 @lisp
3379 (setq org-todo-keywords
3380   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
3381 @end lisp
3383 The vertical bar separates the TODO keywords (states that @emph{need
3384 action}) from the DONE states (which need @emph{no further action}).  If
3385 you don't provide the separator bar, the last state is used as the DONE
3386 state.
3387 @cindex completion, of TODO keywords
3388 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
3389 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED.  You may
3390 also use a numeric prefix argument to quickly select a specific state.  For
3391 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY.
3392 Or you can use @kbd{S-@key{left}} to go backward through the sequence.  If you
3393 define many keywords, you can use in-buffer completion
3394 (@pxref{Completion}) or even a special one-key selection scheme
3395 (@pxref{Fast access to TODO states}) to insert these words into the
3396 buffer.  Changing a TODO state can be logged with a timestamp, see
3397 @ref{Tracking TODO state changes}, for more information.
3399 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
3400 @subsection TODO keywords as types
3401 @cindex TODO types
3402 @cindex names as TODO keywords
3403 @cindex types as TODO keywords
3405 The second possibility is to use TODO keywords to indicate different
3406 @emph{types} of action items.  For example, you might want to indicate
3407 that items are for ``work'' or ``home''.  Or, when you work with several
3408 people on a single project, you might want to assign action items
3409 directly to persons, by using their names as TODO keywords.  This would
3410 be set up like this:
3412 @lisp
3413 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
3414 @end lisp
3416 In this case, different keywords do not indicate a sequence, but rather
3417 different types.  So the normal work flow would be to assign a task to a
3418 person, and later to mark it DONE.  Org-mode supports this style by adapting
3419 the workings of the command @kbd{C-c C-t}@footnote{This is also true for the
3420 @kbd{t} command in the timeline and agenda buffers.}.  When used several
3421 times in succession, it will still cycle through all names, in order to first
3422 select the right type for a task.  But when you return to the item after some
3423 time and execute @kbd{C-c C-t} again, it will switch from any name directly
3424 to DONE.  Use prefix arguments or completion to quickly select a specific
3425 name.  You can also review the items of a specific TODO type in a sparse tree
3426 by using a numeric prefix to @kbd{C-c / t}.  For example, to see all things
3427 Lucy has to do, you would use @kbd{C-3 C-c / t}.  To collect Lucy's items
3428 from all agenda files into a single buffer, you would use the numeric prefix
3429 argument as well when creating the global TODO list: @kbd{C-3 C-c a t}.
3431 @node Multiple sets in one file, Fast access to TODO states, TODO types, TODO extensions
3432 @subsection Multiple keyword sets in one file
3433 @cindex TODO keyword sets
3435 Sometimes you may want to use different sets of TODO keywords in
3436 parallel.  For example, you may want to have the basic
3437 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
3438 separate state indicating that an item has been canceled (so it is not
3439 DONE, but also does not require action).  Your setup would then look
3440 like this:
3442 @lisp
3443 (setq org-todo-keywords
3444       '((sequence "TODO" "|" "DONE")
3445         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
3446         (sequence "|" "CANCELED")))
3447 @end lisp
3449 The keywords should all be different, this helps Org-mode to keep track
3450 of which subsequence should be used for a given entry.  In this setup,
3451 @kbd{C-c C-t} only operates within a subsequence, so it switches from
3452 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
3453 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
3454 select the correct sequence.  Besides the obvious ways like typing a
3455 keyword or using completion, you may also apply the following commands:
3457 @table @kbd
3458 @kindex C-S-@key{right}
3459 @kindex C-S-@key{left}
3460 @kindex C-u C-u C-c C-t
3461 @item C-u C-u C-c C-t
3462 @itemx C-S-@key{right}
3463 @itemx C-S-@key{left}
3464 These keys jump from one TODO subset to the next.  In the above example,
3465 @kbd{C-u C-u C-c C-t} or @kbd{C-S-@key{right}} would jump from @code{TODO} or
3466 @code{DONE} to @code{REPORT}, and any of the words in the second row to
3467 @code{CANCELED}.  Note that the @kbd{C-S-} key binding conflict with
3468 @code{shift-selection-mode} (@pxref{Conflicts}).
3469 @kindex S-@key{right}
3470 @kindex S-@key{left}
3471 @item S-@key{right}
3472 @itemx S-@key{left}
3473 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through @emph{all}
3474 keywords from all sets, so for example @kbd{S-@key{<right>}} would switch
3475 from @code{DONE} to @code{REPORT} in the example above.  See also
3476 @ref{Conflicts}, for a discussion of the interaction with
3477 @code{shift-selection-mode}.
3478 @end table
3480 @node Fast access to TODO states, Per-file keywords, Multiple sets in one file, TODO extensions
3481 @subsection Fast access to TODO states
3483 If you would like to quickly change an entry to an arbitrary TODO state
3484 instead of cycling through the states, you can set up keys for
3485 single-letter access to the states.  This is done by adding the section
3486 key after each keyword, in parentheses.  For example:
3488 @lisp
3489 (setq org-todo-keywords
3490       '((sequence "TODO(t)" "|" "DONE(d)")
3491         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
3492         (sequence "|" "CANCELED(c)")))
3493 @end lisp
3495 @vindex org-fast-tag-selection-include-todo
3496 If you then press @code{C-c C-t} followed by the selection key, the entry
3497 will be switched to this state.  @key{SPC} can be used to remove any TODO
3498 keyword from an entry.@footnote{Check also the variable
3499 @code{org-fast-tag-selection-include-todo}, it allows you to change the TODO
3500 state through the tags interface (@pxref{Setting tags}), in case you like to
3501 mingle the two concepts.  Note that this means you need to come up with
3502 unique keys across both sets of keywords.}
3504 @node Per-file keywords, Faces for TODO keywords, Fast access to TODO states, TODO extensions
3505 @subsection Setting up keywords for individual files
3506 @cindex keyword options
3507 @cindex per-file keywords
3508 @cindex #+TODO
3509 @cindex #+TYP_TODO
3510 @cindex #+SEQ_TODO
3512 It can be very useful to use different aspects of the TODO mechanism in
3513 different files.  For file-local settings, you need to add special lines
3514 to the file which set the keywords and interpretation for that file
3515 only.  For example, to set one of the two examples discussed above, you
3516 need one of the following lines, starting in column zero anywhere in the
3517 file:
3519 @example
3520 #+TODO: TODO FEEDBACK VERIFY | DONE CANCELED
3521 @end example
3522 @noindent (you may also write @code{#+SEQ_TODO} to be explicit about the
3523 interpretation, but it means the same as @code{#+TODO}), or
3524 @example
3525 #+TYP_TODO: Fred Sara Lucy Mike | DONE
3526 @end example
3528 A setup for using several sets in parallel would be:
3530 @example
3531 #+TODO: TODO | DONE
3532 #+TODO: REPORT BUG KNOWNCAUSE | FIXED
3533 #+TODO: | CANCELED
3534 @end example
3536 @cindex completion, of option keywords
3537 @kindex M-@key{TAB}
3538 @noindent To make sure you are using the correct keyword, type
3539 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
3541 @cindex DONE, final TODO keyword
3542 Remember that the keywords after the vertical bar (or the last keyword
3543 if no bar is there) must always mean that the item is DONE (although you
3544 may use a different word).  After changing one of these lines, use
3545 @kbd{C-c C-c} with the cursor still in the line to make the changes
3546 known to Org-mode@footnote{Org-mode parses these lines only when
3547 Org-mode is activated after visiting a file.  @kbd{C-c C-c} with the
3548 cursor in a line starting with @samp{#+} is simply restarting Org-mode
3549 for the current buffer.}.
3551 @node Faces for TODO keywords, TODO dependencies, Per-file keywords, TODO extensions
3552 @subsection Faces for TODO keywords
3553 @cindex faces, for TODO keywords
3555 @vindex org-todo @r{(face)}
3556 @vindex org-done @r{(face)}
3557 @vindex org-todo-keyword-faces
3558 Org-mode highlights TODO keywords with special faces: @code{org-todo}
3559 for keywords indicating that an item still has to be acted upon, and
3560 @code{org-done} for keywords indicating that an item is finished.  If
3561 you are using more than 2 different states, you might want to use
3562 special faces for some of them.  This can be done using the variable
3563 @code{org-todo-keyword-faces}.  For example:
3565 @lisp
3566 @group
3567 (setq org-todo-keyword-faces
3568       '(("TODO" . org-warning) ("STARTED" . "yellow")
3569         ("CANCELED" . (:foreground "blue" :weight bold))))
3570 @end group
3571 @end lisp
3573 While using a list with face properties as shown for CANCELED @emph{should}
3574 work, this does not aways seem to be the case.  If necessary, define a
3575 special face and use that.  A string is interpreted as a color.  The variable
3576 @code{org-faces-easy-properties} determines if that color is interpreted as a
3577 foreground or a background color.
3579 @node TODO dependencies,  , Faces for TODO keywords, TODO extensions
3580 @subsection TODO dependencies
3581 @cindex TODO dependencies
3582 @cindex dependencies, of TODO states
3584 @vindex org-enforce-todo-dependencies
3585 @cindex property, ORDERED
3586 The structure of Org files (hierarchy and lists) makes it easy to define TODO
3587 dependencies.  Usually, a parent TODO task should not be marked DONE until
3588 all subtasks (defined as children tasks) are marked as DONE.  And sometimes
3589 there is a logical sequence to a number of (sub)tasks, so that one task
3590 cannot be acted upon before all siblings above it are done.  If you customize
3591 the variable @code{org-enforce-todo-dependencies}, Org will block entries
3592 from changing state to DONE while they have children that are not DONE.
3593 Furthermore, if an entry has a property @code{ORDERED}, each of its children
3594 will be blocked until all earlier siblings are marked DONE.  Here is an
3595 example:
3597 @example
3598 * TODO Blocked until (two) is done
3599 ** DONE one
3600 ** TODO two
3602 * Parent
3603   :PROPERTIES:
3604     :ORDERED: t
3605   :END:
3606 ** TODO a
3607 ** TODO b, needs to wait for (a)
3608 ** TODO c, needs to wait for (a) and (b)
3609 @end example
3611 @table @kbd
3612 @kindex C-c C-x o
3613 @item C-c C-x o
3614 @vindex org-track-ordered-property-with-tag
3615 @cindex property, ORDERED
3616 Toggle the @code{ORDERED} property of the current entry.  A property is used
3617 for this behavior because this should be local to the current entry, not
3618 inherited like a tag.  However, if you would like to @i{track} the value of
3619 this property with a tag for better visibility, customize the variable
3620 @code{org-track-ordered-property-with-tag}.
3621 @kindex C-u C-u C-u C-c C-t
3622 @item C-u C-u C-u C-c C-t
3623 Change TODO state, circumventing any state blocking.
3624 @end table
3626 @vindex org-agenda-dim-blocked-tasks
3627 If you set the variable @code{org-agenda-dim-blocked-tasks}, TODO entries
3628 that cannot be closed because of such dependencies will be shown in a dimmed
3629 font or even made invisible in agenda views (@pxref{Agenda Views}).
3631 @cindex checkboxes and TODO dependencies
3632 @vindex org-enforce-todo-dependencies
3633 You can also block changes of TODO states by looking at checkboxes
3634 (@pxref{Checkboxes}).  If you set the variable
3635 @code{org-enforce-todo-checkbox-dependencies}, an entry that has unchecked
3636 checkboxes will be blocked from switching to DONE.
3638 If you need more complex dependency structures, for example dependencies
3639 between entries in different trees or files, check out the contributed
3640 module @file{org-depend.el}.
3642 @page
3643 @node Progress logging, Priorities, TODO extensions, TODO Items
3644 @section Progress logging
3645 @cindex progress logging
3646 @cindex logging, of progress
3648 Org-mode can automatically record a timestamp and possibly a note when
3649 you mark a TODO item as DONE, or even each time you change the state of
3650 a TODO item.  This system is highly configurable, settings can be on a
3651 per-keyword basis and can be localized to a file or even a subtree.  For
3652 information on how to clock working time for a task, see @ref{Clocking
3653 work time}.
3655 @menu
3656 * Closing items::               When was this entry marked DONE?
3657 * Tracking TODO state changes::  When did the status change?
3658 * Tracking your habits::        How consistent have you been?
3659 @end menu
3661 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
3662 @subsection Closing items
3664 The most basic logging is to keep track of @emph{when} a certain TODO
3665 item was finished.  This is achieved with@footnote{The corresponding
3666 in-buffer setting is: @code{#+STARTUP: logdone}}.
3668 @lisp
3669 (setq org-log-done 'time)
3670 @end lisp
3672 @noindent
3673 Then each time you turn an entry from a TODO (not-done) state into any
3674 of the DONE states, a line @samp{CLOSED: [timestamp]} will be inserted
3675 just after the headline.  If you turn the entry back into a TODO item
3676 through further state cycling, that line will be removed again.  If you
3677 want to record a note along with the timestamp, use@footnote{The
3678 corresponding in-buffer setting is: @code{#+STARTUP: lognotedone}}
3680 @lisp
3681 (setq org-log-done 'note)
3682 @end lisp
3684 @noindent
3685 You will then be prompted for a note, and that note will be stored below
3686 the entry with a @samp{Closing Note} heading.
3688 In the timeline (@pxref{Timeline}) and in the agenda
3689 (@pxref{Weekly/daily agenda}), you can then use the @kbd{l} key to
3690 display the TODO items with a @samp{CLOSED} timestamp on each day,
3691 giving you an overview of what has been done.
3693 @node Tracking TODO state changes, Tracking your habits, Closing items, Progress logging
3694 @subsection Tracking TODO state changes
3695 @cindex drawer, for state change recording
3697 @vindex org-log-states-order-reversed
3698 @vindex org-log-into-drawer
3699 @cindex property, LOG_INTO_DRAWER
3700 When TODO keywords are used as workflow states (@pxref{Workflow states}), you
3701 might want to keep track of when a state change occurred and maybe take a
3702 note about this change.  You can either record just a timestamp, or a
3703 time-stamped note for a change.  These records will be inserted after the
3704 headline as an itemized list, newest first@footnote{See the variable
3705 @code{org-log-states-order-reversed}}.  When taking a lot of notes, you might
3706 want to get the notes out of the way into a drawer (@pxref{Drawers}).
3707 Customize the variable @code{org-log-into-drawer} to get this
3708 behavior---the recommended drawer for this is called @code{LOGBOOK}.  You can
3709 also overrule the setting of this variable for a subtree by setting a
3710 @code{LOG_INTO_DRAWER} property.
3712 Since it is normally too much to record a note for every state, Org-mode
3713 expects configuration on a per-keyword basis for this.  This is achieved by
3714 adding special markers @samp{!} (for a timestamp) and @samp{@@} (for a note)
3715 in parentheses after each keyword.  For example, with the setting
3717 @lisp
3718 (setq org-todo-keywords
3719   '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
3720 @end lisp
3722 @noindent
3723 @vindex org-log-done
3724 you not only define global TODO keywords and fast access keys, but also
3725 request that a time is recorded when the entry is set to
3726 DONE@footnote{It is possible that Org-mode will record two timestamps
3727 when you are using both @code{org-log-done} and state change logging.
3728 However, it will never prompt for two notes---if you have configured
3729 both, the state change recording note will take precedence and cancel
3730 the @samp{Closing Note}.}, and that a note is recorded when switching to
3731 WAIT or CANCELED.  The setting for WAIT is even more special: the
3732 @samp{!} after the slash means that in addition to the note taken when
3733 entering the state, a timestamp should be recorded when @i{leaving} the
3734 WAIT state, if and only if the @i{target} state does not configure
3735 logging for entering it.  So it has no effect when switching from WAIT
3736 to DONE, because DONE is configured to record a timestamp only.  But
3737 when switching from WAIT back to TODO, the @samp{/!} in the WAIT
3738 setting now triggers a timestamp even though TODO has no logging
3739 configured.
3741 You can use the exact same syntax for setting logging preferences local
3742 to a buffer:
3743 @example
3744 #+TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
3745 @end example
3747 @cindex property, LOGGING
3748 In order to define logging settings that are local to a subtree or a
3749 single item, define a LOGGING property in this entry.  Any non-empty
3750 LOGGING property resets all logging settings to nil.  You may then turn
3751 on logging for this specific tree using STARTUP keywords like
3752 @code{lognotedone} or @code{logrepeat}, as well as adding state specific
3753 settings like @code{TODO(!)}.  For example
3755 @example
3756 * TODO Log each state with only a time
3757   :PROPERTIES:
3758   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
3759   :END:
3760 * TODO Only log when switching to WAIT, and when repeating
3761   :PROPERTIES:
3762   :LOGGING: WAIT(@@) logrepeat
3763   :END:
3764 * TODO No logging at all
3765   :PROPERTIES:
3766   :LOGGING: nil
3767   :END:
3768 @end example
3770 @node Tracking your habits,  , Tracking TODO state changes, Progress logging
3771 @subsection Tracking your habits
3772 @cindex habits
3774 Org has the ability to track the consistency of a special category of TODOs,
3775 called ``habits''.  A habit has the following properties:
3777 @enumerate
3778 @item
3779 You have enabled the @code{habits} module by customizing the variable
3780 @code{org-modules}.
3781 @item
3782 The habit is a TODO, with a TODO keyword representing an open state.
3783 @item
3784 The property @code{STYLE} is set to the value @code{habit}.
3785 @item
3786 The TODO has a scheduled date, with a @code{.+} style repeat interval.
3787 @item
3788 The TODO may also have minimum and maximum ranges specified by using the
3789 syntax @samp{.+2d/3d}, which says that you want to do the task at least every
3790 three days, but at most every two days.
3791 @item
3792 You must also have state logging for the @code{DONE} state enabled, in order
3793 for historical data to be represented in the consistency graph.  If it's not
3794 enabled it's not an error, but the consistency graphs will be largely
3795 meaningless.
3796 @end enumerate
3798 To give you an idea of what the above rules look like in action, here's an
3799 actual habit with some history:
3801 @example
3802 ** TODO Shave
3803    SCHEDULED: <2009-10-17 Sat .+2d/4d>
3804    - State "DONE"       from "TODO"       [2009-10-15 Thu]
3805    - State "DONE"       from "TODO"       [2009-10-12 Mon]
3806    - State "DONE"       from "TODO"       [2009-10-10 Sat]
3807    - State "DONE"       from "TODO"       [2009-10-04 Sun]
3808    - State "DONE"       from "TODO"       [2009-10-02 Fri]
3809    - State "DONE"       from "TODO"       [2009-09-29 Tue]
3810    - State "DONE"       from "TODO"       [2009-09-25 Fri]
3811    - State "DONE"       from "TODO"       [2009-09-19 Sat]
3812    - State "DONE"       from "TODO"       [2009-09-16 Wed]
3813    - State "DONE"       from "TODO"       [2009-09-12 Sat]
3814    :PROPERTIES:
3815    :STYLE:    habit
3816    :LAST_REPEAT: [2009-10-19 Mon 00:36]
3817    :END:
3818 @end example
3820 What this habit says is: I want to shave at most every 2 days (given by the
3821 @code{SCHEDULED} date and repeat interval) and at least every 4 days.  If
3822 today is the 15th, then the habit first appears in the agenda on Oct 17,
3823 after the minimum of 2 days has elapsed, and will appear overdue on Oct 19,
3824 after four days have elapsed.
3826 What's really useful about habits is that they are displayed along with a
3827 consistency graph, to show how consistent you've been at getting that task
3828 done in the past.  This graph shows every day that the task was done over the
3829 past three weeks, with colors for each day.  The colors used are:
3831 @table @code
3832 @item Blue
3833 If the task wasn't to be done yet on that day.
3834 @item Green
3835 If the task could have been done on that day.
3836 @item Yellow
3837 If the task was going to be overdue the next day.
3838 @item Red
3839 If the task was overdue on that day.
3840 @end table
3842 In addition to coloring each day, the day is also marked with an asterisk if
3843 the task was actually done that day, and an exclamation mark to show where
3844 the current day falls in the graph.
3846 There are several configuration variables that can be used to change the way
3847 habits are displayed in the agenda.
3849 @table @code
3850 @item org-habit-graph-column
3851 The buffer column at which the consistency graph should be drawn.  This will
3852 overwrite any text in that column, so it's a good idea to keep your habits'
3853 titles brief and to the point.
3854 @item org-habit-preceding-days
3855 The amount of history, in days before today, to appear in consistency graphs.
3856 @item org-habit-following-days
3857 The number of days after today that will appear in consistency graphs.
3858 @item org-habit-show-habits-only-for-today
3859 If non-nil, only show habits in today's agenda view.  This is set to true by
3860 default.
3861 @end table
3863 Lastly, pressing @kbd{K} in the agenda buffer will cause habits to
3864 temporarily be disabled and they won't appear at all.  Press @kbd{K} again to
3865 bring them back.  They are also subject to tag filtering, if you have habits
3866 which should only be done in certain contexts, for example.
3868 @node Priorities, Breaking down tasks, Progress logging, TODO Items
3869 @section Priorities
3870 @cindex priorities
3872 If you use Org-mode extensively, you may end up with enough TODO items that
3873 it starts to make sense to prioritize them.  Prioritizing can be done by
3874 placing a @emph{priority cookie} into the headline of a TODO item, like this
3876 @example
3877 *** TODO [#A] Write letter to Sam Fortune
3878 @end example
3880 @noindent
3881 @vindex org-priority-faces
3882 By default, Org-mode supports three priorities: @samp{A}, @samp{B}, and
3883 @samp{C}.  @samp{A} is the highest priority.  An entry without a cookie is
3884 treated as priority @samp{B}.  Priorities make a difference only in the
3885 agenda (@pxref{Weekly/daily agenda}); outside the agenda, they have no
3886 inherent meaning to Org-mode.  The cookies can be highlighted with special
3887 faces by customizing the variable @code{org-priority-faces}.
3889 Priorities can be attached to any outline tree entries; they do not need
3890 to be TODO items.
3892 @table @kbd
3893 @kindex @kbd{C-c ,}
3894 @item @kbd{C-c ,}
3895 Set the priority of the current headline.  The command prompts for a
3896 priority character @samp{A}, @samp{B} or @samp{C}.  When you press
3897 @key{SPC} instead, the priority cookie is removed from the headline.
3898 The priorities can also be changed ``remotely'' from the timeline and
3899 agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
3901 @kindex S-@key{up}
3902 @kindex S-@key{down}
3903 @item S-@key{up}
3904 @itemx S-@key{down}
3905 @vindex org-priority-start-cycle-with-default
3906 Increase/decrease priority of current headline@footnote{See also the option
3907 @code{org-priority-start-cycle-with-default}.}.  Note that these keys are
3908 also used to modify timestamps (@pxref{Creating timestamps}).  See also
3909 @ref{Conflicts}, for a discussion of the interaction with
3910 @code{shift-selection-mode}.
3911 @end table
3913 @vindex org-highest-priority
3914 @vindex org-lowest-priority
3915 @vindex org-default-priority
3916 You can change the range of allowed priorities by setting the variables
3917 @code{org-highest-priority}, @code{org-lowest-priority}, and
3918 @code{org-default-priority}.  For an individual buffer, you may set
3919 these values (highest, lowest, default) like this (please make sure that
3920 the highest priority is earlier in the alphabet than the lowest
3921 priority):
3923 @cindex #+PRIORITIES
3924 @example
3925 #+PRIORITIES: A C B
3926 @end example
3928 @node Breaking down tasks, Checkboxes, Priorities, TODO Items
3929 @section Breaking tasks down into subtasks
3930 @cindex tasks, breaking down
3931 @cindex statistics, for TODO items
3933 @vindex org-agenda-todo-list-sublevels
3934 It is often advisable to break down large tasks into smaller, manageable
3935 subtasks.  You can do this by creating an outline tree below a TODO item,
3936 with detailed subtasks on the tree@footnote{To keep subtasks out of the
3937 global TODO list, see the @code{org-agenda-todo-list-sublevels}.}.  To keep
3938 the overview over the fraction of subtasks that are already completed, insert
3939 either @samp{[/]} or @samp{[%]} anywhere in the headline.  These cookies will
3940 be updated each time the TODO status of a child changes, or when pressing
3941 @kbd{C-c C-c} on the cookie.  For example:
3943 @example
3944 * Organize Party [33%]
3945 ** TODO Call people [1/2]
3946 *** TODO Peter
3947 *** DONE Sarah
3948 ** TODO Buy food
3949 ** DONE Talk to neighbor
3950 @end example
3952 @cindex property, COOKIE_DATA
3953 If a heading has both checkboxes and TODO children below it, the meaning of
3954 the statistics cookie become ambiguous.  Set the property
3955 @code{COOKIE_DATA} to either @samp{checkbox} or @samp{todo} to resolve
3956 this issue.
3958 @vindex org-hierarchical-todo-statistics
3959 If you would like to have the statistics cookie count any TODO entries in the
3960 subtree (not just direct children), configure the variable
3961 @code{org-hierarchical-todo-statistics}.  To do this for a single subtree,
3962 include the word @samp{recursive} into the value of the @code{COOKIE_DATA}
3963 property.
3965 @example
3966 * Parent capturing statistics [2/20]
3967   :PROPERTIES:
3968   :COOKIE_DATA: todo recursive
3969   :END:
3970 @end example
3972 If you would like a TODO entry to automatically change to DONE
3973 when all children are done, you can use the following setup:
3975 @example
3976 (defun org-summary-todo (n-done n-not-done)
3977   "Switch entry to DONE when all subentries are done, to TODO otherwise."
3978   (let (org-log-done org-log-states)   ; turn off logging
3979     (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
3981 (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
3982 @end example
3985 Another possibility is the use of checkboxes to identify (a hierarchy of) a
3986 large number of subtasks (@pxref{Checkboxes}).
3989 @node Checkboxes,  , Breaking down tasks, TODO Items
3990 @section Checkboxes
3991 @cindex checkboxes
3993 Every item in a plain list (@pxref{Plain lists}) can be made into a
3994 checkbox by starting it with the string @samp{[ ]}.  This feature is
3995 similar to TODO items (@pxref{TODO Items}), but is more lightweight.
3996 Checkboxes are not included into the global TODO list, so they are often
3997 great to split a task into a number of simple steps.  Or you can use
3998 them in a shopping list.  To toggle a checkbox, use @kbd{C-c C-c}, or
3999 use the mouse (thanks to Piotr Zielinski's @file{org-mouse.el}).
4001 Here is an example of a checkbox list.
4003 @example
4004 * TODO Organize party [2/4]
4005   - [-] call people [1/3]
4006     - [ ] Peter
4007     - [X] Sarah
4008     - [ ] Sam
4009   - [X] order food
4010   - [ ] think about what music to play
4011   - [X] talk to the neighbors
4012 @end example
4014 Checkboxes work hierarchically, so if a checkbox item has children that
4015 are checkboxes, toggling one of the children checkboxes will make the
4016 parent checkbox reflect if none, some, or all of the children are
4017 checked.
4019 @cindex statistics, for checkboxes
4020 @cindex checkbox statistics
4021 @cindex property, COOKIE_DATA
4022 @vindex org-hierarchical-checkbox-statistics
4023 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are cookies
4024 indicating how many checkboxes present in this entry have been checked off,
4025 and the total number of checkboxes present.  This can give you an idea on how
4026 many checkboxes remain, even without opening a folded entry.  The cookies can
4027 be placed into a headline or into (the first line of) a plain list item.
4028 Each cookie covers checkboxes of direct children structurally below the
4029 headline/item on which the cookie appears@footnote{Set the variable
4030 @code{org-hierarchical-checkbox-statistics} if you want such cookies to
4031 represent the all checkboxes below the cookie, not just the direct
4032 children.}.  You have to insert the cookie yourself by typing either
4033 @samp{[/]} or @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m}
4034 result, as in the examples above.  With @samp{[%]} you get information about
4035 the percentage of checkboxes checked (in the above example, this would be
4036 @samp{[50%]} and @samp{[33%]}, respectively).  In a headline, a cookie can
4037 count either checkboxes below the heading or TODO states of children, and it
4038 will display whatever was changed last.  Set the property @code{COOKIE_DATA}
4039 to either @samp{checkbox} or @samp{todo} to resolve this issue.
4041 @cindex blocking, of checkboxes
4042 @cindex checkbox blocking
4043 @cindex property, ORDERED
4044 If the current outline node has an @code{ORDERED} property, checkboxes must
4045 be checked off in sequence, and an error will be thrown if you try to check
4046 off a box while there are unchecked boxes above it.
4048 @noindent The following commands work with checkboxes:
4050 @table @kbd
4051 @kindex C-c C-c
4052 @item C-c C-c
4053 Toggle checkbox status or (with prefix arg) checkbox presence at point.  With
4054 double prefix argument, set it to @samp{[-]}, which is considered to be an
4055 intermediate state.
4056 @kindex C-c C-x C-b
4057 @item C-c C-x C-b
4058 Toggle checkbox status or (with prefix arg) checkbox presence at point.  With
4059 double prefix argument, set it to @samp{[-]}, which is considered to be an
4060 intermediate state.
4061 @itemize @minus
4062 @item
4063 If there is an active region, toggle the first checkbox in the region
4064 and set all remaining boxes to the same status as the first.  With a prefix
4065 arg, add or remove the checkbox for all items in the region.
4066 @item
4067 If the cursor is in a headline, toggle checkboxes in the region between
4068 this headline and the next (so @emph{not} the entire subtree).
4069 @item
4070 If there is no active region, just toggle the checkbox at point.
4071 @end itemize
4072 @kindex M-S-@key{RET}
4073 @item M-S-@key{RET}
4074 Insert a new item with a checkbox.
4075 This works only if the cursor is already in a plain list item
4076 (@pxref{Plain lists}).
4077 @kindex C-c C-x o
4078 @item C-c C-x o
4079 @vindex org-track-ordered-property-with-tag
4080 @cindex property, ORDERED
4081 Toggle the @code{ORDERED} property of the entry, to toggle if checkboxes must
4082 be checked off in sequence.  A property is used for this behavior because
4083 this should be local to the current entry, not inherited like a tag.
4084 However, if you would like to @i{track} the value of this property with a tag
4085 for better visibility, customize the variable
4086 @code{org-track-ordered-property-with-tag}.
4087 @kindex C-c #
4088 @item C-c #
4089 Update the statistics cookie in the current outline entry.  When called with
4090 a @kbd{C-u} prefix, update the entire file.  Checkbox statistic cookies are
4091 updated automatically if you toggle checkboxes with @kbd{C-c C-c} and make
4092 new ones with @kbd{M-S-@key{RET}}.  TODO statistics cookies update when
4093 changing TODO states.  If you delete boxes/entries or add/change them by
4094 hand, use this command to get things back into sync.  Or simply toggle any
4095 entry twice (checkboxes with @kbd{C-c C-c}).
4096 @end table
4098 @node Tags, Properties and Columns, TODO Items, Top
4099 @chapter Tags
4100 @cindex tags
4101 @cindex headline tagging
4102 @cindex matching, tags
4103 @cindex sparse tree, tag based
4105 An excellent way to implement labels and contexts for cross-correlating
4106 information is to assign @i{tags} to headlines.  Org-mode has extensive
4107 support for tags.
4109 @vindex org-tag-faces
4110 Every headline can contain a list of tags; they occur at the end of the
4111 headline.  Tags are normal words containing letters, numbers, @samp{_}, and
4112 @samp{@@}.  Tags must be preceded and followed by a single colon, e.g.,
4113 @samp{:work:}.  Several tags can be specified, as in @samp{:work:urgent:}.
4114 Tags will by default be in bold face with the same color as the headline.
4115 You may specify special faces for specific tags using the variable
4116 @code{org-tag-faces}, in much the same way as you can for TODO keywords
4117 (@pxref{Faces for TODO keywords}).
4119 @menu
4120 * Tag inheritance::             Tags use the tree structure of the outline
4121 * Setting tags::                How to assign tags to a headline
4122 * Tag searches::                Searching for combinations of tags
4123 @end menu
4125 @node Tag inheritance, Setting tags, Tags, Tags
4126 @section Tag inheritance
4127 @cindex tag inheritance
4128 @cindex inheritance, of tags
4129 @cindex sublevels, inclusion into tags match
4131 @i{Tags} make use of the hierarchical structure of outline trees.  If a
4132 heading has a certain tag, all subheadings will inherit the tag as
4133 well.  For example, in the list
4135 @example
4136 * Meeting with the French group      :work:
4137 ** Summary by Frank                  :boss:notes:
4138 *** TODO Prepare slides for him      :action:
4139 @end example
4141 @noindent
4142 the final heading will have the tags @samp{:work:}, @samp{:boss:},
4143 @samp{:notes:}, and @samp{:action:} even though the final heading is not
4144 explicitly marked with those tags.  You can also set tags that all entries in
4145 a file should inherit just as if these tags were defined in a hypothetical
4146 level zero that surrounds the entire file.  Use a line like this@footnote{As
4147 with all these in-buffer settings, pressing @kbd{C-c C-c} activates any
4148 changes in the line.}:
4150 @cindex #+FILETAGS
4151 @example
4152 #+FILETAGS: :Peter:Boss:Secret:
4153 @end example
4155 @noindent
4156 @vindex org-use-tag-inheritance
4157 @vindex org-tags-exclude-from-inheritance
4158 To limit tag inheritance to specific tags, or to turn it off entirely, use
4159 the variables @code{org-use-tag-inheritance} and
4160 @code{org-tags-exclude-from-inheritance}.
4162 @vindex org-tags-match-list-sublevels
4163 When a headline matches during a tags search while tag inheritance is turned
4164 on, all the sublevels in the same tree will (for a simple match form) match
4165 as well@footnote{This is only true if the search does not involve more
4166 complex tests including properties (@pxref{Property searches}).}.  The list
4167 of matches may then become very long.  If you only want to see the first tags
4168 match in a subtree, configure the variable
4169 @code{org-tags-match-list-sublevels} (not recommended).
4171 @node Setting tags, Tag searches, Tag inheritance, Tags
4172 @section Setting tags
4173 @cindex setting tags
4174 @cindex tags, setting
4176 @kindex M-@key{TAB}
4177 Tags can simply be typed into the buffer at the end of a headline.
4178 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
4179 also a special command for inserting tags:
4181 @table @kbd
4182 @kindex C-c C-q
4183 @item C-c C-q
4184 @cindex completion, of tags
4185 @vindex org-tags-column
4186 Enter new tags for the current headline.  Org-mode will either offer
4187 completion or a special single-key interface for setting tags, see
4188 below.  After pressing @key{RET}, the tags will be inserted and aligned
4189 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
4190 tags in the current buffer will be aligned to that column, just to make
4191 things look nice.  TAGS are automatically realigned after promotion,
4192 demotion, and TODO state changes (@pxref{TODO basics}).
4193 @kindex C-c C-c
4194 @item C-c C-c
4195 When the cursor is in a headline, this does the same as @kbd{C-c C-q}.
4196 @end table
4198 @vindex org-tag-alist
4199 Org will support tag insertion based on a @emph{list of tags}.  By
4200 default this list is constructed dynamically, containing all tags
4201 currently used in the buffer.  You may also globally specify a hard list
4202 of tags with the variable @code{org-tag-alist}.  Finally you can set
4203 the default tags for a given file with lines like
4205 @cindex #+TAGS
4206 @example
4207 #+TAGS: @@work @@home @@tennisclub
4208 #+TAGS: laptop car pc sailboat
4209 @end example
4211 If you have globally defined your preferred set of tags using the
4212 variable @code{org-tag-alist}, but would like to use a dynamic tag list
4213 in a specific file, add an empty TAGS option line to that file:
4215 @example
4216 #+TAGS:
4217 @end example
4219 @vindex org-tag-persistent-alist
4220 If you have a preferred set of tags that you would like to use in every file,
4221 in addition to those defined on a per-file basis by TAGS option lines, then
4222 you may specify a list of tags with the variable
4223 @code{org-tag-persistent-alist}.  You may turn this off on a per-file basis
4224 by adding a STARTUP option line to that file:
4226 @example
4227 #+STARTUP: noptag
4228 @end example
4230 By default Org-mode uses the standard minibuffer completion facilities for
4231 entering tags.  However, it also implements another, quicker, tag selection
4232 method called @emph{fast tag selection}.  This allows you to select and
4233 deselect tags with just a single key press.  For this to work well you should
4234 assign unique letters to most of your commonly used tags.  You can do this
4235 globally by configuring the variable @code{org-tag-alist} in your
4236 @file{.emacs} file.  For example, you may find the need to tag many items in
4237 different files with @samp{:@@home:}.  In this case you can set something
4238 like:
4240 @lisp
4241 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
4242 @end lisp
4244 @noindent If the tag is only relevant to the file you are working on, then you
4245 can instead set the TAGS option line as:
4247 @example
4248 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
4249 @end example
4251 @noindent The tags interface will show the available tags in a splash
4252 window.  If you want to start a new line after a specific tag, insert
4253 @samp{\n} into the tag list
4255 @example
4256 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t) \n laptop(l)  pc(p)
4257 @end example
4259 @noindent or write them in two lines:
4261 @example
4262 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)
4263 #+TAGS: laptop(l)  pc(p)
4264 @end example
4266 @noindent
4267 You can also group together tags that are mutually exclusive by using
4268 braces, as in:
4270 @example
4271 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
4272 @end example
4274 @noindent you indicate that at most one of @samp{@@work}, @samp{@@home},
4275 and @samp{@@tennisclub} should be selected.  Multiple such groups are allowed.
4277 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
4278 these lines to activate any changes.
4280 @noindent
4281 To set these mutually exclusive groups in the variable @code{org-tags-alist},
4282 you must use the dummy tags @code{:startgroup} and @code{:endgroup} instead
4283 of the braces.  Similarly, you can use @code{:newline} to indicate a line
4284 break.  The previous example would be set globally by the following
4285 configuration:
4287 @lisp
4288 (setq org-tag-alist '((:startgroup . nil)
4289                       ("@@work" . ?w) ("@@home" . ?h)
4290                       ("@@tennisclub" . ?t)
4291                       (:endgroup . nil)
4292                       ("laptop" . ?l) ("pc" . ?p)))
4293 @end lisp
4295 If at least one tag has a selection key then pressing @kbd{C-c C-c} will
4296 automatically present you with a special interface, listing inherited tags,
4297 the tags of the current headline, and a list of all valid tags with
4298 corresponding keys@footnote{Keys will automatically be assigned to tags which
4299 have no configured keys.}.  In this interface, you can use the following
4300 keys:
4302 @table @kbd
4303 @item a-z...
4304 Pressing keys assigned to tags will add or remove them from the list of
4305 tags in the current line.  Selecting a tag in a group of mutually
4306 exclusive tags will turn off any other tags from that group.
4307 @kindex @key{TAB}
4308 @item @key{TAB}
4309 Enter a tag in the minibuffer, even if the tag is not in the predefined
4310 list.  You will be able to complete on all tags present in the buffer.
4311 @kindex @key{SPC}
4312 @item @key{SPC}
4313 Clear all tags for this line.
4314 @kindex @key{RET}
4315 @item @key{RET}
4316 Accept the modified set.
4317 @item C-g
4318 Abort without installing changes.
4319 @item q
4320 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
4321 @item !
4322 Turn off groups of mutually exclusive tags.  Use this to (as an
4323 exception) assign several tags from such a group.
4324 @item C-c
4325 Toggle auto-exit after the next change (see below).
4326 If you are using expert mode, the first @kbd{C-c} will display the
4327 selection window.
4328 @end table
4330 @noindent
4331 This method lets you assign tags to a headline with very few keys.  With
4332 the above setup, you could clear the current tags and set @samp{@@home},
4333 @samp{laptop} and @samp{pc} tags with just the following keys: @kbd{C-c
4334 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to
4335 @samp{@@work} would be done with @kbd{C-c C-c w @key{RET}} or
4336 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
4337 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
4338 @key{RET} @key{RET}}.
4340 @vindex org-fast-tag-selection-single-key
4341 If you find that most of the time you need only a single key press to
4342 modify your list of tags, set the variable
4343 @code{org-fast-tag-selection-single-key}.  Then you no longer have to
4344 press @key{RET} to exit fast tag selection---it will immediately exit
4345 after the first change.  If you then occasionally need more keys, press
4346 @kbd{C-c} to turn off auto-exit for the current tag selection process
4347 (in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
4348 C-c}).  If you set the variable to the value @code{expert}, the special
4349 window is not even shown for single-key tag selection, it comes up only
4350 when you press an extra @kbd{C-c}.
4352 @node Tag searches,  , Setting tags, Tags
4353 @section Tag searches
4354 @cindex tag searches
4355 @cindex searching for tags
4357 Once a system of tags has been set up, it can be used to collect related
4358 information into special lists.
4360 @table @kbd
4361 @kindex C-c \
4362 @kindex C-c / m
4363 @item C-c \
4364 @itemx C-c / m
4365 Create a sparse tree with all headlines matching a tags search.  With a
4366 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
4367 @kindex C-c a m
4368 @item C-c a m
4369 Create a global list of tag matches from all agenda files.
4370 @xref{Matching tags and properties}.
4371 @kindex C-c a M
4372 @item C-c a M
4373 @vindex org-tags-match-list-sublevels
4374 Create a global list of tag matches from all agenda files, but check
4375 only TODO items and force checking subitems (see variable
4376 @code{org-tags-match-list-sublevels}).
4377 @end table
4379 These commands all prompt for a match string which allows basic Boolean logic
4380 like @samp{+boss+urgent-project1}, to find entries with tags @samp{boss} and
4381 @samp{urgent}, but not @samp{project1}, or @samp{Kathy|Sally} to find entries
4382 which are tagged, like @samp{Kathy} or @samp{Sally}.  The full syntax of the search
4383 string is rich and allows also matching against TODO keywords, entry levels
4384 and properties.  For a complete description with many examples, see
4385 @ref{Matching tags and properties}.
4388 @node Properties and Columns, Dates and Times, Tags, Top
4389 @chapter Properties and columns
4390 @cindex properties
4392 Properties are a set of key-value pairs associated with an entry.  There
4393 are two main applications for properties in Org-mode.  First, properties
4394 are like tags, but with a value.  Second, you can use properties to
4395 implement (very basic) database capabilities in an Org buffer.  For
4396 an example of the first application, imagine maintaining a file where
4397 you document bugs and plan releases for a piece of software.  Instead of
4398 using tags like @code{:release_1:}, @code{:release_2:}, one can use a
4399 property, say @code{:Release:}, that in different subtrees has different
4400 values, such as @code{1.0} or @code{2.0}.  For an example of the second
4401 application of properties, imagine keeping track of your music CDs,
4402 where properties could be things such as the album, artist, date of
4403 release, number of tracks, and so on.
4405 Properties can be conveniently edited and viewed in column view
4406 (@pxref{Column view}).
4408 @menu
4409 * Property syntax::             How properties are spelled out
4410 * Special properties::          Access to other Org-mode features
4411 * Property searches::           Matching property values
4412 * Property inheritance::        Passing values down the tree
4413 * Column view::                 Tabular viewing and editing
4414 * Property API::                Properties for Lisp programmers
4415 @end menu
4417 @node Property syntax, Special properties, Properties and Columns, Properties and Columns
4418 @section Property syntax
4419 @cindex property syntax
4420 @cindex drawer, for properties
4422 Properties are key-value pairs.  They need to be inserted into a special
4423 drawer (@pxref{Drawers}) with the name @code{PROPERTIES}.  Each property
4424 is specified on a single line, with the key (surrounded by colons)
4425 first, and the value after it.  Here is an example:
4427 @example
4428 * CD collection
4429 ** Classic
4430 *** Goldberg Variations
4431     :PROPERTIES:
4432     :Title:     Goldberg Variations
4433     :Composer:  J.S. Bach
4434     :Artist:    Glen Gould
4435     :Publisher: Deutsche Grammophon
4436     :NDisks:    1
4437     :END:
4438 @end example
4440 You may define the allowed values for a particular property @samp{:Xyz:}
4441 by setting a property @samp{:Xyz_ALL:}.  This special property is
4442 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
4443 the entire tree.  When allowed values are defined, setting the
4444 corresponding property becomes easier and is less prone to typing
4445 errors.  For the example with the CD collection, we can predefine
4446 publishers and the number of disks in a box like this:
4448 @example
4449 * CD collection
4450   :PROPERTIES:
4451   :NDisks_ALL:  1 2 3 4
4452   :Publisher_ALL: "Deutsche Grammophon" Philips EMI
4453   :END:
4454 @end example
4456 If you want to set properties that can be inherited by any entry in a
4457 file, use a line like
4458 @cindex property, _ALL
4459 @cindex #+PROPERTY
4460 @example
4461 #+PROPERTY: NDisks_ALL 1 2 3 4
4462 @end example
4464 @vindex org-global-properties
4465 Property values set with the global variable
4466 @code{org-global-properties} can be inherited by all entries in all
4467 Org files.
4469 @noindent
4470 The following commands help to work with properties:
4472 @table @kbd
4473 @kindex M-@key{TAB}
4474 @item M-@key{TAB}
4475 After an initial colon in a line, complete property keys.  All keys used
4476 in the current file will be offered as possible completions.
4477 @kindex C-c C-x p
4478 @item C-c C-x p
4479 Set a property.  This prompts for a property name and a value.  If
4480 necessary, the property drawer is created as well.
4481 @item M-x org-insert-property-drawer
4482 Insert a property drawer into the current entry.  The drawer will be
4483 inserted early in the entry, but after the lines with planning
4484 information like deadlines.
4485 @kindex C-c C-c
4486 @item C-c C-c
4487 With the cursor in a property drawer, this executes property commands.
4488 @item C-c C-c s
4489 Set a property in the current entry.  Both the property and the value
4490 can be inserted using completion.
4491 @kindex S-@key{right}
4492 @kindex S-@key{left}
4493 @item S-@key{left}/@key{right}
4494 Switch property at point to the next/previous allowed value.
4495 @item C-c C-c d
4496 Remove a property from the current entry.
4497 @item C-c C-c D
4498 Globally remove a property, from all entries in the current file.
4499 @item C-c C-c c
4500 Compute the property at point, using the operator and scope from the
4501 nearest column format definition.
4502 @end table
4504 @node Special properties, Property searches, Property syntax, Properties and Columns
4505 @section Special properties
4506 @cindex properties, special
4508 Special properties provide an alternative access method to Org-mode
4509 features, like the TODO state or the priority of an entry, discussed in the
4510 previous chapters.  This interface exists so that you can include
4511 these states in a column view (@pxref{Column view}), or to use them in
4512 queries.  The following property names are special and should not be
4513 used as keys in the properties drawer:
4515 @cindex property, special, TODO
4516 @cindex property, special, TAGS
4517 @cindex property, special, ALLTAGS
4518 @cindex property, special, CATEGORY
4519 @cindex property, special, PRIORITY
4520 @cindex property, special, DEADLINE
4521 @cindex property, special, SCHEDULED
4522 @cindex property, special, CLOSED
4523 @cindex property, special, TIMESTAMP
4524 @cindex property, special, TIMESTAMP_IA
4525 @cindex property, special, CLOCKSUM
4526 @cindex property, special, BLOCKED
4527 @c guessing that ITEM is needed in this area; also, should this list be sorted?
4528 @cindex property, special, ITEM
4529 @example
4530 TODO         @r{The TODO keyword of the entry.}
4531 TAGS         @r{The tags defined directly in the headline.}
4532 ALLTAGS      @r{All tags, including inherited ones.}
4533 CATEGORY     @r{The category of an entry.}
4534 PRIORITY     @r{The priority of the entry, a string with a single letter.}
4535 DEADLINE     @r{The deadline time string, without the angular brackets.}
4536 SCHEDULED    @r{The scheduling timestamp, without the angular brackets.}
4537 CLOSED       @r{When was this entry closed?}
4538 TIMESTAMP    @r{The first keyword-less timestamp in the entry.}
4539 TIMESTAMP_IA @r{The first inactive timestamp in the entry.}
4540 CLOCKSUM     @r{The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}}
4541              @r{must be run first to compute the values.}
4542 BLOCKED      @r{"t" if task is currently blocked by children or siblings}
4543 ITEM         @r{The content of the entry.}
4544 @end example
4546 @node Property searches, Property inheritance, Special properties, Properties and Columns
4547 @section Property searches
4548 @cindex properties, searching
4549 @cindex searching, of properties
4551 To create sparse trees and special lists with selection based on properties,
4552 the same commands are used as for tag searches (@pxref{Tag searches}).
4553 @table @kbd
4554 @kindex C-c \
4555 @kindex C-c / m
4556 @item C-c \
4557 @itemx C-c / m
4558 Create a sparse tree with all matching entries.  With a
4559 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
4560 @kindex C-c a m
4561 @item C-c a m
4562 Create a global list of tag/property  matches from all agenda files.
4563 @xref{Matching tags and properties}.
4564 @kindex C-c a M
4565 @item C-c a M
4566 @vindex org-tags-match-list-sublevels
4567 Create a global list of tag matches from all agenda files, but check
4568 only TODO items and force checking of subitems (see variable
4569 @code{org-tags-match-list-sublevels}).
4570 @end table
4572 The syntax for the search string is described in @ref{Matching tags and
4573 properties}.
4575 There is also a special command for creating sparse trees based on a
4576 single property:
4578 @table @kbd
4579 @kindex C-c / p
4580 @item C-c / p
4581 Create a sparse tree based on the value of a property.  This first
4582 prompts for the name of a property, and then for a value.  A sparse tree
4583 is created with all entries that define this property with the given
4584 value.  If you enclose the value into curly braces, it is interpreted as
4585 a regular expression and matched against the property values.
4586 @end table
4588 @node Property inheritance, Column view, Property searches, Properties and Columns
4589 @section Property Inheritance
4590 @cindex properties, inheritance
4591 @cindex inheritance, of properties
4593 @vindex org-use-property-inheritance
4594 The outline structure of Org-mode documents lends itself for an
4595 inheritance model of properties: if the parent in a tree has a certain
4596 property, the children can inherit this property.  Org-mode does not
4597 turn this on by default, because it can slow down property searches
4598 significantly and is often not needed.  However, if you find inheritance
4599 useful, you can turn it on by setting the variable
4600 @code{org-use-property-inheritance}.  It may be set to @code{t} to make
4601 all properties inherited from the parent, to a list of properties
4602 that should be inherited, or to a regular expression that matches
4603 inherited properties.  If a property has the value @samp{nil}, this is
4604 interpreted as an explicit undefine of he property, so that inheritance
4605 search will stop at this value and return @code{nil}.
4607 Org-mode has a few properties for which inheritance is hard-coded, at
4608 least for the special applications for which they are used:
4610 @cindex property, COLUMNS
4611 @table @code
4612 @item COLUMNS
4613 The @code{:COLUMNS:} property defines the format of column view
4614 (@pxref{Column view}).  It is inherited in the sense that the level
4615 where a @code{:COLUMNS:} property is defined is used as the starting
4616 point for a column view table, independently of the location in the
4617 subtree from where columns view is turned on.
4618 @item CATEGORY
4619 @cindex property, CATEGORY
4620 For agenda view, a category set through a @code{:CATEGORY:} property
4621 applies to the entire subtree.
4622 @item ARCHIVE
4623 @cindex property, ARCHIVE
4624 For archiving, the @code{:ARCHIVE:} property may define the archive
4625 location for the entire subtree (@pxref{Moving subtrees}).
4626 @item LOGGING
4627 @cindex property, LOGGING
4628 The LOGGING property may define logging settings for an entry or a
4629 subtree (@pxref{Tracking TODO state changes}).
4630 @end table
4632 @node Column view, Property API, Property inheritance, Properties and Columns
4633 @section Column view
4635 A great way to view and edit properties in an outline tree is
4636 @emph{column view}.  In column view, each outline node is turned into a
4637 table row.  Columns in this table provide access to properties of the
4638 entries.  Org-mode implements columns by overlaying a tabular structure
4639 over the headline of each item.  While the headlines have been turned
4640 into a table row, you can still change the visibility of the outline
4641 tree.  For example, you get a compact table by switching to CONTENTS
4642 view (@kbd{S-@key{TAB} S-@key{TAB}}, or simply @kbd{c} while column view
4643 is active), but you can still open, read, and edit the entry below each
4644 headline.  Or, you can switch to column view after executing a sparse
4645 tree command and in this way get a table only for the selected items.
4646 Column view also works in agenda buffers (@pxref{Agenda Views}) where
4647 queries have collected selected items, possibly from a number of files.
4649 @menu
4650 * Defining columns::            The COLUMNS format property
4651 * Using column view::           How to create and use column view
4652 * Capturing column view::       A dynamic block for column view
4653 @end menu
4655 @node Defining columns, Using column view, Column view, Column view
4656 @subsection Defining columns
4657 @cindex column view, for properties
4658 @cindex properties, column view
4660 Setting up a column view first requires defining the columns.  This is
4661 done by defining a column format line.
4663 @menu
4664 * Scope of column definitions::  Where defined, where valid?
4665 * Column attributes::           Appearance and content of a column
4666 @end menu
4668 @node Scope of column definitions, Column attributes, Defining columns, Defining columns
4669 @subsubsection Scope of column definitions
4671 To define a column format for an entire file, use a line like
4673 @cindex #+COLUMNS
4674 @example
4675 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
4676 @end example
4678 To specify a format that only applies to a specific tree, add a
4679 @code{:COLUMNS:} property to the top node of that tree, for example:
4681 @example
4682 ** Top node for columns view
4683    :PROPERTIES:
4684    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
4685    :END:
4686 @end example
4688 If a @code{:COLUMNS:} property is present in an entry, it defines columns
4689 for the entry itself, and for the entire subtree below it.  Since the
4690 column definition is part of the hierarchical structure of the document,
4691 you can define columns on level 1 that are general enough for all
4692 sublevels, and more specific columns further down, when you edit a
4693 deeper part of the tree.
4695 @node Column attributes,  , Scope of column definitions, Defining columns
4696 @subsubsection Column attributes
4697 A column definition sets the attributes of a column.  The general
4698 definition looks like this:
4700 @example
4701  %[@var{width}]@var{property}[(@var{title})][@{@var{summary-type}@}]
4702 @end example
4704 @noindent
4705 Except for the percent sign and the property name, all items are
4706 optional.  The individual parts have the following meaning:
4708 @example
4709 @var{width}           @r{An integer specifying the width of the column in characters.}
4710                 @r{If omitted, the width will be determined automatically.}
4711 @var{property}        @r{The property that should be edited in this column.}
4712                 @r{Special properties representing meta data are allowed here}
4713                 @r{as well (@pxref{Special properties})}
4714 @var{title}     @r{The header text for the column. If omitted, the property}
4715                 @r{name is used.}
4716 @{@var{summary-type}@}  @r{The summary type.  If specified, the column values for}
4717                 @r{parent nodes are computed from the children.}
4718                 @r{Supported summary types are:}
4719                 @{+@}       @r{Sum numbers in this column.}
4720                 @{+;%.1f@}  @r{Like @samp{+}, but format result with @samp{%.1f}.}
4721                 @{$@}       @r{Currency, short for @samp{+;%.2f}.}
4722                 @{:@}       @r{Sum times, HH:MM, plain numbers are hours.}
4723                 @{X@}       @r{Checkbox status, @samp{[X]} if all children are @samp{[X]}.}
4724                 @{X/@}      @r{Checkbox status, @samp{[n/m]}.}
4725                 @{X%@}      @r{Checkbox status, @samp{[n%]}.}
4726                 @{min@}     @r{Smallest number in column.}
4727                 @{max@}     @r{Largest number.}
4728                 @{mean@}    @r{Arithmetic mean of numbers.}
4729                 @{:min@}    @r{Smallest time value in column.}
4730                 @{:max@}    @r{Largest time value.}
4731                 @{:mean@}   @r{Arithmetic mean of time values.}
4732                 @{@@min@}    @r{Minimum age (in days/hours/mins/seconds).}
4733                 @{@@max@}    @r{Maximum age (in days/hours/mins/seconds).}
4734                 @{@@mean@}   @r{Arithmetic mean of ages (in days/hours/mins/seconds).}
4735                 @{est+@}    @r{Add low-high estimates.}
4736 @end example
4738 @noindent
4739 Be aware that you can only have one summary type for any property you
4740 include. Subsequent columns referencing the same property will all display the
4741 same summary information.
4743 The @code{est+} summary type requires further explanation.  It is used for
4744 combining estimates, expressed as low-high ranges.  For example, instead
4745 of estimating a particular task will take 5 days, you might estimate it as
4746 5-6 days if you're fairly confident you know how much woark is required, or
4747 1-10 days if you don't really know what needs to be done.  Both ranges
4748 average at 5.5 days, but the first represents a more predictable delivery.
4750 When combining a set of such estimates, simply adding the lows and highs
4751 produces an unrealistically wide result. Instead, @code{est+} adds the
4752 statistical mean and variance of the sub-tasks, generating a final estimate
4753 from the sum.  For example, suppose you had ten tasks, each of which was
4754 estimated at 0.5 to 2 days of work.  Straight addition produces an estimate
4755 of 5 to 20 days, representing what to expect if everything goes either
4756 extremely well or extremely poorly. In contrast, @code{est+} estimates the
4757 full job more realistically, at 10-15 days.
4759 Here is an example for a complete columns definition, along with allowed
4760 values.
4762 @example
4763 :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.}
4764                    %10Time_Estimate@{:@} %CLOCKSUM
4765 :Owner_ALL:    Tammy Mark Karl Lisa Don
4766 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
4767 :Approved_ALL: "[ ]" "[X]"
4768 @end example
4770 @noindent
4771 The first column, @samp{%25ITEM}, means the first 25 characters of the
4772 item itself, i.e. of the headline.  You probably always should start the
4773 column definition with the @samp{ITEM} specifier.  The other specifiers
4774 create columns @samp{Owner} with a list of names as allowed values, for
4775 @samp{Status} with four different possible values, and for a checkbox
4776 field @samp{Approved}.  When no width is given after the @samp{%}
4777 character, the column will be exactly as wide as it needs to be in order
4778 to fully display all values.  The @samp{Approved} column does have a
4779 modified title (@samp{Approved?}, with a question mark).  Summaries will
4780 be created for the @samp{Time_Estimate} column by adding time duration
4781 expressions like HH:MM, and for the @samp{Approved} column, by providing
4782 an @samp{[X]} status if all children have been checked.  The
4783 @samp{CLOCKSUM} column is special, it lists the sum of CLOCK intervals
4784 in the subtree.
4786 @node Using column view, Capturing column view, Defining columns, Column view
4787 @subsection Using column view
4789 @table @kbd
4790 @tsubheading{Turning column view on and off}
4791 @kindex C-c C-x C-c
4792 @item C-c C-x C-c
4793 @vindex org-columns-default-format
4794 Turn on column view.  If the cursor is before the first headline in the file,
4795 column view is turned on for the entire file, using the @code{#+COLUMNS}
4796 definition.  If the cursor is somewhere inside the outline, this command
4797 searches the hierarchy, up from point, for a @code{:COLUMNS:} property that
4798 defines a format.  When one is found, the column view table is established
4799 for the tree starting at the entry that contains the @code{:COLUMNS:}
4800 property.  If no such property is found, the format is taken from the
4801 @code{#+COLUMNS} line or from the variable @code{org-columns-default-format},
4802 and column view is established for the current entry and its subtree.
4803 @kindex r
4804 @item r
4805 Recreate the column view, to include recent changes made in the buffer.
4806 @kindex g
4807 @item g
4808 Same as @kbd{r}.
4809 @kindex q
4810 @item q
4811 Exit column view.
4812 @tsubheading{Editing values}
4813 @item @key{left} @key{right} @key{up} @key{down}
4814 Move through the column view from field to field.
4815 @kindex S-@key{left}
4816 @kindex S-@key{right}
4817 @item  S-@key{left}/@key{right}
4818 Switch to the next/previous allowed value of the field.  For this, you
4819 have to have specified allowed values for a property.
4820 @item 1..9,0
4821 Directly select the nth allowed value, @kbd{0} selects the 10th value.
4822 @kindex n
4823 @kindex p
4824 @itemx  n / p
4825 Same as @kbd{S-@key{left}/@key{right}}
4826 @kindex e
4827 @item e
4828 Edit the property at point.  For the special properties, this will
4829 invoke the same interface that you normally use to change that
4830 property.  For example, when editing a TAGS property, the tag completion
4831 or fast selection interface will pop up.
4832 @kindex C-c C-c
4833 @item C-c C-c
4834 When there is a checkbox at point, toggle it.
4835 @kindex v
4836 @item v
4837 View the full value of this property.  This is useful if the width of
4838 the column is smaller than that of the value.
4839 @kindex a
4840 @item a
4841 Edit the list of allowed values for this property.  If the list is found
4842 in the hierarchy, the modified values is stored there.  If no list is
4843 found, the new value is stored in the first entry that is part of the
4844 current column view.
4845 @tsubheading{Modifying the table structure}
4846 @kindex <
4847 @kindex >
4848 @item < / >
4849 Make the column narrower/wider by one character.
4850 @kindex S-M-@key{right}
4851 @item S-M-@key{right}
4852 Insert a new column, to the left of the current column.
4853 @kindex S-M-@key{left}
4854 @item S-M-@key{left}
4855 Delete the current column.
4856 @end table
4858 @node Capturing column view,  , Using column view, Column view
4859 @subsection Capturing column view
4861 Since column view is just an overlay over a buffer, it cannot be
4862 exported or printed directly.  If you want to capture a column view, use
4863 a @code{columnview} dynamic block (@pxref{Dynamic blocks}).  The frame
4864 of this block looks like this:
4866 @cindex #+BEGIN, columnview
4867 @example
4868 * The column view
4869 #+BEGIN: columnview :hlines 1 :id "label"
4871 #+END:
4872 @end example
4874 @noindent This dynamic block has the following parameters:
4876 @table @code
4877 @item :id
4878 This is the most important parameter.  Column view is a feature that is
4879 often localized to a certain (sub)tree, and the capture block might be
4880 at a different location in the file.  To identify the tree whose view to
4881 capture, you can use 4 values:
4882 @cindex property, ID
4883 @example
4884 local     @r{use the tree in which the capture block is located}
4885 global    @r{make a global view, including all headings in the file}
4886 "file:@var{path-to-file}"
4887           @r{run column view at the top of this file}
4888 "@var{ID}"      @r{call column view in the tree that has an @code{:ID:}}
4889           @r{property with the value @i{label}.  You can use}
4890           @r{@kbd{M-x org-id-copy} to create a globally unique ID for}
4891           @r{the current entry and copy it to the kill-ring.}
4892 @end example
4893 @item :hlines
4894 When @code{t}, insert an hline after every line.  When a number @var{N}, insert
4895 an hline before each headline with level @code{<= @var{N}}.
4896 @item :vlines
4897 When set to @code{t}, force column groups to get vertical lines.
4898 @item :maxlevel
4899 When set to a number, don't capture entries below this level.
4900 @item :skip-empty-rows
4901 When set to @code{t}, skip rows where the only non-empty specifier of the
4902 column view is @code{ITEM}.
4904 @end table
4906 @noindent
4907 The following commands insert or update the dynamic block:
4909 @table @kbd
4910 @kindex C-c C-x i
4911 @item C-c C-x i
4912 Insert a dynamic block capturing a column view.  You will be prompted
4913 for the scope or ID of the view.
4914 @kindex C-c C-c
4915 @item C-c C-c
4916 @kindex C-c C-x C-u
4917 @itemx C-c C-x C-u
4918 Update dynamic block at point.  The cursor needs to be in the
4919 @code{#+BEGIN} line of the dynamic block.
4920 @kindex C-u C-c C-x C-u
4921 @item C-u C-c C-x C-u
4922 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
4923 you have several clock table blocks in a buffer.
4924 @end table
4926 You can add formulas to the column view table and you may add plotting
4927 instructions in front of the table---these will survive an update of the
4928 block.  If there is a @code{#+TBLFM:} after the table, the table will
4929 actually be recalculated automatically after an update.
4931 An alternative way to capture and process property values into a table is
4932 provided by Eric Schulte's @file{org-collector.el} which is a contributed
4933 package@footnote{Contributed packages are not part of Emacs, but are
4934 distributed with the main distribution of Org (visit
4935 @uref{http://orgmode.org}).}.  It provides a general API to collect
4936 properties from entries in a certain scope, and arbitrary Lisp expressions to
4937 process these values before inserting them into a table or a dynamic block.
4939 @node Property API,  , Column view, Properties and Columns
4940 @section The Property API
4941 @cindex properties, API
4942 @cindex API, for properties
4944 There is a full API for accessing and changing properties.  This API can
4945 be used by Emacs Lisp programs to work with properties and to implement
4946 features based on them.  For more information see @ref{Using the
4947 property API}.
4949 @node Dates and Times, Capture - Refile - Archive, Properties and Columns, Top
4950 @chapter Dates and times
4951 @cindex dates
4952 @cindex times
4953 @cindex timestamp
4954 @cindex date stamp
4956 To assist project planning, TODO items can be labeled with a date and/or
4957 a time.  The specially formatted string carrying the date and time
4958 information is called a @emph{timestamp} in Org-mode.  This may be a
4959 little confusing because timestamp is often used as indicating when
4960 something was created or last changed.  However, in Org-mode this term
4961 is used in a much wider sense.
4963 @menu
4964 * Timestamps::                  Assigning a time to a tree entry
4965 * Creating timestamps::         Commands which insert timestamps
4966 * Deadlines and scheduling::    Planning your work
4967 * Clocking work time::          Tracking how long you spend on a task
4968 * Resolving idle time::         Resolving time if you've been idle
4969 * Effort estimates::            Planning work effort in advance
4970 * Relative timer::              Notes with a running timer
4971 @end menu
4974 @node Timestamps, Creating timestamps, Dates and Times, Dates and Times
4975 @section Timestamps, deadlines, and scheduling
4976 @cindex timestamps
4977 @cindex ranges, time
4978 @cindex date stamps
4979 @cindex deadlines
4980 @cindex scheduling
4982 A timestamp is a specification of a date (possibly with a time or a range of
4983 times) in a special format, either @samp{<2003-09-16 Tue>} or
4984 @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16 Tue
4985 12:00-12:30>}@footnote{This is inspired by the standard ISO 8601 date/time
4986 format.  To use an alternative format, see @ref{Custom time format}.}.  A
4987 timestamp can appear anywhere in the headline or body of an Org tree entry.
4988 Its presence causes entries to be shown on specific dates in the agenda
4989 (@pxref{Weekly/daily agenda}).  We distinguish:
4991 @table @var
4992 @item Plain timestamp; Event; Appointment
4993 @cindex timestamp
4994 A simple timestamp just assigns a date/time to an item.  This is just
4995 like writing down an appointment or event in a paper agenda.  In the
4996 timeline and agenda displays, the headline of an entry associated with a
4997 plain timestamp will be shown exactly on that date.
4999 @example
5000 * Meet Peter at the movies <2006-11-01 Wed 19:15>
5001 * Discussion on climate change <2006-11-02 Thu 20:00-22:00>
5002 @end example
5004 @item Timestamp with repeater interval
5005 @cindex timestamp, with repeater interval
5006 A timestamp may contain a @emph{repeater interval}, indicating that it
5007 applies not only on the given date, but again and again after a certain
5008 interval of N days (d), weeks (w), months (m), or years (y).  The
5009 following will show up in the agenda every Wednesday:
5011 @example
5012 * Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
5013 @end example
5015 @item Diary-style sexp entries
5016 For more complex date specifications, Org-mode supports using the
5017 special sexp diary entries implemented in the Emacs calendar/diary
5018 package.  For example
5020 @example
5021 * The nerd meeting on every 2nd Thursday of the month
5022   <%%(diary-float t 4 2)>
5023 @end example
5025 @item Time/Date range
5026 @cindex timerange
5027 @cindex date range
5028 Two timestamps connected by @samp{--} denote a range.  The headline
5029 will be shown on the first and last day of the range, and on any dates
5030 that are displayed and fall in the range.  Here is an example:
5032 @example
5033 ** Meeting in Amsterdam
5034    <2004-08-23 Mon>--<2004-08-26 Thu>
5035 @end example
5037 @item Inactive timestamp
5038 @cindex timestamp, inactive
5039 @cindex inactive timestamp
5040 Just like a plain timestamp, but with square brackets instead of
5041 angular ones.  These timestamps are inactive in the sense that they do
5042 @emph{not} trigger an entry to show up in the agenda.
5044 @example
5045 * Gillian comes late for the fifth time [2006-11-01 Wed]
5046 @end example
5048 @end table
5050 @node Creating timestamps, Deadlines and scheduling, Timestamps, Dates and Times
5051 @section Creating timestamps
5052 @cindex creating timestamps
5053 @cindex timestamps, creating
5055 For Org-mode to recognize timestamps, they need to be in the specific
5056 format.  All commands listed below produce timestamps in the correct
5057 format.
5059 @table @kbd
5060 @kindex C-c .
5061 @item C-c .
5062 Prompt for a date and insert a corresponding timestamp.  When the cursor is
5063 at an existing timestamp in the buffer, the command is used to modify this
5064 timestamp instead of inserting a new one.  When this command is used twice in
5065 succession, a time range is inserted.
5067 @kindex C-c !
5068 @item C-c !
5069 Like @kbd{C-c .}, but insert an inactive timestamp that will not cause
5070 an agenda entry.
5072 @kindex C-u C-c .
5073 @kindex C-u C-c !
5074 @item C-u C-c .
5075 @itemx C-u C-c !
5076 @vindex org-time-stamp-rounding-minutes
5077 Like @kbd{C-c .} and @kbd{C-c !}, but use the alternative format which
5078 contains date and time.  The default time can be rounded to multiples of 5
5079 minutes, see the option @code{org-time-stamp-rounding-minutes}.
5081 @kindex C-c <
5082 @item C-c <
5083 Insert a timestamp corresponding to the cursor date in the Calendar.
5085 @kindex C-c >
5086 @item C-c >
5087 Access the Emacs calendar for the current date.  If there is a
5088 timestamp in the current line, go to the corresponding date
5089 instead.
5091 @kindex C-c C-o
5092 @item C-c C-o
5093 Access the agenda for the date given by the timestamp or -range at
5094 point (@pxref{Weekly/daily agenda}).
5096 @kindex S-@key{left}
5097 @kindex S-@key{right}
5098 @item S-@key{left}
5099 @itemx S-@key{right}
5100 Change date at cursor by one day.  These key bindings conflict with
5101 shift-selection and related modes (@pxref{Conflicts}).
5103 @kindex S-@key{up}
5104 @kindex S-@key{down}
5105 @item S-@key{up}
5106 @itemx S-@key{down}
5107 Change the item under the cursor in a timestamp.  The cursor can be on a
5108 year, month, day, hour or minute.  When the timestamp contains a time range
5109 like @samp{15:30-16:30}, modifying the first time will also shift the second,
5110 shifting the time block with constant length.  To change the length, modify
5111 the second time.  Note that if the cursor is in a headline and not at a
5112 timestamp, these same keys modify the priority of an item.
5113 (@pxref{Priorities}). The key bindings also conflict with shift-selection and
5114 related modes (@pxref{Conflicts}).
5116 @kindex C-c C-y
5117 @cindex evaluate time range
5118 @item C-c C-y
5119 Evaluate a time range by computing the difference between start and end.
5120 With a prefix argument, insert result after the time range (in a table: into
5121 the following column).
5122 @end table
5125 @menu
5126 * The date/time prompt::        How Org-mode helps you entering date and time
5127 * Custom time format::          Making dates look different
5128 @end menu
5130 @node The date/time prompt, Custom time format, Creating timestamps, Creating timestamps
5131 @subsection The date/time prompt
5132 @cindex date, reading in minibuffer
5133 @cindex time, reading in minibuffer
5135 @vindex org-read-date-prefer-future
5136 When Org-mode prompts for a date/time, the default is shown in default
5137 date/time format, and the prompt therefore seems to ask for a specific
5138 format.  But it will in fact accept any string containing some date and/or
5139 time information, and it is really smart about interpreting your input.  You
5140 can, for example, use @kbd{C-y} to paste a (possibly multi-line) string
5141 copied from an email message.  Org-mode will find whatever information is in
5142 there and derive anything you have not specified from the @emph{default date
5143 and time}.  The default is usually the current date and time, but when
5144 modifying an existing timestamp, or when entering the second stamp of a
5145 range, it is taken from the stamp in the buffer.  When filling in
5146 information, Org-mode assumes that most of the time you will want to enter a
5147 date in the future: if you omit the month/year and the given day/month is
5148 @i{before} today, it will assume that you mean a future date@footnote{See the
5149 variable @code{org-read-date-prefer-future}.  You may set that variable to
5150 the symbol @code{time} to even make a time before now shift the date to
5151 tomorrow.}.  If the date has been automatically shifted into the future, the
5152 time prompt will show this with @samp{(=>F).}
5154 For example, let's assume that today is @b{June 13, 2006}.  Here is how
5155 various inputs will be interpreted, the items filled in by Org-mode are
5156 in @b{bold}.
5158 @example
5159 3-2-5         --> 2003-02-05
5160 2/5/3         --> 2003-02-05
5161 14            --> @b{2006}-@b{06}-14
5162 12            --> @b{2006}-@b{07}-12
5163 2/5           --> @b{2007}-02-05
5164 Fri           --> nearest Friday (default date or later)
5165 sep 15        --> @b{2006}-09-15
5166 feb 15        --> @b{2007}-02-15
5167 sep 12 9      --> 2009-09-12
5168 12:45         --> @b{2006}-@b{06}-@b{13} 12:45
5169 22 sept 0:34  --> @b{2006}-09-22 0:34
5170 w4            --> ISO week for of the current year @b{2006}
5171 2012 w4 fri   --> Friday of ISO week 4 in 2012
5172 2012-w04-5    --> Same as above
5173 @end example
5175 Furthermore you can specify a relative date by giving, as the
5176 @emph{first} thing in the input: a plus/minus sign, a number and a
5177 letter ([dwmy]) to indicate change in days, weeks, months, or years.  With a
5178 single plus or minus, the date is always relative to today.  With a
5179 double plus or minus, it is relative to the default date.  If instead of
5180 a single letter, you use the abbreviation of day name, the date will be
5181 the nth such day.  E.g.
5183 @example
5184 +0            --> today
5185 .             --> today
5186 +4d           --> four days from today
5187 +4            --> same as above
5188 +2w           --> two weeks from today
5189 ++5           --> five days from default date
5190 +2tue         --> second Tuesday from now.
5191 @end example
5193 @vindex parse-time-months
5194 @vindex parse-time-weekdays
5195 The function understands English month and weekday abbreviations.  If
5196 you want to use unabbreviated names and/or other languages, configure
5197 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
5199 You can specify a time range by giving start and end times or by giving a
5200 start time and a duration (in HH:MM format). Use '-' or '--' as the separator
5201 in the former case and use '+' as the separator in the latter case. E.g.
5203 @example
5204 11am-1:15pm    --> 11:00-13:15
5205 11am--1:15pm   --> same as above
5206 11am+2:15      --> same as above
5207 @end example
5209 @cindex calendar, for selecting date
5210 @vindex org-popup-calendar-for-date-prompt
5211 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
5212 you don't need/want the calendar, configure the variable
5213 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
5214 prompt, either by clicking on a date in the calendar, or by pressing
5215 @key{RET}, the date selected in the calendar will be combined with the
5216 information entered at the prompt.  You can control the calendar fully
5217 from the minibuffer:
5219 @kindex <
5220 @kindex >
5221 @kindex M-v
5222 @kindex C-v
5223 @kindex mouse-1
5224 @kindex S-@key{right}
5225 @kindex S-@key{left}
5226 @kindex S-@key{down}
5227 @kindex S-@key{up}
5228 @kindex M-S-@key{right}
5229 @kindex M-S-@key{left}
5230 @kindex @key{RET}
5231 @example
5232 @key{RET}           @r{Choose date at cursor in calendar.}
5233 mouse-1        @r{Select date by clicking on it.}
5234 S-@key{right}/@key{left}     @r{One day forward/backward.}
5235 S-@key{down}/@key{up}     @r{One week forward/backward.}
5236 M-S-@key{right}/@key{left}   @r{One month forward/backward.}
5237 > / <          @r{Scroll calendar forward/backward by one month.}
5238 M-v / C-v      @r{Scroll calendar forward/backward by 3 months.}
5239 @end example
5241 @vindex org-read-date-display-live
5242 The actions of the date/time prompt may seem complex, but I assure you they
5243 will grow on you, and you will start getting annoyed by pretty much any other
5244 way of entering a date/time out there.  To help you understand what is going
5245 on, the current interpretation of your input will be displayed live in the
5246 minibuffer@footnote{If you find this distracting, turn the display of with
5247 @code{org-read-date-display-live}.}.
5249 @node Custom time format,  , The date/time prompt, Creating timestamps
5250 @subsection Custom time format
5251 @cindex custom date/time format
5252 @cindex time format, custom
5253 @cindex date format, custom
5255 @vindex org-display-custom-times
5256 @vindex org-time-stamp-custom-formats
5257 Org-mode uses the standard ISO notation for dates and times as it is
5258 defined in ISO 8601.  If you cannot get used to this and require another
5259 representation of date and time to keep you happy, you can get it by
5260 customizing the variables @code{org-display-custom-times} and
5261 @code{org-time-stamp-custom-formats}.
5263 @table @kbd
5264 @kindex C-c C-x C-t
5265 @item C-c C-x C-t
5266 Toggle the display of custom formats for dates and times.
5267 @end table
5269 @noindent
5270 Org-mode needs the default format for scanning, so the custom date/time
5271 format does not @emph{replace} the default format---instead it is put
5272 @emph{over} the default format using text properties.  This has the
5273 following consequences:
5274 @itemize @bullet
5275 @item
5276 You cannot place the cursor onto a timestamp anymore, only before or
5277 after.
5278 @item
5279 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
5280 each component of a timestamp.  If the cursor is at the beginning of
5281 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
5282 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
5283 time will be changed by one minute.
5284 @item
5285 If the timestamp contains a range of clock times or a repeater, these
5286 will not be overlayed, but remain in the buffer as they were.
5287 @item
5288 When you delete a timestamp character-by-character, it will only
5289 disappear from the buffer after @emph{all} (invisible) characters
5290 belonging to the ISO timestamp have been removed.
5291 @item
5292 If the custom timestamp format is longer than the default and you are
5293 using dates in tables, table alignment will be messed up.  If the custom
5294 format is shorter, things do work as expected.
5295 @end itemize
5298 @node Deadlines and scheduling, Clocking work time, Creating timestamps, Dates and Times
5299 @section Deadlines and scheduling
5301 A timestamp may be preceded by special keywords to facilitate planning:
5303 @table @var
5304 @item DEADLINE
5305 @cindex DEADLINE keyword
5307 Meaning: the task (most likely a TODO item, though not necessarily) is supposed
5308 to be finished on that date.
5310 @vindex org-deadline-warning-days
5311 On the deadline date, the task will be listed in the agenda.  In
5312 addition, the agenda for @emph{today} will carry a warning about the
5313 approaching or missed deadline, starting
5314 @code{org-deadline-warning-days} before the due date, and continuing
5315 until the entry is marked DONE.  An example:
5317 @example
5318 *** TODO write article about the Earth for the Guide
5319     The editor in charge is [[bbdb:Ford Prefect]]
5320     DEADLINE: <2004-02-29 Sun>
5321 @end example
5323 You can specify a different lead time for warnings for a specific
5324 deadlines using the following syntax.  Here is an example with a warning
5325 period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.
5327 @item SCHEDULED
5328 @cindex SCHEDULED keyword
5330 Meaning: you are planning to start working on that task on the given
5331 date.
5333 @vindex org-agenda-skip-scheduled-if-done
5334 The headline will be listed under the given date@footnote{It will still
5335 be listed on that date after it has been marked DONE.  If you don't like
5336 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
5337 addition, a reminder that the scheduled date has passed will be present
5338 in the compilation for @emph{today}, until the entry is marked DONE.
5339 I.e. the task will automatically be forwarded until completed.
5341 @example
5342 *** TODO Call Trillian for a date on New Years Eve.
5343     SCHEDULED: <2004-12-25 Sat>
5344 @end example
5346 @noindent
5347 @b{Important:} Scheduling an item in Org-mode should @i{not} be
5348 understood in the same way that we understand @i{scheduling a meeting}.
5349 Setting a date for a meeting is just a simple appointment, you should
5350 mark this entry with a simple plain timestamp, to get this item shown
5351 on the date where it applies.  This is a frequent misunderstanding by
5352 Org users.  In Org-mode, @i{scheduling} means setting a date when you
5353 want to start working on an action item.
5354 @end table
5356 You may use timestamps with repeaters in scheduling and deadline
5357 entries.  Org-mode will issue early and late warnings based on the
5358 assumption that the timestamp represents the @i{nearest instance} of
5359 the repeater.  However, the use of diary sexp entries like
5361 @code{<%%(diary-float t 42)>}
5363 in scheduling and deadline timestamps is limited.  Org-mode does not
5364 know enough about the internals of each sexp function to issue early and
5365 late warnings.  However, it will show the item on each day where the
5366 sexp entry matches.
5368 @menu
5369 * Inserting deadline/schedule::  Planning items
5370 * Repeated tasks::              Items that show up again and again
5371 @end menu
5373 @node Inserting deadline/schedule, Repeated tasks, Deadlines and scheduling, Deadlines and scheduling
5374 @subsection Inserting deadlines or schedules
5376 The following commands allow you to quickly insert a deadline or to schedule
5377 an item:
5379 @table @kbd
5381 @kindex C-c C-d
5382 @item C-c C-d
5383 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will happen
5384 in the line directly following the headline.  When called with a prefix arg,
5385 an existing deadline will be removed from the entry.  Depending on the
5386 variable @code{org-log-redeadline}@footnote{with corresponding
5387 @code{#+STARTUP} keywords @code{logredeadline}, @code{lognoteredeadline},
5388 and @code{nologredeadline}}, a note will be taken when changing an existing
5389 deadline.
5390 @c FIXME Any CLOSED timestamp will be removed.????????
5392 @kindex C-c C-s
5393 @item C-c C-s
5394 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
5395 happen in the line directly following the headline.  Any CLOSED timestamp
5396 will be removed.  When called with a prefix argument, remove the scheduling
5397 date from the entry.  Depending on the variable
5398 @code{org-log-reschedule}@footnote{with corresponding @code{#+STARTUP}
5399 keywords @code{logredeadline}, @code{lognoteredeadline}, and
5400 @code{nologredeadline}}, a note will be taken when changing an existing
5401 scheduling time.
5403 @kindex C-c C-x C-k
5404 @kindex k a
5405 @kindex k s
5406 @item C-c C-x C-k
5407 Mark the current entry for agenda action.  After you have marked the entry
5408 like this, you can open the agenda or the calendar to find an appropriate
5409 date.  With the cursor on the selected date, press @kbd{k s} or @kbd{k d} to
5410 schedule the marked item.
5412 @kindex C-c / d
5413 @cindex sparse tree, for deadlines
5414 @item C-c / d
5415 @vindex org-deadline-warning-days
5416 Create a sparse tree with all deadlines that are either past-due, or
5417 which will become due within @code{org-deadline-warning-days}.
5418 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
5419 prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows
5420 all deadlines due tomorrow.
5422 @kindex C-c / b
5423 @item C-c / b
5424 Sparse tree for deadlines and scheduled items before a given date.
5426 @kindex C-c / a
5427 @item C-c / a
5428 Sparse tree for deadlines and scheduled items after a given date.
5429 @end table
5431 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
5432 @subsection Repeated tasks
5433 @cindex tasks, repeated
5434 @cindex repeated tasks
5436 Some tasks need to be repeated again and again.  Org-mode helps to
5437 organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
5438 or plain timestamp.  In the following example
5439 @example
5440 ** TODO Pay the rent
5441    DEADLINE: <2005-10-01 Sat +1m>
5442 @end example
5443 @noindent
5444 the @code{+1m} is a repeater; the intended interpretation is that the task
5445 has a deadline on <2005-10-01> and repeats itself every (one) month starting
5446 from that time.  If you need both a repeater and a special warning period in
5447 a deadline entry, the repeater should come first and the warning period last:
5448 @code{DEADLINE: <2005-10-01 Sat +1m -3d>}.
5450 @vindex org-todo-repeat-to-state
5451 Deadlines and scheduled items produce entries in the agenda when they are
5452 over-due, so it is important to be able to mark such an entry as completed
5453 once you have done so.  When you mark a DEADLINE or a SCHEDULE with the TODO
5454 keyword DONE, it will no longer produce entries in the agenda.  The problem
5455 with this is, however, that then also the @emph{next} instance of the
5456 repeated entry will not be active.  Org-mode deals with this in the following
5457 way: When you try to mark such an entry DONE (using @kbd{C-c C-t}), it will
5458 shift the base date of the repeating timestamp by the repeater interval, and
5459 immediately set the entry state back to TODO@footnote{In fact, the target
5460 state is taken from, in this sequence, the @code{REPEAT_TO_STATE} property or
5461 the variable @code{org-todo-repeat-to-state}.  If neither of these is
5462 specified, the target state defaults to the first state of the TODO state
5463 sequence.}.  In the example above, setting the state to DONE would actually
5464 switch the date like this:
5466 @example
5467 ** TODO Pay the rent
5468    DEADLINE: <2005-11-01 Tue +1m>
5469 @end example
5471 @vindex org-log-repeat
5472 A timestamp@footnote{You can change this using the option
5473 @code{org-log-repeat}, or the @code{#+STARTUP} options @code{logrepeat},
5474 @code{lognoterepeat}, and @code{nologrepeat}.  With @code{lognoterepeat}, you
5475 will also be prompted for a note.} will be added under the deadline, to keep
5476 a record that you actually acted on the previous instance of this deadline.
5478 As a consequence of shifting the base date, this entry will no longer be
5479 visible in the agenda when checking past dates, but all future instances
5480 will be visible.
5482 With the @samp{+1m} cookie, the date shift will always be exactly one
5483 month.  So if you have not paid the rent for three months, marking this
5484 entry DONE will still keep it as an overdue deadline.  Depending on the
5485 task, this may not be the best way to handle it.  For example, if you
5486 forgot to call you father for 3 weeks, it does not make sense to call
5487 him 3 times in a single day to make up for it.  Finally, there are tasks
5488 like changing batteries which should always repeat a certain time
5489 @i{after} the last time you did it.  For these tasks, Org-mode has
5490 special repeaters markers with @samp{++} and @samp{.+}.  For example:
5492 @example
5493 ** TODO Call Father
5494    DEADLINE: <2008-02-10 Sun ++1w>
5495    Marking this DONE will shift the date by at least one week,
5496    but also by as many weeks as it takes to get this date into
5497    the future.  However, it stays on a Sunday, even if you called
5498    and marked it done on Saturday.
5499 ** TODO Check the batteries in the smoke detectors
5500    DEADLINE: <2005-11-01 Tue .+1m>
5501    Marking this DONE will shift the date to one month after
5502    today.
5503 @end example
5505 You may have both scheduling and deadline information for a specific
5506 task---just make sure that the repeater intervals on both are the same.
5508 An alternative to using a repeater is to create a number of copies of a task
5509 subtree, with dates shifted in each copy.  The command @kbd{C-c C-x c} was
5510 created for this purpose, it is described in @ref{Structure editing}.
5513 @node Clocking work time, Resolving idle time, Deadlines and scheduling, Dates and Times
5514 @section Clocking work time
5516 Org-mode allows you to clock the time you spend on specific tasks in a
5517 project.  When you start working on an item, you can start the clock.
5518 When you stop working on that task, or when you mark the task done, the
5519 clock is stopped and the corresponding time interval is recorded.  It
5520 also computes the total time spent on each subtree of a project.  And it
5521 remembers a history or tasks recently clocked, to that you can jump quickly
5522 between a number of tasks absorbing your time.
5524 To save the clock history across Emacs sessions, use
5525 @lisp
5526 (setq org-clock-persist 'history)
5527 (org-clock-persistence-insinuate)
5528 @end lisp
5529 When you clock into a new task after resuming Emacs, the incomplete
5530 clock@footnote{To resume the clock under the assumption that you have worked
5531 on this task while outside Emacs, use @code{(setq org-clock-persist t)}.}
5532 will be found (@pxref{Resolving idle time}) and you will be prompted about
5533 what to do with it.
5535 @table @kbd
5536 @kindex C-c C-x C-i
5537 @item C-c C-x C-i
5538 @vindex org-clock-into-drawer
5539 Start the clock on the current item (clock-in).  This inserts the CLOCK
5540 keyword together with a timestamp.  If this is not the first clocking of
5541 this item, the multiple CLOCK lines will be wrapped into a
5542 @code{:LOGBOOK:} drawer (see also the variable
5543 @code{org-clock-into-drawer}).  When called with a @kbd{C-u} prefix argument,
5544 select the task from a list of recently clocked tasks.  With two @kbd{C-u
5545 C-u} prefixes, clock into the task at point and mark it as the default task.
5546 The default task will always be available when selecting a clocking task,
5547 with letter @kbd{d}.@*
5548 @cindex property: CLOCK_MODELINE_TOTAL
5549 @cindex property: LAST_REPEAT
5550 @vindex org-clock-modeline-total
5551 While the clock is running, the current clocking time is shown in the mode
5552 line, along with the title of the task.  The clock time shown will be all
5553 time ever clocked for this task and its children.  If the task has an effort
5554 estimate (@pxref{Effort estimates}), the mode line displays the current
5555 clocking time against it@footnote{To add an effort estimate ``on the fly'',
5556 hook a function doing this to @code{org-clock-in-prepare-hook}.}  If the task
5557 is a repeating one (@pxref{Repeated tasks}), only the time since the last
5558 reset of the task @footnote{as recorded by the @code{LAST_REPEAT} property}
5559 will be shown.  More control over what time is shown can be exercised with
5560 the @code{CLOCK_MODELINE_TOTAL} property.  It may have the values
5561 @code{current} to show only the current clocking instance, @code{today} to
5562 show all time clocked on this tasks today (see also the variable
5563 @code{org-extend-today-until}), @code{all} to include all time, or
5564 @code{auto} which is the default@footnote{See also the variable
5565 @code{org-clock-modeline-total}.}.@* Clicking with @kbd{mouse-1} onto the
5566 mode line entry will pop up a menu with clocking options.
5567 @kindex C-c C-x C-o
5568 @item C-c C-x C-o
5569 @vindex org-log-note-clock-out
5570 Stop the clock (clock-out).  This inserts another timestamp at the same
5571 location where the clock was last started.  It also directly computes
5572 the resulting time in inserts it after the time range as @samp{=>
5573 HH:MM}.  See the variable @code{org-log-note-clock-out} for the
5574 possibility to record an additional note together with the clock-out
5575 timestamp@footnote{The corresponding in-buffer setting is:
5576 @code{#+STARTUP: lognoteclock-out}}.
5577 @kindex C-c C-x C-e
5578 @item C-c C-x C-e
5579 Update the effort estimate for the current clock task.
5580 @kindex C-c C-y
5581 @kindex C-c C-c
5582 @item C-c C-y @ @ @r{or}@ @ C-c C-c
5583 Recompute the time interval after changing one of the timestamps.  This
5584 is only necessary if you edit the timestamps directly.  If you change
5585 them with @kbd{S-@key{cursor}} keys, the update is automatic.
5586 @kindex C-c C-t
5587 @item C-c C-t
5588 Changing the TODO state of an item to DONE automatically stops the clock
5589 if it is running in this same item.
5590 @kindex C-c C-x C-x
5591 @item C-c C-x C-x
5592 Cancel the current clock.  This is useful if a clock was started by
5593 mistake, or if you ended up working on something else.
5594 @kindex C-c C-x C-j
5595 @item C-c C-x C-j
5596 Jump to the headline of the currently clocked in task.  With a @kbd{C-u}
5597 prefix arg, select the target task from a list of recently clocked tasks.
5598 @kindex C-c C-x C-d
5599 @item C-c C-x C-d
5600 @vindex org-remove-highlights-with-change
5601 Display time summaries for each subtree in the current buffer.  This
5602 puts overlays at the end of each headline, showing the total time
5603 recorded under that heading, including the time of any subheadings. You
5604 can use visibility cycling to study the tree, but the overlays disappear
5605 when you change the buffer (see variable
5606 @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
5607 @kindex C-c C-x C-r
5608 @item C-c C-x C-r
5609 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
5610 report as an Org-mode table into the current file.  When the cursor is
5611 at an existing clock table, just update it.  When called with a prefix
5612 argument, jump to the first clock report in the current document and
5613 update it.
5614 @cindex #+BEGIN, clocktable
5615 @example
5616 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
5617 #+END: clocktable
5618 @end example
5619 @noindent
5620 If such a block already exists at point, its content is replaced by the
5621 new table.  The @samp{BEGIN} line can specify options:
5622 @example
5623 :maxlevel    @r{Maximum level depth to which times are listed in the table.}
5624 :emphasize   @r{When @code{t}, emphasize level one and level two items.}
5625 :scope       @r{The scope to consider.  This can be any of the following:}
5626              nil        @r{the current buffer or narrowed region}
5627              file       @r{the full current buffer}
5628              subtree    @r{the subtree where the clocktable is located}
5629              tree@var{N}      @r{the surrounding level @var{N} tree, for example @code{tree3}}
5630              tree       @r{the surrounding level 1 tree}
5631              agenda     @r{all agenda files}
5632              ("file"..) @r{scan these files}
5633              file-with-archives    @r{current file and its archives}
5634              agenda-with-archives  @r{all agenda files, including archives}
5635 :block       @r{The time block to consider.  This block is specified either}
5636              @r{absolute, or relative to the current time and may be any of}
5637              @r{these formats:}
5638              2007-12-31    @r{New year eve 2007}
5639              2007-12       @r{December 2007}
5640              2007-W50      @r{ISO-week 50 in 2007}
5641              2007          @r{the year 2007}
5642              today, yesterday, today-@var{N}          @r{a relative day}
5643              thisweek, lastweek, thisweek-@var{N}     @r{a relative week}
5644              thismonth, lastmonth, thismonth-@var{N}  @r{a relative month}
5645              thisyear, lastyear, thisyear-@var{N}     @r{a relative year}
5646              @r{Use @kbd{S-@key{left}/@key{right}} keys to shift the time interval.}
5647 :tstart      @r{A time string specifying when to start considering times.}
5648 :tend        @r{A time string specifying when to stop considering times.}
5649 :step        @r{@code{week} or @code{day}, to split the table into chunks.}
5650              @r{To use this, @code{:block} or @code{:tstart}, @code{:tend} are needed.}
5651 :stepskip0   @r{Don't show steps that have zero time}
5652 :tags        @r{A tags match to select entries that should contribute}
5653 :link        @r{Link the item headlines in the table to their origins.}
5654 :formula     @r{Content of a @code{#+TBLFM} line to be added and evaluated.}
5655              @r{As a special case, @samp{:formula %} adds a column with % time.}
5656              @r{If you do not specify a formula here, any existing formula.}
5657              @r{below the clock table will survive updates and be evaluated.}
5658 :timestamp   @r{A timestamp for the entry, when available.  Look for SCHEDULED,}
5659              @r{DEADLINE, TIMESTAMP and TIMESTAMP_IA, in this order.}
5660 @end example
5661 To get a clock summary of the current level 1 tree, for the current
5662 day, you could write
5663 @example
5664 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
5665 #+END: clocktable
5666 @end example
5667 @noindent
5668 and to use a specific time range you could write@footnote{Note that all
5669 parameters must be specified in a single line---the line is broken here
5670 only to fit it into the manual.}
5671 @example
5672 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
5673                     :tend "<2006-08-10 Thu 12:00>"
5674 #+END: clocktable
5675 @end example
5676 A summary of the current subtree with % times would be
5677 @example
5678 #+BEGIN: clocktable :scope subtree :link t :formula %
5679 #+END: clocktable
5680 @end example
5681 @kindex C-c C-c
5682 @item C-c C-c
5683 @kindex C-c C-x C-u
5684 @itemx C-c C-x C-u
5685 Update dynamic block at point.  The cursor needs to be in the
5686 @code{#+BEGIN} line of the dynamic block.
5687 @kindex C-u C-c C-x C-u
5688 @item C-u C-c C-x C-u
5689 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
5690 you have several clock table blocks in a buffer.
5691 @kindex S-@key{left}
5692 @kindex S-@key{right}
5693 @item S-@key{left}
5694 @itemx S-@key{right}
5695 Shift the current @code{:block} interval and update the table.  The cursor
5696 needs to be in the @code{#+BEGIN: clocktable} line for this command.  If
5697 @code{:block} is @code{today}, it will be shifted to @code{today-1} etc.
5698 @end table
5700 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
5701 the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
5702 worked on or closed during a day.
5704 @node Resolving idle time, Effort estimates, Clocking work time, Dates and Times
5705 @section Resolving idle time
5706 @cindex resolve idle time
5708 @cindex idle, resolve, dangling
5709 If you clock in on a work item, and then walk away from your
5710 computer---perhaps to take a phone call---you often need to ``resolve'' the
5711 time you were away by either subtracting it from the current clock, or
5712 applying it to another one.
5714 @vindex org-clock-idle-time
5715 By customizing the variable @code{org-clock-idle-time} to some integer, such
5716 as 10 or 15, Emacs can alert you when you get back to your computer after
5717 being idle for that many minutes@footnote{On computers using Mac OS X,
5718 idleness is based on actual user idleness, not just Emacs' idle time.  For
5719 X11, you can install a utility program @file{x11idle.c}, available in the
5720 UTILITIES directory of the Org git distribution, to get the same general
5721 treatment of idleness.  On other systems, idle time refers to Emacs idle time
5722 only.}, and ask what you want to do with the idle time.  There will be a
5723 question waiting for you when you get back, indicating how much idle time has
5724 passed (constantly updated with the current amount), as well as a set of
5725 choices to correct the discrepancy:
5727 @table @kbd
5728 @item k
5729 To keep some or all of the minutes and stay clocked in, press @kbd{k}.  Org
5730 will ask how many of the minutes to keep.  Press @key{RET} to keep them all,
5731 effectively changing nothing, or enter a number to keep that many minutes.
5732 @item K
5733 If you use the shift key and press @kbd{K}, it will keep however many minutes
5734 you request and then immediately clock out of that task.  If you keep all of
5735 the minutes, this is the same as just clocking out of the current task.
5736 @item s
5737 To keep none of the minutes, use @kbd{s} to subtract all the away time from
5738 the clock, and then check back in from the moment you returned.
5739 @item S
5740 To keep none of the minutes and just clock out at the start of the away time,
5741 use the shift key and press @kbd{S}.  Remember that using shift will always
5742 leave you clocked out, no matter which option you choose.
5743 @item C
5744 To cancel the clock altogether, use @kbd{C}.  Note that if instead of
5745 canceling you subtract the away time, and the resulting clock amount is less
5746 than a minute, the clock will still be canceled rather than clutter up the
5747 log with an empty entry.
5748 @end table
5750 What if you subtracted those away minutes from the current clock, and now
5751 want to apply them to a new clock?  Simply clock in to any task immediately
5752 after the subtraction.  Org will notice that you have subtracted time ``on
5753 the books'', so to speak, and will ask if you want to apply those minutes to
5754 the next task you clock in on.
5756 There is one other instance when this clock resolution magic occurs.  Say you
5757 were clocked in and hacking away, and suddenly your cat chased a mouse who
5758 scared a hamster that crashed into your UPS's power button!  You suddenly
5759 lose all your buffers, but thanks to auto-save you still have your recent Org
5760 mode changes, including your last clock in.
5762 If you restart Emacs and clock into any task, Org will notice that you have a
5763 dangling clock which was never clocked out from your last session.  Using
5764 that clock's starting time as the beginning of the unaccounted-for period,
5765 Org will ask how you want to resolve that time.  The logic and behavior is
5766 identical to dealing with away time due to idleness, it's just happening due
5767 to a recovery event rather than a set amount of idle time.
5769 You can also check all the files visited by your Org agenda for dangling
5770 clocks at any time using @kbd{M-x org-resolve-clocks}.
5772 @node Effort estimates, Relative timer, Resolving idle time, Dates and Times
5773 @section Effort estimates
5774 @cindex effort estimates
5776 @cindex property, Effort
5777 @vindex org-effort-property
5778 If you want to plan your work in a very detailed way, or if you need to
5779 produce offers with quotations of the estimated work effort, you may want to
5780 assign effort estimates to entries.  If you are also clocking your work, you
5781 may later want to compare the planned effort with the actual working time, a
5782 great way to improve planning estimates.  Effort estimates are stored in a
5783 special property @samp{Effort}@footnote{You may change the property being
5784 used with the variable @code{org-effort-property}.}.  You can set the effort
5785 for an entry with the following commands:
5787 @table @kbd
5788 @kindex C-c C-x e
5789 @item C-c C-x e
5790 Set the effort estimate for the current entry.  With a numeric prefix
5791 argument, set it to the NTH allowed value (see below).  This command is also
5792 accessible from the agenda with the @kbd{e} key.
5793 @kindex C-c C-x C-e
5794 @item C-c C-x C-e
5795 Modify the effort estimate of the item currently being clocked.
5796 @end table
5798 Clearly the best way to work with effort estimates is through column view
5799 (@pxref{Column view}).  You should start by setting up discrete values for
5800 effort estimates, and a @code{COLUMNS} format that displays these values
5801 together with clock sums (if you want to clock your time).  For a specific
5802 buffer you can use
5804 @example
5805 #+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00 8:00
5806 #+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort)@{:@} %CLOCKSUM
5807 @end example
5809 @noindent
5810 @vindex org-global-properties
5811 @vindex org-columns-default-format
5812 or, even better, you can set up these values globally by customizing the
5813 variables @code{org-global-properties} and @code{org-columns-default-format}.
5814 In particular if you want to use this setup also in the agenda, a global
5815 setup may be advised.
5817 The way to assign estimates to individual items is then to switch to column
5818 mode, and to use @kbd{S-@key{right}} and @kbd{S-@key{left}} to change the
5819 value.  The values you enter will immediately be summed up in the hierarchy.
5820 In the column next to it, any clocked time will be displayed.
5822 @vindex org-agenda-columns-add-appointments-to-effort-sum
5823 If you switch to column view in the daily/weekly agenda, the effort column
5824 will summarize the estimated work effort for each day@footnote{Please note
5825 the pitfalls of summing hierarchical data in a flat list (@pxref{Agenda
5826 column view}).}, and you can use this to find space in your schedule.  To get
5827 an overview of the entire part of the day that is committed, you can set the
5828 option @code{org-agenda-columns-add-appointments-to-effort-sum}.  The
5829 appointments on a day that take place over a specified time interval will
5830 then also be added to the load estimate of the day.
5832 Effort estimates can be used in secondary agenda filtering that is triggered
5833 with the @kbd{/} key in the agenda (@pxref{Agenda commands}).  If you have
5834 these estimates defined consistently, two or three key presses will narrow
5835 down the list to stuff that fits into an available time slot.
5837 @node Relative timer,  , Effort estimates, Dates and Times
5838 @section Taking notes with a relative timer
5839 @cindex relative timer
5841 When taking notes during, for example, a meeting or a video viewing, it can
5842 be useful to have access to times relative to a starting time.  Org provides
5843 such a relative timer and make it easy to create timed notes.
5845 @table @kbd
5846 @kindex C-c C-x .
5847 @item C-c C-x .
5848 Insert a relative time into the buffer.  The first time you use this, the
5849 timer will be started.  When called with a prefix argument, the timer is
5850 restarted.
5851 @kindex C-c C-x -
5852 @item C-c C-x -
5853 Insert a description list item with the current relative time.  With a prefix
5854 argument, first reset the timer to 0.
5855 @kindex M-@key{RET}
5856 @item M-@key{RET}
5857 Once the timer list is started, you can also use @kbd{M-@key{RET}} to insert
5858 new timer items.
5859 @kindex C-c C-x ,
5860 @item C-c C-x ,
5861 Pause the timer, or continue it if it is already paused.
5862 @c removed the sentence because it is redundant to the following item
5863 @kindex C-u C-c C-x ,
5864 @item C-u C-c C-x ,
5865 Stop the timer.  After this, you can only start a new timer, not continue the
5866 old one.  This command also removes the timer from the mode line.
5867 @kindex C-c C-x 0
5868 @item C-c C-x 0
5869 Reset the timer without inserting anything into the buffer.  By default, the
5870 timer is reset to 0.  When called with a @kbd{C-u} prefix, reset the timer to
5871 specific starting offset.  The user is prompted for the offset, with a
5872 default taken from a timer string at point, if any, So this can be used to
5873 restart taking notes after a break in the process.  When called with a double
5874 prefix argument @kbd{C-u C-u}, change all timer strings in the active region
5875 by a certain amount.  This can be used to fix timer strings if the timer was
5876 not started at exactly the right moment.
5877 @end table
5879 @node Capture - Refile - Archive, Agenda Views, Dates and Times, Top
5880 @chapter Capture - Refile - Archive
5881 @cindex capture
5883 An important part of any organization system is the ability to quickly
5884 capture new ideas and tasks, and to associate reference material with them.
5885 Org does this using a process called @i{capture}.  It also can store files
5886 related to a task (@i{attachments}) in a special directory.  Once in the
5887 system, tasks and projects need to be moved around.  Moving completed project
5888 trees to an archive file keeps the system compact and fast.
5890 @menu
5891 * Capture::                     Capturing new stuff
5892 * Attachments::                 Add files to tasks
5893 * RSS Feeds::                   Getting input from RSS feeds
5894 * Protocols::                   External (e.g. Browser) access to Emacs and Org
5895 * Refiling notes::              Moving a tree from one place to another
5896 * Archiving::                   What to do with finished projects
5897 @end menu
5899 @node Capture, Attachments, Capture - Refile - Archive, Capture - Refile - Archive
5900 @section Capture
5901 @cindex capture
5903 Org's method for capturing new items is heavily inspired by John Wiegley
5904 excellent remember package.  Up to version 6.36 Org used a special setup
5905 for @file{remember.el}.  @file{org-remember.el} is still part of Org-mode for
5906 backward compatibility with existing setups.  You can find the documentation
5907 for org-remember at @url{http://orgmode.org/org-remember.pdf}.
5909 The new capturing setup described here is preferred and should be used by new
5910 users.  To convert your @code{org-remember-templates}, run the command
5911 @example
5912 @kbd{M-x org-capture-import-remember-templates @key{RET}}
5913 @end example
5914 @noindent and then customize the new variable with @kbd{M-x
5915 customize-variable org-capture-templates}, check the result, and save the
5916 customization.  You can then use both remember and capture until
5917 you are familiar with the new mechanism.
5919 Capture lets you quickly store notes with little interruption of your work
5920 flow.  The basic process of capturing is very similar to remember, but Org
5921 does enhance it with templates and more.
5923 @menu
5924 * Setting up capture::          Where notes will be stored
5925 * Using capture::               Commands to invoke and terminate capture
5926 * Capture templates::           Define the outline of different note types
5927 @end menu
5929 @node Setting up capture, Using capture, Capture, Capture
5930 @subsection Setting up capture
5932 The following customization sets a default target file for notes, and defines
5933 a global key@footnote{Please select your own key, @kbd{C-c c} is only a
5934 suggestion.}  for capturing new material.
5936 @vindex org-default-notes-file
5937 @example
5938 (setq org-default-notes-file (concat org-directory "/notes.org"))
5939 (define-key global-map "\C-cc" 'org-capture)
5940 @end example
5942 @node Using capture, Capture templates, Setting up capture, Capture
5943 @subsection Using capture
5945 @table @kbd
5946 @kindex C-c c
5947 @item C-c c
5948 Call the command @code{org-capture}.  If you have templates defined
5949 @pxref{Capture templates}, it will offer these templates for selection or use
5950 a new Org outline node as the default template.  It will insert the template
5951 into the target file and switch to an indirect buffer narrowed to this new
5952 node.  You may then insert the information you want.
5954 @kindex C-c C-c
5955 @item C-c C-c
5956 Once you have finished entering information into the capture buffer, 
5957 @kbd{C-c C-c} will return you to the window configuration before the capture
5958 process, so that you can resume your work without further distraction.
5960 @kindex C-c C-w
5961 @item C-c C-w
5962 Finalize the capture process by refiling (@pxref{Refiling notes}) the note to
5963 a different place.
5965 @kindex C-c C-k
5966 @item C-c C-k
5967 Abort the capture process and return to the previous state.
5968 @end table
5970 You can also call @code{org-capture} in a special way from the agenda, using
5971 the @kbd{k c} key combination.  With this access, any timestamps inserted by
5972 the selected capture template will default to the cursor date in the agenda,
5973 rather than to the current date.
5975 @node Capture templates,  , Using capture, Capture
5976 @subsection Capture templates
5977 @cindex templates, for Capture
5979 You can use templates for different types of capture items, and
5980 for different target locations.  The easiest way to create such templates is
5981 through the customize interface.
5983 @table @kbd
5984 @kindex C-c c C
5985 @item C-c c C
5986 Customize the variable @code{org-capture-templates}.
5987 @end table
5989 Before we give the formal description of template definitions, let's look at
5990 an example.  Say you would like to use one template to create general TODO
5991 entries, and you want to put these entries under the heading @samp{Tasks} in
5992 your file @file{~/org/gtd.org}.  Also, a date tree in the file
5993 @file{journal.org} should capture journal entries.  A possible configuration
5994 would look like:
5996 @example
5997 (setq org-capture-templates
5998  '(("t" "Todo" entry (file+headline "~/org/gtd.org" "Tasks")
5999         "* TODO %?\n  %i\n  %a")
6000    ("j" "Journal" entry (file+datetree "~/org/journal.org")
6001         "* %?\nEntered on %U\n  %i\n  %a")))
6002 @end example
6004 @noindent If you then press @kbd{C-c c t}, Org will prepare the template
6005 for you like this:
6006 @example
6007 * TODO
6008   [[file:@var{link to where you initiated capture}]]
6009 @end example
6011 @noindent
6012 During expansion of the template, @code{%a} has been replaced by a link to
6013 the location from where you called the capture command.  This can be
6014 extremely useful for deriving tasks from emails, for example.  You fill in
6015 the task definition, press @code{C-c C-c} and Org returns you to the same
6016 place where you started the capture process.
6019 @menu
6020 * Template elements::           What is needed for a complete template entry
6021 * Template expansion::          Filling in information about time and context
6022 @end menu
6024 @node Template elements, Template expansion, Capture templates, Capture templates
6025 @subsubsection Template elements
6027 Now lets look at the elements of a template definition.  Each entry in
6028 @code{org-capture-templates} is a list with the following items: 
6030 @table @var
6031 @item keys
6032 The keys that will select the template, as a string, characters
6033 only, for example @code{"a"} for a template to be selected with a
6034 single key, or @code{"bt"} for selection with two keys.  When using
6035 several keys, keys using the same prefix key must be sequential 
6036 in the list and preceded by a 2-element entry explaining the
6037 prefix key, for example
6038 @example
6039          ("b" "Templates for marking stuff to buy")
6040 @end example
6041 @noindent If you do not define a template for the @kbd{C} key, this key will
6042 be used to open the customize buffer for this complex variable.
6044 @item description
6045 A short string describing the template, which will be shown during
6046 selection.
6048 @item type
6049 The type of entry, a symbol.  Valid values are:
6050 @table @code
6051 @item entry
6052 An Org-mode node, with a headline. Will be filed as the child of the
6053 target entry or as a top-level entry.  The target file should be an Org-mode
6054 file.
6055 @item item
6056 A plain list item, placed in the first plain  list at the target
6057 location.  Again the target file should be an Org file.
6058 @item checkitem
6059 A checkbox item.  This only differs from the plain list item by the
6060 default template.
6061 @item table-line
6062 a new line in the first table at the target location.  Where exactly the
6063 line will be inserted depends on the properties @code{:prepend} and
6064 @code{:table-line-pos} (see below).
6065 @item plain
6066 Text to be inserted as it is.
6067 @end table
6069 @item target
6070 @vindex org-default-notes-file
6071 Specification of where the captured item should be placed.  In Org-mode
6072 files, targets usually define a node.  Entries will become children of this
6073 node, other types will be added to the table or list in the body of this
6074 node.  Most target specifications contain a file name.  If that file name is
6075 the empty string, it defaults to @code{org-default-notes-file}.
6077 Valid values are:
6078 @table @code
6079 @item (file "path/to/file")
6080 Text will be placed at the beginning or end of that file.
6082 @item (id "id of existing org entry")
6083 Filing as child of this entry, or in the body of the entry.
6085 @item (file+headline "path/to/file" "node headline")
6086 Fast configuration if the target heading is unique in the file.
6088 @item (file+olp "path/to/file" "Level 1 heading" "Level 2" ...)
6089 For non-unique headings, the full path is safer.
6091 @item (file+regexp  "path/to/file" "regexp to find location")
6092 Use a regular expression to position the cursor.
6094 @item (file+datetree "path/to/file")
6095 Will create a heading in a date tree.
6097 @item (file+function "path/to/file" function-finding-location)
6098 A function to find the right location in the file.
6100 @item (clock)
6101 File to the entry that is currently being clocked.
6103 @item (function function-finding-location)
6104 Most general way, write your own function to find both
6105 file and location.
6106 @end table
6108 @item template
6109 The template for creating the capture item.  If you leave this empty, an
6110 appropriate default template will be used.  Otherwise this is a string with
6111 escape codes, which will be replaced depending on time and context of the
6112 capture call.  The string with escapes may be loaded from a template file,
6113 using the special syntax @code{(file "path/to/template")}.  See below for
6114 more details.
6116 @item properties
6117 The rest of the entry is a property list of additional options.
6118 Recognized properties are:
6119 @table @code
6120 @item :prepend
6121 Normally new captured information will be appended at
6122 the target location (last child, last table line, last list item...).
6123 Setting this property will change that.
6125 @item :immediate-finish
6126 When set, do not offer to edit the information, just
6127 file it away immediately.  This makes sense if the template only needs
6128 information that can be added automatically.
6130 @item :empty-lines
6131 Set this to the number of lines to insert
6132 before and after the new item.  Default 0, only common other value is 1.
6134 @item :clock-in
6135 Start the clock in this item.
6137 @item :clock-resume
6138 If starting the capture interrupted a clock, restart that clock when finished
6139 with the capture.
6141 @item :unnarrowed
6142 Do not narrow the target buffer, simply show the full buffer.  Default is to
6143 narrow it so that you only see the new material.
6144 @end table
6145 @end table
6147 @node Template expansion,  , Template elements, Capture templates
6148 @subsubsection Template expansion
6150 In the template itself, special @kbd{%}-escapes@footnote{If you need one of
6151 these sequences literally, escape the @kbd{%} with a backslash.}  allow
6152 dynamic insertion of content:
6154 @comment SJE: should these sentences terminate in period?
6155 @smallexample
6156 %^@{@var{prompt}@}  @r{prompt the user for a string and replace this sequence with it.}
6157             @r{You may specify a default value and a completion table with}
6158             @r{%^@{prompt|default|completion2|completion3...@}}
6159             @r{The arrow keys access a prompt-specific history.}
6160 %a          @r{annotation, normally the link created with @code{org-store-link}}
6161 %A          @r{like @code{%a}, but prompt for the description part}
6162 %i          @r{initial content, the region when capture is called while the}
6163             @r{region is active.}
6164             @r{The entire text will be indented like @code{%i} itself.}
6165 %t          @r{timestamp, date only}
6166 %T          @r{timestamp with date and time}
6167 %u, %U      @r{like the above, but inactive timestamps}
6168 %^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
6169             @r{You may define a prompt like @code{%^@{Birthday@}t}}
6170 %n          @r{user name (taken from @code{user-full-name})}
6171 %c          @r{Current kill ring head.}
6172 %x          @r{Content of the X clipboard.}
6173 %^C         @r{Interactive selection of which kill or clip to use.}
6174 %^L         @r{Like @code{%^C}, but insert as link.}
6175 %k          @r{title of the currently clocked task}
6176 %K          @r{link to the currently clocked task}
6177 %^g         @r{prompt for tags, with completion on tags in target file.}
6178 %^G         @r{prompt for tags, with completion all tags in all agenda files.}
6179 %^@{@var{prop}@}p   @r{Prompt the user for a value for property @var{prop}}
6180 %:keyword   @r{specific information for certain link types, see below}
6181 %[@var{file}]     @r{insert the contents of the file given by @var{file}}
6182 %(@var{sexp})     @r{evaluate Elisp @var{sexp} and replace with the result}
6183 @end smallexample
6185 @noindent
6186 For specific link types, the following keywords will be
6187 defined@footnote{If you define your own link types (@pxref{Adding
6188 hyperlink types}), any property you store with
6189 @code{org-store-link-props} can be accessed in capture templates in a
6190 similar way.}:
6192 @vindex org-from-is-user-regexp
6193 @smallexample
6194 Link type          |  Available keywords
6195 -------------------+----------------------------------------------
6196 bbdb               |  %:name %:company
6197 bbdb               |  %::server %:port %:nick
6198 vm, wl, mh, rmail  |  %:type %:subject %:message-id
6199                    |  %:from %:fromname %:fromaddress
6200                    |  %:to   %:toname   %:toaddress
6201                    |  %: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}.}}
6202 gnus               |  %:group, @r{for messages also all email fields}
6203 w3, w3m            |  %:url
6204 info               |  %:file %:node
6205 calendar           |  %:date
6206 @end smallexample
6208 @noindent
6209 To place the cursor after template expansion use:
6211 @smallexample
6212 %?          @r{After completing the template, position cursor here.}
6213 @end smallexample
6216 @node Attachments, RSS Feeds, Capture, Capture - Refile - Archive
6217 @section Attachments
6218 @cindex attachments
6220 @vindex org-attach-directory
6221 It is often useful to associate reference material with an outline node/task.
6222 Small chunks of plain text can simply be stored in the subtree of a project.
6223 Hyperlinks (@pxref{Hyperlinks}) can establish associations with
6224 files that live elsewhere on your computer or in the cloud, like emails or
6225 source code files belonging to a project.  Another method is @i{attachments},
6226 which are files located in a directory belonging to an outline node.  Org
6227 uses directories named by the unique ID of each entry.  These directories are
6228 located in the @file{data} directory which lives in the same directory where
6229 your Org file lives@footnote{If you move entries or Org files from one
6230 directory to another, you may want to configure @code{org-attach-directory}
6231 to contain an absolute path.}.  If you initialize this directory with
6232 @code{git init}, Org will automatically commit changes when it sees them.
6233 The attachment system has been contributed to Org by John Wiegley.
6235 In cases where it seems better to do so, you can also attach a directory of your
6236 choice to an entry.  You can also make children inherit the attachment
6237 directory from a parent, so that an entire subtree uses the same attached
6238 directory.
6240 @noindent The following commands deal with attachments:
6242 @table @kbd
6244 @kindex C-c C-a
6245 @item C-c C-a
6246 The dispatcher for commands related to the attachment system.  After these
6247 keys, a list of commands is displayed and you must press an additional key
6248 to select a command:
6250 @table @kbd
6251 @kindex C-c C-a a
6252 @item a
6253 @vindex org-attach-method
6254 Select a file and move it into the task's attachment directory.  The file
6255 will be copied, moved, or linked, depending on @code{org-attach-method}.
6256 Note that hard links are not supported on all systems.
6258 @kindex C-c C-a c
6259 @kindex C-c C-a m
6260 @kindex C-c C-a l
6261 @item c/m/l
6262 Attach a file using the copy/move/link method.
6263 Note that hard links are not supported on all systems.
6265 @kindex C-c C-a n
6266 @item n
6267 Create a new attachment as an Emacs buffer.
6269 @kindex C-c C-a z
6270 @item z
6271 Synchronize the current task with its attachment directory, in case you added
6272 attachments yourself.
6274 @kindex C-c C-a o
6275 @item o
6276 @vindex org-file-apps
6277 Open current task's attachment.  If there is more than one, prompt for a
6278 file name first.  Opening will follow the rules set by @code{org-file-apps}.
6279 For more details, see the information on following hyperlinks
6280 (@pxref{Handling links}).
6282 @kindex C-c C-a O
6283 @item O
6284 Also open the attachment, but force opening the file in Emacs.
6286 @kindex C-c C-a f
6287 @item f
6288 Open the current task's attachment directory.
6290 @kindex C-c C-a F
6291 @item F
6292 Also open the directory, but force using @command{dired} in Emacs.
6294 @kindex C-c C-a d
6295 @item d
6296 Select and delete a single attachment.
6298 @kindex C-c C-a D
6299 @item D
6300 Delete all of a task's attachments.  A safer way is to open the directory in
6301 @command{dired} and delete from there.
6303 @kindex C-c C-a s
6304 @item C-c C-a s
6305 @cindex property, ATTACH_DIR
6306 Set a specific directory as the entry's attachment directory.  This works by
6307 putting the directory path into the @code{ATTACH_DIR} property.
6309 @kindex C-c C-a i
6310 @item C-c C-a i
6311 @cindex property, ATTACH_DIR_INHERIT
6312 Set the @code{ATTACH_DIR_INHERIT} property, so that children will use the
6313 same directory for attachments as the parent does.
6314 @end table
6315 @end table
6317 @node RSS Feeds, Protocols, Attachments, Capture - Refile - Archive
6318 @section RSS feeds
6319 @cindex RSS feeds
6320 @cindex Atom feeds
6322 Org can add and change entries based on information found in RSS feeds and
6323 Atom feeds.  You could use this to make a task out of each new podcast in a
6324 podcast feed.  Or you could use a phone-based note-creating service on the
6325 web to import tasks into Org.  To access feeds, configure the variable
6326 @code{org-feed-alist}.  The docstring of this variable has detailed
6327 information.  Here is just an example:
6329 @example
6330 (setq org-feed-alist
6331      '(("Slashdot"
6332          "http://rss.slashdot.org/Slashdot/slashdot"
6333          "~/txt/org/feeds.org" "Slashdot Entries")))
6334 @end example
6336 @noindent
6337 will configure that new items from the feed provided by
6338 @code{rss.slashdot.org} will result in new entries in the file
6339 @file{~/org/feeds.org} under the heading @samp{Slashdot Entries}, whenever
6340 the following command is used:
6342 @table @kbd
6343 @kindex C-c C-x g
6344 @item C-c C-x g
6345 Collect items from the feeds configured in @code{org-feed-alist} and act upon
6346 them.
6347 @kindex C-c C-x G
6348 @item C-c C-x G
6349 Prompt for a feed name and go to the inbox configured for this feed.
6350 @end table
6352 Under the same headline, Org will create a drawer @samp{FEEDSTATUS} in which
6353 it will store information about the status of items in the feed, to avoid
6354 adding the same item several times.  You should add @samp{FEEDSTATUS} to the
6355 list of drawers in that file:
6357 @example
6358 #+DRAWERS: LOGBOOK PROPERTIES FEEDSTATUS
6359 @end example
6361 For more information, including how to read atom feeds, see
6362 @file{org-feed.el} and the docstring of @code{org-feed-alist}.
6364 @node Protocols, Refiling notes, RSS Feeds, Capture - Refile - Archive
6365 @section Protocols for external access
6366 @cindex protocols, for external access
6367 @cindex emacsserver
6369 You can set up Org for handling protocol calls from outside applications that
6370 are passed to Emacs through the @file{emacsserver}.  For example, you can
6371 configure bookmarks in your web browser to send a link to the current page to
6372 Org and create a note from it using capture (@pxref{Capture}).  Or you
6373 could create a bookmark that will tell Emacs to open the local source file of
6374 a remote website you are looking at with the browser.  See
6375 @uref{http://orgmode.org/worg/org-contrib/org-protocol.php} for detailed
6376 documentation and setup instructions.
6378 @node Refiling notes, Archiving, Protocols, Capture - Refile - Archive
6379 @section Refiling notes
6380 @cindex refiling notes
6382 When reviewing the captured data, you may want to refile some of the entries
6383 into a different list, for example into a project.  Cutting, finding the
6384 right location, and then pasting the note is cumbersome.  To simplify this
6385 process, you can use the following special command:
6387 @table @kbd
6388 @kindex C-c C-w
6389 @item C-c C-w
6390 @vindex org-reverse-note-order
6391 @vindex org-refile-targets
6392 @vindex org-refile-use-outline-path
6393 @vindex org-outline-path-complete-in-steps
6394 @vindex org-refile-allow-creating-parent-nodes
6395 @vindex org-log-refile
6396 @vindex org-refile-use-cache
6397 Refile the entry or region at point.  This command offers possible locations
6398 for refiling the entry and lets you select one with completion.  The item (or
6399 all items in the region) is filed below the target heading as a subitem.
6400 Depending on @code{org-reverse-note-order}, it will be either the first or
6401 last subitem.@*
6402 By default, all level 1 headlines in the current buffer are considered to be
6403 targets, but you can have more complex definitions across a number of files.
6404 See the variable @code{org-refile-targets} for details.  If you would like to
6405 select a location via a file-path-like completion along the outline path, see
6406 the variables @code{org-refile-use-outline-path} and
6407 @code{org-outline-path-complete-in-steps}.  If you would like to be able to
6408 create new nodes as new parents for refiling on the fly, check the
6409 variable @code{org-refile-allow-creating-parent-nodes}.
6410 When the variable @code{org-log-refile}@footnote{with corresponding
6411 @code{#+STARTUP} keywords @code{logrefile}, @code{lognoterefile},
6412 and @code{nologrefile}} is set, a time stamp or a note will be
6413 recorded when an entry has been refiled.
6414 @kindex C-u C-c C-w
6415 @item C-u C-c C-w
6416 Use the refile interface to jump to a heading.
6417 @kindex C-u C-u C-c C-w
6418 @item C-u C-u C-c C-w
6419 Jump to the location where @code{org-refile} last moved a tree to.
6420 @item C-2 C-c C-w
6421 Refile as the child of the item currently being clocked.
6422 @item C-0 C-c C-w @ @r{or} @ C-u C-u C-u C-c C-w
6423 Clear the target cache.  Caching of refile targets can be turned on by
6424 setting @code{org-refile-use-cache}.  To make the command seen new possible
6425 targets, you have to clear the cache with this command.
6426 @end table
6428 @node Archiving,  , Refiling notes, Capture - Refile - Archive
6429 @section Archiving
6430 @cindex archiving
6432 When a project represented by a (sub)tree is finished, you may want
6433 to move the tree out of the way and to stop it from contributing to the
6434 agenda.  Archiving is important to keep your working files compact and global
6435 searches like the construction of agenda views fast.
6437 @table @kbd
6438 @kindex C-c C-x C-a
6439 @item C-c C-x C-a
6440 @vindex org-archive-default-command
6441 Archive the current entry using the command specified in the variable
6442 @code{org-archive-default-command}.
6443 @end table
6445 @menu
6446 * Moving subtrees::             Moving a tree to an archive file
6447 * Internal archiving::          Switch off a tree but keep it in the file
6448 @end menu
6450 @node Moving subtrees, Internal archiving, Archiving, Archiving
6451 @subsection Moving a tree to the archive file
6452 @cindex external archiving
6454 The most common archiving action is to move a project tree to another file,
6455 the archive file.
6457 @table @kbd
6458 @kindex C-c $
6459 @kindex C-c C-x C-s
6460 @item C-c C-x C-s@ @r{or short} @ C-c $
6461 @vindex org-archive-location
6462 Archive the subtree starting at the cursor position to the location
6463 given by @code{org-archive-location}.
6464 @kindex C-u C-c C-x C-s
6465 @item C-u C-c C-x C-s
6466 Check if any direct children of the current headline could be moved to
6467 the archive.  To do this, each subtree is checked for open TODO entries.
6468 If none are found, the command offers to move it to the archive
6469 location.  If the cursor is @emph{not} on a headline when this command
6470 is invoked, the level 1 trees will be checked.
6471 @end table
6473 @cindex archive locations
6474 The default archive location is a file in the same directory as the
6475 current file, with the name derived by appending @file{_archive} to the
6476 current file name.  For information and examples on how to change this,
6477 see the documentation string of the variable
6478 @code{org-archive-location}.  There is also an in-buffer option for
6479 setting this variable, for example@footnote{For backward compatibility,
6480 the following also works: If there are several such lines in a file,
6481 each specifies the archive location for the text below it.  The first
6482 such line also applies to any text before its definition.  However,
6483 using this method is @emph{strongly} deprecated as it is incompatible
6484 with the outline structure of the document.  The correct method for
6485 setting multiple archive locations in a buffer is using properties.}:
6487 @cindex #+ARCHIVE
6488 @example
6489 #+ARCHIVE: %s_done::
6490 @end example
6492 @cindex property, ARCHIVE
6493 @noindent
6494 If you would like to have a special ARCHIVE location for a single entry
6495 or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
6496 location as the value (@pxref{Properties and Columns}).
6498 @vindex org-archive-save-context-info
6499 When a subtree is moved, it receives a number of special properties that
6500 record context information like the file from where the entry came, its
6501 outline path the archiving time etc.  Configure the variable
6502 @code{org-archive-save-context-info} to adjust the amount of information
6503 added.
6506 @node Internal archiving,  , Moving subtrees, Archiving
6507 @subsection Internal archiving
6509 If you want to just switch off (for agenda views) certain subtrees without
6510 moving them to a different file, you can use the @code{ARCHIVE tag}.
6512 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
6513 its location in the outline tree, but behaves in the following way:
6514 @itemize @minus
6515 @item
6516 @vindex org-cycle-open-archived-trees
6517 It does not open when you attempt to do so with a visibility cycling
6518 command (@pxref{Visibility cycling}).  You can force cycling archived
6519 subtrees with @kbd{C-@key{TAB}}, or by setting the option
6520 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
6521 @code{show-all} will open archived subtrees.
6522 @item
6523 @vindex org-sparse-tree-open-archived-trees
6524 During sparse tree construction (@pxref{Sparse trees}), matches in
6525 archived subtrees are not exposed, unless you configure the option
6526 @code{org-sparse-tree-open-archived-trees}.
6527 @item
6528 @vindex org-agenda-skip-archived-trees
6529 During agenda view construction (@pxref{Agenda Views}), the content of
6530 archived trees is ignored unless you configure the option
6531 @code{org-agenda-skip-archived-trees}, in which case these trees will always
6532 be included.  In the agenda you can press @kbd{v a} to get archives
6533 temporarily included.
6534 @item
6535 @vindex org-export-with-archived-trees
6536 Archived trees are not exported (@pxref{Exporting}), only the headline
6537 is.  Configure the details using the variable
6538 @code{org-export-with-archived-trees}.
6539 @item
6540 @vindex org-columns-skip-archived-trees
6541 Archived trees are excluded from column view unless the variable
6542 @code{org-columns-skip-archived-trees} is configured to @code{nil}.
6543 @end itemize
6545 The following commands help manage the ARCHIVE tag:
6547 @table @kbd
6548 @kindex C-c C-x a
6549 @item C-c C-x a
6550 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
6551 the headline changes to a shadowed face, and the subtree below it is
6552 hidden.
6553 @kindex C-u C-c C-x a
6554 @item C-u C-c C-x a
6555 Check if any direct children of the current headline should be archived.
6556 To do this, each subtree is checked for open TODO entries.  If none are
6557 found, the command offers to set the ARCHIVE tag for the child.  If the
6558 cursor is @emph{not} on a headline when this command is invoked, the
6559 level 1 trees will be checked.
6560 @kindex C-@kbd{TAB}
6561 @item C-@kbd{TAB}
6562 Cycle a tree even if it is tagged with ARCHIVE.
6563 @kindex C-c C-x A
6564 @item C-c C-x A
6565 Move the current entry to the @emph{Archive Sibling}.  This is a sibling of
6566 the entry with the heading @samp{Archive} and the tag @samp{ARCHIVE}.  The
6567 entry becomes a child of that sibling and in this way retains a lot of its
6568 original context, including inherited tags and approximate position in the
6569 outline.
6570 @end table
6573 @node Agenda Views, Markup, Capture - Refile - Archive, Top
6574 @chapter Agenda views
6575 @cindex agenda views
6577 Due to the way Org works, TODO items, time-stamped items, and
6578 tagged headlines can be scattered throughout a file or even a number of
6579 files.  To get an overview of open action items, or of events that are
6580 important for a particular date, this information must be collected,
6581 sorted and displayed in an organized way.
6583 Org can select items based on various criteria and display them
6584 in a separate buffer.  Seven different view types are provided:
6586 @itemize @bullet
6587 @item
6588 an @emph{agenda} that is like a calendar and shows information
6589 for specific dates,
6590 @item
6591 a @emph{TODO list} that covers all unfinished
6592 action items,
6593 @item
6594 a @emph{match view}, showings headlines based on the tags, properties, and
6595 TODO state associated with them,
6596 @item
6597 a @emph{timeline view} that shows all events in a single Org file,
6598 in time-sorted view,
6599 @item
6600 a @emph{text search view} that shows all entries from multiple files
6601 that contain specified keywords,
6602 @item
6603 a @emph{stuck projects view} showing projects that currently don't move
6604 along, and
6605 @item
6606 @emph{custom views} that are special searches and combinations of different
6607 views.
6608 @end itemize
6610 @noindent
6611 The extracted information is displayed in a special @emph{agenda
6612 buffer}.  This buffer is read-only, but provides commands to visit the
6613 corresponding locations in the original Org files, and even to
6614 edit these files remotely.
6616 @vindex org-agenda-window-setup
6617 @vindex org-agenda-restore-windows-after-quit
6618 Two variables control how the agenda buffer is displayed and whether the
6619 window configuration is restored when the agenda exits:
6620 @code{org-agenda-window-setup} and
6621 @code{org-agenda-restore-windows-after-quit}.
6623 @menu
6624 * Agenda files::                Files being searched for agenda information
6625 * Agenda dispatcher::           Keyboard access to agenda views
6626 * Built-in agenda views::       What is available out of the box?
6627 * Presentation and sorting::    How agenda items are prepared for display
6628 * Agenda commands::             Remote editing of Org trees
6629 * Custom agenda views::         Defining special searches and views
6630 * Exporting Agenda Views::      Writing a view to a file
6631 * Agenda column view::          Using column view for collected entries
6632 @end menu
6634 @node Agenda files, Agenda dispatcher, Agenda Views, Agenda Views
6635 @section Agenda files
6636 @cindex agenda files
6637 @cindex files for agenda
6639 @vindex org-agenda-files
6640 The information to be shown is normally collected from all @emph{agenda
6641 files}, the files listed in the variable
6642 @code{org-agenda-files}@footnote{If the value of that variable is not a
6643 list, but a single file name, then the list of agenda files will be
6644 maintained in that external file.}. If a directory is part of this list,
6645 all files with the extension @file{.org} in this directory will be part
6646 of the list.
6648 Thus, even if you only work with a single Org file, that file should
6649 be put into the list@footnote{When using the dispatcher, pressing
6650 @kbd{<} before selecting a command will actually limit the command to
6651 the current file, and ignore @code{org-agenda-files} until the next
6652 dispatcher command.}.  You can customize @code{org-agenda-files}, but
6653 the easiest way to maintain it is through the following commands
6655 @cindex files, adding to agenda list
6656 @table @kbd
6657 @kindex C-c [
6658 @item C-c [
6659 Add current file to the list of agenda files.  The file is added to
6660 the front of the list.  If it was already in the list, it is moved to
6661 the front.  With a prefix argument, file is added/moved to the end.
6662 @kindex C-c ]
6663 @item C-c ]
6664 Remove current file from the list of agenda files.
6665 @kindex C-,
6666 @kindex C-'
6667 @item C-,
6668 @itemx C-'
6669 Cycle through agenda file list, visiting one file after the other.
6670 @kindex M-x org-iswitchb
6671 @item M-x org-iswitchb
6672 Command to use an @code{iswitchb}-like interface to switch to and between Org
6673 buffers.
6674 @end table
6676 @noindent
6677 The Org menu contains the current list of files and can be used
6678 to visit any of them.
6680 If you would like to focus the agenda temporarily on a file not in
6681 this list, or on just one file in the list, or even on only a subtree in a
6682 file, then this can be done in different ways.  For a single agenda command,
6683 you may press @kbd{<} once or several times in the dispatcher
6684 (@pxref{Agenda dispatcher}).  To restrict the agenda scope for an
6685 extended period, use the following commands:
6687 @table @kbd
6688 @kindex C-c C-x <
6689 @item C-c C-x <
6690 Permanently restrict the agenda to the current subtree.  When with a
6691 prefix argument, or with the cursor before the first headline in a file,
6692 the agenda scope is set to the entire file.  This restriction remains in
6693 effect until removed with @kbd{C-c C-x >}, or by typing either @kbd{<}
6694 or @kbd{>} in the agenda dispatcher.  If there is a window displaying an
6695 agenda view, the new restriction takes effect immediately.
6696 @kindex C-c C-x >
6697 @item C-c C-x >
6698 Remove the permanent restriction created by @kbd{C-c C-x <}.
6699 @end table
6701 @noindent
6702 When working with @file{speedbar.el}, you can use the following commands in
6703 the Speedbar frame:
6704 @table @kbd
6705 @kindex <
6706 @item < @r{in the speedbar frame}
6707 Permanently restrict the agenda to the item---either an Org file or a subtree
6708 in such a file---at the cursor in the Speedbar frame.
6709 If there is a window displaying an agenda view, the new restriction takes
6710 effect immediately.
6711 @kindex >
6712 @item > @r{in the speedbar frame}
6713 Lift the restriction.
6714 @end table
6716 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda Views
6717 @section The agenda dispatcher
6718 @cindex agenda dispatcher
6719 @cindex dispatching agenda commands
6720 The views are created through a dispatcher, which should be bound to a
6721 global key---for example @kbd{C-c a} (@pxref{Installation}).  In the
6722 following we will assume that @kbd{C-c a} is indeed how the dispatcher
6723 is accessed and list keyboard access to commands accordingly.  After
6724 pressing @kbd{C-c a}, an additional letter is required to execute a
6725 command.  The dispatcher offers the following default commands:
6726 @table @kbd
6727 @item a
6728 Create the calendar-like agenda (@pxref{Weekly/daily agenda}).
6729 @item t @r{/} T
6730 Create a list of all TODO items (@pxref{Global TODO list}).
6731 @item m @r{/} M
6732 Create a list of headlines matching a TAGS expression (@pxref{Matching
6733 tags and properties}).
6734 @item L
6735 Create the timeline view for the current buffer (@pxref{Timeline}).
6736 @item s
6737 Create a list of entries selected by a boolean expression of keywords
6738 and/or regular expressions that must or must not occur in the entry.
6739 @item /
6740 @vindex org-agenda-text-search-extra-files
6741 Search for a regular expression in all agenda files and additionally in
6742 the files listed in @code{org-agenda-text-search-extra-files}.  This
6743 uses the Emacs command @code{multi-occur}.  A prefix argument can be
6744 used to specify the number of context lines for each match, default is
6746 @item # @r{/} !
6747 Create a list of stuck projects (@pxref{Stuck projects}).
6748 @item <
6749 Restrict an agenda command to the current buffer@footnote{For backward
6750 compatibility, you can also press @kbd{1} to restrict to the current
6751 buffer.}.  After pressing @kbd{<}, you still need to press the character
6752 selecting the command.
6753 @item < <
6754 If there is an active region, restrict the following agenda command to
6755 the region.  Otherwise, restrict it to the current subtree@footnote{For
6756 backward compatibility, you can also press @kbd{0} to restrict to the
6757 current region/subtree.}.  After pressing @kbd{< <}, you still need to press the
6758 character selecting the command.
6759 @end table
6761 You can also define custom commands that will be accessible through the
6762 dispatcher, just like the default commands.  This includes the
6763 possibility to create extended agenda buffers that contain several
6764 blocks together, for example the weekly agenda, the global TODO list and
6765 a number of special tags matches.  @xref{Custom agenda views}.
6767 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda Views
6768 @section The built-in agenda views
6770 In this section we describe the built-in views.
6772 @menu
6773 * Weekly/daily agenda::         The calendar page with current tasks
6774 * Global TODO list::            All unfinished action items
6775 * Matching tags and properties::  Structured information with fine-tuned search
6776 * Timeline::                    Time-sorted view for single file
6777 * Search view::                 Find entries by searching for text
6778 * Stuck projects::              Find projects you need to review
6779 @end menu
6781 @node Weekly/daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
6782 @subsection The weekly/daily agenda
6783 @cindex agenda
6784 @cindex weekly agenda
6785 @cindex daily agenda
6787 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
6788 paper agenda, showing all the tasks for the current week or day.
6790 @table @kbd
6791 @cindex org-agenda, command
6792 @kindex C-c a a
6793 @item C-c a a
6794 @vindex org-agenda-ndays
6795 Compile an agenda for the current week from a list of Org files.  The agenda
6796 shows the entries for each day.  With a numeric prefix@footnote{For backward
6797 compatibility, the universal prefix @kbd{C-u} causes all TODO entries to be
6798 listed before the agenda.  This feature is deprecated, use the dedicated TODO
6799 list, or a block agenda instead (@pxref{Block agenda}).}  (like @kbd{C-u 2 1
6800 C-c a a}) you may set the number of days to be displayed (see also the
6801 variable @code{org-agenda-ndays})
6802 @end table
6804 Remote editing from the agenda buffer means, for example, that you can
6805 change the dates of deadlines and appointments from the agenda buffer.
6806 The commands available in the Agenda buffer are listed in @ref{Agenda
6807 commands}.
6809 @subsubheading Calendar/Diary integration
6810 @cindex calendar integration
6811 @cindex diary integration
6813 Emacs contains the calendar and diary by Edward M. Reingold.  The
6814 calendar displays a three-month calendar with holidays from different
6815 countries and cultures.  The diary allows you to keep track of
6816 anniversaries, lunar phases, sunrise/set, recurrent appointments
6817 (weekly, monthly) and more.  In this way, it is quite complementary to
6818 Org.  It can be very useful to combine output from Org with
6819 the diary.
6821 In order to include entries from the Emacs diary into Org-mode's
6822 agenda, you only need to customize the variable
6824 @lisp
6825 (setq org-agenda-include-diary t)
6826 @end lisp
6828 @noindent After that, everything will happen automatically.  All diary
6829 entries including holidays, anniversaries, etc., will be included in the
6830 agenda buffer created by Org-mode.  @key{SPC}, @key{TAB}, and
6831 @key{RET} can be used from the agenda buffer to jump to the diary
6832 file in order to edit existing diary entries.  The @kbd{i} command to
6833 insert new entries for the current date works in the agenda buffer, as
6834 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
6835 Sunrise/Sunset times, show lunar phases and to convert to other
6836 calendars, respectively.  @kbd{c} can be used to switch back and forth
6837 between calendar and agenda.
6839 If you are using the diary only for sexp entries and holidays, it is
6840 faster to not use the above setting, but instead to copy or even move
6841 the entries into an Org file. Org-mode evaluates diary-style sexp
6842 entries, and does it faster because there is no overhead for first
6843 creating the diary display.  Note that the sexp entries must start at
6844 the left margin, no whitespace is allowed before them.  For example,
6845 the following segment of an Org file will be processed and entries
6846 will be made in the agenda:
6848 @example
6849 * Birthdays and similar stuff
6850 #+CATEGORY: Holiday
6851 %%(org-calendar-holiday)   ; special function for holiday names
6852 #+CATEGORY: Ann
6853 %%(diary-anniversary  5 14 1956)@footnote{Note that the order of the arguments (month, day, year) depends on the setting of @code{calendar-date-style}.} Arthur Dent is %d years old
6854 %%(diary-anniversary 10  2 1869) Mahatma Gandhi would be %d years old
6855 @end example
6857 @subsubheading Anniversaries from BBDB
6858 @cindex BBDB, anniversaries
6859 @cindex anniversaries, from BBDB
6861 If you are using the Big Brothers Database to store your contacts, you will
6862 very likely prefer to store anniversaries in BBDB rather than in a
6863 separate Org or diary file.  Org supports this and will show BBDB
6864 anniversaries as part of the agenda.  All you need to do is to add the
6865 following to one your your agenda files:
6867 @example
6868 * Anniversaries
6869   :PROPERTIES:
6870   :CATEGORY: Anniv
6871   :END:
6872 %%(org-bbdb-anniversaries)
6873 @end example
6875 You can then go ahead and define anniversaries for a BBDB record.  Basically,
6876 you need to press @kbd{C-o anniversary @key{RET}} with the cursor in a BBDB
6877 record and then add the date in the format @code{YYYY-MM-DD}, followed by a
6878 space and the class of the anniversary (@samp{birthday} or @samp{wedding}, or
6879 a format string).  If you omit the class, it will default to @samp{birthday}.
6880 Here are a few examples, the header for the file @file{org-bbdb.el} contains
6881 more detailed information.
6883 @example
6884 1973-06-22
6885 1955-08-02 wedding
6886 2008-04-14 %s released version 6.01 of org-mode, %d years ago
6887 @end example
6889 After a change to BBDB, or for the first agenda display during an Emacs
6890 session, the agenda display will suffer a short delay as Org updates its
6891 hash with anniversaries.  However, from then on things will be very fast---much
6892 faster in fact than a long list of @samp{%%(diary-anniversary)} entries
6893 in an Org or Diary file.
6895 @subsubheading Appointment reminders
6896 @cindex @file{appt.el}
6897 @cindex appointment reminders
6899 Org can interact with Emacs appointments notification facility.  To add all
6900 the appointments of your agenda files, use the command
6901 @code{org-agenda-to-appt}.  This command also lets you filter through the
6902 list of your appointments and add only those belonging to a specific category
6903 or matching a regular expression. See the docstring for details.
6905 @node Global TODO list, Matching tags and properties, Weekly/daily agenda, Built-in agenda views
6906 @subsection The global TODO list
6907 @cindex global TODO list
6908 @cindex TODO list, global
6910 The global TODO list contains all unfinished TODO items formatted and
6911 collected into a single place.
6913 @table @kbd
6914 @kindex C-c a t
6915 @item C-c a t
6916 Show the global TODO list.  This collects the TODO items from all agenda
6917 files (@pxref{Agenda Views}) into a single buffer.  By default, this lists
6918 items with a state the is not a DONE state.  The buffer is in
6919 @code{agenda-mode}, so there are commands to examine and manipulate the TODO
6920 entries directly from that buffer (@pxref{Agenda commands}).
6921 @kindex C-c a T
6922 @item C-c a T
6923 @cindex TODO keyword matching
6924 @vindex org-todo-keywords
6925 Like the above, but allows selection of a specific TODO keyword.  You can
6926 also do this by specifying a prefix argument to @kbd{C-c a t}.  You are
6927 prompted for a keyword, and you may also specify several keywords by
6928 separating them with @samp{|} as the boolean OR operator.  With a numeric
6929 prefix, the nth keyword in @code{org-todo-keywords} is selected.
6930 @kindex r
6931 The @kbd{r} key in the agenda buffer regenerates it, and you can give
6932 a prefix argument to this command to change the selected TODO keyword,
6933 for example @kbd{3 r}.  If you often need a search for a specific
6934 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
6935 Matching specific TODO keywords can also be done as part of a tags
6936 search (@pxref{Tag searches}).
6937 @end table
6939 Remote editing of TODO items means that you can change the state of a
6940 TODO entry with a single key press.  The commands available in the
6941 TODO list are described in @ref{Agenda commands}.
6943 @cindex sublevels, inclusion into TODO list
6944 Normally the global TODO list simply shows all headlines with TODO
6945 keywords.  This list can become very long.  There are two ways to keep
6946 it more compact:
6947 @itemize @minus
6948 @item
6949 @vindex org-agenda-todo-ignore-scheduled
6950 @vindex org-agenda-todo-ignore-deadlines
6951 @vindex org-agenda-todo-ignore-with-date
6952 Some people view a TODO item that has been @emph{scheduled} for execution or
6953 have a @emph{deadline} (@pxref{Timestamps}) as no longer @emph{open}.
6954 Configure the variables @code{org-agenda-todo-ignore-scheduled},
6955 @code{org-agenda-todo-ignore-deadlines}, and/or
6956 @code{org-agenda-todo-ignore-with-date} to exclude such items from the
6957 global TODO list.
6958 @item
6959 @vindex org-agenda-todo-list-sublevels
6960 TODO items may have sublevels to break up the task into subtasks.  In
6961 such cases it may be enough to list only the highest level TODO headline
6962 and omit the sublevels from the global list.  Configure the variable
6963 @code{org-agenda-todo-list-sublevels} to get this behavior.
6964 @end itemize
6966 @node Matching tags and properties, Timeline, Global TODO list, Built-in agenda views
6967 @subsection Matching tags and properties
6968 @cindex matching, of tags
6969 @cindex matching, of properties
6970 @cindex tags view
6971 @cindex match view
6973 If headlines in the agenda files are marked with @emph{tags} (@pxref{Tags}),
6974 or have properties (@pxref{Properties and Columns}), you can select headlines
6975 based on this metadata and collect them into an agenda buffer.  The match
6976 syntax described here also applies when creating sparse trees with @kbd{C-c /
6979 @table @kbd
6980 @kindex C-c a m
6981 @item C-c a m
6982 Produce a list of all headlines that match a given set of tags.  The
6983 command prompts for a selection criterion, which is a boolean logic
6984 expression with tags, like @samp{+work+urgent-withboss} or
6985 @samp{work|home} (@pxref{Tags}).  If you often need a specific search,
6986 define a custom command for it (@pxref{Agenda dispatcher}).
6987 @kindex C-c a M
6988 @item C-c a M
6989 @vindex org-tags-match-list-sublevels
6990 @vindex org-agenda-tags-todo-honor-ignore-options
6991 Like @kbd{C-c a m}, but only select headlines that are also TODO items in a
6992 not-DONE state and force checking subitems (see variable
6993 @code{org-tags-match-list-sublevels}).  To exclude scheduled/deadline items,
6994 see the variable @code{org-agenda-tags-todo-honor-ignore-options}.  Matching
6995 specific TODO keywords together with a tags match is also possible, see
6996 @ref{Tag searches}.
6997 @end table
6999 The commands available in the tags list are described in @ref{Agenda
7000 commands}.
7002 @subsubheading Match syntax
7004 @cindex Boolean logic, for tag/property searches
7005 A search string can use Boolean operators @samp{&} for AND and @samp{|} for
7006 OR.  @samp{&} binds more strongly than @samp{|}.  Parentheses are currently
7007 not implemented.  Each element in the search is either a tag, a regular
7008 expression matching tags, or an expression like @code{PROPERTY OPERATOR
7009 VALUE} with a comparison operator, accessing a property value.  Each element
7010 may be preceded by @samp{-}, to select against it, and @samp{+} is syntactic
7011 sugar for positive selection.  The AND operator @samp{&} is optional when
7012 @samp{+} or @samp{-} is present.  Here are some examples, using only tags.
7014 @table @samp
7015 @item +work-boss
7016 Select headlines tagged @samp{:work:}, but discard those also tagged
7017 @samp{:boss:}.
7018 @item work|laptop
7019 Selects lines tagged @samp{:work:} or @samp{:laptop:}.
7020 @item work|laptop+night
7021 Like before, but require the @samp{:laptop:} lines to be tagged also
7022 @samp{:night:}.
7023 @end table
7025 @cindex regular expressions, with tags search
7026 Instead of a tag, you may also specify a regular expression enclosed in curly
7027 braces.  For example,
7028 @samp{work+@{^boss.*@}} matches headlines that contain the tag
7029 @samp{:work:} and any tag @i{starting} with @samp{boss}.
7031 @cindex TODO keyword matching, with tags search
7032 @cindex level, require for tags/property match
7033 @cindex category, require for tags/property match
7034 @vindex org-odd-levels-only
7035 You may also test for properties (@pxref{Properties and Columns}) at the same
7036 time as matching tags.  The properties may be real properties, or special
7037 properties that represent other metadata (@pxref{Special properties}).  For
7038 example, the ``property'' @code{TODO} represents the TODO keyword of the
7039 entry.  Or, the ``property'' @code{LEVEL} represents the level of an entry.
7040 So a search @samp{+LEVEL=3+boss-TODO="DONE"} lists all level three headlines
7041 that have the tag @samp{boss} and are @emph{not} marked with the TODO keyword
7042 DONE.  In buffers with @code{org-odd-levels-only} set, @samp{LEVEL} does not
7043 count the number of stars, but @samp{LEVEL=2} will correspond to 3 stars etc.
7045 Here are more examples:
7046 @table @samp
7047 @item work+TODO="WAITING"
7048 Select @samp{:work:}-tagged TODO lines with the specific TODO
7049 keyword @samp{WAITING}.
7050 @item work+TODO="WAITING"|home+TODO="WAITING"
7051 Waiting tasks both at work and at home.
7052 @end table
7054 When matching properties, a number of different operators can be used to test
7055 the value of a property.  Here is a complex example:
7057 @example
7058 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2         \
7059          +With=@{Sarah\|Denny@}+SCHEDULED>="<2008-10-11>"
7060 @end example
7062 @noindent
7063 The type of comparison will depend on how the comparison value is written:
7064 @itemize @minus
7065 @item
7066 If the comparison value is a plain number, a numerical comparison is done,
7067 and the allowed operators are @samp{<}, @samp{=}, @samp{>}, @samp{<=},
7068 @samp{>=}, and @samp{<>}.
7069 @item
7070 If the comparison value is enclosed in double-quotes,
7071 a string comparison is done, and the same operators are allowed.
7072 @item
7073 If the comparison value is enclosed in double-quotes @emph{and} angular
7074 brackets (like @samp{DEADLINE<="<2008-12-24 18:30>"}), both values are
7075 assumed to be date/time specifications in the standard Org way, and the
7076 comparison will be done accordingly.  Special values that will be recognized
7077 are @code{"<now>"} for now (including time), and @code{"<today>"}, and
7078 @code{"<tomorrow>"} for these days at 0:00 hours, i.e. without a time
7079 specification.  Also strings like @code{"<+5d>"} or @code{"<-2m>"} with units
7080 @code{d}, @code{w}, @code{m}, and @code{y} for day, week, month, and year,
7081 respectively, can be used.
7082 @item
7083 If the comparison value is enclosed
7084 in curly braces, a regexp match is performed, with @samp{=} meaning that the
7085 regexp matches the property value, and @samp{<>} meaning that it does not
7086 match.
7087 @end itemize
7089 So the search string in the example finds entries tagged @samp{:work:} but
7090 not @samp{:boss:}, which also have a priority value @samp{A}, a
7091 @samp{:Coffee:} property with the value @samp{unlimited}, an @samp{Effort}
7092 property that is numerically smaller than 2, a @samp{:With:} property that is
7093 matched by the regular expression @samp{Sarah\|Denny}, and that are scheduled
7094 on or after October 11, 2008.
7096 Accessing TODO, LEVEL, and CATEGORY during a search is fast.  Accessing any
7097 other properties will slow down the search.  However, once you have paid the
7098 price by accessing one property, testing additional properties is cheap
7099 again.
7101 You can configure Org-mode to use property inheritance during a search, but
7102 beware that this can slow down searches considerably.  See @ref{Property
7103 inheritance}, for details.
7105 For backward compatibility, and also for typing speed, there is also a
7106 different way to test TODO states in a search.  For this, terminate the
7107 tags/property part of the search string (which may include several terms
7108 connected with @samp{|}) with a @samp{/} and then specify a Boolean
7109 expression just for TODO keywords.  The syntax is then similar to that for
7110 tags, but should be applied with care: for example, a positive selection on
7111 several TODO keywords cannot meaningfully be combined with boolean AND.
7112 However, @emph{negative selection} combined with AND can be meaningful.  To
7113 make sure that only lines are checked that actually have any TODO keyword
7114 (resulting in a speed-up), use @kbd{C-c a M}, or equivalently start the TODO
7115 part after the slash with @samp{!}.  Using @kbd{C-c a M} or @samp{/!} will
7116 not match TODO keywords in a DONE state.  Examples:
7118 @table @samp
7119 @item work/WAITING
7120 Same as @samp{work+TODO="WAITING"}
7121 @item work/!-WAITING-NEXT
7122 Select @samp{:work:}-tagged TODO lines that are neither @samp{WAITING}
7123 nor @samp{NEXT}
7124 @item work/!+WAITING|+NEXT
7125 Select @samp{:work:}-tagged TODO lines that are either @samp{WAITING} or
7126 @samp{NEXT}.
7127 @end table
7129 @node Timeline, Search view, Matching tags and properties, Built-in agenda views
7130 @subsection Timeline for a single file
7131 @cindex timeline, single file
7132 @cindex time-sorted view
7134 The timeline summarizes all time-stamped items from a single Org-mode
7135 file in a @emph{time-sorted view}.  The main purpose of this command is
7136 to give an overview over events in a project.
7138 @table @kbd
7139 @kindex C-c a L
7140 @item C-c a L
7141 Show a time-sorted view of the Org file, with all time-stamped items.
7142 When called with a @kbd{C-u} prefix, all unfinished TODO entries
7143 (scheduled or not) are also listed under the current date.
7144 @end table
7146 @noindent
7147 The commands available in the timeline buffer are listed in
7148 @ref{Agenda commands}.
7150 @node Search view, Stuck projects, Timeline, Built-in agenda views
7151 @subsection Search view
7152 @cindex search view
7153 @cindex text search
7154 @cindex searching, for text
7156 This agenda view is a general text search facility for Org-mode entries.
7157 It is particularly useful to find notes.
7159 @table @kbd
7160 @kindex C-c a s
7161 @item C-c a s
7162 This is a special search that lets you select entries by matching a substring
7163 or specific words using a boolean logic.
7164 @end table
7165 For example, the search string @samp{computer equipment} will find entries
7166 that contain @samp{computer equipment} as a substring.  If the two words are
7167 separated by more space or a line break, the search will still match.
7168 Search view can also search for specific keywords in the entry, using Boolean
7169 logic.  The search string @samp{+computer +wifi -ethernet -@{8\.11[bg]@}}
7170 will search for note entries that contain the keywords @code{computer}
7171 and @code{wifi}, but not the keyword @code{ethernet}, and which are also
7172 not matched by the regular expression @code{8\.11[bg]}, meaning to
7173 exclude both 8.11b and 8.11g.  The first @samp{+} is necessary to turn on
7174 word search, other @samp{+} characters are optional.  For more details, see
7175 the docstring of the command @code{org-search-view}.
7177 @vindex org-agenda-text-search-extra-files
7178 Note that in addition to the agenda files, this command will also search
7179 the files listed in @code{org-agenda-text-search-extra-files}.
7181 @node Stuck projects,  , Search view, Built-in agenda views
7182 @subsection Stuck projects
7184 If you are following a system like David Allen's GTD to organize your
7185 work, one of the ``duties'' you have is a regular review to make sure
7186 that all projects move along.  A @emph{stuck} project is a project that
7187 has no defined next actions, so it will never show up in the TODO lists
7188 Org-mode produces.  During the review, you need to identify such
7189 projects and define next actions for them.
7191 @table @kbd
7192 @kindex C-c a #
7193 @item C-c a #
7194 List projects that are stuck.
7195 @kindex C-c a !
7196 @item C-c a !
7197 @vindex org-stuck-projects
7198 Customize the variable @code{org-stuck-projects} to define what a stuck
7199 project is and how to find it.
7200 @end table
7202 You almost certainly will have to configure this view before it will
7203 work for you.  The built-in default assumes that all your projects are
7204 level-2 headlines, and that a project is not stuck if it has at least
7205 one entry marked with a TODO keyword TODO or NEXT or NEXTACTION.
7207 Let's assume that you, in your own way of using Org-mode, identify
7208 projects with a tag PROJECT, and that you use a TODO keyword MAYBE to
7209 indicate a project that should not be considered yet.  Let's further
7210 assume that the TODO keyword DONE marks finished projects, and that NEXT
7211 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
7212 is a next action even without the NEXT tag.  Finally, if the project
7213 contains the special word IGNORE anywhere, it should not be listed
7214 either.  In this case you would start by identifying eligible projects
7215 with a tags/todo match@footnote{@xref{Tag searches}.}
7216 @samp{+PROJECT/-MAYBE-DONE}, and then check for TODO, NEXT, @@SHOP, and
7217 IGNORE in the subtree to identify projects that are not stuck.  The
7218 correct customization for this is
7220 @lisp
7221 (setq org-stuck-projects
7222       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
7223                                "\\<IGNORE\\>"))
7224 @end lisp
7226 Note that if a project is identified as non-stuck, the subtree of this entry
7227 will still be searched for stuck projects.
7229 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda Views
7230 @section Presentation and sorting
7231 @cindex presentation, of agenda items
7233 @vindex org-agenda-prefix-format
7234 Before displaying items in an agenda view, Org-mode visually prepares
7235 the items and sorts them.  Each item occupies a single line.  The line
7236 starts with a @emph{prefix} that contains the @emph{category}
7237 (@pxref{Categories}) of the item and other important information.  You can
7238 customize the prefix using the option @code{org-agenda-prefix-format}.
7239 The prefix is followed by a cleaned-up version of the outline headline
7240 associated with the item.
7242 @menu
7243 * Categories::                  Not all tasks are equal
7244 * Time-of-day specifications::  How the agenda knows the time
7245 * Sorting of agenda items::     The order of things
7246 @end menu
7248 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
7249 @subsection Categories
7251 @cindex category
7252 The category is a broad label assigned to each agenda item.  By default,
7253 the category is simply derived from the file name, but you can also
7254 specify it with a special line in the buffer, like this@footnote{For
7255 backward compatibility, the following also works: if there are several
7256 such lines in a file, each specifies the category for the text below it.
7257 The first category also applies to any text before the first CATEGORY
7258 line.  However, using this method is @emph{strongly} deprecated as it is
7259 incompatible with the outline structure of the document.  The correct
7260 method for setting multiple categories in a buffer is using a
7261 property.}:
7263 @example
7264 #+CATEGORY: Thesis
7265 @end example
7267 @noindent
7268 @cindex property, CATEGORY
7269 If you would like to have a special CATEGORY for a single entry or a
7270 (sub)tree, give the entry a @code{:CATEGORY:} property with the
7271 special category you want to apply as the value.
7273 @noindent
7274 The display in the agenda buffer looks best if the category is not
7275 longer than 10 characters.
7277 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
7278 @subsection Time-of-day specifications
7279 @cindex time-of-day specification
7281 Org-mode checks each agenda item for a time-of-day specification.  The
7282 time can be part of the timestamp that triggered inclusion into the
7283 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
7284 ranges can be specified with two timestamps, like
7286 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
7288 In the headline of the entry itself, a time(range) may also appear as
7289 plain text (like @samp{12:45} or a @samp{8:30-1pm}).  If the agenda
7290 integrates the Emacs diary (@pxref{Weekly/daily agenda}), time
7291 specifications in diary entries are recognized as well.
7293 For agenda display, Org-mode extracts the time and displays it in a
7294 standard 24 hour format as part of the prefix.  The example times in
7295 the previous paragraphs would end up in the agenda like this:
7297 @example
7298     8:30-13:00 Arthur Dent lies in front of the bulldozer
7299    12:45...... Ford Prefect arrives and takes Arthur to the pub
7300    19:00...... The Vogon reads his poem
7301    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
7302 @end example
7304 @cindex time grid
7305 If the agenda is in single-day mode, or for the display of today, the
7306 timed entries are embedded in a time grid, like
7308 @example
7309     8:00...... ------------------
7310     8:30-13:00 Arthur Dent lies in front of the bulldozer
7311    10:00...... ------------------
7312    12:00...... ------------------
7313    12:45...... Ford Prefect arrives and takes Arthur to the pub
7314    14:00...... ------------------
7315    16:00...... ------------------
7316    18:00...... ------------------
7317    19:00...... The Vogon reads his poem
7318    20:00...... ------------------
7319    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
7320 @end example
7322 @vindex org-agenda-use-time-grid
7323 @vindex org-agenda-time-grid
7324 The time grid can be turned on and off with the variable
7325 @code{org-agenda-use-time-grid}, and can be configured with
7326 @code{org-agenda-time-grid}.
7328 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
7329 @subsection Sorting of agenda items
7330 @cindex sorting, of agenda items
7331 @cindex priorities, of agenda items
7332 Before being inserted into a view, the items are sorted.  How this is
7333 done depends on the type of view.
7334 @itemize @bullet
7335 @item
7336 @vindex org-agenda-files
7337 For the daily/weekly agenda, the items for each day are sorted.  The
7338 default order is to first collect all items containing an explicit
7339 time-of-day specification.  These entries will be shown at the beginning
7340 of the list, as a @emph{schedule} for the day.  After that, items remain
7341 grouped in categories, in the sequence given by @code{org-agenda-files}.
7342 Within each category, items are sorted by priority (@pxref{Priorities}),
7343 which is composed of the base priority (2000 for priority @samp{A}, 1000
7344 for @samp{B}, and 0 for @samp{C}), plus additional increments for
7345 overdue scheduled or deadline items.
7346 @item
7347 For the TODO list, items remain in the order of categories, but within
7348 each category, sorting takes place according to priority
7349 (@pxref{Priorities}).  The priority used for sorting derives from the
7350 priority cookie, with additions depending on how close an item is to its due
7351 or scheduled date.
7352 @item
7353 For tags matches, items are not sorted at all, but just appear in the
7354 sequence in which they are found in the agenda files.
7355 @end itemize
7357 @vindex org-agenda-sorting-strategy
7358 Sorting can be customized using the variable
7359 @code{org-agenda-sorting-strategy}, and may also include criteria based on
7360 the estimated effort of an entry (@pxref{Effort estimates}).
7362 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda Views
7363 @section Commands in the agenda buffer
7364 @cindex commands, in agenda buffer
7366 Entries in the agenda buffer are linked back to the Org file or diary
7367 file where they originate.  You are not allowed to edit the agenda
7368 buffer itself, but commands are provided to show and jump to the
7369 original entry location, and to edit the Org files ``remotely'' from
7370 the agenda buffer.  In this way, all information is stored only once,
7371 removing the risk that your agenda and note files may diverge.
7373 Some commands can be executed with mouse clicks on agenda lines.  For
7374 the other commands, the cursor needs to be in the desired line.
7376 @table @kbd
7377 @tsubheading{Motion}
7378 @cindex motion commands in agenda
7379 @kindex n
7380 @item n
7381 Next line (same as @key{up} and @kbd{C-p}).
7382 @kindex p
7383 @item p
7384 Previous line (same as @key{down} and @kbd{C-n}).
7385 @tsubheading{View/Go to Org file}
7386 @kindex mouse-3
7387 @kindex @key{SPC}
7388 @item mouse-3
7389 @itemx @key{SPC}
7390 Display the original location of the item in another window.
7391 With prefix arg, make sure that the entire entry is made visible in the
7392 outline, not only the heading.
7394 @kindex L
7395 @item L
7396 Display original location and recenter that window.
7398 @kindex mouse-2
7399 @kindex mouse-1
7400 @kindex @key{TAB}
7401 @item mouse-2
7402 @itemx mouse-1
7403 @itemx @key{TAB}
7404 Go to the original location of the item in another window.  Under Emacs
7405 22, @kbd{mouse-1} will also works for this.
7407 @kindex @key{RET}
7408 @itemx @key{RET}
7409 Go to the original location of the item and delete other windows.
7411 @kindex F
7412 @item F
7413 @vindex org-agenda-start-with-follow-mode
7414 Toggle Follow mode.  In Follow mode, as you move the cursor through
7415 the agenda buffer, the other window always shows the corresponding
7416 location in the Org file.  The initial setting for this mode in new
7417 agenda buffers can be set with the variable
7418 @code{org-agenda-start-with-follow-mode}.
7420 @kindex C-c C-x b
7421 @item C-c C-x b
7422 Display the entire subtree of the current item in an indirect buffer.  With a
7423 numeric prefix argument N, go up to level N and then take that tree.  If N is
7424 negative, go up that many levels.  With a @kbd{C-u} prefix, do not remove the
7425 previously used indirect buffer.
7427 @kindex C-c C-o
7428 @item C-c C-o
7429 Follow a link in the entry.  This will offer a selection of any links in the
7430 text belonging to the referenced Org node.  If there is only one link, it
7431 will be followed without a selection prompt.
7433 @tsubheading{Change display}
7434 @cindex display changing, in agenda
7435 @kindex o
7436 @item o
7437 Delete other windows.
7439 @kindex v d
7440 @kindex d
7441 @kindex v w
7442 @kindex w
7443 @kindex v m
7444 @kindex v y
7445 @item v d @ @r{or short} @ d
7446 @itemx v w @ @r{or short} @ w
7447 @itemx v m
7448 @itemx v y
7449 Switch to day/week/month/year view.  When switching to day or week view,
7450 this setting becomes the default for subsequent agenda commands.  Since
7451 month and year views are slow to create, they do not become the default.
7452 A numeric prefix argument may be used to jump directly to a specific day
7453 of the year, ISO week, month, or year, respectively.  For example,
7454 @kbd{32 d} jumps to February 1st, @kbd{9 w} to ISO week number 9.  When
7455 setting day, week, or month view, a year may be encoded in the prefix
7456 argument as well.  For example, @kbd{200712 w} will jump to week 12 in
7457 2007.  If such a year specification has only one or two digits, it will
7458 be mapped to the interval 1938-2037.
7460 @kindex f
7461 @item f
7462 @vindex org-agenda-ndays
7463 Go forward in time to display the following @code{org-agenda-ndays} days.
7464 For example, if the display covers a week, switch to the following week.
7465 With prefix arg, go forward that many times @code{org-agenda-ndays} days.
7467 @kindex b
7468 @item b
7469 Go backward in time to display earlier dates.
7471 @kindex .
7472 @item .
7473 Go to today.
7475 @kindex j
7476 @item j
7477 Prompt for a date and go there.
7479 @kindex J
7480 @item J
7481 Go to the currently clocked in task in the agenda buffer.
7483 @kindex D
7484 @item D
7485 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
7487 @kindex v l
7488 @kindex v L
7489 @kindex l
7490 @item v l @ @r{or short} @ l
7491 @vindex org-log-done
7492 @vindex org-agenda-log-mode-items
7493 Toggle Logbook mode.  In Logbook mode, entries that were marked DONE while
7494 logging was on (variable @code{org-log-done}) are shown in the agenda, as are
7495 entries that have been clocked on that day.  You can configure the entry
7496 types that should be included in log mode using the variable
7497 @code{org-agenda-log-mode-items}.  When called with a @kbd{C-u} prefix, show
7498 all possible logbook entries, including state changes.  When called with two
7499 prefix args @kbd{C-u C-u}, show only logging information, nothing else.
7500 @kbd{v L} is equivalent to @kbd{C-u v l}.
7502 @kindex v [
7503 @kindex [
7504 @item v [ @ @r{or short} @ [
7505 Include inactive timestamps into the current view.  Only for weekly/daily
7506 agenda and timeline views.
7508 @kindex v a
7509 @kindex v A
7510 @item v a
7511 @itemx v A
7512 Toggle Archives mode.  In Archives mode, trees that are marked
7513 @code{ARCHIVED} are also scanned when producing the agenda.  When you use the
7514 capital @kbd{A}, even all archive files are included.  To exit archives mode,
7515 press @kbd{v a} again.
7517 @kindex v R
7518 @kindex R
7519 @item v R @ @r{or short} @ R
7520 @vindex org-agenda-start-with-clockreport-mode
7521 Toggle Clockreport mode.  In Clockreport mode, the daily/weekly agenda will
7522 always show a table with the clocked times for the timespan and file scope
7523 covered by the current agenda view.  The initial setting for this mode in new
7524 agenda buffers can be set with the variable
7525 @code{org-agenda-start-with-clockreport-mode}.
7527 @kindex v E
7528 @kindex E
7529 @item v E @ @r{or short} @ E
7530 @vindex org-agenda-start-with-entry-text-mode
7531 @vindex org-agenda-entry-text-maxlines
7532 Toggle entry text mode.  In entry text mode, a number of lines from the Org
7533 outline node referenced by an agenda line will be displayed below the line.
7534 The maximum number of lines is given by the variable
7535 @code{org-agenda-entry-text-maxlines}.  Calling this command with a numeric
7536 prefix argument will temporarily modify that number to the prefix value.
7538 @kindex G
7539 @item G
7540 @vindex org-agenda-use-time-grid
7541 @vindex org-agenda-time-grid
7542 Toggle the time grid on and off.  See also the variables
7543 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
7545 @kindex r
7546 @item r
7547 Recreate the agenda buffer, for example to reflect the changes after
7548 modification of the timestamps of items with @kbd{S-@key{left}} and
7549 @kbd{S-@key{right}}.  When the buffer is the global TODO list, a prefix
7550 argument is interpreted to create a selective list for a specific TODO
7551 keyword.
7552 @kindex g
7553 @item g
7554 Same as @kbd{r}.
7556 @kindex s
7557 @kindex C-x C-s
7558 @item s
7559 @itemx C-x C-s
7560 Save all Org buffers in the current Emacs session, and also the locations of
7561 IDs.
7563 @kindex C-c C-x C-c
7564 @item C-c C-x C-c
7565 @vindex org-columns-default-format
7566 Invoke column view (@pxref{Column view}) in the agenda buffer.  The column
7567 view format is taken from the entry at point, or (if there is no entry at
7568 point), from the first entry in the agenda view.  So whatever the format for
7569 that entry would be in the original buffer (taken from a property, from a
7570 @code{#+COLUMNS} line, or from the default variable
7571 @code{org-columns-default-format}), will be used in the agenda.
7573 @kindex C-c C-x >
7574 @item C-c C-x >
7575 Remove the restriction lock on the agenda, if it is currently restricted to a
7576 file or subtree (@pxref{Agenda files}).
7578 @tsubheading{Secondary filtering and query editing}
7579 @cindex filtering, by tag and effort, in agenda
7580 @cindex tag filtering, in agenda
7581 @cindex effort filtering, in agenda
7582 @cindex query editing, in agenda
7584 @kindex /
7585 @item /
7586 @vindex org-agenda-filter-preset
7587 Filter the current agenda view with respect to a tag and/or effort estimates.
7588 The difference between this and a custom agenda command is that filtering is
7589 very fast, so that you can switch quickly between different filters without
7590 having to recreate the agenda@footnote{Custom commands can preset a filter by
7591 binding the variable @code{org-agenda-filter-preset} as an option.  This
7592 filter will then be applied to the view and persist as a basic filter through
7593 refreshes and more secondary filtering.  The filter is a global property of
7594 the entire agenda view - in a block agenda, you should only set this in the
7595 global options section, not in the section of an individual block.}
7597 You will be prompted for a tag selection letter, SPC will mean any tag at
7598 all.  Pressing @key{TAB} at that prompt will offer use completion to select a
7599 tag (including any tags that do not have a selection character).  The command
7600 then hides all entries that do not contain or inherit this tag.  When called
7601 with prefix arg, remove the entries that @emph{do} have the tag.  A second
7602 @kbd{/} at the prompt will turn off the filter and unhide any hidden entries.
7603 If the first key you press is either @kbd{+} or @kbd{-}, the previous filter
7604 will be narrowed by requiring or forbidding the selected additional tag.
7605 Instead of pressing @kbd{+} or @kbd{-} after @kbd{/}, you can also
7606 immediately use the @kbd{\} command.
7608 @vindex org-sort-agenda-noeffort-is-high
7609 In order to filter for effort estimates, you should set-up allowed
7610 efforts globally, for example
7611 @lisp
7612 (setq org-global-properties
7613     '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
7614 @end lisp
7615 You can then filter for an effort by first typing an operator, one of
7616 @kbd{<}, @kbd{>}, and @kbd{=}, and then the one-digit index of an effort
7617 estimate in your array of allowed values, where @kbd{0} means the 10th value.
7618 The filter will then restrict to entries with effort smaller-or-equal, equal,
7619 or larger-or-equal than the selected value.  If the digits 0-9 are not used
7620 as fast access keys to tags, you can also simply press the index digit
7621 directly without an operator.  In this case, @kbd{<} will be assumed.  For
7622 application of the operator, entries without a defined effort will be treated
7623 according to the value of @code{org-sort-agenda-noeffort-is-high}.  To filter
7624 for tasks without effort definition, press @kbd{?} as the operator.
7626 Org also supports automatic, context-aware tag filtering.  If the variable
7627 @code{org-agenda-auto-exclude-function} is set to a user-defined function,
7628 that function can decide which tags should be excluded from the agenda
7629 automatically.  Once this is set, the @kbd{/} command then accepts @kbd{RET}
7630 as a sub-option key and runs the auto exclusion logic.  For example, let's
7631 say you use a @code{Net} tag to identify tasks which need network access, an
7632 @code{Errand} tag for errands in town, and a @code{Call} tag for making phone
7633 calls.  You could auto-exclude these tags based on the availability of the
7634 Internet, and outside of business hours, with something like this:
7636 @lisp
7637 @group
7638 (defun org-my-auto-exclude-function (tag)
7639   (and (cond
7640         ((string= tag "Net")
7641          (/= 0 (call-process "/sbin/ping" nil nil nil
7642                              "-c1" "-q" "-t1" "mail.gnu.org")))
7643         ((or (string= tag "Errand") (string= tag "Call"))
7644          (let ((hour (nth 2 (decode-time))))
7645            (or (< hour 8) (> hour 21)))))
7646        (concat "-" tag)))
7648 (setq org-agenda-auto-exclude-function 'org-my-auto-exclude-function)
7649 @end group
7650 @end lisp
7652 @kindex \
7653 @item \
7654 Narrow the current agenda filter by an additional condition.  When called with
7655 prefix arg, remove the entries that @emph{do} have the tag, or that do match
7656 the effort criterion.  You can achieve the same effect by pressing @kbd{+} or
7657 @kbd{-} as the first key after the @kbd{/} command.
7659 @kindex [
7660 @kindex ]
7661 @kindex @{
7662 @kindex @}
7663 @item [ ] @{ @}
7664 @table @i
7665 @item @r{in} search view
7666 add new search words (@kbd{[} and @kbd{]}) or new regular expressions
7667 (@kbd{@{} and @kbd{@}}) to the query string.  The opening bracket/brace will
7668 add a positive search term prefixed by @samp{+}, indicating that this search
7669 term @i{must} occur/match in the entry.  The closing bracket/brace will add a
7670 negative search term which @i{must not} occur/match in the entry for it to be
7671 selected.
7672 @end table
7674 @page
7675 @tsubheading{Remote editing}
7676 @cindex remote editing, from agenda
7678 @item 0-9
7679 Digit argument.
7681 @cindex undoing remote-editing events
7682 @cindex remote editing, undo
7683 @kindex C-_
7684 @item C-_
7685 Undo a change due to a remote editing command.  The change is undone
7686 both in the agenda buffer and in the remote buffer.
7688 @kindex t
7689 @item t
7690 Change the TODO state of the item, both in the agenda and in the
7691 original org file.
7693 @kindex C-S-@key{right}
7694 @kindex C-S-@key{left}
7695 @item C-S-@key{right}@r{/}@key{left}
7696 Switch to the next/previous set of TODO keywords.
7698 @kindex C-k
7699 @item C-k
7700 @vindex org-agenda-confirm-kill
7701 Delete the current agenda item along with the entire subtree belonging
7702 to it in the original Org file.  If the text to be deleted remotely
7703 is longer than one line, the kill needs to be confirmed by the user.  See
7704 variable @code{org-agenda-confirm-kill}.
7706 @kindex C-c C-w
7707 @item C-c C-w
7708 Refile the entry at point.
7710 @kindex C-c C-x C-a
7711 @kindex a
7712 @item C-c C-x C-a @ @r{or short} @ a
7713 @vindex org-archive-default-command
7714 Archive the subtree corresponding to the entry at point using the default
7715 archiving command set in @code{org-archive-default-command}.  When using the
7716 @code{a} key, confirmation will be required.
7718 @kindex C-c C-x a
7719 @item C-c C-x a
7720 Toggle the ARCHIVE tag for the current headline.
7722 @kindex C-c C-x A
7723 @item C-c C-x A
7724 Move the subtree corresponding to the current entry to its @emph{archive
7725 sibling}.
7727 @kindex $
7728 @kindex C-c C-x C-s
7729 @item C-c C-x C-s @ @r{or short} @ $
7730 Archive the subtree corresponding to the current headline.  This means the
7731 entry will be moved to the configured archive location, most likely a
7732 different file.
7734 @kindex T
7735 @item T
7736 @vindex org-agenda-show-inherited-tags
7737 Show all tags associated with the current item.  This is useful if you have
7738 turned off @code{org-agenda-show-inherited-tags}, but still want to see all
7739 tags of a headline occasionally.
7741 @kindex :
7742 @item :
7743 Set tags for the current headline.  If there is an active region in the
7744 agenda, change a tag for all headings in the region.
7746 @kindex ,
7747 @item ,
7748 Set the priority for the current item.  Org-mode prompts for the
7749 priority character. If you reply with @key{SPC}, the priority cookie
7750 is removed from the entry.
7752 @kindex P
7753 @item P
7754 Display weighted priority of current item.
7756 @kindex +
7757 @kindex S-@key{up}
7758 @item +
7759 @itemx S-@key{up}
7760 Increase the priority of the current item.  The priority is changed in
7761 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
7762 key for this.
7764 @kindex -
7765 @kindex S-@key{down}
7766 @item -
7767 @itemx S-@key{down}
7768 Decrease the priority of the current item.
7770 @kindex C-c C-z
7771 @kindex z
7772 @item z @ @r{or also} @ C-c C-z
7773 @vindex org-log-into-drawer
7774 Add a note to the entry.  This note will be recorded, and then files to the
7775 same location where state change notes are put.  Depending on
7776 @code{org-log-into-drawer}, this maybe inside a drawer.
7778 @kindex C-c C-a
7779 @item C-c C-a
7780 Dispatcher for all command related to attachments.
7782 @kindex C-c C-s
7783 @item C-c C-s
7784 Schedule this item, with prefix arg remove the scheduling timestamp
7786 @kindex C-c C-d
7787 @item C-c C-d
7788 Set a deadline for this item, with prefix arg remove the deadline.
7790 @kindex k
7791 @item k
7792 Agenda actions, to set dates for selected items to the cursor date.
7793 This command also works in the calendar!  The command prompts for an
7794 additional key:
7795 @example
7796 m   @r{Mark the entry at point for action.  You can also make entries}
7797     @r{in Org files with @kbd{C-c C-x C-k}.}
7798 d   @r{Set the deadline of the marked entry to the date at point.}
7799 s   @r{Schedule the marked entry at the date at point.}
7800 r   @r{Call @code{org-capture} with the cursor date as default date.}
7801 @end example
7802 @noindent
7803 Press @kbd{r} afterward to refresh the agenda and see the effect of the
7804 command.
7806 @kindex S-@key{right}
7807 @item S-@key{right}
7808 Change the timestamp associated with the current line by one day into the
7809 future.  With a numeric prefix argument, change it by that many days.  For
7810 example, @kbd{3 6 5 S-@key{right}} will change it by a year.  With a
7811 @kbd{C-u} prefix, change the time by one hour.  If you immediately repeat the
7812 command, it will continue to change hours even without the prefix arg.  With
7813 a double @kbd{C-u C-u} prefix, do the same for changing minutes.  The stamp
7814 is changed in the original Org file, but the change is not directly reflected
7815 in the agenda buffer.  Use @kbd{r} or @kbd{g} to update the buffer.
7817 @kindex S-@key{left}
7818 @item S-@key{left}
7819 Change the timestamp associated with the current line by one day
7820 into the past.
7822 @kindex >
7823 @item >
7824 Change the timestamp associated with the current line.  The key @kbd{>} has
7825 been chosen, because it is the same as @kbd{S-.}  on my keyboard.
7827 @kindex I
7828 @item I
7829 Start the clock on the current item.  If a clock is running already, it
7830 is stopped first.
7832 @kindex O
7833 @item O
7834 Stop the previously started clock.
7836 @kindex X
7837 @item X
7838 Cancel the currently running clock.
7840 @kindex J
7841 @item J
7842 Jump to the running clock in another window.
7844 @tsubheading{Bulk remote editing selected entries}
7845 @cindex remote editing, bulk, from agenda
7847 @kindex m
7848 @item m
7849 Mark the entry at point for bulk action.
7851 @kindex u
7852 @item u
7853 Unmark entry for bulk action.
7855 @kindex U
7856 @item U
7857 Unmark all marked entries for bulk action.
7859 @kindex B
7860 @item B
7861 Bulk action: act on all marked entries in the agenda.  This will prompt for
7862 another key to select the action to be applied.  The prefix arg to @kbd{B}
7863 will be passed through to the @kbd{s} and @kbd{d} commands, to bulk-remove
7864 these special timestamps.
7865 @example
7866 r  @r{Prompt for a single refile target and move all entries.  The entries}
7867    @r{will no longer be in the agenda, refresh (@kbd{g}) to bring them back.}
7868 $  @r{Archive all selected entries.}
7869 A  @r{Archive entries by moving them to their respective archive siblings.}
7870 t  @r{Change TODO state.  This prompts for a single TODO keyword and}
7871    @r{changes the state of all selected entries, bypassing blocking and}
7872    @r{suppressing logging notes (but not time stamps).}
7873 +  @r{Add a tag to all selected entries.}
7874 -  @r{Remove a tag from all selected entries.}
7875 s  @r{Schedule all items to a new date.  To shift existing schedule dates}
7876    @r{by a fixed number of days, use something starting with double plus}
7877    @r{at the prompt, for example @samp{++8d} or @samp{++2w}.}
7878 d  @r{Set deadline to a specific date.}
7879 @end example
7882 @tsubheading{Calendar commands}
7883 @cindex calendar commands, from agenda
7884 @kindex c
7885 @item c
7886 Open the Emacs calendar and move to the date at the agenda cursor.
7888 @item c
7889 When in the calendar, compute and show the Org-mode agenda for the
7890 date at the cursor.
7892 @cindex diary entries, creating from agenda
7893 @kindex i
7894 @item i
7895 @vindex org-agenda-diary-file
7896 Insert a new entry into the diary, using the date at the cursor and (for
7897 block entries) the date at the mark.  This will add to the Emacs diary
7898 file@footnote{This file is parsed for the agenda when
7899 @code{org-agenda-include-diary} is set.}, in a way similar to the @kbd{i}
7900 command in the calendar.  The diary file will pop up in another window, where
7901 you can add the entry.
7903 If you configure @code{org-agenda-diary-file} to point to an Org-mode file,
7904 Org will create entries (in org-mode syntax) in that file instead.  Most
7905 entries will be stored in a date-based outline tree that will later make it
7906 easy to archive appointments from previous months/years.  The tree will be
7907 built under an entry with a @code{DATE_TREE} property, or else with years as
7908 top-level entries.  Emacs will prompt you for the entry text - if you specify
7909 it, the entry will be created in @code{org-agenda-diary-file} without further
7910 interaction.  If you directly press @key{RET} at the prompt without typing
7911 text, the target file will be shown in another window for you to finish the
7912 entry there.  See also the @kbd{k r} command.
7914 @kindex M
7915 @item M
7916 Show the phases of the moon for the three months around current date.
7918 @kindex S
7919 @item S
7920 Show sunrise and sunset times.  The geographical location must be set
7921 with calendar variables, see the documentation for the Emacs calendar.
7923 @kindex C
7924 @item C
7925 Convert the date at cursor into many other cultural and historic
7926 calendars.
7928 @kindex H
7929 @item H
7930 Show holidays for three months around the cursor date.
7932 @item M-x org-export-icalendar-combine-agenda-files
7933 Export a single iCalendar file containing entries from all agenda files.
7934 This is a globally available command, and also available in the agenda menu.
7936 @tsubheading{Exporting to a file}
7937 @kindex C-x C-w
7938 @item C-x C-w
7939 @cindex exporting agenda views
7940 @cindex agenda views, exporting
7941 @vindex org-agenda-exporter-settings
7942 Write the agenda view to a file.  Depending on the extension of the selected
7943 file name, the view will be exported as HTML (extension @file{.html} or
7944 @file{.htm}), Postscript (extension @file{.ps}), PDF (extension @file{.pdf}),
7945 and plain text (any other extension).  When called with a @kbd{C-u} prefix
7946 argument, immediately open the newly created file.  Use the variable
7947 @code{org-agenda-exporter-settings} to set options for @file{ps-print} and
7948 for @file{htmlize} to be used during export.
7950 @tsubheading{Quit and Exit}
7951 @kindex q
7952 @item q
7953 Quit agenda, remove the agenda buffer.
7955 @kindex x
7956 @cindex agenda files, removing buffers
7957 @item x
7958 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
7959 for the compilation of the agenda.  Buffers created by the user to
7960 visit Org files will not be removed.
7961 @end table
7964 @node Custom agenda views, Exporting Agenda Views, Agenda commands, Agenda Views
7965 @section Custom agenda views
7966 @cindex custom agenda views
7967 @cindex agenda views, custom
7969 Custom agenda commands serve two purposes: to store and quickly access
7970 frequently used TODO and tags searches, and to create special composite
7971 agenda buffers.  Custom agenda commands will be accessible through the
7972 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
7974 @menu
7975 * Storing searches::            Type once, use often
7976 * Block agenda::                All the stuff you need in a single buffer
7977 * Setting Options::             Changing the rules
7978 @end menu
7980 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
7981 @subsection Storing searches
7983 The first application of custom searches is the definition of keyboard
7984 shortcuts for frequently used searches, either creating an agenda
7985 buffer, or a sparse tree (the latter covering of course only the current
7986 buffer).
7987 @kindex C-c a C
7988 @vindex org-agenda-custom-commands
7989 Custom commands are configured in the variable
7990 @code{org-agenda-custom-commands}.  You can customize this variable, for
7991 example by pressing @kbd{C-c a C}.  You can also directly set it with
7992 Emacs Lisp in @file{.emacs}.  The following example contains all valid
7993 search types:
7995 @lisp
7996 @group
7997 (setq org-agenda-custom-commands
7998       '(("w" todo "WAITING")
7999         ("W" todo-tree "WAITING")
8000         ("u" tags "+boss-urgent")
8001         ("v" tags-todo "+boss-urgent")
8002         ("U" tags-tree "+boss-urgent")
8003         ("f" occur-tree "\\<FIXME\\>")
8004         ("h" . "HOME+Name tags searches") ; description for "h" prefix
8005         ("hl" tags "+home+Lisa")
8006         ("hp" tags "+home+Peter")
8007         ("hk" tags "+home+Kim")))
8008 @end group
8009 @end lisp
8011 @noindent
8012 The initial string in each entry defines the keys you have to press
8013 after the dispatcher command @kbd{C-c a} in order to access the command.
8014 Usually this will be just a single character, but if you have many
8015 similar commands, you can also define two-letter combinations where the
8016 first character is the same in several combinations and serves as a
8017 prefix key@footnote{You can provide a description for a prefix key by
8018 inserting a cons cell with the prefix and the description.}.  The second
8019 parameter is the search type, followed by the string or regular
8020 expression to be used for the matching.  The example above will
8021 therefore define:
8023 @table @kbd
8024 @item C-c a w
8025 as a global search for TODO entries with @samp{WAITING} as the TODO
8026 keyword
8027 @item C-c a W
8028 as the same search, but only in the current buffer and displaying the
8029 results as a sparse tree
8030 @item C-c a u
8031 as a global tags search for headlines marked @samp{:boss:} but not
8032 @samp{:urgent:}
8033 @item C-c a v
8034 as the same search as @kbd{C-c a u}, but limiting the search to
8035 headlines that are also TODO items
8036 @item C-c a U
8037 as the same search as @kbd{C-c a u}, but only in the current buffer and
8038 displaying the result as a sparse tree
8039 @item C-c a f
8040 to create a sparse tree (again: current buffer only) with all entries
8041 containing the word @samp{FIXME}
8042 @item C-c a h
8043 as a prefix command for a HOME tags search where you have to press an
8044 additional key (@kbd{l}, @kbd{p} or @kbd{k}) to select a name (Lisa,
8045 Peter, or Kim) as additional tag to match.
8046 @end table
8048 @node Block agenda, Setting Options, Storing searches, Custom agenda views
8049 @subsection Block agenda
8050 @cindex block agenda
8051 @cindex agenda, with block views
8053 Another possibility is the construction of agenda views that comprise
8054 the results of @emph{several} commands, each of which creates a block in
8055 the agenda buffer.  The available commands include @code{agenda} for the
8056 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
8057 for the global TODO list (as constructed with @kbd{C-c a t}), and the
8058 matching commands discussed above: @code{todo}, @code{tags}, and
8059 @code{tags-todo}.  Here are two examples:
8061 @lisp
8062 @group
8063 (setq org-agenda-custom-commands
8064       '(("h" "Agenda and Home-related tasks"
8065          ((agenda "")
8066           (tags-todo "home")
8067           (tags "garden")))
8068         ("o" "Agenda and Office-related tasks"
8069          ((agenda "")
8070           (tags-todo "work")
8071           (tags "office")))))
8072 @end group
8073 @end lisp
8075 @noindent
8076 This will define @kbd{C-c a h} to create a multi-block view for stuff
8077 you need to attend to at home.  The resulting agenda buffer will contain
8078 your agenda for the current week, all TODO items that carry the tag
8079 @samp{home}, and also all lines tagged with @samp{garden}.  Finally the
8080 command @kbd{C-c a o} provides a similar view for office tasks.
8082 @node Setting Options,  , Block agenda, Custom agenda views
8083 @subsection Setting options for custom commands
8084 @cindex options, for custom agenda views
8086 @vindex org-agenda-custom-commands
8087 Org-mode contains a number of variables regulating agenda construction
8088 and display.  The global variables define the behavior for all agenda
8089 commands, including the custom commands.  However, if you want to change
8090 some settings just for a single custom view, you can do so.  Setting
8091 options requires inserting a list of variable names and values at the
8092 right spot in @code{org-agenda-custom-commands}.  For example:
8094 @lisp
8095 @group
8096 (setq org-agenda-custom-commands
8097       '(("w" todo "WAITING"
8098          ((org-agenda-sorting-strategy '(priority-down))
8099           (org-agenda-prefix-format "  Mixed: ")))
8100         ("U" tags-tree "+boss-urgent"
8101          ((org-show-following-heading nil)
8102           (org-show-hierarchy-above nil)))
8103         ("N" search ""
8104          ((org-agenda-files '("~org/notes.org"))
8105           (org-agenda-text-search-extra-files nil)))))
8106 @end group
8107 @end lisp
8109 @noindent
8110 Now the @kbd{C-c a w} command will sort the collected entries only by
8111 priority, and the prefix format is modified to just say @samp{  Mixed: }
8112 instead of giving the category of the entry.  The sparse tags tree of
8113 @kbd{C-c a U} will now turn out ultra-compact, because neither the
8114 headline hierarchy above the match, nor the headline following the match
8115 will be shown.  The command @kbd{C-c a N} will do a text search limited
8116 to only a single file.
8118 @vindex org-agenda-custom-commands
8119 For command sets creating a block agenda,
8120 @code{org-agenda-custom-commands} has two separate spots for setting
8121 options.  You can add options that should be valid for just a single
8122 command in the set, and options that should be valid for all commands in
8123 the set.  The former are just added to the command entry, the latter
8124 must come after the list of command entries.  Going back to the block
8125 agenda example (@pxref{Block agenda}), let's change the sorting strategy
8126 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
8127 the results for GARDEN tags query in the opposite order,
8128 @code{priority-up}.  This would look like this:
8130 @lisp
8131 @group
8132 (setq org-agenda-custom-commands
8133       '(("h" "Agenda and Home-related tasks"
8134          ((agenda)
8135           (tags-todo "home")
8136           (tags "garden"
8137                 ((org-agenda-sorting-strategy '(priority-up)))))
8138          ((org-agenda-sorting-strategy '(priority-down))))
8139         ("o" "Agenda and Office-related tasks"
8140          ((agenda)
8141           (tags-todo "work")
8142           (tags "office")))))
8143 @end group
8144 @end lisp
8146 As you see, the values and parentheses setting is a little complex.
8147 When in doubt, use the customize interface to set this variable---it
8148 fully supports its structure.  Just one caveat: when setting options in
8149 this interface, the @emph{values} are just Lisp expressions.  So if the
8150 value is a string, you need to add the double-quotes around the value
8151 yourself.
8154 @node Exporting Agenda Views, Agenda column view, Custom agenda views, Agenda Views
8155 @section Exporting Agenda Views
8156 @cindex agenda views, exporting
8158 If you are away from your computer, it can be very useful to have a printed
8159 version of some agenda views to carry around.  Org-mode can export custom
8160 agenda views as plain text, HTML@footnote{You need to install Hrvoje Niksic's
8161 @file{htmlize.el}.}, Postscript, PDF@footnote{To create PDF output, the
8162 ghostscript @file{ps2pdf} utility must be installed on the system.  Selecting
8163 a PDF file with also create the postscript file.}, and iCalendar files.  If
8164 you want to do this only occasionally, use the command
8166 @table @kbd
8167 @kindex C-x C-w
8168 @item C-x C-w
8169 @cindex exporting agenda views
8170 @cindex agenda views, exporting
8171 @vindex org-agenda-exporter-settings
8172 Write the agenda view to a file.  Depending on the extension of the selected
8173 file name, the view will be exported as HTML (extension @file{.html} or
8174 @file{.htm}), Postscript (extension @file{.ps}), iCalendar (extension
8175 @file{.ics}), or plain text (any other extension).  Use the variable
8176 @code{org-agenda-exporter-settings} to set options for @file{ps-print} and
8177 for @file{htmlize} to be used during export, for example
8179 @vindex org-agenda-add-entry-text-maxlines
8180 @vindex htmlize-output-type
8181 @vindex ps-number-of-columns
8182 @vindex ps-landscape-mode
8183 @lisp
8184 (setq org-agenda-exporter-settings
8185       '((ps-number-of-columns 2)
8186         (ps-landscape-mode t)
8187         (org-agenda-add-entry-text-maxlines 5)
8188         (htmlize-output-type 'css)))
8189 @end lisp
8190 @end table
8192 If you need to export certain agenda views frequently, you can associate
8193 any custom agenda command with a list of output file names
8194 @footnote{If you want to store standard views like the weekly agenda
8195 or the global TODO list as well, you need to define custom commands for
8196 them in order to be able to specify file names.}.  Here is an example
8197 that first defines custom commands for the agenda and the global
8198 TODO list, together with a number of files to which to export them.
8199 Then we define two block agenda commands and specify file names for them
8200 as well.  File names can be relative to the current working directory,
8201 or absolute.
8203 @lisp
8204 @group
8205 (setq org-agenda-custom-commands
8206       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
8207         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
8208         ("h" "Agenda and Home-related tasks"
8209          ((agenda "")
8210           (tags-todo "home")
8211           (tags "garden"))
8212          nil
8213          ("~/views/home.html"))
8214         ("o" "Agenda and Office-related tasks"
8215          ((agenda)
8216           (tags-todo "work")
8217           (tags "office"))
8218          nil
8219          ("~/views/office.ps" "~/calendars/office.ics"))))
8220 @end group
8221 @end lisp
8223 The extension of the file name determines the type of export.  If it is
8224 @file{.html}, Org-mode will use the @file{htmlize.el} package to convert
8225 the buffer to HTML and save it to this file name.  If the extension is
8226 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
8227 Postscript output.  If the extension is @file{.ics}, iCalendar export is
8228 run export over all files that were used to construct the agenda, and
8229 limit the export to entries listed in the agenda.  Any other
8230 extension produces a plain ASCII file.
8232 The export files are @emph{not} created when you use one of those
8233 commands interactively because this might use too much overhead.
8234 Instead, there is a special command to produce @emph{all} specified
8235 files in one step:
8237 @table @kbd
8238 @kindex C-c a e
8239 @item C-c a e
8240 Export all agenda views that have export file names associated with
8241 them.
8242 @end table
8244 You can use the options section of the custom agenda commands to also
8245 set options for the export commands.  For example:
8247 @lisp
8248 (setq org-agenda-custom-commands
8249       '(("X" agenda ""
8250          ((ps-number-of-columns 2)
8251           (ps-landscape-mode t)
8252           (org-agenda-prefix-format " [ ] ")
8253           (org-agenda-with-colors nil)
8254           (org-agenda-remove-tags t))
8255          ("theagenda.ps"))))
8256 @end lisp
8258 @noindent
8259 This command sets two options for the Postscript exporter, to make it
8260 print in two columns in landscape format---the resulting page can be cut
8261 in two and then used in a paper agenda.  The remaining settings modify
8262 the agenda prefix to omit category and scheduling information, and
8263 instead include a checkbox to check off items.  We also remove the tags
8264 to make the lines compact, and we don't want to use colors for the
8265 black-and-white printer.  Settings specified in
8266 @code{org-agenda-exporter-settings} will also apply, but the settings
8267 in @code{org-agenda-custom-commands} take precedence.
8269 @noindent
8270 From the command line you may also use
8271 @example
8272 emacs -f org-batch-store-agenda-views -kill
8273 @end example
8274 @noindent
8275 or, if you need to modify some parameters@footnote{Quoting depends on the
8276 system you use, please check the FAQ for examples.}
8277 @example
8278 emacs -eval '(org-batch-store-agenda-views                      \
8279               org-agenda-ndays 30                               \
8280               org-agenda-start-day "2007-11-01"                 \
8281               org-agenda-include-diary nil                      \
8282               org-agenda-files (quote ("~/org/project.org")))'  \
8283       -kill
8284 @end example
8285 @noindent
8286 which will create the agenda views restricted to the file
8287 @file{~/org/project.org}, without diary entries and with a 30-day
8288 extent.
8290 You can also extract agenda information in a way that allows further
8291 processing by other programs.  See @ref{Extracting agenda information}, for
8292 more information.
8295 @node Agenda column view,  , Exporting Agenda Views, Agenda Views
8296 @section Using column view in the agenda
8297 @cindex column view, in agenda
8298 @cindex agenda, column view
8300 Column view (@pxref{Column view}) is normally used to view and edit
8301 properties embedded in the hierarchical structure of an Org file.  It can be
8302 quite useful to use column view also from the agenda, where entries are
8303 collected by certain criteria.
8305 @table @kbd
8306 @kindex C-c C-x C-c
8307 @item C-c C-x C-c
8308 Turn on column view in the agenda.
8309 @end table
8311 To understand how to use this properly, it is important to realize that the
8312 entries in the agenda are no longer in their proper outline environment.
8313 This causes the following issues:
8315 @enumerate
8316 @item
8317 @vindex org-columns-default-format
8318 @vindex org-overriding-columns-format
8319 Org needs to make a decision which @code{COLUMNS} format to use.  Since the
8320 entries in the agenda are collected from different files, and different files
8321 may have different @code{COLUMNS} formats, this is a non-trivial problem.
8322 Org first checks if the variable @code{org-overriding-columns-format} is
8323 currently set, and if so, takes the format from there.  Otherwise it takes
8324 the format associated with the first item in the agenda, or, if that item
8325 does not have a specific format (defined in a property, or in its file), it
8326 uses @code{org-columns-default-format}.
8327 @item
8328 @cindex property, special, CLOCKSUM
8329 If any of the columns has a summary type defined (@pxref{Column attributes}),
8330 turning on column view in the agenda will visit all relevant agenda files and
8331 make sure that the computations of this property are up to date.  This is
8332 also true for the special @code{CLOCKSUM} property.  Org will then sum the
8333 values displayed in the agenda.  In the daily/weekly agenda, the sums will
8334 cover a single day, in all other views they cover the entire block.  It is
8335 vital to realize that the agenda may show the same entry @emph{twice} (for
8336 example as scheduled and as a deadline), and it may show two entries from the
8337 same hierarchy (for example a @emph{parent} and its @emph{child}).  In these
8338 cases, the summation in the agenda will lead to incorrect results because
8339 some values will count double.
8340 @item
8341 When the column view in the agenda shows the @code{CLOCKSUM}, that is always
8342 the entire clocked time for this item.  So even in the daily/weekly agenda,
8343 the clocksum listed in column view may originate from times outside the
8344 current view.  This has the advantage that you can compare these values with
8345 a column listing the planned total effort for a task---one of the major
8346 applications for column view in the agenda.  If you want information about
8347 clocked time in the displayed period use clock table mode (press @kbd{R} in
8348 the agenda).
8349 @end enumerate
8352 @node Markup, Exporting, Agenda Views, Top
8353 @chapter Markup for rich export
8355 When exporting Org-mode documents, the exporter tries to reflect the
8356 structure of the document as accurately as possible in the backend.  Since
8357 export targets like HTML, La@TeX{}, or DocBook allow much richer formatting,
8358 Org-mode has rules on how to prepare text for rich export.  This section
8359 summarizes the markup rules used in an Org-mode buffer.
8361 @menu
8362 * Structural markup elements::  The basic structure as seen by the exporter
8363 * Images and tables::           Tables and Images will be included
8364 * Literal examples::            Source code examples with special formatting
8365 * Include files::               Include additional files into a document
8366 * Index entries::               Making an index
8367 * Macro replacement::           Use macros to create complex output
8368 * Embedded LaTeX::              LaTeX can be freely used inside Org documents
8369 @end menu
8371 @node Structural markup elements, Images and tables, Markup, Markup
8372 @section Structural markup elements
8374 @menu
8375 * Document title::              Where the title is taken from
8376 * Headings and sections::       The document structure as seen by the exporter
8377 * Table of contents::           The if and where of the table of contents
8378 * Initial text::                Text before the first heading?
8379 * Lists::                       Lists
8380 * Paragraphs::                  Paragraphs
8381 * Footnote markup::             Footnotes
8382 * Emphasis and monospace::      Bold, italic, etc.
8383 * Horizontal rules::            Make a line
8384 * Comment lines::               What will *not* be exported
8385 @end menu
8387 @node Document title, Headings and sections, Structural markup elements, Structural markup elements
8388 @subheading Document title
8389 @cindex document title, markup rules
8391 @noindent
8392 The title of the exported document is taken from the special line
8394 @cindex #+TITLE
8395 @example
8396 #+TITLE: This is the title of the document
8397 @end example
8399 @noindent
8400 If this line does not exist, the title is derived from the first non-empty,
8401 non-comment line in the buffer.  If no such line exists, or if you have
8402 turned off exporting of the text before the first headline (see below), the
8403 title will be the file name without extension.
8405 @cindex property, EXPORT_TITLE
8406 If you are exporting only a subtree by marking is as the region, the heading
8407 of the subtree will become the title of the document.  If the subtree has a
8408 property @code{EXPORT_TITLE}, that will take precedence.
8410 @node Headings and sections, Table of contents, Document title, Structural markup elements
8411 @subheading Headings and sections
8412 @cindex headings and sections, markup rules
8414 @vindex org-export-headline-levels
8415 The outline structure of the document as described in @ref{Document
8416 Structure}, forms the basis for defining sections of the exported document.
8417 However, since the outline structure is also used for (for example) lists of
8418 tasks, only the first three outline levels will be used as headings.  Deeper
8419 levels will become itemized lists.  You can change the location of this
8420 switch globally by setting the variable @code{org-export-headline-levels}, or on a
8421 per-file basis with a line
8423 @cindex #+OPTIONS
8424 @example
8425 #+OPTIONS: H:4
8426 @end example
8428 @node Table of contents, Initial text, Headings and sections, Structural markup elements
8429 @subheading Table of contents
8430 @cindex table of contents, markup rules
8432 @vindex org-export-with-toc
8433 The table of contents is normally inserted directly before the first headline
8434 of the file.  If you would like to get it to a different location, insert the
8435 string @code{[TABLE-OF-CONTENTS]} on a line by itself at the desired
8436 location.  The depth of the table of contents is by default the same as the
8437 number of headline levels, but you can choose a smaller number, or turn off
8438 the table of contents entirely, by configuring the variable
8439 @code{org-export-with-toc}, or on a per-file basis with a line like
8441 @example
8442 #+OPTIONS: toc:2          (only to two levels in TOC)
8443 #+OPTIONS: toc:nil        (no TOC at all)
8444 @end example
8446 @node Initial text, Lists, Table of contents, Structural markup elements
8447 @subheading Text before the first headline
8448 @cindex text before first headline, markup rules
8449 @cindex #+TEXT
8451 Org-mode normally exports the text before the first headline, and even uses
8452 the first line as the document title.  The text will be fully marked up.  If
8453 you need to include literal HTML, La@TeX{}, or DocBook code, use the special
8454 constructs described below in the sections for the individual exporters.
8456 @vindex org-export-skip-text-before-1st-heading
8457 Some people like to use the space before the first headline for setup and
8458 internal links and therefore would like to control the exported text before
8459 the first headline in a different way.  You can do so by setting the variable
8460 @code{org-export-skip-text-before-1st-heading} to @code{t}.  On a per-file
8461 basis, you can get the same effect with @samp{#+OPTIONS: skip:t}.
8463 @noindent
8464 If you still want to have some text before the first headline, use the
8465 @code{#+TEXT} construct:
8467 @example
8468 #+OPTIONS: skip:t
8469 #+TEXT: This text will go before the *first* headline.
8470 #+TEXT: [TABLE-OF-CONTENTS]
8471 #+TEXT: This goes between the table of contents and the first headline
8472 @end example
8474 @node Lists, Paragraphs, Initial text, Structural markup elements
8475 @subheading Lists
8476 @cindex lists, markup rules
8478 Plain lists as described in @ref{Plain lists}, are translated to the backend's
8479 syntax for such lists.  Most backends support unordered, ordered, and
8480 description lists.
8482 @node Paragraphs, Footnote markup, Lists, Structural markup elements
8483 @subheading Paragraphs, line breaks, and quoting
8484 @cindex paragraphs, markup rules
8486 Paragraphs are separated by at least one empty line.  If you need to enforce
8487 a line break within a paragraph, use @samp{\\} at the end of a line.
8489 To keep the line breaks in a region, but otherwise use normal formatting, you
8490 can use this construct, which can also be used to format poetry.
8492 @cindex #+BEGIN_VERSE
8493 @example
8494 #+BEGIN_VERSE
8495  Great clouds overhead
8496  Tiny black birds rise and fall
8497  Snow covers Emacs
8499      -- AlexSchroeder
8500 #+END_VERSE
8501 @end example
8503 When quoting a passage from another document, it is customary to format this
8504 as a paragraph that is indented on both the left and the right margin.  You
8505 can include quotations in Org-mode documents like this:
8507 @cindex #+BEGIN_QUOTE
8508 @example
8509 #+BEGIN_QUOTE
8510 Everything should be made as simple as possible,
8511 but not any simpler -- Albert Einstein
8512 #+END_QUOTE
8513 @end example
8515 If you would like to center some text, do it like this:
8516 @cindex #+BEGIN_CENTER
8517 @example
8518 #+BEGIN_CENTER
8519 Everything should be made as simple as possible, \\
8520 but not any simpler
8521 #+END_CENTER
8522 @end example
8525 @node Footnote markup, Emphasis and monospace, Paragraphs, Structural markup elements
8526 @subheading Footnote markup
8527 @cindex footnotes, markup rules
8528 @cindex @file{footnote.el}
8530 Footnotes defined in the way described in @ref{Footnotes}, will be exported by
8531 all backends.  Org allows multiple references to the same note, and
8532 different backends support this to varying degrees.
8534 @node Emphasis and monospace, Horizontal rules, Footnote markup, Structural markup elements
8535 @subheading Emphasis and monospace
8537 @cindex underlined text, markup rules
8538 @cindex bold text, markup rules
8539 @cindex italic text, markup rules
8540 @cindex verbatim text, markup rules
8541 @cindex code text, markup rules
8542 @cindex strike-through text, markup rules
8543 You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
8544 and @code{~verbatim~}, and, if you must, @samp{+strike-through+}.  Text
8545 in the code and verbatim string is not processed for Org-mode specific
8546 syntax, it is exported verbatim.
8548 @node Horizontal rules, Comment lines, Emphasis and monospace, Structural markup elements
8549 @subheading  Horizontal rules
8550 @cindex horizontal rules, markup rules
8551 A line consisting of only dashes, and at least 5 of them, will be
8552 exported as a horizontal line (@samp{<hr/>} in HTML).
8554 @node Comment lines,  , Horizontal rules, Structural markup elements
8555 @subheading Comment lines
8556 @cindex comment lines
8557 @cindex exporting, not
8558 @cindex #+BEGIN_COMMENT
8560 Lines starting with @samp{#} in column zero are treated as comments and will
8561 never be exported. If you want an indented line to be treated as a comment,
8562 start it with @samp{#+ }.  Also entire subtrees starting with the word
8563 @samp{COMMENT} will never be exported.  Finally, regions surrounded by
8564 @samp{#+BEGIN_COMMENT} ... @samp{#+END_COMMENT} will not be exported.
8566 @table @kbd
8567 @kindex C-c ;
8568 @item C-c ;
8569 Toggle the COMMENT keyword at the beginning of an entry.
8570 @end table
8573 @node Images and tables, Literal examples, Structural markup elements, Markup
8574 @section Images and Tables
8576 @cindex tables, markup rules
8577 @cindex #+CAPTION
8578 @cindex #+LABEL
8579 Both the native Org-mode tables (@pxref{Tables}) and tables formatted with
8580 the @file{table.el} package will be exported properly.  For Org-mode tables,
8581 the lines before the first horizontal separator line will become table header
8582 lines.  You can use the following lines somewhere before the table to assign
8583 a caption and a label for cross references, and in the text you can refer to
8584 the object with @code{\ref@{tab:basic-data@}}:
8586 @example
8587 #+CAPTION: This is the caption for the next table (or link)
8588 #+LABEL:   tbl:basic-data
8589    | ... | ...|
8590    |-----|----|
8591 @end example
8593 @cindex inlined images, markup rules
8594 Some backends (HTML, La@TeX{}, and DocBook) allow you to directly include
8595 images into the exported document.  Org does this, if a link to an image
8596 files does not have a description part, for example @code{[[./img/a.jpg]]}.
8597 If you wish to define a caption for the image and maybe a label for internal
8598 cross references, make sure that the link is on a line by itself and precede
8599 it with @code{#+CAPTION} and @code{#+LABEL} as follows:
8601 @example
8602 #+CAPTION: This is the caption for the next figure link (or table)
8603 #+LABEL:   fig:SED-HR4049
8604 [[./img/a.jpg]]
8605 @end example
8607 You may also define additional attributes for the figure.  As this is
8608 backend-specific, see the sections about the individual backends for more
8609 information.
8612 @node Literal examples, Include files, Images and tables, Markup
8613 @section Literal examples
8614 @cindex literal examples, markup rules
8615 @cindex code line references, markup rules
8617 You can include literal examples that should not be subjected to
8618 markup.  Such examples will be typeset in monospace, so this is well suited
8619 for source code and similar examples.
8620 @cindex #+BEGIN_EXAMPLE
8622 @example
8623 #+BEGIN_EXAMPLE
8624 Some example from a text file.
8625 #+END_EXAMPLE
8626 @end example
8628 Note that such blocks may be @i{indented} in order to align nicely with
8629 indented text and in particular with plain list structure (@pxref{Plain
8630 lists}).  For simplicity when using small examples, you can also start the
8631 example lines with a colon followed by a space.  There may also be additional
8632 whitespace before the colon:
8634 @example
8635 Here is an example
8636    : Some example from a text file.
8637 @end example
8639 @cindex formatting source code, markup rules
8640 If the example is source code from a programming language, or any other text
8641 that can be marked up by font-lock in Emacs, you can ask for the example to
8642 look like the fontified Emacs buffer@footnote{Currently this works for the
8643 HTML backend, and requires the @file{htmlize.el} package version 1.34 or
8644 later.  It also works for LaTeX with the listings package, if you turn on the
8645 option @code{org-export-latex-listings} and make sure that the listings
8646 package is included by the LaTeX header.}.  This is done with the @samp{src}
8647 block, where you also need to specify the name of the major mode that should
8648 be used to fontify the example:
8649 @cindex #+BEGIN_SRC
8651 @example
8652 #+BEGIN_SRC emacs-lisp
8653   (defun org-xor (a b)
8654      "Exclusive or."
8655      (if a (not b) b))
8656 #+END_SRC
8657 @end example
8659 Both in @code{example} and in @code{src} snippets, you can add a @code{-n}
8660 switch to the end of the @code{BEGIN} line, to get the lines of the example
8661 numbered.  If you use a @code{+n} switch, the numbering from the previous
8662 numbered snippet will be continued in the current one.  In literal examples,
8663 Org will interpret strings like @samp{(ref:name)} as labels, and use them as
8664 targets for special hyperlinks like @code{[[(name)]]} (i.e. the reference name
8665 enclosed in single parenthesis).  In HTML, hovering the mouse over such a
8666 link will remote-highlight the corresponding code line, which is kind of
8667 cool.
8669 You can also add a @code{-r} switch which @i{removes} the labels from the
8670 source code@footnote{Adding @code{-k} to @code{-n -r} will @i{keep} the
8671 labels in the source code while using line numbers for the links, which might
8672 be useful to explain those in an org-mode example code.}.  With the @code{-n}
8673 switch, links to these references will be labeled by the line numbers from
8674 the code listing, otherwise links will use the labels with no parentheses.
8675 Here is an example:
8677 @example
8678 #+BEGIN_SRC emacs-lisp -n -r
8679 (save-excursion                  (ref:sc)
8680    (goto-char (point-min))       (ref:jump)
8681 #+END_SRC
8682 In line [[(sc)]] we remember the current position.  [[(jump)][Line (jump)]]
8683 jumps to point-min.
8684 @end example
8686 @vindex org-coderef-label-format
8687 If the syntax for the label format conflicts with the language syntax, use a
8688 @code{-l} switch to change the format, for example @samp{#+BEGIN_SRC pascal
8689 -n -r -l "((%s))"}.  See also the variable @code{org-coderef-label-format}.
8691 HTML export also allows examples to be published as text areas, @xref{Text
8692 areas in HTML export}.
8694 @table @kbd
8695 @kindex C-c '
8696 @item C-c '
8697 Edit the source code example at point in its native mode.  This works by
8698 switching to a temporary buffer with the source code.  You need to exit by
8699 pressing @kbd{C-c '} again@footnote{Upon exit, lines starting with @samp{*}
8700 or @samp{#} will get a comma prepended, to keep them from being interpreted
8701 by Org as outline nodes or special comments.  These commas will be stripped
8702 for editing with @kbd{C-c '}, and also for export.}, the edited version will
8703 then replace the old version in the Org buffer.  Fixed-width regions
8704 (where each line starts with a colon followed by a space) will be edited
8705 using @code{artist-mode}@footnote{You may select a different-mode with the
8706 variable @code{org-edit-fixed-width-region-mode}.} to allow creating ASCII
8707 drawings easily.  Using this command in an empty line will create a new
8708 fixed-width region.
8709 @kindex C-c l
8710 @item C-c l
8711 Calling @code{org-store-link} while editing a source code example in a
8712 temporary buffer created with @kbd{C-c '} will prompt for a label, make sure
8713 that it is unique in the current buffer, and insert it with the proper
8714 formatting like @samp{(ref:label)} at the end of the current line.  Then the
8715 label is stored as a link @samp{(label)}, for retrieval with @kbd{C-c C-l}.
8716 @end table
8719 @node Include files, Index entries, Literal examples, Markup
8720 @section Include files
8721 @cindex include files, markup rules
8723 During export, you can include the content of another file.  For example, to
8724 include your @file{.emacs} file, you could use:
8725 @cindex #+INCLUDE
8727 @example
8728 #+INCLUDE: "~/.emacs" src emacs-lisp
8729 @end example
8730 @noindent
8731 The optional second and third parameter are the markup (e.g. @samp{quote},
8732 @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
8733 language for formatting the contents.  The markup is optional, if it is not
8734 given, the text will be assumed to be in Org-mode format and will be
8735 processed normally.  The include line will also allow additional keyword
8736 parameters @code{:prefix1} and @code{:prefix} to specify prefixes for the
8737 first line and for each following line, as well as any options accepted by
8738 the selected markup.  For example, to include a file as an item, use
8740 @example
8741 #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
8742 @end example
8744 @table @kbd
8745 @kindex C-c '
8746 @item C-c '
8747 Visit the include file at point.
8748 @end table
8750 @node Index entries, Macro replacement, Include files, Markup
8751 @section Index entries
8752 @cindex index entries, for publishing
8754 You can specify entries that will be used for generating an index during
8755 publishing.  This is done by lines starting with @code{#+INDEX}.  An entry
8756 the contains an exclamation mark will create a sub item.  See @ref{Generating
8757 an index} for more information.
8759 @example
8760 * Curriculum Vitae
8761 #+INDEX: CV
8762 #+INDEX: Application!CV
8763 @end example
8768 @node Macro replacement, Embedded LaTeX, Index entries, Markup
8769 @section Macro replacement
8770 @cindex macro replacement, during export
8771 @cindex #+MACRO
8773 You can define text snippets with
8775 @example
8776 #+MACRO: name   replacement text $1, $2 are arguments
8777 @end example
8779 @noindent which can be referenced anywhere in the document (even in
8780 code examples) with @code{@{@{@{name(arg1,arg2)@}@}@}}.  In addition to
8781 defined macros, @code{@{@{@{title@}@}@}}, @code{@{@{@{author@}@}@}}, etc.,
8782 will reference information set by the @code{#+TITLE:}, @code{#+AUTHOR:}, and
8783 similar lines.  Also, @code{@{@{@{date(@var{FORMAT})@}@}@}} and
8784 @code{@{@{@{modification-time(@var{FORMAT})@}@}@}} refer to current date time
8785 and to the modification time of the file being exported, respectively.
8786 @var{FORMAT} should be a format string understood by
8787 @code{format-time-string}.
8789 Macro expansion takes place during export, and some people use it to
8790 construct complex HTML code.
8793 @node Embedded LaTeX,  , Macro replacement, Markup
8794 @section Embedded La@TeX{}
8795 @cindex @TeX{} interpretation
8796 @cindex La@TeX{} interpretation
8798 Plain ASCII is normally sufficient for almost all note taking.  One
8799 exception, however, are scientific notes which need to be able to contain
8800 mathematical symbols and the occasional formula.  La@TeX{}@footnote{La@TeX{}
8801 is a macro system based on Donald E. Knuth's @TeX{} system.  Many of the
8802 features described here as ``La@TeX{}'' are really from @TeX{}, but for
8803 simplicity I am blurring this distinction.}  is widely used to typeset
8804 scientific documents. Org-mode supports embedding La@TeX{} code into its
8805 files, because many academics are used to writing and reading La@TeX{} source
8806 code, and because it can be readily processed to produce pretty output for a
8807 number of export backends.
8809 @menu
8810 * Special symbols::             Greek letters and other symbols
8811 * Subscripts and superscripts::  Simple syntax for raising/lowering text
8812 * LaTeX fragments::             Complex formulas made easy
8813 * Previewing LaTeX fragments::  What will this snippet look like?
8814 * CDLaTeX mode::                Speed up entering of formulas
8815 @end menu
8817 @node Special symbols, Subscripts and superscripts, Embedded LaTeX, Embedded LaTeX
8818 @subsection Special symbols
8819 @cindex math symbols
8820 @cindex special symbols
8821 @cindex @TeX{} macros
8822 @cindex La@TeX{} fragments, markup rules
8823 @cindex HTML entities
8824 @cindex La@TeX{} entities
8826 You can use La@TeX{} macros to insert special symbols like @samp{\alpha} to
8827 indicate the Greek letter, or @samp{\to} to indicate an arrow.  Completion
8828 for these macros is available, just type @samp{\} and maybe a few letters,
8829 and press @kbd{M-@key{TAB}} to see possible completions.  Unlike La@TeX{}
8830 code, Org-mode allows these macros to be present without surrounding math
8831 delimiters, for example:
8833 @example
8834 Angles are written as Greek letters \alpha, \beta and \gamma.
8835 @end example
8837 @vindex org-entities
8838 During export, these symbols will be transformed into the native format of
8839 the exporter backend.  Strings like @code{\alpha} will be exported as
8840 @code{&alpha;} in the HTML output, and as @code{$\alpha$} in the La@TeX{}
8841 output.  Similarly, @code{\nbsp} will become @code{&nbsp;} in HTML and
8842 @code{~} in La@TeX{}.  If you need such a symbol inside a word, terminate it
8843 like this: @samp{\Aacute@{@}stor}.
8845 A large number of entities is provided, with names taken from both HTML and
8846 La@TeX{}, see the variable @code{org-entities} for the complete list.
8847 @samp{\-} is treated as a shy hyphen, and @samp{--}, @samp{---}, and
8848 @samp{...} are all converted into special commands creating hyphens of
8849 different lengths or a compact set of dots.
8851 If you would like to see entities displayed as UTF8 characters, use the
8852 following command@footnote{You can turn this on by default by setting the
8853 variable @code{org-pretty-entities}, or on a per-file base with the
8854 @code{#+STARTUP} option @code{entitiespretty}.}:
8856 @table @kbd
8857 @kindex C-c C-x \
8858 @item C-c C-x \
8859 Toggle display of entities as UTF8 characters.  This does not change the
8860 buffer content which remains plain ASCII, but it overlays the UTF8 character
8861 for display purposes only.
8862 @end table
8864 @node Subscripts and superscripts, LaTeX fragments, Special symbols, Embedded LaTeX
8865 @subsection Subscripts and superscripts
8866 @cindex subscript
8867 @cindex superscript
8869 Just like in La@TeX{}, @samp{^} and @samp{_} are used to indicate super-
8870 and subscripts.  Again, these can be used without embedding them in
8871 math-mode delimiters.  To increase the readability of ASCII text, it is
8872 not necessary (but OK) to surround multi-character sub- and superscripts
8873 with curly braces.  For example
8875 @example
8876 The mass if the sun is M_sun = 1.989 x 10^30 kg.  The radius of
8877 the sun is R_@{sun@} = 6.96 x 10^8 m.
8878 @end example
8880 @vindex org-export-with-sub-superscripts
8881 To avoid interpretation as raised or lowered text, you can quote @samp{^} and
8882 @samp{_} with a backslash: @samp{\^} and @samp{\_}.  If you write a text
8883 where the underscore is often used in a different context, Org's convention
8884 to always interpret these as subscripts can get in your way.  Configure the
8885 variable @code{org-export-with-sub-superscripts} to globally change this
8886 convention, or use, on a per-file basis:
8888 @example
8889 #+OPTIONS: ^:@{@}
8890 @end example
8892 @noindent With this setting, @samp{a_b} will not be interpreted as a
8893 subscript, but @samp{a_@{b@}} will.
8895 @table @kbd
8896 @kindex C-c C-x \
8897 @item C-c C-x \
8898 In addition to showing entities as UTF8 characters, this command will also
8899 format sub- and superscripts in a WYSIWYM way.
8900 @end table
8902 @node LaTeX fragments, Previewing LaTeX fragments, Subscripts and superscripts, Embedded LaTeX
8903 @subsection La@TeX{} fragments
8904 @cindex La@TeX{} fragments
8906 @vindex org-format-latex-header
8907 Going beyond symbols and sub- and superscripts, a full formula language is
8908 needed.  Org-mode can contain La@TeX{} math fragments, and it supports ways
8909 to process these for several export backends.  When exporting to La@TeX{},
8910 the code is obviously left as it is.  When exporting to HTML, Org invokes the
8911 @uref{http://www.mathjax.org, MathJax library} (@pxref{Math formatting in
8912 HTML export}) to process and display the math@footnote{If you plan to use
8913 this regularly or on pages with significant page views, you should install
8914 @file{MathJax} on your own server in order to limit the load of our server.}.
8915 Finally, it can also process the mathematical expressions into
8916 images@footnote{For this to work you need to be on a system with a working
8917 La@TeX{} installation. You also need the @file{dvipng} program, available at
8918 @url{http://sourceforge.net/projects/dvipng/}.  The La@TeX{} header that will
8919 be used when processing a fragment can be configured with the variable
8920 @code{org-format-latex-header}.}  that can be displayed in a browser or in
8921 DocBook documents.
8923 La@TeX{} fragments don't need any special marking at all.  The following
8924 snippets will be identified as La@TeX{} source code:
8925 @itemize @bullet
8926 @item
8927 Environments of any kind@footnote{When @file{MathJax} is used, only the
8928 environment recognized by @file{MathJax} will be processed.  When dvipng is
8929 used to create images, any La@TeX{} environments will be handled.}.  The only
8930 requirement is that the @code{\begin} statement appears on a new line,
8931 preceded by only whitespace.
8932 @item
8933 Text within the usual La@TeX{} math delimiters.  To avoid conflicts with
8934 currency specifications, single @samp{$} characters are only recognized as
8935 math delimiters if the enclosed text contains at most two line breaks, is
8936 directly attached to the @samp{$} characters with no whitespace in between,
8937 and if the closing @samp{$} is followed by whitespace, punctuation or a dash.
8938 For the other delimiters, there is no such restriction, so when in doubt, use
8939 @samp{\(...\)} as inline math delimiters.
8940 @end itemize
8942 @noindent For example:
8944 @example
8945 \begin@{equation@}                          % arbitrary environments,
8946 x=\sqrt@{b@}                                % even tables, figures
8947 \end@{equation@}                            % etc
8949 If $a^2=b$ and \( b=2 \), then the solution must be
8950 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
8951 @end example
8953 @noindent
8954 @vindex org-format-latex-options
8955 If you need any of the delimiter ASCII sequences for other purposes, you
8956 can configure the option @code{org-format-latex-options} to deselect the
8957 ones you do not wish to have interpreted by the La@TeX{} converter.
8959 @vindex org-export-with-LaTeX-fragments
8960 LaTeX processing can be configured with the variable
8961 @code{org-export-with-LaTeX-fragments}.  The default setting is @code{t}
8962 which means @file{MathJax} for HTML, and no processing for DocBook, ASCII and
8963 LaTeX backends.  You can also set this variable on a per-file basis using one
8964 of these lines:
8966 @example
8967 #+OPTIONS: LaTeX:t          @r{Do the right thing automatically (MathJax)}
8968 #+OPTIONS: LaTeX:dvipng     @r{Force using dvipng images}
8969 #+OPTIONS: LaTeX:nil        @r{Do not process La@TeX{} fragments at all}
8970 #+OPTIONS: LaTeX:verbatim   @r{Verbatim export, for jsMath or so}
8971 @end example
8973 @node Previewing LaTeX fragments, CDLaTeX mode, LaTeX fragments, Embedded LaTeX
8974 @subsection Previewing LaTeX fragments
8975 @cindex LaTeX fragments, preview
8977 If you have @file{dvipng} installed, La@TeX{} fragments can be processed to
8978 produce preview images of the typeset expressions:
8980 @table @kbd
8981 @kindex C-c C-x C-l
8982 @item C-c C-x C-l
8983 Produce a preview image of the La@TeX{} fragment at point and overlay it
8984 over the source code.  If there is no fragment at point, process all
8985 fragments in the current entry (between two headlines).  When called
8986 with a prefix argument, process the entire subtree.  When called with
8987 two prefix arguments, or when the cursor is before the first headline,
8988 process the entire buffer.
8989 @kindex C-c C-c
8990 @item C-c C-c
8991 Remove the overlay preview images.
8992 @end table
8994 @vindex org-format-latex-options
8995 You can customize the variable @code{org-format-latex-options} to influence
8996 some aspects of the preview. In particular, the @code{:scale} (and for HTML
8997 export, @code{:html-scale}) property can be used to adjust the size of the
8998 preview images.
9000 @node CDLaTeX mode,  , Previewing LaTeX fragments, Embedded LaTeX
9001 @subsection Using CDLa@TeX{} to enter math
9002 @cindex CDLa@TeX{}
9004 CDLa@TeX{} mode is a minor mode that is normally used in combination with a
9005 major La@TeX{} mode like AUC@TeX{} in order to speed-up insertion of
9006 environments and math templates.  Inside Org-mode, you can make use of
9007 some of the features of CDLa@TeX{} mode.  You need to install
9008 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
9009 AUC@TeX{}) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
9010 Don't use CDLa@TeX{} mode itself under Org-mode, but use the light
9011 version @code{org-cdlatex-mode} that comes as part of Org-mode.  Turn it
9012 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
9013 Org files with
9015 @lisp
9016 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
9017 @end lisp
9019 When this mode is enabled, the following features are present (for more
9020 details see the documentation of CDLa@TeX{} mode):
9021 @itemize @bullet
9022 @kindex C-c @{
9023 @item
9024 Environment templates can be inserted with @kbd{C-c @{}.
9025 @item
9026 @kindex @key{TAB}
9027 The @key{TAB} key will do template expansion if the cursor is inside a
9028 La@TeX{} fragment@footnote{Org-mode has a method to test if the cursor is
9029 inside such a fragment, see the documentation of the function
9030 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
9031 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
9032 correctly inside the first brace.  Another @key{TAB} will get you into
9033 the second brace.  Even outside fragments, @key{TAB} will expand
9034 environment abbreviations at the beginning of a line.  For example, if
9035 you write @samp{equ} at the beginning of a line and press @key{TAB},
9036 this abbreviation will be expanded to an @code{equation} environment.
9037 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
9038 @item
9039 @kindex _
9040 @kindex ^
9041 @vindex cdlatex-simplify-sub-super-scripts
9042 Pressing @kbd{_} and @kbd{^} inside a La@TeX{} fragment will insert these
9043 characters together with a pair of braces.  If you use @key{TAB} to move
9044 out of the braces, and if the braces surround only a single character or
9045 macro, they are removed again (depending on the variable
9046 @code{cdlatex-simplify-sub-super-scripts}).
9047 @item
9048 @kindex `
9049 Pressing the backquote @kbd{`} followed by a character inserts math
9050 macros, also outside La@TeX{} fragments.  If you wait more than 1.5 seconds
9051 after the backquote, a help window will pop up.
9052 @item
9053 @kindex '
9054 Pressing the single-quote @kbd{'} followed by another character modifies
9055 the symbol before point with an accent or a font.  If you wait more than
9056 1.5 seconds after the backquote, a help window will pop up.  Character
9057 modification will work only inside La@TeX{} fragments, outside the quote
9058 is normal.
9059 @end itemize
9061 @node Exporting, Publishing, Markup, Top
9062 @chapter Exporting
9063 @cindex exporting
9065 Org-mode documents can be exported into a variety of other formats.  For
9066 printing and sharing of notes, ASCII export produces a readable and simple
9067 version of an Org file.  HTML export allows you to publish a notes file on
9068 the web, while the XOXO format provides a solid base for exchange with a
9069 broad range of other applications. La@TeX{} export lets you use Org-mode and
9070 its structured editing functions to easily create La@TeX{} files.  DocBook
9071 export makes it possible to convert Org files to many other formats using
9072 DocBook tools.  For project management you can create gantt and resource
9073 charts by using TaskJuggler export.  To incorporate entries with associated
9074 times like deadlines or appointments into a desktop calendar program like
9075 iCal, Org-mode can also produce extracts in the iCalendar format.  Currently
9076 Org-mode only supports export, not import of these different formats.
9078 Org supports export of selected regions when @code{transient-mark-mode} is
9079 enabled (default in Emacs 23).
9081 @menu
9082 * Selective export::            Using tags to select and exclude trees
9083 * Export options::              Per-file export settings
9084 * The export dispatcher::       How to access exporter commands
9085 * ASCII/Latin-1/UTF-8 export::  Exporting to flat files with encoding
9086 * HTML export::                 Exporting to HTML
9087 * LaTeX and PDF export::        Exporting to La@TeX{}, and processing to PDF
9088 * DocBook export::              Exporting to DocBook
9089 * TaskJuggler export::          Exporting to TaskJuggler
9090 * Freemind export::             Exporting to Freemind mind maps
9091 * XOXO export::                 Exporting to XOXO
9092 * iCalendar export::            Exporting in iCalendar format
9093 @end menu
9095 @node Selective export, Export options, Exporting, Exporting
9096 @section Selective export
9097 @cindex export, selective by tags
9099 @vindex org-export-select-tags
9100 @vindex org-export-exclude-tags
9101 You may use tags to select the parts of a document that should be exported,
9102 or to exclude parts from export.  This behavior is governed by two variables:
9103 @code{org-export-select-tags} and @code{org-export-exclude-tags}.
9105 Org first checks if any of the @emph{select} tags is present in the buffer.
9106 If yes, all trees that do not carry one of these tags will be excluded.  If a
9107 selected tree is a subtree, the heading hierarchy above it will also be
9108 selected for export, but not the text below those headings.
9110 @noindent
9111 If none of the select tags is found, the whole buffer will be selected for
9112 export.
9114 @noindent
9115 Finally, all subtrees that are marked by any of the @emph{exclude} tags will
9116 be removed from the export buffer.
9118 @node Export options, The export dispatcher, Selective export, Exporting
9119 @section Export options
9120 @cindex options, for export
9122 @cindex completion, of option keywords
9123 The exporter recognizes special lines in the buffer which provide
9124 additional information.  These lines may be put anywhere in the file.
9125 The whole set of lines can be inserted into the buffer with @kbd{C-c
9126 C-e t}.  For individual lines, a good way to make sure the keyword is
9127 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
9128 (@pxref{Completion}).   For a summary of other in-buffer settings not
9129 specifically related to export, see @ref{In-buffer settings}.
9130 In particular, note that you can place commonly-used (export) options in
9131 a separate file which can be included using @code{#+SETUPFILE}.
9133 @table @kbd
9134 @kindex C-c C-e t
9135 @item C-c C-e t
9136 Insert template with export options, see example below.
9137 @end table
9139 @cindex #+TITLE
9140 @cindex #+AUTHOR
9141 @cindex #+DATE
9142 @cindex #+EMAIL
9143 @cindex #+DESCRIPTION
9144 @cindex #+KEYWORDS
9145 @cindex #+LANGUAGE
9146 @cindex #+TEXT
9147 @cindex #+OPTIONS
9148 @cindex #+BIND
9149 @cindex #+LINK_UP
9150 @cindex #+LINK_HOME
9151 @cindex #+EXPORT_SELECT_TAGS
9152 @cindex #+EXPORT_EXCLUDE_TAGS
9153 @cindex #+XSLT
9154 @cindex #+LATEX_HEADER
9155 @vindex user-full-name
9156 @vindex user-mail-address
9157 @vindex org-export-default-language
9158 @example
9159 #+TITLE:       the title to be shown (default is the buffer name)
9160 #+AUTHOR:      the author (default taken from @code{user-full-name})
9161 #+DATE:        a date, fixed, of a format string for @code{format-time-string}
9162 #+EMAIL:       his/her email address (default from @code{user-mail-address})
9163 #+DESCRIPTION: the page description, e.g. for the XHTML meta tag
9164 #+KEYWORDS:    the page keywords, e.g. for the XHTML meta tag
9165 #+LANGUAGE:    language for HTML, e.g. @samp{en} (@code{org-export-default-language})
9166 #+TEXT:        Some descriptive text to be inserted at the beginning.
9167 #+TEXT:        Several lines may be given.
9168 #+OPTIONS:     H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
9169 #+BIND:        lisp-var lisp-val, e.g.: org-export-latex-low-levels itemize
9170                @r{You need to confirm using these, or configure @code{org-export-allow-BIND}}
9171 #+LINK_UP:     the ``up'' link of an exported page
9172 #+LINK_HOME:   the ``home'' link of an exported page
9173 #+LATEX_HEADER: extra line(s) for the LaTeX header, like \usepackage@{xyz@}
9174 #+EXPORT_SELECT_TAGS:   Tags that select a tree for export
9175 #+EXPORT_EXCLUDE_TAGS:  Tags that exclude a tree from export
9176 #+XSLT:        the XSLT stylesheet used by DocBook exporter to generate FO file
9177 @end example
9179 @noindent
9180 The OPTIONS line is a compact@footnote{If you want to configure many options
9181 this way, you can use several OPTIONS lines.} form to specify export settings.  Here
9182 you can:
9183 @cindex headline levels
9184 @cindex section-numbers
9185 @cindex table of contents
9186 @cindex line-break preservation
9187 @cindex quoted HTML tags
9188 @cindex fixed-width sections
9189 @cindex tables
9190 @cindex @TeX{}-like syntax for sub- and superscripts
9191 @cindex footnotes
9192 @cindex special strings
9193 @cindex emphasized text
9194 @cindex @TeX{} macros
9195 @cindex La@TeX{} fragments
9196 @cindex author info, in export
9197 @cindex time info, in export
9198 @example
9199 H:         @r{set the number of headline levels for export}
9200 num:       @r{turn on/off section-numbers}
9201 toc:       @r{turn on/off table of contents, or set level limit (integer)}
9202 \n:        @r{turn on/off line-break-preservation (DOES NOT WORK)}
9203 @@:         @r{turn on/off quoted HTML tags}
9204 ::         @r{turn on/off fixed-width sections}
9205 |:         @r{turn on/off tables}
9206 ^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
9207            @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
9208            @r{the simple @code{a_b} will be left as it is.}
9209 -:         @r{turn on/off conversion of special strings.}
9210 f:         @r{turn on/off footnotes like this[1].}
9211 todo:      @r{turn on/off inclusion of TODO keywords into exported text}
9212 pri:       @r{turn on/off priority cookies}
9213 tags:      @r{turn on/off inclusion of tags, may also be @code{not-in-toc}}
9214 <:         @r{turn on/off inclusion of any time/date stamps like DEADLINES}
9215 *:         @r{turn on/off emphasized text (bold, italic, underlined)}
9216 TeX:       @r{turn on/off simple @TeX{} macros in plain text}
9217 LaTeX:     @r{configure export of La@TeX{} fragments.  Default @code{auto}}
9218 skip:      @r{turn on/off skipping the text before the first heading}
9219 author:    @r{turn on/off inclusion of author name/email into exported file}
9220 email:     @r{turn on/off inclusion of author email into exported file}
9221 creator:   @r{turn on/off inclusion of creator info into exported file}
9222 timestamp: @r{turn on/off inclusion creation time into exported file}
9223 d:         @r{turn on/off inclusion of drawers}
9224 @end example
9225 @noindent
9226 These options take effect in both the HTML and La@TeX{} export, except
9227 for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
9228 @code{nil} for the La@TeX{} export.
9230 When exporting only a single subtree by selecting it with @kbd{C-c @@} before
9231 calling an export command, the subtree can overrule some of the file's export
9232 settings with properties @code{EXPORT_FILE_NAME}, @code{EXPORT_TITLE},
9233 @code{EXPORT_TEXT}, @code{EXPORT_AUTHOR}, @code{EXPORT_DATE}, and
9234 @code{EXPORT_OPTIONS}.
9236 @node The export dispatcher, ASCII/Latin-1/UTF-8 export, Export options, Exporting
9237 @section The export dispatcher
9238 @cindex dispatcher, for export commands
9240 All export commands can be reached using the export dispatcher, which is a
9241 prefix key that prompts for an additional key specifying the command.
9242 Normally the entire file is exported, but if there is an active region that
9243 contains one outline tree, the first heading is used as document title and
9244 the subtrees are exported.
9246 @table @kbd
9247 @kindex C-c C-e
9248 @item C-c C-e
9249 @vindex org-export-run-in-background
9250 Dispatcher for export and publishing commands.  Displays a help-window
9251 listing the additional key(s) needed to launch an export or publishing
9252 command.  The prefix arg is passed through to the exporter.  A double prefix
9253 @kbd{C-u C-u} causes most commands to be executed in the background, in a
9254 separate Emacs process@footnote{To make this behavior the default, customize
9255 the variable @code{org-export-run-in-background}.}.
9256 @kindex C-c C-e v
9257 @item C-c C-e v
9258 Like @kbd{C-c C-e}, but only export the text that is currently visible
9259 (i.e. not hidden by outline visibility).
9260 @kindex C-u C-u C-c C-e
9261 @item C-u C-u C-c C-e
9262 @vindex org-export-run-in-background
9263 Call an the exporter, but reverse the setting of
9264 @code{org-export-run-in-background}, i.e. request background processing if
9265 not set, or force processing in the current Emacs process if set.
9266 @end table
9268 @node ASCII/Latin-1/UTF-8 export, HTML export, The export dispatcher, Exporting
9269 @section ASCII/Latin-1/UTF-8 export
9270 @cindex ASCII export
9271 @cindex Latin-1 export
9272 @cindex UTF-8 export
9274 ASCII export produces a simple and very readable version of an Org-mode
9275 file, containing only plain ASCII.  Latin-1 and UTF-8 export augment the file
9276 with special characters and symbols available in these encodings.
9278 @cindex region, active
9279 @cindex active region
9280 @cindex transient-mark-mode
9281 @table @kbd
9282 @kindex C-c C-e a
9283 @item C-c C-e a
9284 @cindex property, EXPORT_FILE_NAME
9285 Export as ASCII file.  For an Org file, @file{myfile.org}, the ASCII file
9286 will be @file{myfile.txt}.  The file will be overwritten without
9287 warning.  If there is an active region@footnote{This requires
9288 @code{transient-mark-mode} be turned on.}, only the region will be
9289 exported. If the selected region is a single tree@footnote{To select the
9290 current subtree, use @kbd{C-c @@}.}, the tree head will
9291 become the document title.  If the tree head entry has or inherits an
9292 @code{EXPORT_FILE_NAME} property, that name will be used for the
9293 export.
9294 @kindex C-c C-e A
9295 @item C-c C-e A
9296 Export to a temporary buffer, do not create a file.
9297 @kindex C-c C-e n
9298 @kindex C-c C-e N
9299 @item C-c C-e n @ @ @r{and} @ @ C-c C-e N
9300 Like the above commands, but use Latin-1 encoding.
9301 @kindex C-c C-e u
9302 @kindex C-c C-e U
9303 @item C-c C-e u @ @ @r{and} @ @ C-c C-e U
9304 Like the above commands, but use UTF-8 encoding.
9305 @kindex C-c C-e v a
9306 @kindex C-c C-e v n
9307 @kindex C-c C-e v u
9308 @item C-c C-e v a @ @ @r{and} @ @ C-c C-e v n @ @ @r{and} @ @ C-c C-e v u
9309 Export only the visible part of the document.
9310 @end table
9312 @cindex headline levels, for exporting
9313 In the exported version, the first 3 outline levels will become
9314 headlines, defining a general document structure.  Additional levels
9315 will be exported as itemized lists.  If you want that transition to occur
9316 at a different level, specify it with a prefix argument.  For example,
9318 @example
9319 @kbd{C-1 C-c C-e a}
9320 @end example
9322 @noindent
9323 creates only top level headlines and does the rest as items.  When
9324 headlines are converted to items, the indentation of the text following
9325 the headline is changed to fit nicely under the item.  This is done with
9326 the assumption that the first body line indicates the base indentation of
9327 the body text.  Any indentation larger than this is adjusted to preserve
9328 the layout relative to the first line.  Should there be lines with less
9329 indentation than the first, these are left alone.
9331 @vindex org-export-ascii-links-to-notes
9332 Links will be exported in a footnote-like style, with the descriptive part in
9333 the text and the link in a note before the next heading.  See the variable
9334 @code{org-export-ascii-links-to-notes} for details and other options.
9336 @node HTML export, LaTeX and PDF export, ASCII/Latin-1/UTF-8 export, Exporting
9337 @section HTML export
9338 @cindex HTML export
9340 Org-mode contains an HTML (XHTML 1.0 strict) exporter with extensive
9341 HTML formatting, in ways similar to John Gruber's @emph{markdown}
9342 language, but with additional support for tables.
9344 @menu
9345 * HTML Export commands::        How to invoke HTML export
9346 * Quoting HTML tags::           Using direct HTML in Org-mode
9347 * Links in HTML export::        How links will be interpreted and formatted
9348 * Tables in HTML export::       How to modify the formatting of tables
9349 * Images in HTML export::       How to insert figures into HTML output
9350 * Math formatting in HTML export::  Beautiful math also on the web
9351 * Text areas in HTML export::   An alternative way to show an example
9352 * CSS support::                 Changing the appearance of the output
9353 * JavaScript support::          Info and Folding in a web browser
9354 @end menu
9356 @node HTML Export commands, Quoting HTML tags, HTML export, HTML export
9357 @subsection HTML export commands
9359 @cindex region, active
9360 @cindex active region
9361 @cindex transient-mark-mode
9362 @table @kbd
9363 @kindex C-c C-e h
9364 @item C-c C-e h
9365 @cindex property, EXPORT_FILE_NAME
9366 Export as HTML file @file{myfile.html}.  For an Org file @file{myfile.org},
9367 the ASCII file will be @file{myfile.html}.  The file will be overwritten
9368 without warning.  If there is an active region@footnote{This requires
9369 @code{transient-mark-mode} be turned on.}, only the region will be
9370 exported. If the selected region is a single tree@footnote{To select the
9371 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
9372 title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
9373 property, that name will be used for the export.
9374 @kindex C-c C-e b
9375 @item C-c C-e b
9376 Export as HTML file and immediately open it with a browser.
9377 @kindex C-c C-e H
9378 @item C-c C-e H
9379 Export to a temporary buffer, do not create a file.
9380 @kindex C-c C-e R
9381 @item C-c C-e R
9382 Export the active region to a temporary buffer.  With a prefix argument, do
9383 not produce the file header and footer, but just the plain HTML section for
9384 the region.  This is good for cut-and-paste operations.
9385 @kindex C-c C-e v h
9386 @kindex C-c C-e v b
9387 @kindex C-c C-e v H
9388 @kindex C-c C-e v R
9389 @item C-c C-e v h
9390 @item C-c C-e v b
9391 @item C-c C-e v H
9392 @item C-c C-e v R
9393 Export only the visible part of the document.
9394 @item M-x org-export-region-as-html
9395 Convert the region to HTML under the assumption that it was Org-mode
9396 syntax before.  This is a global command that can be invoked in any
9397 buffer.
9398 @item M-x org-replace-region-by-HTML
9399 Replace the active region (assumed to be in Org-mode syntax) by HTML
9400 code.
9401 @end table
9403 @cindex headline levels, for exporting
9404 In the exported version, the first 3 outline levels will become headlines,
9405 defining a general document structure.  Additional levels will be exported as
9406 itemized lists.  If you want that transition to occur at a different level,
9407 specify it with a numeric prefix argument.  For example,
9409 @example
9410 @kbd{C-2 C-c C-e b}
9411 @end example
9413 @noindent
9414 creates two levels of headings and does the rest as items.
9416 @node Quoting HTML tags, Links in HTML export, HTML Export commands, HTML export
9417 @subsection Quoting HTML tags
9419 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
9420 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
9421 which should be interpreted as such, mark them with @samp{@@} as in
9422 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
9423 simple tags.  For more extensive HTML that should be copied verbatim to
9424 the exported file use either
9426 @cindex #+HTML
9427 @cindex #+BEGIN_HTML
9428 @example
9429 #+HTML: Literal HTML code for export
9430 @end example
9432 @noindent or
9433 @cindex #+BEGIN_HTML
9435 @example
9436 #+BEGIN_HTML
9437 All lines between these markers are exported literally
9438 #+END_HTML
9439 @end example
9442 @node Links in HTML export, Tables in HTML export, Quoting HTML tags, HTML export
9443 @subsection Links in HTML export
9445 @cindex links, in HTML export
9446 @cindex internal links, in HTML export
9447 @cindex external links, in HTML export
9448 Internal links (@pxref{Internal links}) will continue to work in HTML.  This
9449 includes automatic links created by radio targets (@pxref{Radio
9450 targets}).  Links to external files will still work if the target file is on
9451 the same @i{relative} path as the published Org file.  Links to other
9452 @file{.org} files will be translated into HTML links under the assumption
9453 that an HTML version also exists of the linked file, at the same relative
9454 path.  @samp{id:} links can then be used to jump to specific entries across
9455 files.  For information related to linking files while publishing them to a
9456 publishing directory see @ref{Publishing links}.
9458 If you want to specify attributes for links, you can do so using a special
9459 @code{#+ATTR_HTML} line to define attributes that will be added to the
9460 @code{<a>} or @code{<img>} tags.  Here is an example that sets @code{title}
9461 and @code{style} attributes for a link:
9463 @cindex #+ATTR_HTML
9464 @example
9465 #+ATTR_HTML: title="The Org-mode homepage" style="color:red;"
9466 [[http://orgmode.org]]
9467 @end example
9469 @node Tables in HTML export, Images in HTML export, Links in HTML export, HTML export
9470 @subsection Tables
9471 @cindex tables, in HTML
9472 @vindex org-export-html-table-tag
9474 Org-mode tables are exported to HTML using the table tag defined in
9475 @code{org-export-html-table-tag}.  The default setting makes tables without
9476 cell borders and frame.  If you would like to change this for individual
9477 tables, place something like the following before the table:
9479 @cindex #+CAPTION
9480 @cindex #+ATTR_HTML
9481 @example
9482 #+CAPTION: This is a table with lines around and between cells
9483 #+ATTR_HTML: border="2" rules="all" frame="all"
9484 @end example
9486 @node Images in HTML export, Math formatting in HTML export, Tables in HTML export, HTML export
9487 @subsection Images in HTML export
9489 @cindex images, inline in HTML
9490 @cindex inlining images in HTML
9491 @vindex org-export-html-inline-images
9492 HTML export can inline images given as links in the Org file, and
9493 it can make an image the clickable part of a link.  By
9494 default@footnote{But see the variable
9495 @code{org-export-html-inline-images}.}, images are inlined if a link does
9496 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
9497 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
9498 @samp{the image} that points to the image.  If the description part
9499 itself is a @code{file:} link or a @code{http:} URL pointing to an
9500 image, this image will be inlined and activated so that clicking on the
9501 image will activate the link.  For example, to include a thumbnail that
9502 will link to a high resolution version of the image, you could use:
9504 @example
9505 [[file:highres.jpg][file:thumb.jpg]]
9506 @end example
9508 If you need to add attributes to an inlined image, use a @code{#+ATTR_HTML}.
9509 In the example below we specify the @code{alt} and @code{title} attributes to
9510 support text viewers and accessibility, and align it to the right.
9512 @cindex #+CAPTION
9513 @cindex #+ATTR_HTML
9514 @example
9515 #+CAPTION: A black cat stalking a spider
9516 #+ATTR_HTML: alt="cat/spider image" title="Action!" align="right"
9517 [[./img/a.jpg]]
9518 @end example
9520 @noindent
9521 and you could use @code{http} addresses just as well.
9523 @node Math formatting in HTML export, Text areas in HTML export, Images in HTML export, HTML export
9524 @subsection Math formatting in HTML export
9525 @cindex MathJax
9526 @cindex dvipng
9528 La@TeX{} math snippets (@pxref{LaTeX fragments}) can be displayed in two
9529 different ways on HTML pages.  The default is to use the
9530 @uref{http://www.mathjax.org, MathJax system} which should work out of the
9531 box with Org mode installation because @code{http://orgmode.org} serves
9532 @file{MathJax} for Org-mode users for small applications and for testing
9533 purposes.  @b{If you plan to use this regularly or on pages with significant
9534 page views, you should install MathJax on your own server in order to limit
9535 the load of our server.}  To configure @file{MathJax}, use the variable
9536 @code{org-export-html-mathjax-options} or insert something like the following
9537 into the buffer:
9539 @example
9540 #+MATHJAX: align:"left" mathml:t path:"/MathJax/MathJax.js"
9541 @end example
9543 @noindent See the docstring of the variable
9544 @code{org-export-html-mathjax-options} for the meaning of the parameters in
9545 this line.
9547 If you prefer, you can also request that La@TeX{} are processed into small
9548 images that will be inserted into the browser page.  Before the availability
9549 of MathJax, this was the default method for Org files.  This method requires
9550 that the @file{dvipng} program is available on your system.  You can still
9551 get this processing with
9553 @example
9554 #+OPTIONS: LaTeX:dvipng
9555 @end example
9557 @node Text areas in HTML export, CSS support, Math formatting in HTML export, HTML export
9558 @subsection Text areas in HTML export
9560 @cindex text areas, in HTML
9561 An alternative way to publish literal code examples in HTML is to use text
9562 areas, where the example can even be edited before pasting it into an
9563 application.  It is triggered by a @code{-t} switch at an @code{example} or
9564 @code{src} block.  Using this switch disables any options for syntax and
9565 label highlighting, and line numbering, which may be present.  You may also
9566 use @code{-h} and @code{-w} switches to specify the height and width of the
9567 text area, which default to the number of lines in the example, and 80,
9568 respectively.  For example
9570 @example
9571 #+BEGIN_EXAMPLE -t -w 40
9572   (defun org-xor (a b)
9573      "Exclusive or."
9574      (if a (not b) b))
9575 #+END_EXAMPLE
9576 @end example
9579 @node CSS support, JavaScript support, Text areas in HTML export, HTML export
9580 @subsection CSS support
9581 @cindex CSS, for HTML export
9582 @cindex HTML export, CSS
9584 @vindex org-export-html-todo-kwd-class-prefix
9585 @vindex org-export-html-tag-class-prefix
9586 You can also give style information for the exported file.  The HTML exporter
9587 assigns the following special CSS classes@footnote{If the classes on TODO
9588 keywords and tags lead to conflicts, use the variables
9589 @code{org-export-html-todo-kwd-class-prefix} and
9590 @code{org-export-html-tag-class-prefix} to make them unique.} to appropriate
9591 parts of the document---your style specifications may change these, in
9592 addition to any of the standard classes like for headlines, tables, etc.
9593 @example
9594 p.author            @r{author information, including email}
9595 p.date              @r{publishing date}
9596 p.creator           @r{creator info, about org-mode version}
9597 .title              @r{document title}
9598 .todo               @r{TODO keywords, all not-done states}
9599 .done               @r{the DONE keywords, all stated the count as done}
9600 .WAITING            @r{each TODO keyword also uses a class named after itself}
9601 .timestamp          @r{timestamp}
9602 .timestamp-kwd      @r{keyword associated with a timestamp, like SCHEDULED}
9603 .timestamp-wrapper  @r{span around keyword plus timestamp}
9604 .tag                @r{tag in a headline}
9605 ._HOME              @r{each tag uses itself as a class, "@@" replaced by "_"}
9606 .target             @r{target for links}
9607 .linenr             @r{the line number in a code example}
9608 .code-highlighted   @r{for highlighting referenced code lines}
9609 div.outline-N       @r{div for outline level N (headline plus text))}
9610 div.outline-text-N  @r{extra div for text at outline level N}
9611 .section-number-N   @r{section number in headlines, different for each level}
9612 div.figure          @r{how to format an inlined image}
9613 pre.src             @r{formatted source code}
9614 pre.example         @r{normal example}
9615 p.verse             @r{verse paragraph}
9616 div.footnotes       @r{footnote section headline}
9617 p.footnote          @r{footnote definition paragraph, containing a footnote}
9618 .footref            @r{a footnote reference number (always a <sup>)}
9619 .footnum            @r{footnote number in footnote definition (always <sup>)}
9620 @end example
9622 @vindex org-export-html-style-default
9623 @vindex org-export-html-style-include-default
9624 @vindex org-export-html-style
9625 @vindex org-export-html-extra
9626 @vindex org-export-html-style-default
9627 Each exported file contains a compact default style that defines these
9628 classes in a basic way@footnote{This style is defined in the constant
9629 @code{org-export-html-style-default}, which you should not modify.  To turn
9630 inclusion of these defaults off, customize
9631 @code{org-export-html-style-include-default}}.  You may overwrite these
9632 settings, or add to them by using the variables @code{org-export-html-style}
9633 (for Org-wide settings) and @code{org-export-html-style-extra} (for more
9634 granular settings, like file-local settings).  To set the latter variable
9635 individually for each file, you can use
9637 @cindex #+STYLE
9638 @example
9639 #+STYLE: <link rel="stylesheet" type="text/css" href="stylesheet.css" />
9640 @end example
9642 @noindent
9643 For longer style definitions, you can use several such lines.  You could also
9644 directly write a @code{<style>} @code{</style>} section in this way, without
9645 referring to an external file.
9647 @c FIXME: More about header and footer styles
9648 @c FIXME: Talk about links and targets.
9650 @node JavaScript support,  , CSS support, HTML export
9651 @subsection JavaScript supported display of web pages
9653 @cindex Rose, Sebastian
9654 Sebastian Rose has written a JavaScript program especially designed to
9655 enhance the web viewing experience of HTML files created with Org.  This
9656 program allows you to view large files in two different ways.  The first one
9657 is an @emph{Info}-like mode where each section is displayed separately and
9658 navigation can be done with the @kbd{n} and @kbd{p} keys (and some other keys
9659 as well, press @kbd{?} for an overview of the available keys).  The second
9660 view type is a @emph{folding} view much like Org provides inside Emacs.  The
9661 script is available at @url{http://orgmode.org/org-info.js} and you can find
9662 the documentation for it at @url{http://orgmode.org/worg/code/org-info-js/}.
9663 We host the script at our site, but if you use it a lot, you might
9664 not want to be dependent on @url{orgmode.org} and prefer to install a local
9665 copy on your own web server.
9667 To use the script, you need to make sure that the @file{org-jsinfo.el} module
9668 gets loaded.  It should be loaded by default, but you can try @kbd{M-x
9669 customize-variable @key{RET} org-modules @key{RET}} to convince yourself that
9670 this is indeed the case.  All it then takes to make use of the program is
9671 adding a single line to the Org file:
9673 @cindex #+INFOJS_OPT
9674 @example
9675 #+INFOJS_OPT: view:info toc:nil
9676 @end example
9678 @noindent
9679 If this line is found, the HTML header will automatically contain the code
9680 needed to invoke the script.  Using the line above, you can set the following
9681 viewing options:
9683 @example
9684 path:    @r{The path to the script.  The default is to grab the script from}
9685          @r{@url{http://orgmode.org/org-info.js}, but you might want to have}
9686          @r{a local copy and use a path like @samp{../scripts/org-info.js}.}
9687 view:    @r{Initial view when website is first shown.  Possible values are:}
9688          info      @r{Info-like interface with one section per page.}
9689          overview  @r{Folding interface, initially showing only top-level.}
9690          content   @r{Folding interface, starting with all headlines visible.}
9691          showall   @r{Folding interface, all headlines and text visible.}
9692 sdepth:  @r{Maximum headline level that will still become an independent}
9693          @r{section for info and folding modes.  The default is taken from}
9694          @r{@code{org-export-headline-levels} (= the @code{H} switch in @code{#+OPTIONS}).}
9695          @r{If this is smaller than in @code{org-export-headline-levels}, each}
9696          @r{info/folding section can still contain child headlines.}
9697 toc:     @r{Should the table of content @emph{initially} be visible?}
9698          @r{Even when @code{nil}, you can always get to the "toc" with @kbd{i}.}
9699 tdepth:  @r{The depth of the table of contents.  The defaults are taken from}
9700          @r{the variables @code{org-export-headline-levels} and @code{org-export-with-toc}.}
9701 ftoc:    @r{Does the css of the page specify a fixed position for the "toc"?}
9702          @r{If yes, the toc will never be displayed as a section.}
9703 ltoc:    @r{Should there be short contents (children) in each section?}
9704          @r{Make this @code{above} if the section should be above initial text.}
9705 mouse:   @r{Headings are highlighted when the mouse is over them.  Should be}
9706          @r{@samp{underline} (default) or a background color like @samp{#cccccc}.}
9707 buttons: @r{Should view-toggle buttons be everywhere?  When @code{nil} (the}
9708          @r{default), only one such button will be present.}
9709 @end example
9710 @noindent
9711 @vindex org-infojs-options
9712 @vindex org-export-html-use-infojs
9713 You can choose default values for these options by customizing the variable
9714 @code{org-infojs-options}.  If you always want to apply the script to your
9715 pages, configure the variable @code{org-export-html-use-infojs}.
9717 @node LaTeX and PDF export, DocBook export, HTML export, Exporting
9718 @section La@TeX{} and PDF export
9719 @cindex La@TeX{} export
9720 @cindex PDF export
9721 @cindex Guerry, Bastien
9723 Org-mode contains a La@TeX{} exporter written by Bastien Guerry.  With
9724 further processing@footnote{The default LaTeX output is designed for
9725 processing with pdftex or latex.  It includes packages that are not
9726 compatible with xetex and possibly luatex.  See the variables
9727 @code{org-export-latex-default-packages-alist} and
9728 @code{org-export-latex-packages-alist}.}, this backend is also used to
9729 produce PDF output.  Since the La@TeX{} output uses @file{hyperref} to
9730 implement links and cross references, the PDF output file will be fully
9731 linked.
9733 @menu
9734 * LaTeX/PDF export commands::   Which key invokes which commands
9735 * Header and sectioning::       Setting up the export file structure
9736 * Quoting LaTeX code::          Incorporating literal La@TeX{} code
9737 * Tables in LaTeX export::      Options for exporting tables to La@TeX{}
9738 * Images in LaTeX export::      How to insert figures into La@TeX{} output
9739 * Beamer class export::         Turning the file into a presentation
9740 @end menu
9742 @node LaTeX/PDF export commands, Header and sectioning, LaTeX and PDF export, LaTeX and PDF export
9743 @subsection La@TeX{} export commands
9745 @cindex region, active
9746 @cindex active region
9747 @cindex transient-mark-mode
9748 @table @kbd
9749 @kindex C-c C-e l
9750 @item C-c C-e l
9751 @cindex property EXPORT_FILE_NAME
9752 Export as La@TeX{} file @file{myfile.tex}.  For an Org file
9753 @file{myfile.org}, the ASCII file will be @file{myfile.tex}.  The file will
9754 be overwritten without warning.  If there is an active region@footnote{This
9755 requires @code{transient-mark-mode} be turned on.}, only the region will be
9756 exported. If the selected region is a single tree@footnote{To select the
9757 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
9758 title.  If the tree head entry has or inherits an @code{EXPORT_FILE_NAME}
9759 property, that name will be used for the export.
9760 @kindex C-c C-e L
9761 @item C-c C-e L
9762 Export to a temporary buffer, do not create a file.
9763 @kindex C-c C-e v l
9764 @kindex C-c C-e v L
9765 @item C-c C-e v l
9766 @item C-c C-e v L
9767 Export only the visible part of the document.
9768 @item M-x org-export-region-as-latex
9769 Convert the region to La@TeX{} under the assumption that it was Org-mode
9770 syntax before.  This is a global command that can be invoked in any
9771 buffer.
9772 @item M-x org-replace-region-by-latex
9773 Replace the active region (assumed to be in Org-mode syntax) by La@TeX{}
9774 code.
9775 @kindex C-c C-e p
9776 @item C-c C-e p
9777 Export as La@TeX{} and then process to PDF.
9778 @kindex C-c C-e d
9779 @item C-c C-e d
9780 Export as La@TeX{} and then process to PDF, then open the resulting PDF file.
9781 @end table
9783 @cindex headline levels, for exporting
9784 @vindex org-latex-low-levels
9785 In the exported version, the first 3 outline levels will become
9786 headlines, defining a general document structure.  Additional levels
9787 will be exported as description lists.  The exporter can ignore them or
9788 convert them to a custom string depending on
9789 @code{org-latex-low-levels}.
9791 If you want that transition to occur at a different level, specify it
9792 with a numeric prefix argument. For example,
9794 @example
9795 @kbd{C-2 C-c C-e l}
9796 @end example
9798 @noindent
9799 creates two levels of headings and does the rest as items.
9801 @node Header and sectioning, Quoting LaTeX code, LaTeX/PDF export commands, LaTeX and PDF export
9802 @subsection Header and sectioning structure
9803 @cindex La@TeX{} class
9804 @cindex La@TeX{} sectioning structure
9805 @cindex La@TeX{} header
9806 @cindex header, for LaTeX files
9807 @cindex sectioning structure, for LaTeX export
9809 By default, the La@TeX{} output uses the class @code{article}.
9811 @vindex org-export-latex-default-class
9812 @vindex org-export-latex-classes
9813 @vindex org-export-latex-default-packages-alist
9814 @vindex org-export-latex-packages-alist
9815 @cindex #+LATEX_HEADER
9816 @cindex #+LATEX_CLASS
9817 @cindex #+LATEX_CLASS_OPTIONS
9818 @cindex property, LATEX_CLASS
9819 @cindex property, LATEX_CLASS_OPTIONS
9820 You can change this globally by setting a different value for
9821 @code{org-export-latex-default-class} or locally by adding an option like
9822 @code{#+LaTeX_CLASS: myclass} in your file, or with a @code{:LaTeX_CLASS:}
9823 property that applies when exporting a region containing only this (sub)tree.
9824 The class must be listed in @code{org-export-latex-classes}.  This variable
9825 defines a header template for each class@footnote{Into which the values of
9826 @code{org-export-latex-default-packages-alist} and
9827 @code{org-export-latex-packages-alist} are spliced.}, and allows you to
9828 define the sectioning structure for each class.  You can also define your own
9829 classes there.  @code{#+LaTeX_CLASS_OPTIONS} or a @code{LaTeX_CLASS_OPTIONS}
9830 property can specify the options for the @code{\documentclass} macro.  You
9831 can also use @code{#+LATEX_HEADER: \usepackage@{xyz@}} to add lines to the
9832 header.  See the docstring of @code{org-export-latex-classes} for more
9833 information.
9835 @node Quoting LaTeX code, Tables in LaTeX export, Header and sectioning, LaTeX and PDF export
9836 @subsection Quoting La@TeX{} code
9838 Embedded La@TeX{} as described in @ref{Embedded LaTeX}, will be correctly
9839 inserted into the La@TeX{} file.  This includes simple macros like
9840 @samp{\ref@{LABEL@}} to create a cross reference to a figure.  Furthermore,
9841 you can add special code that should only be present in La@TeX{} export with
9842 the following constructs:
9844 @cindex #+LaTeX
9845 @cindex #+BEGIN_LaTeX
9846 @example
9847 #+LaTeX: Literal LaTeX code for export
9848 @end example
9850 @noindent or
9851 @cindex #+BEGIN_LaTeX
9853 @example
9854 #+BEGIN_LaTeX
9855 All lines between these markers are exported literally
9856 #+END_LaTeX
9857 @end example
9860 @node Tables in LaTeX export, Images in LaTeX export, Quoting LaTeX code, LaTeX and PDF export
9861 @subsection Tables in La@TeX{} export
9862 @cindex tables, in La@TeX{} export
9864 For La@TeX{} export of a table, you can specify a label and a caption
9865 (@pxref{Images and tables}).  You can also use the @code{ATTR_LaTeX} line to
9866 request a @code{longtable} environment for the table, so that it may span
9867 several pages, or provide the @code{multicolumn} keyword that will make the
9868 table span the page in a multicolumn environment (@code{table*} environment).
9869 Finally, you can set the alignment string:
9871 @cindex #+CAPTION
9872 @cindex #+LABEL
9873 @cindex #+ATTR_LaTeX
9874 @example
9875 #+CAPTION: A long table
9876 #+LABEL: tbl:long
9877 #+ATTR_LaTeX: longtable align=l|lp@{3cm@}r|l
9878 | ..... | ..... |
9879 | ..... | ..... |
9880 @end example
9883 @node Images in LaTeX export, Beamer class export, Tables in LaTeX export, LaTeX and PDF export
9884 @subsection Images in La@TeX{} export
9885 @cindex images, inline in La@TeX{}
9886 @cindex inlining images in La@TeX{}
9888 Images that are linked to without a description part in the link, like
9889 @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]} will be inserted into the PDF
9890 output file resulting from La@TeX{} processing.  Org will use an
9891 @code{\includegraphics} macro to insert the image.  If you have specified a
9892 caption and/or a label as described in @ref{Images and tables}, the figure
9893 will be wrapped into a @code{figure} environment and thus become a floating
9894 element.  You can use an @code{#+ATTR_LaTeX:} line to specify the various
9895 options that can be used in the optional argument of the
9896 @code{\includegraphics} macro.  To modify the placement option of the
9897 @code{figure} environment, add something like @samp{placement=[h!]} to the
9898 Attributes.
9900 If you would like to let text flow around the image, add the word @samp{wrap}
9901 to the @code{#+ATTR_LaTeX:} line, which will make the figure occupy the left
9902 half of the page.  To fine-tune, the @code{placement} field will be the set
9903 of additional arguments needed by the @code{wrapfigure} environment.  Note
9904 that if you change the size of the image, you need to use compatible settings
9905 for @code{\includegraphics} and @code{wrapfigure}.
9907 @cindex #+CAPTION
9908 @cindex #+LABEL
9909 @cindex #+ATTR_LaTeX
9910 @example
9911 #+CAPTION:    The black-body emission of the disk around HR 4049
9912 #+LABEL:      fig:SED-HR4049
9913 #+ATTR_LaTeX: width=5cm,angle=90
9914 [[./img/sed-hr4049.pdf]]
9916 #+ATTR_LaTeX: width=0.38\textwidth wrap placement=@{r@}@{0.4\textwidth@}
9917 [[./img/hst.png]]
9918 @end example
9920 If you need references to a label created in this way, write
9921 @samp{\ref@{fig:SED-HR4049@}} just like in La@TeX{}.
9923 @node Beamer class export,  , Images in LaTeX export, LaTeX and PDF export
9924 @subsection Beamer class export
9926 The LaTeX class @file{beamer} allows production of high quality presentations
9927 using LaTeX and pdf processing.  Org-mode has special support for turning an
9928 Org-mode file or tree into a @file{beamer} presentation.
9930 When the LaTeX class for the current buffer (as set with @code{#+LaTeX_CLASS:
9931 beamer}) or subtree (set with a @code{LaTeX_CLASS} property) is
9932 @code{beamer}, a special export mode will turn the file or tree into a beamer
9933 presentation.  Any tree with not-too-deep level nesting should in principle be
9934 exportable as a beamer presentation.  By default, the top-level entries (or
9935 the first level below the selected subtree heading) will be turned into
9936 frames, and the outline structure below this level will become itemize lists.
9937 You can also configure the variable @code{org-beamer-frame-level} to a
9938 different level - then the hierarchy above frames will produce the sectioning
9939 structure of the presentation.
9941 A template for useful in-buffer settings or properties can be inserted into
9942 the buffer with @kbd{M-x org-insert-beamer-options-template}.  Among other
9943 things, this will install a column view format which is very handy for
9944 editing special properties used by beamer.
9946 You can influence the structure of the presentation using the following
9947 properties:
9949 @table @code
9950 @item BEAMER_env
9951 The environment that should be used to format this entry.  Valid environments
9952 are defined in the constant @code{org-beamer-environments-default}, and you
9953 can define more in @code{org-beamer-environments-extra}.  If this property is
9954 set, the entry will also get a @code{:B_environment:} tag to make this
9955 visible.  This tag has no semantic meaning, it is only a visual aid.
9956 @item BEAMER_envargs
9957 The beamer-special arguments that should be used for the environment, like
9958 @code{[t]} or @code{[<+->]} of @code{<2-3>}.  If the @code{BEAMER_col}
9959 property is also set, something like @code{C[t]} can be added here as well to
9960 set an options argument for the implied @code{columns} environment.
9961 @code{c[t]} will set an option for the implied @code{column} environment.
9962 @item BEAMER_col
9963 The width of a column that should start with this entry.  If this property is
9964 set, the entry will also get a @code{:BMCOL:} property to make this visible.
9965 Also this tag is only a visual aid.  When this is a plain number, it will be
9966 interpreted as a fraction of @code{\textwidth}.  Otherwise it will be assumed
9967 that you have specified the units, like @samp{3cm}.  The first such property
9968 in a frame will start a @code{columns} environment to surround the columns.
9969 This environment is closed when an entry has a @code{BEAMER_col} property
9970 with value 0 or 1, or automatically at the end of the frame.
9971 @item BEAMER_extra
9972 Additional commands that should be inserted after the environment has been
9973 opened.  For example, when creating a frame, this can be used to specify
9974 transitions.
9975 @end table
9977 Frames will automatically receive a @code{fragile} option if they contain
9978 source code that uses the verbatim environment.  Special @file{beamer}
9979 specific code can be inserted using @code{#+BEAMER:} and
9980 @code{#+BEGIN_beamer...#+end_beamer} constructs, similar to other export
9981 backends, but with the difference that @code{#+LaTeX:} stuff will be included
9982 in the presentation as well.
9984 Outline nodes with @code{BEAMER_env} property value @samp{note} or
9985 @samp{noteNH} will be formatted as beamer notes, i,e, they will be wrapped
9986 into @code{\note@{...@}}.  The former will include the heading as part of the
9987 note text, the latter will ignore the heading of that node.  To simplify note
9988 generation, it is actually enough to mark the note with a @emph{tag} (either
9989 @code{:B_note:} or @code{:B_noteNH:}) instead of creating the
9990 @code{BEAMER_env} property.
9992 You can turn on a special minor mode @code{org-beamer-mode} for editing
9993 support with
9995 @example
9996 #+STARTUP: beamer
9997 @end example
9999 @table @kbd
10000 @kindex C-c C-b
10001 @item C-c C-b
10002 In @code{org-beamer-mode}, this key offers fast selection of a beamer
10003 environment or the @code{BEAMER_col} property.
10004 @end table
10006 Column view provides a great way to set the environment of a node and other
10007 important parameters.  Make sure you are using a COLUMN format that is geared
10008 toward this special purpose.  The command @kbd{M-x
10009 org-insert-beamer-options-template} defines such a format.
10011 Here is a simple example Org document that is intended for beamer export.
10013 @smallexample
10014 #+LaTeX_CLASS: beamer
10015 #+TITLE: Example Presentation
10016 #+AUTHOR: Carsten Dominik
10017 #+LaTeX_CLASS_OPTIONS: [presentation]
10018 #+BEAMER_FRAME_LEVEL: 2
10019 #+BEAMER_HEADER_EXTRA: \usetheme@{Madrid@}\usecolortheme@{default@}
10020 #+COLUMNS: %35ITEM %10BEAMER_env(Env) %10BEAMER_envargs(Args) %4BEAMER_col(Col) %8BEAMER_extra(Ex)
10022 * This is the first structural section
10024 ** Frame 1 \\ with a subtitle
10025 *** Thanks to Eric Fraga                                      :BMCOL:B_block:
10026     :PROPERTIES:
10027     :BEAMER_env: block
10028     :BEAMER_envargs: C[t]
10029     :BEAMER_col: 0.5
10030     :END:
10031     for the first viable beamer setup in Org
10032 *** Thanks to everyone else                                   :BMCOL:B_block:
10033     :PROPERTIES:
10034     :BEAMER_col: 0.5
10035     :BEAMER_env: block
10036     :BEAMER_envargs: <2->
10037     :END:
10038     for contributing to the discussion
10039 **** This will be formatted as a beamer note                  :B_note:
10040 ** Frame 2 \\ where we will not use columns
10041 *** Request                                                   :B_block:
10042     Please test this stuff!
10043     :PROPERTIES:
10044     :BEAMER_env: block
10045     :END:
10046 @end smallexample
10048 For more information, see the documentation on Worg.
10050 @node DocBook export, TaskJuggler export, LaTeX and PDF export, Exporting
10051 @section DocBook export
10052 @cindex DocBook export
10053 @cindex PDF export
10054 @cindex Cui, Baoqiu
10056 Org contains a DocBook exporter written by Baoqiu Cui.  Once an Org file is
10057 exported to DocBook format, it can be further processed to produce other
10058 formats, including PDF, HTML, man pages, etc., using many available DocBook
10059 tools and stylesheets.
10061 Currently DocBook exporter only supports DocBook V5.0.
10063 @menu
10064 * DocBook export commands::     How to invoke DocBook export
10065 * Quoting DocBook code::        Incorporating DocBook code in Org files
10066 * Recursive sections::          Recursive sections in DocBook
10067 * Tables in DocBook export::    Tables are exported as HTML tables
10068 * Images in DocBook export::    How to insert figures into DocBook output
10069 * Special characters::          How to handle special characters
10070 @end menu
10072 @node DocBook export commands, Quoting DocBook code, DocBook export, DocBook export
10073 @subsection DocBook export commands
10075 @cindex region, active
10076 @cindex active region
10077 @cindex transient-mark-mode
10078 @table @kbd
10079 @kindex C-c C-e D
10080 @item C-c C-e D
10081 @cindex property EXPORT_FILE_NAME
10082 Export as DocBook file.  For an Org file, @file{myfile.org}, the DocBook XML
10083 file will be @file{myfile.xml}.  The file will be overwritten without
10084 warning.  If there is an active region@footnote{This requires
10085 @code{transient-mark-mode} to be turned on}, only the region will be
10086 exported.  If the selected region is a single tree@footnote{To select the
10087 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
10088 title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
10089 property, that name will be used for the export.
10090 @kindex C-c C-e V
10091 @item C-c C-e V
10092 Export as DocBook file, process to PDF, then open the resulting PDF file.
10094 @vindex org-export-docbook-xslt-proc-command
10095 @vindex org-export-docbook-xsl-fo-proc-command
10096 Note that, in order to produce PDF output based on exported DocBook file, you
10097 need to have XSLT processor and XSL-FO processor software installed on your
10098 system.  Check variables @code{org-export-docbook-xslt-proc-command} and
10099 @code{org-export-docbook-xsl-fo-proc-command}.
10101 @vindex org-export-docbook-xslt-stylesheet
10102 The stylesheet argument @code{%s} in variable
10103 @code{org-export-docbook-xslt-proc-command} is replaced by the value of
10104 variable @code{org-export-docbook-xslt-stylesheet}, which needs to be set by
10105 the user.  You can also overrule this global setting on a per-file basis by
10106 adding an in-buffer setting @code{#+XSLT:} to the Org file.
10108 @kindex C-c C-e v D
10109 @item C-c C-e v D
10110 Export only the visible part of the document.
10111 @end table
10113 @node Quoting DocBook code, Recursive sections, DocBook export commands, DocBook export
10114 @subsection Quoting DocBook code
10116 You can quote DocBook code in Org files and copy it verbatim into exported
10117 DocBook file with the following constructs:
10119 @cindex #+DOCBOOK
10120 @cindex #+BEGIN_DOCBOOK
10121 @example
10122 #+DOCBOOK: Literal DocBook code for export
10123 @end example
10125 @noindent or
10126 @cindex #+BEGIN_DOCBOOK
10128 @example
10129 #+BEGIN_DOCBOOK
10130 All lines between these markers are exported by DocBook exporter
10131 literally.
10132 #+END_DOCBOOK
10133 @end example
10135 For example, you can use the following lines to include a DocBook warning
10136 admonition.  As to what this warning says, you should pay attention to the
10137 document context when quoting DocBook code in Org files.  You may make
10138 exported DocBook XML files invalid by not quoting DocBook code correctly.
10140 @example
10141 #+BEGIN_DOCBOOK
10142 <warning>
10143   <para>You should know what you are doing when quoting DocBook XML code
10144   in your Org file.  Invalid DocBook XML file may be generated by
10145   DocBook exporter if you are not careful!</para>
10146 </warning>
10147 #+END_DOCBOOK
10148 @end example
10150 @node Recursive sections, Tables in DocBook export, Quoting DocBook code, DocBook export
10151 @subsection Recursive sections
10152 @cindex DocBook recursive sections
10154 DocBook exporter exports Org files as articles using the @code{article}
10155 element in DocBook.  Recursive sections, i.e. @code{section} elements, are
10156 used in exported articles.  Top level headlines in Org files are exported as
10157 top level sections, and lower level headlines are exported as nested
10158 sections.  The entire structure of Org files will be exported completely, no
10159 matter how many nested levels of headlines there are.
10161 Using recursive sections makes it easy to port and reuse exported DocBook
10162 code in other DocBook document types like @code{book} or @code{set}.
10164 @node Tables in DocBook export, Images in DocBook export, Recursive sections, DocBook export
10165 @subsection Tables in DocBook export
10166 @cindex tables, in DocBook export
10168 Tables in Org files are exported as HTML tables, which have been supported since
10169 DocBook V4.3.
10171 If a table does not have a caption, an informal table is generated using the
10172 @code{informaltable} element; otherwise, a formal table will be generated
10173 using the @code{table} element.
10175 @node Images in DocBook export, Special characters, Tables in DocBook export, DocBook export
10176 @subsection Images in DocBook export
10177 @cindex images, inline in DocBook
10178 @cindex inlining images in DocBook
10180 Images that are linked to without a description part in the link, like
10181 @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]}, will be exported to DocBook
10182 using @code{mediaobject} elements.  Each @code{mediaobject} element contains
10183 an @code{imageobject} that wraps an @code{imagedata} element.  If you have
10184 specified a caption for an image as described in @ref{Images and tables}, a
10185 @code{caption} element will be added in @code{mediaobject}.  If a label is
10186 also specified, it will be exported as an @code{xml:id} attribute of the
10187 @code{mediaobject} element.
10189 @vindex org-export-docbook-default-image-attributes
10190 Image attributes supported by the @code{imagedata} element, like @code{align}
10191 or @code{width}, can be specified in two ways: you can either customize
10192 variable @code{org-export-docbook-default-image-attributes} or use the
10193 @code{#+ATTR_DOCBOOK:} line.  Attributes specified in variable
10194 @code{org-export-docbook-default-image-attributes} are applied to all inline
10195 images in the Org file to be exported (unless they are overridden by image
10196 attributes specified in @code{#+ATTR_DOCBOOK:} lines).
10198 The @code{#+ATTR_DOCBOOK:} line can be used to specify additional image
10199 attributes or override default image attributes for individual images.  If
10200 the same attribute appears in both the @code{#+ATTR_DOCBOOK:} line and
10201 variable @code{org-export-docbook-default-image-attributes}, the former
10202 takes precedence.  Here is an example about how image attributes can be
10203 set:
10205 @cindex #+CAPTION
10206 @cindex #+LABEL
10207 @cindex #+ATTR_DOCBOOK
10208 @example
10209 #+CAPTION:    The logo of Org-mode
10210 #+LABEL:      unicorn-svg
10211 #+ATTR_DOCBOOK: scalefit="1" width="100%" depth="100%"
10212 [[./img/org-mode-unicorn.svg]]
10213 @end example
10215 @vindex org-export-docbook-inline-image-extensions
10216 By default, DocBook exporter recognizes the following image file types:
10217 @file{jpeg}, @file{jpg}, @file{png}, @file{gif}, and @file{svg}.  You can
10218 customize variable @code{org-export-docbook-inline-image-extensions} to add
10219 more types to this list as long as DocBook supports them.
10221 @node Special characters,  , Images in DocBook export, DocBook export
10222 @subsection Special characters in DocBook export
10223 @cindex Special characters in DocBook export
10225 @vindex org-export-docbook-doctype
10226 @vindex org-entities
10227 Special characters that are written in @TeX{}-like syntax, such as @code{\alpha},
10228 @code{\Gamma}, and @code{\Zeta}, are supported by DocBook exporter.  These
10229 characters are rewritten to XML entities, like @code{&alpha;},
10230 @code{&Gamma;}, and @code{&Zeta;}, based on the list saved in variable
10231 @code{org-entities}.  As long as the generated DocBook file includes the
10232 corresponding entities, these special characters are recognized.
10234 You can customize variable @code{org-export-docbook-doctype} to include the
10235 entities you need.  For example, you can set variable
10236 @code{org-export-docbook-doctype} to the following value to recognize all
10237 special characters included in XHTML entities:
10239 @example
10240 "<!DOCTYPE article [
10241 <!ENTITY % xhtml1-symbol PUBLIC
10242 \"-//W3C//ENTITIES Symbol for HTML//EN//XML\"
10243 \"http://www.w3.org/2003/entities/2007/xhtml1-symbol.ent\"
10245 %xhtml1-symbol;
10248 @end example
10250 @node  TaskJuggler export, Freemind export, DocBook export, Exporting
10251 @section TaskJuggler export
10252 @cindex TaskJuggler export
10253 @cindex Project management
10255 @uref{http://www.taskjuggler.org/, TaskJuggler} is a project management tool.
10256 It provides an optimizing scheduler that computes your project time lines and
10257 resource assignments based on the project outline and the constraints that
10258 you have provided.
10260 The TaskJuggler exporter is a bit different from other exporters, such as the
10261 HTML and LaTeX exporters for example, in that it does not export all the
10262 nodes of a document or strictly follow the order of the nodes in the
10263 document.
10265 Instead the TaskJuggler exporter looks for a tree that defines the tasks and
10266 a optionally tree that defines the resources for this project. It then
10267 creates a TaskJuggler file based on these trees and the attributes defined in
10268 all the nodes.
10270 @subsection TaskJuggler export commands
10272 @table @kbd
10273 @kindex C-c C-e j
10274 @item C-c C-e j
10275 Export as TaskJuggler file.
10277 @kindex C-c C-e J
10278 @item C-c C-e J
10279 Export as TaskJuggler file and then open the file with TaskJugglerUI.
10280 @end table
10282 @subsection Tasks
10284 @vindex org-export-taskjuggler-project-tag
10285 Create your tasks as you usually do with Org-mode. Assign efforts to each
10286 task using properties (it's easiest to do this in the column view). You
10287 should end up with something similar to the example by Peter Jones in
10288 @url{http://www.contextualdevelopment.com/static/artifacts/articles/2008/project-planning/project-planning.org}.
10289 Now mark the top node of your tasks with a tag named
10290 @code{:taskjuggler_project:} (or whatever you customized
10291 @code{org-export-taskjuggler-project-tag} to). You are now ready to export
10292 the project plan with @kbd{C-c C-e J} which will export the project plan and
10293 open a gantt chart in TaskJugglerUI.
10295 @subsection Resources
10297 @vindex org-export-taskjuggler-resource-tag
10298 Next you can define resources and assign those to work on specific tasks. You
10299 can group your resources hierarchically. Tag the top node of the resources
10300 with @code{:taskjuggler_resource:} (or whatever you customized
10301 @code{org-export-taskjuggler-resource-tag} to). You can optionally assign an
10302 identifier (named @samp{resource_id}) to the resources (using the standard
10303 Org properties commands, @pxref{Property syntax}) or you can let the exporter
10304 generate identifiers automatically (the exporter picks the first word of the
10305 headline as the identifier as long as it is unique, see the documentation of
10306 @code{org-taskjuggler-get-unique-id}). Using that identifier you can then
10307 allocate resources to tasks. This is again done with the @samp{allocate}
10308 property on the tasks. Do this in column view or when on the task type
10309 @kbd{C-c C-x p allocate @key{RET} <resource_id> @key{RET}}.
10311 Once the allocations are done you can again export to TaskJuggler and check
10312 in the Resource Allocation Graph which person is working on what task at what
10313 time.
10315 @subsection Export of properties
10317 The exporter also takes TODO state information into consideration, i.e. if a
10318 task is marked as done it will have the corresponding attribute in
10319 TaskJuggler (@samp{complete 100}). Also it will export any property on a task
10320 resource or resource node which is known to TaskJuggler, such as
10321 @samp{limits}, @samp{vacation}, @samp{shift}, @samp{booking},
10322 @samp{efficiency}, @samp{journalentry}, @samp{rate} for resources or
10323 @samp{account}, @samp{start}, @samp{note}, @samp{duration}, @samp{end},
10324 @samp{journalentry}, @samp{milestone}, @samp{reference}, @samp{responsible},
10325 @samp{scheduling}, etc for tasks.
10327 @subsection Dependencies
10329 The exporter will handle dependencies that are defined in the tasks either
10330 with the @samp{ORDERED} attribute (@pxref{TODO dependencies}), with the
10331 @samp{BLOCKER} attribute (see org-depend.el) or alternatively with a
10332 @samp{depends} attribute. Both the @samp{BLOCKER} and the @samp{depends}
10333 attribute can be either @samp{previous-sibling} or a reference to an
10334 identifier (named @samp{task_id}) which is defined for another task in the
10335 project. @samp{BLOCKER} and the @samp{depends} attribute can define multiple
10336 dependencies separated by either space or comma. You can also specify
10337 optional attributes on the dependency by simply appending it. The following
10338 examples should illustrate this:
10340 @example
10341 * Preparation
10342   :PROPERTIES:
10343   :task_id:  preparation
10344   :ORDERED:  t
10345   :END:
10346 * Training material
10347   :PROPERTIES:
10348   :task_id:  training_material
10349   :ORDERED:  t
10350   :END:
10351 ** Markup Guidelines
10352    :PROPERTIES:
10353    :Effort:   2.0
10354    :END:
10355 ** Workflow Guidelines
10356    :PROPERTIES:
10357    :Effort:   2.0
10358    :END:
10359 * Presentation
10360   :PROPERTIES:
10361   :Effort:   2.0
10362   :BLOCKER:  training_material @{ gapduration 1d @} preparation
10363   :END:
10364 @end example
10366 @subsection Reports
10368 @vindex org-export-taskjuggler-default-reports
10369 TaskJuggler can produce many kinds of reports (e.g. gantt chart, resource
10370 allocation, etc). The user defines what kind of reports should be generated
10371 for a project in the TaskJuggler file. The exporter will automatically insert
10372 some default reports in the file. These defaults are defined in
10373 @code{org-export-taskjuggler-default-reports}. They can be modified using
10374 customize along with a number of other options. For a more complete list, see
10375 @kbd{M-x customize-group @key{RET} org-export-taskjuggler @key{RET}}.
10377 For more information and examples see the Org-taskjuggler tutorial at
10378 @uref{http://orgmode.org/worg/org-tutorials/org-taskjuggler.php}.
10380 @node Freemind export, XOXO export, TaskJuggler export, Exporting
10381 @section Freemind export
10382 @cindex Freemind export
10383 @cindex mind map
10385 The Freemind exporter was written by Lennart Borgman.
10387 @table @kbd
10388 @kindex C-c C-e m
10389 @item C-c C-e m
10390 Export as Freemind mind map @file{myfile.mm}.
10391 @end table
10393 @node XOXO export, iCalendar export, Freemind export, Exporting
10394 @section XOXO export
10395 @cindex XOXO export
10397 Org-mode contains an exporter that produces XOXO-style output.
10398 Currently, this exporter only handles the general outline structure and
10399 does not interpret any additional Org-mode features.
10401 @table @kbd
10402 @kindex C-c C-e x
10403 @item C-c C-e x
10404 Export as XOXO file @file{myfile.html}.
10405 @kindex C-c C-e v
10406 @item C-c C-e v x
10407 Export only the visible part of the document.
10408 @end table
10410 @node iCalendar export,  , XOXO export, Exporting
10411 @section iCalendar export
10412 @cindex iCalendar export
10414 @vindex org-icalendar-include-todo
10415 @vindex org-icalendar-use-deadline
10416 @vindex org-icalendar-use-scheduled
10417 @vindex org-icalendar-categories
10418 @vindex org-icalendar-alarm-time
10419 Some people use Org-mode for keeping track of projects, but still prefer a
10420 standard calendar application for anniversaries and appointments.  In this
10421 case it can be useful to show deadlines and other time-stamped items in Org
10422 files in the calendar application.  Org-mode can export calendar information
10423 in the standard iCalendar format.  If you also want to have TODO entries
10424 included in the export, configure the variable
10425 @code{org-icalendar-include-todo}.  Plain timestamps are exported as VEVENT,
10426 and TODO items as VTODO.  It will also create events from deadlines that are
10427 in non-TODO items.  Deadlines and scheduling dates in TODO items will be used
10428 to set the start and due dates for the TODO entry@footnote{See the variables
10429 @code{org-icalendar-use-deadline} and @code{org-icalendar-use-scheduled}.}.
10430 As categories, it will use the tags locally defined in the heading, and the
10431 file/tree category@footnote{To add inherited tags or the TODO state,
10432 configure the variable @code{org-icalendar-categories}.}.  See the variable
10433 @code{org-icalendar-alarm-time} for a way to assign alarms to entries with a
10434 time.
10436 @vindex org-icalendar-store-UID
10437 @cindex property, ID
10438 The iCalendar standard requires each entry to have a globally unique
10439 identifier (UID).  Org creates these identifiers during export.  If you set
10440 the variable @code{org-icalendar-store-UID}, the UID will be stored in the
10441 @code{:ID:} property of the entry and re-used next time you report this
10442 entry.  Since a single entry can give rise to multiple iCalendar entries (as
10443 a timestamp, a deadline, a scheduled item, and as a TODO item), Org adds
10444 prefixes to the UID, depending on what triggered the inclusion of the entry.
10445 In this way the UID remains unique, but a synchronization program can still
10446 figure out from which entry all the different instances originate.
10448 @table @kbd
10449 @kindex C-c C-e i
10450 @item C-c C-e i
10451 Create iCalendar entries for the current file and store them in the same
10452 directory, using a file extension @file{.ics}.
10453 @kindex C-c C-e I
10454 @item C-c C-e I
10455 @vindex org-agenda-files
10456 Like @kbd{C-c C-e i}, but do this for all files in
10457 @code{org-agenda-files}.  For each of these files, a separate iCalendar
10458 file will be written.
10459 @kindex C-c C-e c
10460 @item C-c C-e c
10461 @vindex org-combined-agenda-icalendar-file
10462 Create a single large iCalendar file from all files in
10463 @code{org-agenda-files} and write it to the file given by
10464 @code{org-combined-agenda-icalendar-file}.
10465 @end table
10467 @vindex org-use-property-inheritance
10468 @vindex org-icalendar-include-body
10469 @cindex property, SUMMARY
10470 @cindex property, DESCRIPTION
10471 @cindex property, LOCATION
10472 The export will honor SUMMARY, DESCRIPTION and LOCATION@footnote{The LOCATION
10473 property can be inherited from higher in the hierarchy if you configure
10474 @code{org-use-property-inheritance} accordingly.} properties if the selected
10475 entries have them.  If not, the summary will be derived from the headline,
10476 and the description from the body (limited to
10477 @code{org-icalendar-include-body} characters).
10479 How this calendar is best read and updated, depends on the application
10480 you are using.  The FAQ covers this issue.
10482 @node Publishing, Working With Source Code, Exporting, Top
10483 @chapter Publishing
10484 @cindex publishing
10486 Org includes a publishing management system that allows you to configure
10487 automatic HTML conversion of @emph{projects} composed of interlinked org
10488 files.  You can also configure Org to automatically upload your exported HTML
10489 pages and related attachments, such as images and source code files, to a web
10490 server.
10492 You can also use Org to convert files into PDF, or even combine HTML and PDF
10493 conversion so that files are available in both formats on the server.
10495 Publishing has been contributed to Org by David O'Toole.
10497 @menu
10498 * Configuration::               Defining projects
10499 * Uploading files::             How to get files up on the server
10500 * Sample configuration::        Example projects
10501 * Triggering publication::      Publication commands
10502 @end menu
10504 @node Configuration, Uploading files, Publishing, Publishing
10505 @section Configuration
10507 Publishing needs significant configuration to specify files, destination
10508 and many other properties of a project.
10510 @menu
10511 * Project alist::               The central configuration variable
10512 * Sources and destinations::    From here to there
10513 * Selecting files::             What files are part of the project?
10514 * Publishing action::           Setting the function doing the publishing
10515 * Publishing options::          Tweaking HTML export
10516 * Publishing links::            Which links keep working after publishing?
10517 * Sitemap::                     Generating a list of all pages
10518 * Generating an index::         An index that reaches across pages
10519 @end menu
10521 @node Project alist, Sources and destinations, Configuration, Configuration
10522 @subsection The variable @code{org-publish-project-alist}
10523 @cindex org-publish-project-alist
10524 @cindex projects, for publishing
10526 @vindex org-publish-project-alist
10527 Publishing is configured almost entirely through setting the value of one
10528 variable, called @code{org-publish-project-alist}.  Each element of the list
10529 configures one project, and may be in one of the two following forms:
10531 @lisp
10532    ("project-name" :property value :property value ...)
10533 @r{or}
10534    ("project-name" :components ("project-name" "project-name" ...))
10536 @end lisp
10538 In both cases, projects are configured by specifying property values.  A
10539 project defines the set of files that will be published, as well as the
10540 publishing configuration to use when publishing those files.  When a project
10541 takes the second form listed above, the individual members of the
10542 @code{:components} property are taken to be sub-projects, which group
10543 together files requiring different publishing options.  When you publish such
10544 a ``meta-project'', all the components will also be published, in the
10545 sequence given.
10547 @node Sources and destinations, Selecting files, Project alist, Configuration
10548 @subsection Sources and destinations for files
10549 @cindex directories, for publishing
10551 Most properties are optional, but some should always be set.  In
10552 particular, Org needs to know where to look for source files,
10553 and where to put published files.
10555 @multitable @columnfractions 0.3 0.7
10556 @item @code{:base-directory}
10557 @tab Directory containing publishing source files
10558 @item @code{:publishing-directory}
10559 @tab Directory where output files will be published.  You can directly
10560 publish to a webserver using a file name syntax appropriate for
10561 the Emacs @file{tramp} package.  Or you can publish to a local directory and
10562 use external tools to upload your website (@pxref{Uploading files}).
10563 @item @code{:preparation-function}
10564 @tab Function or list of functions to be called before starting the
10565 publishing process, for example, to run @code{make} for updating files to be
10566 published.  The project property list is scoped into this call as the
10567 variable @code{project-plist}.
10568 @item @code{:completion-function}
10569 @tab Function or list of functions called after finishing the publishing
10570 process, for example, to change permissions of the resulting files.  The
10571 project property list is scoped into this call as the variable
10572 @code{project-plist}.
10573 @end multitable
10574 @noindent
10576 @node Selecting files, Publishing action, Sources and destinations, Configuration
10577 @subsection Selecting files
10578 @cindex files, selecting for publishing
10580 By default, all files with extension @file{.org} in the base directory
10581 are considered part of the project.  This can be modified by setting the
10582 properties
10583 @multitable @columnfractions 0.25 0.75
10584 @item @code{:base-extension}
10585 @tab Extension (without the dot!) of source files.  This actually is a
10586 regular expression.  Set this to the symbol @code{any} if you want to get all
10587 files in @code{:base-directory}, even without extension.
10589 @item @code{:exclude}
10590 @tab Regular expression to match file names that should not be
10591 published, even though they have been selected on the basis of their
10592 extension.
10594 @item @code{:include}
10595 @tab List of files to be included regardless of @code{:base-extension}
10596 and @code{:exclude}.
10597 @end multitable
10599 @node Publishing action, Publishing options, Selecting files, Configuration
10600 @subsection Publishing action
10601 @cindex action, for publishing
10603 Publishing means that a file is copied to the destination directory and
10604 possibly transformed in the process.  The default transformation is to export
10605 Org files as HTML files, and this is done by the function
10606 @code{org-publish-org-to-html} which calls the HTML exporter (@pxref{HTML
10607 export}).  But you also can publish your content as PDF files using
10608 @code{org-publish-org-to-pdf}.  If you want to publish the Org file itself,
10609 but with @i{archived}, @i{commented}, and @i{tag-excluded} trees removed, use
10610 @code{org-publish-org-to-org} and set the parameters @code{:plain-source}
10611 and/or @code{:htmlized-source}.  This will produce @file{file.org} and
10612 @file{file.org.html} in the publishing
10613 directory@footnote{@file{file-source.org} and @file{file-source.org.html} if
10614 source and publishing directories are equal.  Note that with this kind of
10615 setup, you need to add @code{:exclude "-source\\.org"} to the project
10616 definition in @code{org-publish-project-alist} to avoid that the published
10617 source files will be considered as new org files the next time the project is
10618 published.}.  Other files like images only
10619 need to be copied to the publishing destination, for this you may use
10620 @code{org-publish-attachment}.  For non-Org files, you always need to
10621 specify the publishing function:
10623 @multitable @columnfractions 0.3 0.7
10624 @item @code{:publishing-function}
10625 @tab Function executing the publication of a file.  This may also be a
10626 list of functions, which will all be called in turn.
10627 @item @code{:plain-source}
10628 @tab Non-nil means, publish plain source.
10629 @item @code{:htmlized-source}
10630 @tab Non-nil means, publish htmlized source.
10631 @end multitable
10633 The function must accept three arguments: a property list containing at least
10634 a @code{:publishing-directory} property, the name of the file to be
10635 published, and the path to the publishing directory of the output file.  It
10636 should take the specified file, make the necessary transformation (if any)
10637 and place the result into the destination folder.
10639 @node Publishing options, Publishing links, Publishing action, Configuration
10640 @subsection Options for the HTML/La@TeX{} exporters
10641 @cindex options, for publishing
10643 The property list can be used to set many export options for the HTML
10644 and La@TeX{} exporters.  In most cases, these properties correspond to user
10645 variables in Org.  The table below lists these properties along
10646 with the variable they belong to.  See the documentation string for the
10647 respective variable for details.
10649 @vindex org-export-html-link-up
10650 @vindex org-export-html-link-home
10651 @vindex org-export-default-language
10652 @vindex org-display-custom-times
10653 @vindex org-export-headline-levels
10654 @vindex org-export-with-section-numbers
10655 @vindex org-export-section-number-format
10656 @vindex org-export-with-toc
10657 @vindex org-export-preserve-breaks
10658 @vindex org-export-with-archived-trees
10659 @vindex org-export-with-emphasize
10660 @vindex org-export-with-sub-superscripts
10661 @vindex org-export-with-special-strings
10662 @vindex org-export-with-footnotes
10663 @vindex org-export-with-drawers
10664 @vindex org-export-with-tags
10665 @vindex org-export-with-todo-keywords
10666 @vindex org-export-with-priority
10667 @vindex org-export-with-TeX-macros
10668 @vindex org-export-with-LaTeX-fragments
10669 @vindex org-export-skip-text-before-1st-heading
10670 @vindex org-export-with-fixed-width
10671 @vindex org-export-with-timestamps
10672 @vindex org-export-author-info
10673 @vindex org-export-email
10674 @vindex org-export-creator-info
10675 @vindex org-export-with-tables
10676 @vindex org-export-highlight-first-table-line
10677 @vindex org-export-html-style-include-default
10678 @vindex org-export-html-style
10679 @vindex org-export-html-style-extra
10680 @vindex org-export-html-link-org-files-as-html
10681 @vindex org-export-html-inline-images
10682 @vindex org-export-html-extension
10683 @vindex org-export-html-table-tag
10684 @vindex org-export-html-expand
10685 @vindex org-export-html-with-timestamp
10686 @vindex org-export-publishing-directory
10687 @vindex org-export-html-preamble
10688 @vindex org-export-html-postamble
10689 @vindex org-export-html-auto-preamble
10690 @vindex org-export-html-auto-postamble
10691 @vindex user-full-name
10692 @vindex user-mail-address
10693 @vindex org-export-select-tags
10694 @vindex org-export-exclude-tags
10696 @multitable @columnfractions 0.32 0.68
10697 @item @code{:link-up}               @tab @code{org-export-html-link-up}
10698 @item @code{:link-home}             @tab @code{org-export-html-link-home}
10699 @item @code{:language}              @tab @code{org-export-default-language}
10700 @item @code{:customtime}            @tab @code{org-display-custom-times}
10701 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
10702 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
10703 @item @code{:section-number-format} @tab @code{org-export-section-number-format}
10704 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
10705 @item @code{:preserve-breaks}       @tab @code{org-export-preserve-breaks}
10706 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
10707 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
10708 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
10709 @item @code{:special-strings}       @tab @code{org-export-with-special-strings}
10710 @item @code{:footnotes}             @tab @code{org-export-with-footnotes}
10711 @item @code{:drawers}               @tab @code{org-export-with-drawers}
10712 @item @code{:tags}                  @tab @code{org-export-with-tags}
10713 @item @code{:todo-keywords}         @tab @code{org-export-with-todo-keywords}
10714 @item @code{:priority}              @tab @code{org-export-with-priority}
10715 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
10716 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
10717 @item @code{:latex-listings}        @tab @code{org-export-latex-listings}
10718 @item @code{:skip-before-1st-heading} @tab @code{org-export-skip-text-before-1st-heading}
10719 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
10720 @item @code{:timestamps}            @tab @code{org-export-with-timestamps}
10721 @item @code{:author-info}           @tab @code{org-export-author-info}
10722 @item @code{:email-info}            @tab @code{org-export-email-info}
10723 @item @code{:creator-info}          @tab @code{org-export-creator-info}
10724 @item @code{:tables}                @tab @code{org-export-with-tables}
10725 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
10726 @item @code{:style-include-default} @tab @code{org-export-html-style-include-default}
10727 @item @code{:style}                 @tab @code{org-export-html-style}
10728 @item @code{:style-extra}           @tab @code{org-export-html-style-extra}
10729 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
10730 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
10731 @item @code{:html-extension}        @tab @code{org-export-html-extension}
10732 @item @code{:xml-declaration}       @tab @code{org-export-html-xml-declaration}
10733 @item @code{:html-table-tag}        @tab @code{org-export-html-table-tag}
10734 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
10735 @item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
10736 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
10737 @item @code{:preamble}              @tab @code{org-export-html-preamble}
10738 @item @code{:postamble}             @tab @code{org-export-html-postamble}
10739 @item @code{:auto-preamble}         @tab @code{org-export-html-auto-preamble}
10740 @item @code{:auto-postamble}        @tab @code{org-export-html-auto-postamble}
10741 @item @code{:author}                @tab @code{user-full-name}
10742 @item @code{:email}                 @tab @code{user-mail-address} : @code{addr;addr;..}
10743 @item @code{:select-tags}           @tab @code{org-export-select-tags}
10744 @item @code{:exclude-tags}          @tab @code{org-export-exclude-tags}
10745 @item @code{:latex-image-options}   @tab @code{org-export-latex-image-default-option}
10746 @end multitable
10748 Most of the @code{org-export-with-*} variables have the same effect in
10749 both HTML and La@TeX{} exporters, except for @code{:TeX-macros} and
10750 @code{:LaTeX-fragments}, respectively @code{nil} and @code{t} in the
10751 La@TeX{} export.
10753 @vindex org-publish-project-alist
10754 When a property is given a value in @code{org-publish-project-alist},
10755 its setting overrides the value of the corresponding user variable (if
10756 any) during publishing.  Options set within a file (@pxref{Export
10757 options}), however, override everything.
10759 @node Publishing links, Sitemap, Publishing options, Configuration
10760 @subsection Links between published files
10761 @cindex links, publishing
10763 To create a link from one Org file to another, you would use
10764 something like @samp{[[file:foo.org][The foo]]} or simply
10765 @samp{file:foo.org.} (@pxref{Hyperlinks}).  When published, this link
10766 becomes a link to @file{foo.html}.  In this way, you can interlink the
10767 pages of your "org web" project and the links will work as expected when
10768 you publish them to HTML.  If you also publish the Org source file and want
10769 to link to that, use an @code{http:} link instead of a @code{file:} link,
10770 because @code{file:} links are converted to link to the corresponding
10771 @file{html} file.
10773 You may also link to related files, such as images. Provided you are careful
10774 with relative file names, and provided you have also configured Org to upload
10775 the related files, these links will work too. See @ref{Complex example}, for
10776 an example of this usage.
10778 Sometimes an Org file to be published may contain links that are
10779 only valid in your production environment, but not in the publishing
10780 location.  In this case, use the property
10782 @multitable @columnfractions 0.4 0.6
10783 @item @code{:link-validation-function}
10784 @tab Function to validate links
10785 @end multitable
10787 @noindent
10788 to define a function for checking link validity.  This function must
10789 accept two arguments, the file name and a directory relative to which
10790 the file name is interpreted in the production environment.  If this
10791 function returns @code{nil}, then the HTML generator will only insert a
10792 description into the HTML file, but no link.  One option for this
10793 function is @code{org-publish-validate-link} which checks if the given
10794 file is part of any project in @code{org-publish-project-alist}.
10796 @node Sitemap, Generating an index, Publishing links, Configuration
10797 @subsection Generating a sitemap
10798 @cindex sitemap, of published pages
10800 The following properties may be used to control publishing of
10801 a map of files for a given project.
10803 @multitable @columnfractions 0.35 0.65
10804 @item @code{:auto-sitemap}
10805 @tab When non-nil, publish a sitemap during @code{org-publish-current-project}
10806 or @code{org-publish-all}.
10808 @item @code{:sitemap-filename}
10809 @tab Filename for output of sitemap. Defaults to @file{sitemap.org} (which
10810 becomes @file{sitemap.html}).
10812 @item @code{:sitemap-title}
10813 @tab Title of sitemap page. Defaults to name of file.
10815 @item @code{:sitemap-function}
10816 @tab Plug-in function to use for generation of the sitemap.
10817 Defaults to @code{org-publish-org-sitemap}, which generates a plain list
10818 of links to all files in the project.
10820 @item @code{:sitemap-sort-folders}
10821 @tab Where folders should appear in the sitemap.  Set this to @code{first}
10822 (default) or @code{last} to display folders first or last,
10823 respectively.  Any other value will mix files and folders.
10825 @item @code{:sitemap-alphabetically}
10826 @tab The site map is normally sorted alphabetically.  Set this explicitly to
10827 @code{nil} to turn off sorting.
10829 @item @code{:sitemap-ignore-case}
10830 @tab Should sorting be case-sensitive?  Default @code{nil}.
10832 @end multitable
10834 @node Generating an index,  , Sitemap, Configuration
10835 @subsection Generating an index
10836 @cindex index, in a publishing project
10838 Org-mode can generate an index across the files of a publishing project.
10840 @multitable @columnfractions 0.25 0.75
10841 @item @code{:makeindex}
10842 @tab When non-nil, generate in index in the file @file{theindex.org} and
10843 publish it as @file{theindex.html}.
10844 @end multitable
10846 The file will be create when first publishing a project with the
10847 @code{:makeindex} set.  The file only contains a statement @code{#+include:
10848 "theindex.inc"}.  You can then built around this include statement by adding
10849 a title, style information etc.
10851 @node Uploading files, Sample configuration, Configuration, Publishing
10852 @section Uploading files
10853 @cindex rsync
10854 @cindex unison
10856 For those people already utilizing third party sync tools such as
10857 @command{rsync} or @command{unison}, it might be preferable not to use the built in
10858 @i{remote} publishing facilities of Org-mode which rely heavily on
10859 Tramp.  Tramp, while very useful and powerful, tends not to be
10860 so efficient for multiple file transfer and has been known to cause problems
10861 under heavy usage.
10863 Specialized synchronization utilities offer several advantages.  In addition
10864 to timestamp comparison, they also do content and permissions/attribute
10865 checks.  For this reason you might prefer to publish your web to a local
10866 directory (possibly even @i{in place} with your Org files) and then use
10867 @file{unison} or @file{rsync} to do the synchronization with the remote host.
10869 Since Unison (for example) can be configured as to which files to transfer to
10870 a certain remote destination, it can greatly simplify the project publishing
10871 definition.  Simply keep all files in the correct location, process your Org
10872 files with @code{org-publish} and let the synchronization tool do the rest.
10873 You do not need, in this scenario, to include attachments such as @file{jpg},
10874 @file{css} or @file{gif} files in the project definition since the 3rd party
10875 tool syncs them.
10877 Publishing to a local directory is also much faster than to a remote one, so
10878 that you can afford more easily to republish entire projects.  If you set
10879 @code{org-publish-use-timestamps-flag} to @code{nil}, you gain the main
10880 benefit of re-including any changed external files such as source example
10881 files you might include with @code{#+INCLUDE}.  The timestamp mechanism in
10882 Org is not smart enough to detect if included files have been modified.
10884 @node Sample configuration, Triggering publication, Uploading files, Publishing
10885 @section Sample configuration
10887 Below we provide two example configurations.  The first one is a simple
10888 project publishing only a set of Org files.  The second example is
10889 more complex, with a multi-component project.
10891 @menu
10892 * Simple example::              One-component publishing
10893 * Complex example::             A multi-component publishing example
10894 @end menu
10896 @node Simple example, Complex example, Sample configuration, Sample configuration
10897 @subsection Example: simple publishing configuration
10899 This example publishes a set of Org files to the @file{public_html}
10900 directory on the local machine.
10902 @lisp
10903 (setq org-publish-project-alist
10904       '(("org"
10905          :base-directory "~/org/"
10906          :publishing-directory "~/public_html"
10907          :section-numbers nil
10908          :table-of-contents nil
10909          :style "<link rel=\"stylesheet\"
10910                 href=\"../other/mystyle.css\"
10911                 type=\"text/css\"/>")))
10912 @end lisp
10914 @node Complex example,  , Simple example, Sample configuration
10915 @subsection Example: complex publishing configuration
10917 This more complicated example publishes an entire website, including
10918 Org files converted to HTML, image files, Emacs Lisp source code, and
10919 style sheets. The publishing directory is remote and private files are
10920 excluded.
10922 To ensure that links are preserved, care should be taken to replicate
10923 your directory structure on the web server, and to use relative file
10924 paths. For example, if your Org files are kept in @file{~/org} and your
10925 publishable images in @file{~/images}, you would link to an image with
10927 @example
10928 file:../images/myimage.png
10929 @end example
10931 On the web server, the relative path to the image should be the
10932 same. You can accomplish this by setting up an "images" folder in the
10933 right place on the web server, and publishing images to it.
10935 @lisp
10936 (setq org-publish-project-alist
10937       '(("orgfiles"
10938           :base-directory "~/org/"
10939           :base-extension "org"
10940           :publishing-directory "/ssh:user@@host:~/html/notebook/"
10941           :publishing-function org-publish-org-to-html
10942           :exclude "PrivatePage.org"   ;; regexp
10943           :headline-levels 3
10944           :section-numbers nil
10945           :table-of-contents nil
10946           :style "<link rel=\"stylesheet\"
10947                   href=\"../other/mystyle.css\" type=\"text/css\"/>"
10948           :auto-preamble t
10949           :auto-postamble nil)
10951          ("images"
10952           :base-directory "~/images/"
10953           :base-extension "jpg\\|gif\\|png"
10954           :publishing-directory "/ssh:user@@host:~/html/images/"
10955           :publishing-function org-publish-attachment)
10957          ("other"
10958           :base-directory "~/other/"
10959           :base-extension "css\\|el"
10960           :publishing-directory "/ssh:user@@host:~/html/other/"
10961           :publishing-function org-publish-attachment)
10962          ("website" :components ("orgfiles" "images" "other"))))
10963 @end lisp
10965 @node Triggering publication,  , Sample configuration, Publishing
10966 @section Triggering publication
10968 Once properly configured, Org can publish with the following commands:
10970 @table @kbd
10971 @kindex C-c C-e C
10972 @item C-c C-e C
10973 Prompt for a specific project and publish all files that belong to it.
10974 @kindex C-c C-e P
10975 @item C-c C-e P
10976 Publish the project containing the current file.
10977 @kindex C-c C-e F
10978 @item C-c C-e F
10979 Publish only the current file.
10980 @kindex C-c C-e E
10981 @item C-c C-e E
10982 Publish every project.
10983 @end table
10985 @vindex org-publish-use-timestamps-flag
10986 Org uses timestamps to track when a file has changed. The above functions
10987 normally only publish changed files. You can override this and force
10988 publishing of all files by giving a prefix argument to any of the commands
10989 above, or by customizing the variable @code{org-publish-use-timestamps-flag}.
10990 This may be necessary in particular if files include other files via
10991 @code{#+SETUPFILE:} or @code{#+INCLUDE:}.
10993 @comment  node-name,  next,  previous,  up
10994 @comment Working With Source Code, Miscellaneous, Publishing, Top
10996 @node Working With Source Code, Miscellaneous, Publishing, Top
10997 @chapter Working with source code
10998 @cindex Schulte, Eric
10999 @cindex Davison, Dan
11000 @cindex source code, working with
11002 Source code can be included in Org-mode documents using a @samp{src} block,
11003 e.g.
11005 @example
11006 #+BEGIN_SRC emacs-lisp
11007   (defun org-xor (a b)
11008      "Exclusive or."
11009      (if a (not b) b))
11010 #+END_SRC
11011 @end example
11013 Org-mode provides a number of features for working with live source code,
11014 including editing of code blocks in their native major-mode, evaluation of
11015 code blocks, tangling of code blocks, and exporting code blocks and their
11016 results in several formats.  This functionality was contributed by Eric
11017 Schulte and Dan Davison, and was originally named Org-babel.
11019 The following sections describe Org-mode's code block handling facilities.
11021 @menu
11022 * Structure of code blocks::    Code block syntax described
11023 * Editing source code::         Language major-mode editing
11024 * Exporting code blocks::       Export contents and/or results
11025 * Extracting source code::      Create pure source code files
11026 * Evaluating code blocks::      Place results of evaluation in the Org-mode buffer
11027 * Library of Babel::            Use and contribute to a library of useful code blocks
11028 * Languages::                   List of supported code block languages
11029 * Header arguments::            Configure code block functionality
11030 * Results of evaluation::       How evaluation results are handled
11031 * Noweb reference syntax::      Literate programming in Org-mode
11032 * Key bindings and useful functions::  Work quickly with code blocks
11033 * Batch execution::             Call functions from the command line
11034 @end menu
11036 @comment  node-name,  next,  previous,  up
11037 @comment  Structure of code blocks, Editing source code, Working With Source Code, Working With Source Code
11039 @node Structure of code blocks, Editing source code, Working With Source Code, Working With Source Code
11040 @section Structure of code blocks
11041 @cindex code block, structure
11042 @cindex source code, block structure
11044 The structure of code blocks is as follows:
11046 @example
11047 #+srcname: <name>
11048 #+begin_src <language> <switches> <header arguments>
11049   <body>
11050 #+end_src
11051 @end example
11053 @table @code
11054 @item <name>
11055 This name is associated with the code block.  This is similar to the
11056 @samp{#+tblname} lines that can be used to name tables in Org-mode files.
11057 Referencing the name of a code block makes it possible to evaluate the
11058 block from other places in the file, other files, or from Org-mode table
11059 formulas (see @ref{The spreadsheet}).
11060 @item <language>
11061 The language of the code in the block.
11062 @item <switches>
11063 Switches controlling exportation of the code block (see switches discussion in
11064 @ref{Literal examples})
11065 @item <header arguments>
11066 Optional header arguments control many aspects of evaluation, export and
11067 tangling of code blocks. See the @ref{Header arguments}
11068 section. Header arguments can also be set on a per-buffer or per-subtree
11069 basis using properties.
11070 @item <body>
11071 The source code.
11072 @end table
11074 @comment  node-name,  next,  previous,  up
11075 @comment  Editing source code, Exporting code blocks, Structure of code blocks, Working With Source Code
11077 @node Editing source code, Exporting code blocks, Structure of code blocks, Working With Source Code
11078 @section Editing source code
11079 @cindex code block, editing
11080 @cindex source code, editing
11082 @kindex C-c '
11083 Use @kbd{C-c '} to edit the current code block. This brings up
11084 a language major-mode edit buffer containing the body of the code
11085 block. Saving this buffer will write the new contents back to the Org
11086 buffer. Use @kbd{C-c '} again to exit.
11088 The @code{org-src-mode} minor mode will be active in the edit buffer. The
11089 following variables can be used to configure the behavior of the edit
11090 buffer. See also the customization group @code{org-edit-structure} for
11091 further configuration options.
11093 @table @code
11094 @item org-src-lang-modes
11095 If an Emacs major-mode named @code{<lang>-mode} exists, where
11096 @code{<lang>} is the language named in the header line of the code block,
11097 then the edit buffer will be placed in that major-mode. This variable
11098 can be used to map arbitrary language names to existing major modes.
11099 @item org-src-window-setup
11100 Controls the way Emacs windows are rearranged when the edit buffer is created.
11101 @item org-src-preserve-indentation
11102 This variable is especially useful for tangling languages such as
11103 python, in which whitespace indentation in the output is critical.
11104 @item org-src-ask-before-returning-to-edit-buffer
11105 By default, Org will ask before returning to an open edit buffer. Set
11106 this variable to nil to switch without asking.
11107 @end table
11109 @comment  node-name,  next,  previous,  up
11110 @comment  Exporting code blocks, Extracting source code, Editing source code, Working With Source Code
11112 @node Exporting code blocks, Extracting source code, Editing source code, Working With Source Code
11113 @section Exporting code blocks
11114 @cindex code block, exporting
11115 @cindex source code, exporting
11117 It is possible to export the @emph{contents} of code blocks, the
11118 @emph{results} of code block evaluation, @emph{neither}, or @emph{both}.  For
11119 most languages, the default exports the contents of code blocks. However, for
11120 some languages (e.g. @code{ditaa}) the default exports the results of code
11121 block evaluation.  For information on exporting code block bodies, see
11122 @ref{Literal examples}.
11124 The @code{:exports} header argument can be used to specify export
11125 behavior:
11127 @subsubheading Header arguments:
11128 @table @code
11129 @item :exports code
11130 The default in most languages. The body of the code block is exported, as
11131 described in @ref{Literal examples}.
11132 @item :exports results
11133 The code block will be evaluated and the results will be placed in the
11134 Org-mode buffer for export, either updating previous results of the code
11135 block located anywhere in the buffer or, if no previous results exist,
11136 placing the results immediately after the code block.  The body of the code
11137 block will not be exported.
11138 @item :exports both
11139 Both the code block and its results will be exported.
11140 @item :exports none
11141 Neither the code block nor its results will be exported.
11142 @end table
11144 It is possible to inhibit the evaluation of code blocks during export.
11145 Setting the the @code{org-export-babel-evaluate} variable to @code{nil} will
11146 ensure that no code blocks are evaluated as part of the export process.  This
11147 can be useful in situations where potentially untrusted Org-mode files are
11148 exported in an automated fashion, for example when Org-mode is used as the
11149 markup language for a wiki.
11151 @comment  node-name,  next,  previous,  up
11152 @comment  Extracting source code, Evaluating code blocks, Exporting code blocks, Working With Source Code
11153 @node Extracting source code, Evaluating code blocks, Exporting code blocks, Working With Source Code
11154 @section Extracting source code
11155 @cindex source code, extracting
11156 @cindex code block, extracting source code
11158 Creating pure source code files by extracting code from source blocks is
11159 referred to as ``tangling''---a term adopted from the literate programming
11160 community.  During ``tangling'' of code blocks their bodies are expanded
11161 using @code{org-babel-expand-src-block} which can expand both variable and
11162 ``noweb'' style references  (see @ref{Noweb reference syntax}).
11164 @subsubheading Header arguments
11165 @table @code
11166 @item :tangle no
11167 The default.  The code block is not included in the tangled output.
11168 @item :tangle yes
11169 Include the code block in the tangled output. The output file name is the
11170 name of the org file with the extension @samp{.org} replaced by the extension
11171 for the block language.
11172 @item :tangle filename
11173 Include the code block in the tangled output to file @samp{filename}.
11174 @end table
11176 @kindex  C-c C-v t
11177 @subsubheading Functions
11178 @table @code
11179 @item org-babel-tangle 
11180 Tangle the current file.  Bound to @kbd{C-c C-v t}.
11181 @item org-babel-tangle-file
11182 Choose a file to tangle.   Bound to @kbd{C-c C-v f}.
11183 @end table
11185 @subsubheading Hooks
11186 @table @code
11187 @item org-babel-post-tangle-hook
11188 This hook is run from within code files tangled by @code{org-babel-tangle}.
11189 Example applications could include post-processing, compilation or evaluation
11190 of tangled code files.
11191 @end table
11193 @node Evaluating code blocks, Library of Babel, Extracting source code, Working With Source Code
11194 @section Evaluating code blocks
11195 @cindex code block, evaluating
11196 @cindex source code, evaluating
11198 Code blocks can be evaluated@footnote{Whenever code is evaluated there is a
11199 potential for that code to do harm.  Org-mode provides a number of safeguards
11200 to ensure that it only evaluates code with explicit confirmation from the
11201 user.  For information on these safeguards (and on how to disable them) see
11202 @ref{Code evaluation security}.} and the results placed in the Org-mode
11203 buffer.  By default, evaluation is only turned on for @code{emacs-lisp} code
11204 blocks, however support exists for evaluating blocks in many languages.  See
11205 @ref{Languages} for a list of supported languages.  See @ref{Structure of
11206 code blocks} for information on the syntax used to define a code block.
11208 @kindex C-c C-c
11209 There are a number of ways to evaluate code blocks.  The simplest is to press
11210 @kbd{C-c C-c} or @kbd{C-c C-v e} with the point on a code block@footnote{The
11211 @code{org-babel-no-eval-on-ctrl-c-ctrl-c} variable can be used to remove code
11212 evaluation from the @kbd{C-c C-c} key binding.}.  This will call the
11213 @code{org-babel-execute-src-block} function to evaluate the block and insert
11214 its results into the Org-mode buffer.
11216 It is also possible to evaluate named code blocks from anywhere in an
11217 Org-mode buffer or an Org-mode table.  @code{#+call} (or synonymously
11218 @code{#+function} or @code{#+lob}) lines can be used to remotely execute code
11219 blocks located in the current Org-mode buffer or in the ``Library of Babel''
11220 (see @ref{Library of Babel}).  These lines use the following syntax.
11222 @example
11223 #+call: <name>(<arguments>) <header arguments>
11224 #+function: <name>(<arguments>) <header arguments>
11225 #+lob: <name>(<arguments>) <header arguments>
11226 @end example
11228 @table @code
11229 @item <name>
11230 The name of the code block to be evaluated.
11231 @item <arguments>
11232 Arguments specified in this section will be passed to the code block.
11233 @item <header arguments>
11234 Header arguments can be placed after the function invocation.  See
11235 @ref{Header arguments} for more information on header arguments.
11236 @end table
11239 @node Library of Babel, Languages, Evaluating code blocks, Working With Source Code
11240 @section Library of Babel
11241 @cindex babel, library of
11242 @cindex source code, library
11243 @cindex code block, library
11245 The ``Library of Babel'' is a library of code blocks
11246 that can be called from any Org-mode file.  The library is housed in an
11247 Org-mode file located in the @samp{contrib} directory of Org-mode.
11248 Org-mode users can deposit functions they believe to be generally
11249 useful in the library.
11251 Code blocks defined in the ``Library of Babel'' can be called remotely as if
11252 they were in the current Org-mode buffer (see @ref{Evaluating code blocks}
11253 for information on the syntax of remote code block evaluation).
11255 @kindex C-c C-v l
11256 Code blocks located in any Org-mode file can be loaded into the ``Library of
11257 Babel'' with the @code{org-babel-lob-ingest} function, bound to @kbd{C-c C-v
11260 @node Languages, Header arguments, Library of Babel, Working With Source Code
11261 @section Languages
11262 @cindex babel, languages
11263 @cindex source code, languages
11264 @cindex code block, languages
11266 Code blocks in the following languages are supported.
11268 @multitable @columnfractions 0.28 0.3 0.22 0.2
11269 @item @b{Language} @tab @b{Identifier} @tab @b{Language} @tab @b{Identifier}
11270 @item Asymptote @tab asymptote @tab C @tab C
11271 @item C++ @tab C++ @tab Clojure @tab clojure
11272 @item css @tab css @tab ditaa @tab ditaa
11273 @item Graphviz @tab dot @tab Emacs Lisp @tab emacs-lisp
11274 @item gnuplot @tab gnuplot @tab Haskell @tab haskell
11275 @item LaTeX @tab latex @tab Matlab @tab matlab
11276 @item Mscgen @tab mscgen @tab Objective Caml @tab ocaml
11277 @item Octave @tab octave @tab OZ @tab oz
11278 @item Perl @tab perl @tab Python @tab python
11279 @item R @tab R @tab Ruby @tab ruby
11280 @item Sass @tab sass @tab GNU Screen @tab screen
11281 @item shell @tab sh @tab SQL @tab sql
11282 @item Sqlite @tab sqlite
11283 @end multitable
11285 Language-specific documentation is available for some languages.  If
11286 available, it can be found at
11287 @uref{http://orgmode.org/worg/org-contrib/babel/languages}.
11289 The @code{org-babel-load-languages} controls which languages are enabled for
11290 evaluation (by default only @code{emacs-lisp} is enabled).  This variable can
11291 be set using the customization interface or by adding code like the following
11292 to your emacs configuration.
11294 @quotation
11295 The following disables @code{emacs-lisp} evaluation and enables evaluation of
11296 @code{R} code blocks.
11297 @end quotation
11299 @lisp
11300 (org-babel-do-load-languages
11301  'org-babel-load-languages
11302  '((emacs-lisp . nil)
11303    (R . t)))
11304 @end lisp
11306 It is also possible to enable support for a language by loading the related
11307 elisp file with @code{require}.
11309 @quotation
11310 The following adds support for evaluating @code{clojure} code blocks.
11311 @end quotation
11313 @lisp
11314 (require 'ob-clojure)
11315 @end lisp
11317 @node Header arguments, Results of evaluation, Languages, Working With Source Code
11318 @section Header arguments
11319 @cindex code block, header arguments
11320 @cindex source code, block header arguments
11322 Code block functionality can be configured with header arguments.  This
11323 section provides an overview of the use of header arguments, and then
11324 describes each header argument in detail.
11326 @menu
11327 * Using header arguments::      Different ways to set header arguments
11328 * Specific header arguments::   List of header arguments
11329 @end menu
11331 @node Using header arguments, Specific header arguments, Header arguments, Header arguments
11332 @subsection Using header arguments
11334 The values of header arguments can be set in five different ways, each more
11335 specific (and having higher priority) than the last.
11336 @menu
11337 * System-wide header arguments::  Set global default values
11338 * Language-specific header arguments::  Set default values by language
11339 * Buffer-wide header arguments::  Set default values for a specific buffer
11340 * Header arguments in Org-mode properties::  Set default values for a buffer or heading
11341 * Code block specific header arguments::  The most common way to set values
11342 @end menu
11345 @node System-wide header arguments, Language-specific header arguments, Using header arguments, Using header arguments
11346 @subsubheading System-wide header arguments
11347 @vindex org-babel-default-header-args
11348 System-wide values of header arguments can be specified by customizing the
11349 @code{org-babel-default-header-args} variable:
11351 @example
11352 :session    => "none"
11353 :results    => "replace"
11354 :exports    => "code"
11355 :cache      => "no"
11356 :noweb      => "no"
11357 @end example
11359 @c @example
11360 @c   org-babel-default-header-args is a variable defined in `org-babel.el'.
11361 @c   Its value is
11362 @c   ((:session . "none")
11363 @c    (:results . "replace")
11364 @c    (:exports . "code")
11365 @c    (:cache . "no")
11366 @c    (:noweb . "no"))
11369 @c   Documentation:
11370 @c   Default arguments to use when evaluating a code block.
11371 @c @end example
11373 For example, the following example could be used to set the default value of
11374 @code{:noweb} header arguments to @code{yes}.  This would have the effect of
11375 expanding @code{:noweb} references by default when evaluating source code
11376 blocks.
11378 @lisp
11379 (setq org-babel-default-header-args
11380 (cons '(:noweb . "yes")
11381 (assq-delete-all :noweb org-babel-default-header-args)))
11382 @end lisp
11384 @node Language-specific header arguments, Buffer-wide header arguments, System-wide header arguments, Using header arguments
11385 @subsubheading Language-specific header arguments
11386 Each language can define its own set of default header arguments.  See the
11387 language-specific documentation available online at
11388 @uref{http://orgmode.org/worg/org-contrib/babel}.
11390 @node Buffer-wide header arguments, Header arguments in Org-mode properties, Language-specific header arguments, Using header arguments
11391 @subsubheading Buffer-wide header arguments
11392 Buffer-wide header arguments may be specified through the use of a special
11393 line placed anywhere in an Org-mode file.  The line consists of the
11394 @code{#+BABEL:} keyword followed by a series of header arguments which may be
11395 specified using the standard header argument syntax.
11397 For example the following would set @code{session} to @code{*R*}, and
11398 @code{results} to @code{silent} for every code block in the buffer, ensuring
11399 that all execution took place in the same session, and no results would be
11400 inserted into the buffer.
11402 @example
11403 #+BABEL: :session *R* :results silent
11404 @end example
11406 @node Header arguments in Org-mode properties, Code block specific header arguments, Buffer-wide header arguments, Using header arguments
11407 @subsubheading Header arguments in Org-mode properties
11409 Header arguments are also read from Org-mode properties (see @ref{Property
11410 syntax}), which can be set on a buffer-wide or per-heading basis. An example
11411 of setting a header argument for all code blocks in a buffer is
11413 @example
11414 #+property: tangle yes
11415 @end example
11417 When properties are used to set default header arguments, they are looked up
11418 with inheritance, so the value of the @code{:cache} header argument will default
11419 to @code{yes} in all code blocks in the subtree rooted at the following
11420 heading:
11422 @example
11423 * outline header
11424 :PROPERTIES:
11425 :cache:    yes
11426 :END:
11427 @end example
11429 @kindex C-c C-x p
11430 @vindex org-babel-default-header-args
11431 Properties defined in this way override the properties set in
11432 @code{org-babel-default-header-args}.  It is convenient to use the
11433 @code{org-set-property} function bound to @kbd{C-c C-x p} to set properties
11434 in Org-mode documents.
11436 @node Code block specific header arguments,  , Header arguments in Org-mode properties, Using header arguments
11437 @subsubheading Code block specific header arguments
11439 The most common way to assign values to header arguments is at the
11440 code block level.  This can be done by listing a sequence of header
11441 arguments and their values as part of the @code{#+begin_src} line.
11442 Properties set in this way override both the values of
11443 @code{org-babel-default-header-args} and header arguments specified as
11444 properties.  In the following example, the @code{:results} header argument
11445 is set to @code{silent}, meaning the results of execution will not be
11446 inserted in the buffer, and the @code{:exports} header argument is set to
11447 @code{code}, meaning only the body of the code block will be
11448 preserved on export to HTML or LaTeX.
11450 @example
11451 #+source: factorial
11452 #+begin_src haskell :results silent :exports code :var n=0
11453 fac 0 = 1
11454 fac n = n * fac (n-1)
11455 #+end_src
11456 @end example
11458 Similarly, it is possible to set header arguments for inline code blocks:
11460 @example
11461 src_haskell[:exports both]@{fac 5@}
11462 @end example
11464 Header arguments for ``Library of Babel'' or function call lines can be set as shown below:
11466 @example
11467 #+call: factorial(n=5) :exports results
11468 @end example
11470 @node Specific header arguments,  , Using header arguments, Header arguments
11471 @subsection Specific header arguments
11472 The following header arguments are defined:
11474 @menu
11475 * var::                         Pass arguments to code blocks
11476 * results::                     Specify the type of results and how they will
11477                                 be collected and handled
11478 * file::                        Specify a path for file output
11479 * dir::                         Specify the default (possibly remote)
11480                                 directory for code block execution
11481 * exports::                     Export code and/or results
11482 * tangle::                      Toggle tangling and specify file name
11483 * comments::                    Toggle insertion of comments in tangled
11484                                 code files
11485 * no-expand::                   Turn off variable assignment and noweb
11486                                 expansion during tangling
11487 * session::                     Preserve the state of code evaluation
11488 * noweb::                       Toggle expansion of noweb references
11489 * cache::                       Avoid re-evaluating unchanged code blocks
11490 * hlines::                      Handle horizontal lines in tables
11491 * colnames::                    Handle column names in tables
11492 * rownames::                    Handle row names in tables
11493 * shebang::                     Make tangled files executable
11494 * eval::                        Limit evaluation of specific code blocks
11495 @end menu
11497 @node var, results, Specific header arguments, Specific header arguments
11498 @subsubsection @code{:var}
11499 The @code{:var} header argument is used to pass arguments to code blocks.
11500 The specifics of how arguments are included in a code block vary by language;
11501 these are addressed in the language-specific documentation. However, the
11502 syntax used to specify arguments is the same across all languages.  The
11503 values passed to arguments can be literal values, values from org-mode tables
11504 and literal example blocks, or the results of other code blocks.
11506 These values can be indexed in a manner similar to arrays---see the
11507 ``indexable variable values'' heading below.
11509 The following syntax is used to pass arguments to code blocks using the
11510 @code{:var} header argument.
11512 @example
11513 :var name=assign
11514 @end example
11516 where @code{assign} can take one of the following forms
11518 @itemize @bullet
11519 @item literal value
11520 either a string @code{"string"} or a number @code{9}.
11521 @item reference
11522 a table name:
11524 @example
11525 #+tblname: example-table
11526 | 1 |
11527 | 2 |
11528 | 3 |
11529 | 4 |
11531 #+source: table-length
11532 #+begin_src emacs-lisp :var table=example-table
11533 (length table)
11534 #+end_src
11536 #+results: table-length
11537 : 4
11538 @end example
11540 a code block name, as assigned by @code{#+srcname:}, followed by
11541 parentheses:
11543 @example
11544 #+begin_src emacs-lisp :var length=table-length()
11545 (* 2 length)
11546 #+end_src
11548 #+results:
11549 : 8
11550 @end example
11552 In addition, an argument can be passed to the code block referenced
11553 by @code{:var}.  The argument is passed within the parentheses following the
11554 code block name:
11556 @example
11557 #+source: double
11558 #+begin_src emacs-lisp :var input=8
11559 (* 2 input)
11560 #+end_src
11562 #+results: double
11563 : 16
11565 #+source: squared
11566 #+begin_src emacs-lisp :var input=double(input=1)
11567 (* input input)
11568 #+end_src
11570 #+results: squared
11571 : 4
11572 @end example
11573 @end itemize
11575 @subsubheading Alternate argument syntax
11576 It is also possible to specify arguments in a potentially more natural way
11577 using the @code{#+source:} line of a code block.  As in the following
11578 example arguments can be packed inside of parenthesis, separated by commas,
11579 following the source name.
11581 @example
11582 #+source: double(input=0, x=2)
11583 #+begin_src emacs-lisp
11584 (* 2 (+ input x))
11585 #+end_src
11586 @end example
11588 @subsubheading Indexable variable values
11589 It is possible to reference portions of variable values by ``indexing'' into
11590 the variables.  Indexes are 0 based with negative values counting back from
11591 the end.  If an index is separated by @code{,}s then each subsequent section
11592 will index into the next deepest nesting or dimension of the value.  The
11593 following example assigns the last cell of the first row the table
11594 @code{example-table} to the variable @code{data}:
11596 @example
11597 #+results: example-table
11598 | 1 | a |
11599 | 2 | b |
11600 | 3 | c |
11601 | 4 | d |
11603 #+begin_src emacs-lisp :var data=example-table[0,-1]
11604   data
11605 #+end_src
11607 #+results:
11608 : a
11609 @end example
11611 Ranges of variable values can be referenced using two integers separated by a
11612 @code{:}, in which case the entire inclusive range is referenced.  For
11613 example the following assigns the middle three rows of @code{example-table}
11614 to @code{data}.
11616 @example
11617 #+results: example-table
11618 | 1 | a |
11619 | 2 | b |
11620 | 3 | c |
11621 | 4 | d |
11622 | 5 | 3 |
11624 #+begin_src emacs-lisp :var data=example-table[1:3]
11625   data
11626 #+end_src
11628 #+results:
11629 | 2 | b |
11630 | 3 | c |
11631 | 4 | d |
11632 @end example
11634 Additionally, an empty index, or the single character @code{*}, are both
11635 interpreted to mean the entire range and as such are equivalent to
11636 @code{0:-1}, as shown in the following example in which the entire first
11637 column is referenced.
11639 @example
11640 #+results: example-table
11641 | 1 | a |
11642 | 2 | b |
11643 | 3 | c |
11644 | 4 | d |
11646 #+begin_src emacs-lisp :var data=example-table[,0]
11647   data
11648 #+end_src
11650 #+results:
11651 | 1 | 2 | 3 | 4 |
11652 @end example
11654 It is possible to index into the results of code blocks as well as tables.
11655 Any number of dimensions can be indexed.  Dimensions are separated from one
11656 another by commas, as shown in the following example.
11658 @example
11659 #+source: 3D
11660 #+begin_src emacs-lisp
11661   '(((1  2  3)  (4  5  6)  (7  8  9))
11662     ((10 11 12) (13 14 15) (16 17 18))
11663     ((19 20 21) (22 23 24) (25 26 27)))
11664 #+end_src
11666 #+begin_src emacs-lisp :var data=3D[1,,1]
11667   data
11668 #+end_src
11670 #+results:
11671 | 11 | 14 | 17 |
11672 @end example
11674 @node results, file, var, Specific header arguments
11675 @subsubsection @code{:results}
11677 There are three classes of @code{:results} header argument.  Only one option of
11678 each type may be supplied per code block.
11680 @itemize @bullet
11681 @item
11682 @b{collection} header arguments specify how the results should be collected
11683 from the code block
11684 @item
11685 @b{type} header arguments specify what type of result the code block will
11686 return---which has implications for how they will be inserted into the
11687 Org-mode buffer
11688 @item
11689 @b{handling} header arguments specify how the results of evaluating the code
11690 block should be handled.
11691 @end itemize
11693 @subsubheading Collection
11694 The following options are mutually exclusive, and specify how the results
11695 should be collected from the code block.
11697 @itemize @bullet
11698 @item @code{value}
11699 This is the default.  The result is the value of the last statement in the
11700 code block.  This header argument places the evaluation in functional
11701 mode.  Note that in some languages, e.g., python, use of this result type
11702 requires that a @code{return} statement be included in the body of the source
11703 code block. E.g., @code{:results value}.
11704 @item @code{output}
11705 The result is the collection of everything printed to STDOUT during the
11706 execution of the code block.  This header argument places the
11707 evaluation in scripting mode.  E.g., @code{:results output}.
11708 @end itemize
11710 @subsubheading Type
11712 The following options are mutually exclusive and specify what type of results
11713 the code block will return.  By default, results are inserted as either a
11714 table or scalar depending on their value.
11716 @itemize @bullet
11717 @item @code{table}, @code{vector}
11718 The results should be interpreted as an Org-mode table.  If a single value is
11719 returned, it will be converted into a table with one row and one column.
11720 E.g., @code{:results value table}.
11721 @item @code{scalar}, @code{verbatim}
11722 The results should be interpreted literally---they will not be
11723 converted into a table.  The results will be inserted into the Org-mode
11724 buffer as quoted text.  E.g., @code{:results value verbatim}.
11725 @item @code{file}
11726 The results will be interpreted as the path to a file, and will be inserted
11727 into the Org-mode buffer as a file link.  E.g., @code{:results value file}.
11728 @item @code{raw}, @code{org}
11729 The results are interpreted as raw Org-mode code and are inserted directly
11730 into the buffer.  If the results look like a table they will be aligned as
11731 such by Org-mode.  E.g., @code{:results value raw}.
11732 @item @code{html}
11733 Results are assumed to be HTML and will be enclosed in a @code{begin_html}
11734 block.  E.g., @code{:results value html}.
11735 @item @code{latex}
11736 Results assumed to be LaTeX and are enclosed in a @code{begin_latex} block.
11737 E.g., @code{:results value latex}.
11738 @item @code{code}
11739 Result are assumed to be parseable code and are enclosed in a code block.
11740 E.g., @code{:results value code}.
11741 @item @code{pp}
11742 The result is converted to pretty-printed code and is enclosed in a code
11743 block.  This option currently supports Emacs Lisp, python, and ruby.  E.g.,
11744 @code{:results value pp}.
11745 @end itemize
11747 @subsubheading Handling
11748 The following results options indicate what happens with the
11749 results once they are collected.
11751 @itemize @bullet
11752 @item @code{silent}
11753 The results will be echoed in the minibuffer but will not be inserted into
11754 the Org-mode buffer.  E.g., @code{:results output silent}.
11755 @item @code{replace}
11756 The default value.  Any existing results will be removed, and the new results
11757 will be inserted into the Org-mode buffer in their place.  E.g.,
11758 @code{:results output replace}.
11759 @item @code{append}
11760 If there are pre-existing results of the code block then the new results will
11761 be appended to the existing results.  Otherwise the new results will be
11762 inserted as with @code{replace}.
11763 @item @code{prepend}
11764 If there are pre-existing results of the code block then the new results will
11765 be prepended to the existing results.  Otherwise the new results will be
11766 inserted as with @code{replace}.
11767 @end itemize
11769 @node file, dir, results, Specific header arguments
11770 @subsubsection @code{:file}
11772 The header argument @code{:file} is used to specify a path for file output.
11773 An Org-mode style @code{file:} link is inserted into the buffer as the result
11774 (see @ref{Link format}). Common examples are graphical output from R,
11775 gnuplot, ditaa and LaTeX code blocks.
11777 Note that for some languages, including R, gnuplot, LaTeX and ditaa,
11778 graphical output is sent to the specified file without the file being
11779 referenced explicitly in the code block. See the documentation for the
11780 individual languages for details. In contrast, general purpose languages such
11781 as python and ruby require that the code explicitly create output
11782 corresponding to the path indicated by @code{:file}.
11785 @node dir, exports, file, Specific header arguments
11786 @subsubsection @code{:dir} and remote execution
11788 While the @code{:file} header argument can be used to specify the path to the
11789 output file, @code{:dir} specifies the default directory during code block
11790 execution. If it is absent, then the directory associated with the current
11791 buffer is used. In other words, supplying @code{:dir path} temporarily has
11792 the same effect as changing the current directory with @kbd{M-x cd path}, and
11793 then not supplying @code{:dir}. Under the surface, @code{:dir} simply sets
11794 the value of the Emacs variable @code{default-directory}.
11796 When using @code{:dir}, you should supply a relative path for file output
11797 (e.g. @code{:file myfile.jpg} or @code{:file results/myfile.jpg}) in which
11798 case that path will be interpreted relative to the default directory.
11800 In other words, if you want your plot to go into a folder called Work in your
11801 home directory, you could use
11803 @example
11804 #+begin_src R :file myplot.png :dir ~/Work
11805 matplot(matrix(rnorm(100), 10), type="l")
11806 #+end_src
11807 @end example
11809 @subsubheading Remote execution
11810 A directory on a remote machine can be specified using tramp file syntax, in
11811 which case the code will be evaluated on the remote machine. An example is
11813 @example
11814 #+begin_src R :file plot.png :dir /dand@@yakuba.princeton.edu:
11815 plot(1:10, main=system("hostname", intern=TRUE))
11816 #+end_src
11817 @end example
11819 Text results will be returned to the local Org-mode buffer as usual, and file
11820 output will be created on the remote machine with relative paths interpreted
11821 relative to the remote directory. An Org-mode link to the remote file will be
11822 created.
11824 So, in the above example a plot will be created on the remote machine,
11825 and a link of the following form will be inserted in the org buffer:
11827 @example
11828 [[file:/scp:dand@@yakuba.princeton.edu:/home/dand/plot.png][plot.png]]
11829 @end example
11831 Most of this functionality follows immediately from the fact that @code{:dir}
11832 sets the value of the Emacs variable @code{default-directory}, thanks to
11833 tramp. Those using XEmacs, or GNU Emacs prior to version 23 may need to
11834 install tramp separately in order for the these features to work correctly.
11836 @subsubheading Further points
11838 @itemize @bullet
11839 @item
11840 If @code{:dir} is used in conjunction with @code{:session}, although it will
11841 determine the starting directory for a new session as expected, no attempt is
11842 currently made to alter the directory associated with an existing session.
11843 @item
11844 @code{:dir} should typically not be used to create files during export with
11845 @code{:exports results} or @code{:exports both}. The reason is that, in order
11846 to retain portability of exported material between machines, during export
11847 links inserted into the buffer will *not* be expanded against @code{default
11848 directory}. Therefore, if @code{default-directory} is altered using
11849 @code{:dir}, it is probable that the file will be created in a location to
11850 which the link does not point.
11851 @end itemize
11853 @node exports, tangle, dir, Specific header arguments
11854 @subsubsection @code{:exports}
11856 The @code{:exports} header argument specifies what should be included in HTML
11857 or LaTeX exports of the Org-mode file.
11859 @itemize @bullet
11860 @item @code{code}
11861 The default.  The body of code is included into the exported file.  E.g.,
11862 @code{:exports code}.
11863 @item @code{results}
11864 The result of evaluating the code is included in the exported file. E.g.,
11865 @code{:exports results}.
11866 @item @code{both}
11867 Both the code and results are included in the exported file. E.g.,
11868 @code{:exports both}.
11869 @item @code{none}
11870 Nothing is included in the exported file.  E.g., @code{:exports none}.
11871 @end itemize
11873 @node tangle, comments, exports, Specific header arguments
11874 @subsubsection @code{:tangle}
11876 The @code{:tangle} header argument specifies whether or not the code
11877 block should be included in tangled extraction of source code files.
11879 @itemize @bullet
11880 @item @code{yes}
11881 The code block is exported to a source code file named after the
11882 basename (name w/o extension) of the Org-mode file.  E.g., @code{:tangle
11883 yes}.
11884 @item @code{no}
11885 The default.  The code block is not exported to a source code file.
11886 E.g., @code{:tangle no}.
11887 @item other
11888 Any other string passed to the @code{:tangle} header argument is interpreted
11889 as a file basename to which the block will be exported.  E.g., @code{:tangle
11890 basename}.
11891 @end itemize
11893 @node comments, no-expand, tangle, Specific header arguments
11894 @subsubsection @code{:comments}
11895 By default code blocks are tangled to source-code files without any insertion
11896 of comments beyond those which may already exist in the body of the code
11897 block.  The @code{:comments} header argument can be set to ``yes''
11898 e.g. @code{:comments yes} to enable the insertion of comments around code
11899 blocks during tangling.  The inserted comments contain pointers back to the
11900 original Org file from which the comment was tangled.
11902 @node no-expand, session, comments, Specific header arguments
11903 @subsubsection @code{:no-expand}
11905 By default, code blocks are expanded with @code{org-babel-expand-src-block}
11906 during tangling.  This has the effect of assigning values to variables
11907 specified with @code{:var} (see @ref{var}), and of replacing ``noweb''
11908 references (see @ref{Noweb reference syntax}) with their targets.  The
11909 @code{:no-expand} header argument can be used to turn off this behavior.
11911 @node session, noweb, no-expand, Specific header arguments
11912 @subsubsection @code{:session}
11914 The @code{:session} header argument starts a session for an interpreted
11915 language where state is preserved.
11917 By default, a session is not started.
11919 A string passed to the @code{:session} header argument will give the session
11920 a name.  This makes it possible to run concurrent sessions for each
11921 interpreted language.
11923 @node noweb, cache, session, Specific header arguments
11924 @subsubsection @code{:noweb}
11926 The @code{:noweb} header argument controls expansion of ``noweb'' style (see
11927 @ref{Noweb reference syntax}) references in a code block.  This header
11928 argument can have one of two values: @code{yes} or @code{no}.
11930 @itemize @bullet
11931 @item @code{no}
11932 The default.  No ``noweb'' syntax specific action is taken on evaluating
11933 code blocks, However, noweb references will still be expanded during
11934 tangling.
11935 @item @code{yes}
11936 All ``noweb'' syntax references in the body of the code block will be
11937 expanded before the block is evaluated.
11938 @end itemize
11940 @subsubheading Noweb prefix lines
11941 Noweb insertions are now placed behind the line prefix of the
11942 @code{<<reference>>}.
11943 This behavior is illustrated in the following example.  Because the
11944 @code{<<example>>} noweb reference appears behind the SQL comment syntax,
11945 each line of the expanded noweb reference will be commented.
11947 This code block:
11949 @example
11950 -- <<example>>
11951 @end example
11954 expands to:
11956 @example
11957 -- this is the
11958 -- multi-line body of example
11959 @end example
11961 Note that noweb replacement text that does not contain any newlines will not
11962 be affected by this change, so it is still possible to use inline noweb
11963 references.
11965 @node cache, hlines, noweb, Specific header arguments
11966 @subsubsection @code{:cache}
11968 The @code{:cache} header argument controls the use of in-buffer caching of
11969 the results of evaluating code blocks.  It can be used to avoid re-evaluating
11970 unchanged code blocks.  This header argument can have one of two
11971 values: @code{yes} or @code{no}.
11973 @itemize @bullet
11974 @item @code{no}
11975 The default.  No caching takes place, and the code block will be evaluated
11976 every time it is called.
11977 @item @code{yes}
11978 Every time the code block is run a sha1 hash of the code and arguments
11979 passed to the block will be generated.  This hash is packed into the
11980 @code{#+results:} line and will be checked on subsequent
11981 executions of the code block.  If the code block has not
11982 changed since the last time it was evaluated, it will not be re-evaluated.
11983 @end itemize
11985 @node hlines, colnames, cache, Specific header arguments
11986 @subsubsection @code{:hlines}
11988 Tables are frequently represented with one or more horizontal lines, or
11989 hlines.  The @code{:hlines} argument to a code block accepts the
11990 values @code{yes} or @code{no}, with a default value of @code{no}.
11992 @itemize @bullet
11993 @item @code{no}
11994 Strips horizontal lines from the input table.  In most languages this is the
11995 desired effect because an @code{hline} symbol is interpreted as an unbound
11996 variable and raises an error.  Setting @code{:hlines no} or relying on the
11997 default value yields the following results.
11999 @example
12000 #+tblname: many-cols
12001 | a | b | c |
12002 |---+---+---|
12003 | d | e | f |
12004 |---+---+---|
12005 | g | h | i |
12007 #+source: echo-table
12008 #+begin_src python :var tab=many-cols
12009   return tab
12010 #+end_src
12012 #+results: echo-table
12013 | a | b | c |
12014 | d | e | f |
12015 | g | h | i |
12016 @end example
12018 @item @code{yes}
12019 Leaves hlines in the table. Setting @code{:hlines yes} has this effect.
12021 @example
12022 #+tblname: many-cols
12023 | a | b | c |
12024 |---+---+---|
12025 | d | e | f |
12026 |---+---+---|
12027 | g | h | i |
12029 #+source: echo-table
12030 #+begin_src python :var tab=many-cols :hlines yes
12031   return tab
12032 #+end_src
12034 #+results: echo-table
12035 | a | b | c |
12036 |---+---+---|
12037 | d | e | f |
12038 |---+---+---|
12039 | g | h | i |
12040 @end example
12041 @end itemize
12043 @node colnames, rownames, hlines, Specific header arguments
12044 @subsubsection @code{:colnames}
12046 The @code{:colnames} header argument accepts the values @code{yes},
12047 @code{no}, or @code{nil} for unassigned.  The default value is @code{nil}.
12049 @itemize @bullet
12050 @item @code{nil}
12051 If an input table looks like it has column names
12052 (because its second row is an hline), then the column
12053 names will be removed from the table before
12054 processing, then reapplied to the results.
12056 @example
12057 #+tblname: less-cols
12058 | a |
12059 |---|
12060 | b |
12061 | c |
12063 #+srcname: echo-table-again
12064 #+begin_src python :var tab=less-cols
12065   return [[val + '*' for val in row] for row in tab]
12066 #+end_src
12068 #+results: echo-table-again
12069 | a  |
12070 |----|
12071 | b* |
12072 | c* |
12073 @end example
12075 @item @code{no}
12076 No column name pre-processing takes place
12078 @item @code{yes}
12079 Column names are removed and reapplied as with @code{nil} even if the table
12080 does not ``look like'' it has column names (i.e. the second row is not an
12081 hline)
12082 @end itemize
12084 @node rownames, shebang, colnames, Specific header arguments
12085 @subsubsection @code{:rownames}
12087 The @code{:rownames} header argument can take on the values @code{yes}
12088 or @code{no}, with a default value of @code{no}.
12090 @itemize @bullet
12091 @item @code{no}
12092 No row name pre-processing will take place.
12094 @item @code{yes}
12095 The first column of the table is removed from the table before processing,
12096 and is then reapplied to the results.
12098 @example
12099 #+tblname: with-rownames
12100 | one | 1 | 2 | 3 | 4 |  5 |
12101 | two | 6 | 7 | 8 | 9 | 10 |
12103 #+srcname: echo-table-once-again
12104 #+begin_src python :var tab=with-rownames :rownames yes
12105   return [[val + 10 for val in row] for row in tab]
12106 #+end_src
12108 #+results: echo-table-once-again
12109 | one | 11 | 12 | 13 | 14 | 15 |
12110 | two | 16 | 17 | 18 | 19 | 20 |
12111 @end example
12112 @end itemize
12114 @node shebang, eval, rownames, Specific header arguments
12115 @subsubsection @code{:shebang}
12117 Setting the @code{:shebang} header argument to a string value
12118 (e.g. @code{:shebang "#!/bin/bash"}) causes the string to be inserted as the
12119 first line of any tangled file holding the code block, and the file
12120 permissions of the tangled file are set to make it executable.
12122 @node eval,  , shebang, Specific header arguments
12123 @subsubsection @code{:eval}
12124 The @code{:eval} header argument can be used to limit the evaluation of
12125 specific code blocks.  @code{:eval} accepts two arguments ``never'' and
12126 ``query''.  @code{:eval never} will ensure that a code block is never
12127 evaluated, this can be useful for protecting against the evaluation of
12128 dangerous code blocks.  @code{:eval query} will require a query for every
12129 execution of a code block regardless of the value of the
12130 @code{org-confirm-babel-evaluate} variable.
12132 @node Results of evaluation, Noweb reference syntax, Header arguments, Working With Source Code
12133 @section Results of evaluation
12134 @cindex code block, results of evaluation
12135 @cindex source code, results of evaluation
12137 The way in which results are handled depends on whether a session is invoked,
12138 as well as on whether @code{:results value} or @code{:results output} is
12139 used. The following table shows the possibilities:
12141 @multitable @columnfractions 0.26 0.33 0.41
12142 @item @tab @b{Non-session} @tab @b{Session}
12143 @item @code{:results value} @tab value of last expression @tab value of last expression
12144 @item @code{:results output} @tab contents of STDOUT @tab concatenation of interpreter output
12145 @end multitable
12147 Note: With @code{:results value}, the result in both @code{:session} and
12148 non-session is returned to Org-mode as a table (a one- or two-dimensional
12149 vector of strings or numbers) when appropriate.
12151 @subsection Non-session
12152 @subsubsection @code{:results value}
12153 This is the default. Internally, the value is obtained by wrapping the code
12154 in a function definition in the external language, and evaluating that
12155 function. Therefore, code should be written as if it were the body of such a
12156 function. In particular, note that python does not automatically return a
12157 value from a function unless a @code{return} statement is present, and so a
12158 @samp{return} statement will usually be required in python.
12160 This is the only one of the four evaluation contexts in which the code is
12161 automatically wrapped in a function definition.
12163 @subsubsection @code{:results output}
12164 The code is passed to the interpreter as an external process, and the
12165 contents of the standard output stream are returned as text. (In certain
12166 languages this also contains the error output stream; this is an area for
12167 future work.)
12169 @subsection @code{:session}
12170 @subsubsection @code{:results value}
12171 The code is passed to the interpreter running as an interactive Emacs
12172 inferior process. The result returned is the result of the last evaluation
12173 performed by the interpreter. (This is obtained in a language-specific
12174 manner: the value of the variable @code{_} in python and ruby, and the value
12175 of @code{.Last.value} in R).
12177 @subsubsection @code{:results output}
12178 The code is passed to the interpreter running as an interactive Emacs
12179 inferior process. The result returned is the concatenation of the sequence of
12180 (text) output from the interactive interpreter. Notice that this is not
12181 necessarily the same as what would be sent to @code{STDOUT} if the same code
12182 were passed to a non-interactive interpreter running as an external
12183 process. For example, compare the following two blocks:
12185 @example
12186 #+begin_src python :results output
12187  print "hello"
12189  print "bye"
12190 #+end_src
12192 #+resname:
12193 : hello
12194 : bye
12195 @end example
12197 In non-session mode, the '2' is not printed and does not appear.
12198 @example
12199 #+begin_src python :results output :session
12200  print "hello"
12202  print "bye"
12203 #+end_src
12205 #+resname:
12206 : hello
12207 : 2
12208 : bye
12209 @end example
12211 But in @code{:session} mode, the interactive interpreter receives input '2'
12212 and prints out its value, '2'. (Indeed, the other print statements are
12213 unnecessary here).
12215 @node Noweb reference syntax, Key bindings and useful functions, Results of evaluation, Working With Source Code
12216 @section Noweb reference syntax
12217 @cindex code block, noweb reference
12218 @cindex syntax, noweb
12219 @cindex source code, noweb reference
12221 The ``noweb'' (see @uref{http://www.cs.tufts.edu/~nr/noweb/}) Literate
12222 Programming system allows named blocks of code to be referenced by using the
12223 familiar Noweb syntax:
12225 @example
12226 <<code-block-name>>
12227 @end example
12229 When a code block is tangled or evaluated, whether or not ``noweb''
12230 references are expanded depends upon the value of the @code{:noweb} header
12231 argument.  If @code{:noweb yes}, then a Noweb reference is expanded before
12232 evaluation.  If @code{:noweb no}, the default, then the reference is not
12233 expanded before evaluation.
12235 Note: the default value, @code{:noweb no}, was chosen to ensure that
12236 correct code is not broken in a language, such as Ruby, where
12237 @code{<<arg>>} is a syntactically valid construct.  If @code{<<arg>>} is not
12238 syntactically valid in languages that you use, then please consider setting
12239 the default value.
12241 @node Key bindings and useful functions, Batch execution, Noweb reference syntax, Working With Source Code
12242 @section Key bindings and useful functions
12243 @cindex code block, key bindings
12245 Many common Org-mode key sequences are re-bound depending on
12246 the context.
12248 Within a code block, the following key bindings
12249 are active:
12251 @multitable @columnfractions 0.25 0.75
12252 @kindex C-c C-c
12253 @item @kbd{C-c C-c} @tab org-babel-execute-src-block
12254 @kindex C-c C-o
12255 @item @kbd{C-c C-o} @tab org-babel-open-src-block-result
12256 @kindex C-up
12257 @item @kbd{C-@key{up}}    @tab org-babel-load-in-session
12258 @kindex M-down
12259 @item @kbd{M-@key{down}}  @tab org-babel-pop-to-session
12260 @end multitable
12262 In an Org-mode buffer, the following key bindings are active:
12264 @multitable @columnfractions 0.45 0.55
12265 @kindex C-c C-v a
12266 @kindex C-c C-v C-a
12267 @item @kbd{C-c C-v a} @ @ @r{or} @ @ @kbd{C-c C-v C-a} @tab org-babel-sha1-hash
12268 @kindex C-c C-v b
12269 @kindex C-c C-v C-b
12270 @item @kbd{C-c C-v b} @ @ @r{or} @ @ @kbd{C-c C-v C-b} @tab org-babel-execute-buffer
12271 @kindex C-c C-v f
12272 @kindex C-c C-v C-f
12273 @item @kbd{C-c C-v f} @ @ @r{or} @ @ @kbd{C-c C-v C-f} @tab org-babel-tangle-file
12274 @kindex C-c C-v g
12275 @item @kbd{C-c C-v g} @tab org-babel-goto-named-source-block
12276 @kindex C-c C-v h
12277 @item @kbd{C-c C-v h} @tab org-babel-describe-bindings
12278 @kindex C-c C-v l
12279 @kindex C-c C-v C-l
12280 @item @kbd{C-c C-v l} @ @ @r{or} @ @ @kbd{C-c C-v C-l} @tab org-babel-lob-ingest
12281 @kindex C-c C-v p
12282 @kindex C-c C-v C-p
12283 @item @kbd{C-c C-v p} @ @ @r{or} @ @ @kbd{C-c C-v C-p} @tab org-babel-expand-src-block
12284 @kindex C-c C-v s
12285 @kindex C-c C-v C-s
12286 @item @kbd{C-c C-v s} @ @ @r{or} @ @ @kbd{C-c C-v C-s} @tab org-babel-execute-subtree
12287 @kindex C-c C-v t
12288 @kindex C-c C-v C-t
12289 @item @kbd{C-c C-v t} @ @ @r{or} @ @ @kbd{C-c C-v C-t} @tab org-babel-tangle
12290 @kindex C-c C-v z
12291 @kindex C-c C-v C-z
12292 @item @kbd{C-c C-v z} @ @ @r{or} @ @ @kbd{C-c C-v C-z} @tab org-babel-switch-to-session
12293 @end multitable
12295 @c When possible these keybindings were extended to work when the control key is
12296 @c kept pressed, resulting in the following additional keybindings.
12298 @c @multitable @columnfractions 0.25 0.75
12299 @c @item @kbd{C-c C-v C-a} @tab org-babel-sha1-hash
12300 @c @item @kbd{C-c C-v C-b} @tab org-babel-execute-buffer
12301 @c @item @kbd{C-c C-v C-f} @tab org-babel-tangle-file
12302 @c @item @kbd{C-c C-v C-l} @tab org-babel-lob-ingest
12303 @c @item @kbd{C-c C-v C-p} @tab org-babel-expand-src-block
12304 @c @item @kbd{C-c C-v C-s} @tab org-babel-execute-subtree
12305 @c @item @kbd{C-c C-v C-t} @tab org-babel-tangle
12306 @c @item @kbd{C-c C-v C-z} @tab org-babel-switch-to-session
12307 @c @end multitable
12309 @node Batch execution,  , Key bindings and useful functions, Working With Source Code
12310 @section Batch execution
12311 @cindex code block, batch execution
12312 @cindex source code, batch execution
12314 It is possible to call functions from the command line.  This shell
12315 script calls @code{org-babel-tangle} on every one of its arguments.
12317 Be sure to adjust the paths to fit your system.
12319 @example
12320 #!/bin/sh
12321 # -*- mode: shell-script -*-
12323 # tangle a file with org-mode
12325 DIR=`pwd`
12326 FILES=""
12328 # wrap each argument in the code required to call tangle on it
12329 for i in $@@; do
12330 FILES="$FILES \"$i\""
12331 done
12333 emacsclient \
12334 --eval "(progn
12335 (add-to-list 'load-path (expand-file-name \"~/src/org/lisp/\"))
12336 (add-to-list 'load-path (expand-file-name \"~/src/org/contrib/lisp/\"))
12337 (require 'org)(require 'org-exp)(require 'ob)(require 'ob-tangle)
12338 (mapc (lambda (file)
12339        (find-file (expand-file-name file \"$DIR\"))
12340        (org-babel-tangle)
12341        (kill-buffer)) '($FILES)))"
12342 @end example
12344 @node Miscellaneous, Hacking, Working With Source Code, Top
12345 @chapter Miscellaneous
12347 @menu
12348 * Completion::                  M-TAB knows what you need
12349 * Easy Templates::              Quick insertion of structural elements
12350 * Speed keys::                  Electric commands at the beginning of a headline
12351 * Code evaluation security::    Org mode files evaluate inline code
12352 * Customization::               Adapting Org to your taste
12353 * In-buffer settings::          Overview of the #+KEYWORDS
12354 * The very busy C-c C-c key::   When in doubt, press C-c C-c
12355 * Clean view::                  Getting rid of leading stars in the outline
12356 * TTY keys::                    Using Org on a tty
12357 * Interaction::                 Other Emacs packages
12358 @end menu
12361 @node Completion, Easy Templates, Miscellaneous, Miscellaneous
12362 @section Completion
12363 @cindex completion, of @TeX{} symbols
12364 @cindex completion, of TODO keywords
12365 @cindex completion, of dictionary words
12366 @cindex completion, of option keywords
12367 @cindex completion, of tags
12368 @cindex completion, of property keys
12369 @cindex completion, of link abbreviations
12370 @cindex @TeX{} symbol completion
12371 @cindex TODO keywords completion
12372 @cindex dictionary word completion
12373 @cindex option keyword completion
12374 @cindex tag completion
12375 @cindex link abbreviations, completion of
12377 Emacs would not be Emacs without completion, and Org-mode uses it whenever it
12378 makes sense.  If you prefer an @i{iswitchb}- or @i{ido}-like interface for
12379 some of the completion prompts, you can specify your preference by setting at
12380 most one of the variables @code{org-completion-use-iswitchb}
12381 @code{org-completion-use-ido}.
12383 Org supports in-buffer completion.  This type of completion does
12384 not make use of the minibuffer.  You simply type a few letters into
12385 the buffer and use the key to complete text right there.
12387 @table @kbd
12388 @kindex M-@key{TAB}
12389 @item M-@key{TAB}
12390 Complete word at point
12391 @itemize @bullet
12392 @item
12393 At the beginning of a headline, complete TODO keywords.
12394 @item
12395 After @samp{\}, complete @TeX{} symbols supported by the exporter.
12396 @item
12397 After @samp{*}, complete headlines in the current buffer so that they
12398 can be used in search links like @samp{[[*find this headline]]}.
12399 @item
12400 After @samp{:} in a headline, complete tags.  The list of tags is taken
12401 from the variable @code{org-tag-alist} (possibly set through the
12402 @samp{#+TAGS} in-buffer option, @pxref{Setting tags}), or it is created
12403 dynamically from all tags used in the current buffer.
12404 @item
12405 After @samp{:} and not in a headline, complete property keys.  The list
12406 of keys is constructed dynamically from all keys used in the current
12407 buffer.
12408 @item
12409 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
12410 @item
12411 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
12412 @samp{OPTIONS} which set file-specific options for Org-mode.  When the
12413 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
12414 will insert example settings for this keyword.
12415 @item
12416 In the line after @samp{#+STARTUP: }, complete startup keywords,
12417 i.e. valid keys for this line.
12418 @item
12419 Elsewhere, complete dictionary words using Ispell.
12420 @end itemize
12421 @end table
12423 @node Easy Templates, Speed keys, Completion, Miscellaneous
12424 @section Easy Templates
12425 @cindex template insertion
12426 @cindex insertion, of templates
12428 Org-mode supports insertion of empty structural elements (like
12429 @code{#+BEGIN_SRC} and @code{#+END_SRC} pairs) with just a few key
12430 strokes.  This is achieved through a native template expansion mechanism.
12431 Note that Emacs has several other template mechanisms which could be used in
12432 a similar way, for example @file{yasnippet}.
12434 To insert a structural element, type a @samp{<}, followed by a template
12435 selector and @kbd{@key{TAB}}.  Completion takes effect only when the above
12436 keystrokes are typed on a line by itself.
12438 The following template selectors are currently supported.
12440 @multitable @columnfractions 0.1 0.9
12441 @item @kbd{s} @tab @code{#+begin_src     ... #+end_src}
12442 @item @kbd{e} @tab @code{#+begin_example ... #+end_example}
12443 @item @kbd{q} @tab @code{#+begin_quote   ... #+end_quote}
12444 @item @kbd{v} @tab @code{#+begin_verse   ... #+end_verse}
12445 @item @kbd{c} @tab @code{#+begin_center  ... #+end_center}
12446 @item @kbd{l} @tab @code{#+begin_latex   ... #+end_latex}
12447 @item @kbd{L} @tab @code{#+latex:}
12448 @item @kbd{h} @tab @code{#+begin_html    ... #+end_html}
12449 @item @kbd{H} @tab @code{#+html:}
12450 @item @kbd{a} @tab @code{#+begin_ascii   ... #+end_ascii}
12451 @item @kbd{A} @tab @code{#+ascii:}
12452 @item @kbd{i} @tab @code{#+include:} line
12453 @end multitable
12455 For example, on an empty line, typing "<e" and then pressing TAB, will expand
12456 into a complete EXAMPLE template.
12458 You can install additional templates by customizing the variable
12459 @code{org-structure-template-alist}. Refer docstring of the variable for
12460 additional details.
12462 @node Speed keys, Code evaluation security, Easy Templates, Miscellaneous
12463 @section Speed keys
12464 @cindex speed keys
12465 @vindex org-use-speed-commands
12466 @vindex org-speed-commands-user
12468 Single keys can be made to execute commands when the cursor is at the
12469 beginning of a headline, i.e. before the first star.  Configure the variable
12470 @code{org-use-speed-commands} to activate this feature.  There is a
12471 pre-defined list of commands, and you can add more such commands using the
12472 variable @code{org-speed-commands-user}.  Speed keys do not only speed up
12473 navigation and other commands, but they also provide an alternative way to
12474 execute commands bound to keys that are not or not easily available on a tty,
12475 or on a small mobile device with a limited keyboard.
12477 To see which commands are available, activate the feature and press @kbd{?}
12478 with the cursor at the beginning of a headline.
12480 @node Code evaluation security, Customization, Speed keys, Miscellaneous
12481 @section Code evaluation and security issues
12483 Org provides tools to work with the code snippets, including evaluating them.
12485 Running code on your machine always comes with a security risk.  Badly
12486 written or malicious code can be executed on purpose or by accident.  Org has
12487 default settings which will only evaluate such code if you give explicit
12488 permission to do so, and as a casual user of these features you should leave
12489 these precautions intact.
12491 For people who regularly work with such code, the confirmation prompts can
12492 become annoying, and you might want to turn them off.  This can be done, but
12493 you must be aware of the risks that are involved.
12495 Code evaluation can happen under the following circumstances:
12497 @table @i
12498 @item Source code blocks
12499 Source code blocks can be evaluated during export, or when pressing @kbd{C-c
12500 C-c} in the block.  The most important thing to realize here is that Org mode
12501 files which contain code snippets are, in a certain sense, like executable
12502 files.  So you should accept them and load them into Emacs only from trusted
12503 sources - just like you would do with a program you install on your computer.
12505 Make sure you know what you are doing before customizing the variables
12506 which take off the default security brakes.
12508 @defopt org-confirm-babel-evaluate
12509 When set to t user is queried before code block evaluation
12510 @end defopt
12512 @item Following @code{shell} and @code{elisp} links
12513 Org has two link types that can directly evaluate code (@pxref{External
12514 links}).  These links can be problematic because the code to be evaluated is
12515 not visible.
12517 @defopt org-confirm-shell-link-function
12518 Function to queries user about shell link execution.
12519 @end defopt
12520 @defopt org-confirm-elisp-link-function
12521 Functions to query user for Emacs Lisp link execution.
12522 @end defopt
12524 @item Formulas in tables
12525 Formulas in tables (@pxref{The spreadsheet}) are code that is evaluated
12526 either by the @i{calc} interpreter, or by the @i{Emacs Lisp} interpreter.
12527 @end table
12529 @node Customization, In-buffer settings, Code evaluation security, Miscellaneous
12530 @section Customization
12531 @cindex customization
12532 @cindex options, for customization
12533 @cindex variables, for customization
12535 There are more than 180 variables that can be used to customize
12536 Org.  For the sake of compactness of the manual, I am not
12537 describing the variables here.  A structured overview of customization
12538 variables is available with @kbd{M-x org-customize}.  Or select
12539 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
12540 settings can also be activated on a per-file basis, by putting special
12541 lines into the buffer (@pxref{In-buffer settings}).
12543 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
12544 @section Summary of in-buffer settings
12545 @cindex in-buffer settings
12546 @cindex special keywords
12548 Org-mode uses special lines in the buffer to define settings on a
12549 per-file basis.  These lines start with a @samp{#+} followed by a
12550 keyword, a colon, and then individual words defining a setting.  Several
12551 setting words can be in the same line, but you can also have multiple
12552 lines for the keyword.  While these settings are described throughout
12553 the manual, here is a summary.  After changing any of those lines in the
12554 buffer, press @kbd{C-c C-c} with the cursor still in the line to
12555 activate the changes immediately.  Otherwise they become effective only
12556 when the file is visited again in a new Emacs session.
12558 @vindex org-archive-location
12559 @table @kbd
12560 @item #+ARCHIVE: %s_done::
12561 This line sets the archive location for the agenda file.  It applies for
12562 all subsequent lines until the next @samp{#+ARCHIVE} line, or the end
12563 of the file.  The first such line also applies to any entries before it.
12564 The corresponding variable is @code{org-archive-location}.
12565 @item #+CATEGORY:
12566 This line sets the category for the agenda file.  The category applies
12567 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
12568 end of the file.  The first such line also applies to any entries before it.
12569 @item #+COLUMNS: %25ITEM .....
12570 @cindex property, COLUMNS
12571 Set the default format for columns view.  This format applies when
12572 columns view is invoked in locations where no @code{COLUMNS} property
12573 applies.
12574 @item #+CONSTANTS: name1=value1 ...
12575 @vindex org-table-formula-constants
12576 @vindex org-table-formula
12577 Set file-local values for constants to be used in table formulas.  This
12578 line set the local variable @code{org-table-formula-constants-local}.
12579 The global version of this variable is
12580 @code{org-table-formula-constants}.
12581 @item #+FILETAGS: :tag1:tag2:tag3:
12582 Set tags that can be inherited by any entry in the file, including the
12583 top-level entries.
12584 @item #+DRAWERS: NAME1 .....
12585 @vindex org-drawers
12586 Set the file-local set of drawers.  The corresponding global variable is
12587 @code{org-drawers}.
12588 @item #+LINK:  linkword replace
12589 @vindex org-link-abbrev-alist
12590 These lines (several are allowed) specify link abbreviations.
12591 @xref{Link abbreviations}.  The corresponding variable is
12592 @code{org-link-abbrev-alist}.
12593 @item #+PRIORITIES: highest lowest default
12594 @vindex org-highest-priority
12595 @vindex org-lowest-priority
12596 @vindex org-default-priority
12597 This line sets the limits and the default for the priorities.  All three
12598 must be either letters A-Z or numbers 0-9.  The highest priority must
12599 have a lower ASCII number that the lowest priority.
12600 @item #+PROPERTY: Property_Name Value
12601 This line sets a default inheritance value for entries in the current
12602 buffer, most useful for specifying the allowed values of a property.
12603 @cindex #+SETUPFILE
12604 @item #+SETUPFILE: file
12605 This line defines a file that holds more in-buffer setup.  Normally this is
12606 entirely ignored.  Only when the buffer is parsed for option-setting lines
12607 (i.e. when starting Org-mode for a file, when pressing @kbd{C-c C-c} in a
12608 settings line, or when exporting), then the contents of this file are parsed
12609 as if they had been included in the buffer.  In particular, the file can be
12610 any other Org-mode file with internal setup.  You can visit the file the
12611 cursor is in the line with @kbd{C-c '}.
12612 @item #+STARTUP:
12613 @cindex #+STARTUP:
12614 This line sets options to be used at startup of Org-mode, when an
12615 Org file is being visited.
12617 The first set of options deals with the initial visibility of the outline
12618 tree.  The corresponding variable for global default settings is
12619 @code{org-startup-folded}, with a default value @code{t}, which means
12620 @code{overview}.
12621 @vindex org-startup-folded
12622 @cindex @code{overview}, STARTUP keyword
12623 @cindex @code{content}, STARTUP keyword
12624 @cindex @code{showall}, STARTUP keyword
12625 @cindex @code{showeverything}, STARTUP keyword
12626 @example
12627 overview         @r{top-level headlines only}
12628 content          @r{all headlines}
12629 showall          @r{no folding of any entries}
12630 showeverything   @r{show even drawer contents}
12631 @end example
12633 @vindex org-startup-indented
12634 @cindex @code{indent}, STARTUP keyword
12635 @cindex @code{noindent}, STARTUP keyword
12636 Dynamic virtual indentation is controlled by the variable
12637 @code{org-startup-indented}@footnote{Emacs 23 and Org-mode 6.29 are required}
12638 @example
12639 indent     @r{start with @code{org-indent-mode} turned on}
12640 noindent   @r{start with @code{org-indent-mode} turned off}
12641 @end example
12643 @vindex org-startup-align-all-tables
12644 Then there are options for aligning tables upon visiting a file.  This
12645 is useful in files containing narrowed table columns.  The corresponding
12646 variable is @code{org-startup-align-all-tables}, with a default value
12647 @code{nil}.
12648 @cindex @code{align}, STARTUP keyword
12649 @cindex @code{noalign}, STARTUP keyword
12650 @example
12651 align      @r{align all tables}
12652 noalign    @r{don't align tables on startup}
12653 @end example
12654 @vindex org-log-done
12655 @vindex org-log-note-clock-out
12656 @vindex org-log-repeat
12657 Logging the closing and reopening of TODO items and clock intervals can be
12658 configured using these options (see variables @code{org-log-done},
12659 @code{org-log-note-clock-out} and @code{org-log-repeat})
12660 @cindex @code{logdone}, STARTUP keyword
12661 @cindex @code{lognotedone}, STARTUP keyword
12662 @cindex @code{nologdone}, STARTUP keyword
12663 @cindex @code{lognoteclock-out}, STARTUP keyword
12664 @cindex @code{nolognoteclock-out}, STARTUP keyword
12665 @cindex @code{logrepeat}, STARTUP keyword
12666 @cindex @code{lognoterepeat}, STARTUP keyword
12667 @cindex @code{nologrepeat}, STARTUP keyword
12668 @cindex @code{logreschedule}, STARTUP keyword
12669 @cindex @code{lognotereschedule}, STARTUP keyword
12670 @cindex @code{nologreschedule}, STARTUP keyword
12671 @cindex @code{logredeadline}, STARTUP keyword
12672 @cindex @code{lognoteredeadline}, STARTUP keyword
12673 @cindex @code{nologredeadline}, STARTUP keyword
12674 @cindex @code{logrefile}, STARTUP keyword
12675 @cindex @code{lognoterefile}, STARTUP keyword
12676 @cindex @code{nologrefile}, STARTUP keyword
12677 @example
12678 logdone            @r{record a timestamp when an item is marked DONE}
12679 lognotedone        @r{record timestamp and a note when DONE}
12680 nologdone          @r{don't record when items are marked DONE}
12681 logrepeat          @r{record a time when reinstating a repeating item}
12682 lognoterepeat      @r{record a note when reinstating a repeating item}
12683 nologrepeat        @r{do not record when reinstating repeating item}
12684 lognoteclock-out   @r{record a note when clocking out}
12685 nolognoteclock-out @r{don't record a note when clocking out}
12686 logreschedule      @r{record a timestamp when scheduling time changes}
12687 lognotereschedule  @r{record a note when scheduling time changes}
12688 nologreschedule    @r{do not record when a scheduling date changes}
12689 logredeadline      @r{record a timestamp when deadline changes}
12690 lognoteredeadline  @r{record a note when deadline changes}
12691 nologredeadline    @r{do not record when a deadline date changes}
12692 logrefile          @r{record a timestamp when refiling}
12693 lognoterefile      @r{record a note when refiling}
12694 nologrefile        @r{do not record when refiling}
12695 @end example
12696 @vindex org-hide-leading-stars
12697 @vindex org-odd-levels-only
12698 Here are the options for hiding leading stars in outline headings, and for
12699 indenting outlines.  The corresponding variables are
12700 @code{org-hide-leading-stars} and @code{org-odd-levels-only}, both with a
12701 default setting @code{nil} (meaning @code{showstars} and @code{oddeven}).
12702 @cindex @code{hidestars}, STARTUP keyword
12703 @cindex @code{showstars}, STARTUP keyword
12704 @cindex @code{odd}, STARTUP keyword
12705 @cindex @code{even}, STARTUP keyword
12706 @example
12707 hidestars  @r{make all but one of the stars starting a headline invisible.}
12708 showstars  @r{show all stars starting a headline}
12709 indent     @r{virtual indentation according to outline level}
12710 noindent   @r{no virtual indentation according to outline level}
12711 odd        @r{allow only odd outline levels (1,3,...)}
12712 oddeven    @r{allow all outline levels}
12713 @end example
12714 @vindex org-put-time-stamp-overlays
12715 @vindex org-time-stamp-overlay-formats
12716 To turn on custom format overlays over timestamps (variables
12717 @code{org-put-time-stamp-overlays} and
12718 @code{org-time-stamp-overlay-formats}), use
12719 @cindex @code{customtime}, STARTUP keyword
12720 @example
12721 customtime @r{overlay custom time format}
12722 @end example
12723 @vindex constants-unit-system
12724 The following options influence the table spreadsheet (variable
12725 @code{constants-unit-system}).
12726 @cindex @code{constcgs}, STARTUP keyword
12727 @cindex @code{constSI}, STARTUP keyword
12728 @example
12729 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
12730 constSI    @r{@file{constants.el} should use the SI unit system}
12731 @end example
12732 @vindex org-footnote-define-inline
12733 @vindex org-footnote-auto-label
12734 @vindex org-footnote-auto-adjust
12735 To influence footnote settings, use the following keywords.  The
12736 corresponding variables are @code{org-footnote-define-inline},
12737 @code{org-footnote-auto-label}, and @code{org-footnote-auto-adjust}.
12738 @cindex @code{fninline}, STARTUP keyword
12739 @cindex @code{nofninline}, STARTUP keyword
12740 @cindex @code{fnlocal}, STARTUP keyword
12741 @cindex @code{fnprompt}, STARTUP keyword
12742 @cindex @code{fnauto}, STARTUP keyword
12743 @cindex @code{fnconfirm}, STARTUP keyword
12744 @cindex @code{fnplain}, STARTUP keyword
12745 @cindex @code{fnadjust}, STARTUP keyword
12746 @cindex @code{nofnadjust}, STARTUP keyword
12747 @example
12748 fninline    @r{define footnotes inline}
12749 fnnoinline  @r{define footnotes in separate section}
12750 fnlocal     @r{define footnotes near first reference, but not inline}
12751 fnprompt    @r{prompt for footnote labels}
12752 fnauto      @r{create [fn:1]-like labels automatically (default)}
12753 fnconfirm   @r{offer automatic label for editing or confirmation}
12754 fnplain     @r{create [1]-like labels automatically}
12755 fnadjust    @r{automatically renumber and sort footnotes}
12756 nofnadjust  @r{do not renumber and sort automatically}
12757 @end example
12758 @cindex org-hide-block-startup
12759 To hide blocks on startup, use these keywords. The corresponding variable is
12760 @code{org-hide-block-startup}.
12761 @cindex @code{hideblocks}, STARTUP keyword
12762 @cindex @code{nohideblocks}, STARTUP keyword
12763 @example
12764 hideblocks   @r{Hide all begin/end blocks on startup}
12765 nohideblocks @r{Do not hide blocks on startup}
12766 @end example
12767 @cindex org-pretty-entities
12768 The the display of entities as UTF8 characters is governed by the variable
12769 @code{org-pretty-entities} and the keywords
12770 @cindex @code{entitiespretty}, STARTUP keyword
12771 @cindex @code{entitiesplain}, STARTUP keyword
12772 @example
12773 entitiespretty  @r{Show entities as UTF8 characters where possible}
12774 entitiesplain   @r{Leave entities plain}
12775 @end example
12776 @item #+TAGS:  TAG1(c1) TAG2(c2)
12777 @vindex org-tag-alist
12778 These lines (several such lines are allowed) specify the valid tags in
12779 this file, and (potentially) the corresponding @emph{fast tag selection}
12780 keys.  The corresponding variable is @code{org-tag-alist}.
12781 @item #+TBLFM:
12782 This line contains the formulas for the table directly above the line.
12783 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+DATE:,
12784 @itemx #+OPTIONS:, #+BIND:, #+XSLT:,
12785 @itemx #+DESCRIPTION:, #+KEYWORDS:,
12786 @itemx #+LATEX_HEADER:, #+STYLE:, #+LINK_UP:, #+LINK_HOME:,
12787 @itemx #+EXPORT_SELECT_TAGS:, #+EXPORT_EXCLUDE_TAGS:
12788 These lines provide settings for exporting files.  For more details see
12789 @ref{Export options}.
12790 @item #+TODO:    #+SEQ_TODO:   #+TYP_TODO:
12791 @vindex org-todo-keywords
12792 These lines set the TODO keywords and their interpretation in the
12793 current file.  The corresponding variable is @code{org-todo-keywords}.
12794 @end table
12796 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
12797 @section The very busy C-c C-c key
12798 @kindex C-c C-c
12799 @cindex C-c C-c, overview
12801 The key @kbd{C-c C-c} has many purposes in Org, which are all
12802 mentioned scattered throughout this manual.  One specific function of
12803 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
12804 other circumstances it means something like @emph{``Hey Org, look
12805 here and update according to what you see here''}.  Here is a summary of
12806 what this means in different contexts.
12808 @itemize @minus
12809 @item
12810 If there are highlights in the buffer from the creation of a sparse
12811 tree, or from clock display, remove these highlights.
12812 @item
12813 If the cursor is in one of the special @code{#+KEYWORD} lines, this
12814 triggers scanning the buffer for these lines and updating the
12815 information.
12816 @item
12817 If the cursor is inside a table, realign the table.  This command
12818 works even if the automatic table editor has been turned off.
12819 @item
12820 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
12821 the entire table.
12822 @item
12823 If the current buffer is a capture buffer, close the note and file it.
12824 With a prefix argument, file it, without further interaction, to the
12825 default location.
12826 @item
12827 If the cursor is on a @code{<<<target>>>}, update radio targets and
12828 corresponding links in this buffer.
12829 @item
12830 If the cursor is in a property line or at the start or end of a property
12831 drawer, offer property commands.
12832 @item
12833 If the cursor is at a footnote reference, go to the corresponding
12834 definition, and vice versa.
12835 @item
12836 If the cursor is on a statistics cookie, update it.
12837 @item
12838 If the cursor is in a plain list item with a checkbox, toggle the status
12839 of the checkbox.
12840 @item
12841 If the cursor is on a numbered item in a plain list, renumber the
12842 ordered list.
12843 @item
12844 If the cursor is on the @code{#+BEGIN} line of a dynamic block, the
12845 block is updated.
12846 @end itemize
12848 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
12849 @section A cleaner outline view
12850 @cindex hiding leading stars
12851 @cindex dynamic indentation
12852 @cindex odd-levels-only outlines
12853 @cindex clean outline view
12855 Some people find it noisy and distracting that the Org headlines start with a
12856 potentially large number of stars, and that text below the headlines is not
12857 indented.  While this is no problem when writing a @emph{book-like} document
12858 where the outline headings are really section headings, in a more
12859 @emph{list-oriented} outline, indented structure is a lot cleaner:
12861 @example
12862 @group
12863 * Top level headline             |    * Top level headline
12864 ** Second level                  |      * Second level
12865 *** 3rd level                    |        * 3rd level
12866 some text                        |          some text
12867 *** 3rd level                    |        * 3rd level
12868 more text                        |          more text
12869 * Another top level headline     |    * Another top level headline
12870 @end group
12871 @end example
12873 @noindent
12875 If you are using at least Emacs 23.2@footnote{Emacs 23.1 can actually crash
12876 with @code{org-indent-mode}} and version 6.29 of Org, this kind of view can
12877 be achieved dynamically at display time using @code{org-indent-mode}.  In
12878 this minor mode, all lines are prefixed for display with the necessary amount
12879 of space@footnote{@code{org-indent-mode} also sets the @code{wrap-prefix}
12880 property, such that @code{visual-line-mode} (or purely setting
12881 @code{word-wrap}) wraps long lines (including headlines) correctly indented.
12882 }.  Also headlines are prefixed with additional stars, so that the amount of
12883 indentation shifts by two@footnote{See the variable
12884 @code{org-indent-indentation-per-level}.}  spaces per level.  All headline
12885 stars but the last one are made invisible using the @code{org-hide}
12886 face@footnote{Turning on @code{org-indent-mode} sets
12887 @code{org-hide-leading-stars} to @code{t} and @code{org-adapt-indentation} to
12888 @code{nil}.} - see below under @samp{2.} for more information on how this
12889 works.  You can turn on @code{org-indent-mode} for all files by customizing
12890 the variable @code{org-startup-indented}, or you can turn it on for
12891 individual files using
12893 @example
12894 #+STARTUP: indent
12895 @end example
12897 If you want a similar effect in earlier version of Emacs and/or Org, or if
12898 you want the indentation to be hard space characters so that the plain text
12899 file looks as similar as possible to the Emacs display, Org supports you in
12900 the following way:
12902 @enumerate
12903 @item
12904 @emph{Indentation of text below headlines}@*
12905 You may indent text below each headline to make the left boundary line up
12906 with the headline, like
12908 @example
12909 *** 3rd level
12910     more text, now indented
12911 @end example
12913 @vindex org-adapt-indentation
12914 Org supports this with paragraph filling, line wrapping, and structure
12915 editing@footnote{See also the variable @code{org-adapt-indentation}.},
12916 preserving or adapting the indentation as appropriate.
12918 @item
12919 @vindex org-hide-leading-stars
12920 @emph{Hiding leading stars}@* You can modify the display in such a way that
12921 all leading stars become invisible.  To do this in a global way, configure
12922 the variable @code{org-hide-leading-stars} or change this on a per-file basis
12923 with
12925 @example
12926 #+STARTUP: hidestars
12927 #+STARTUP: showstars
12928 @end example
12930 With hidden stars, the tree becomes:
12932 @example
12933 @group
12934 * Top level headline
12935  * Second level
12936   * 3rd level
12937   ...
12938 @end group
12939 @end example
12941 @noindent
12942 @vindex org-hide @r{(face)}
12943 The leading stars are not truly replaced by whitespace, they are only
12944 fontified with the face @code{org-hide} that uses the background color as
12945 font color.  If you are not using either white or black background, you may
12946 have to customize this face to get the wanted effect.  Another possibility is
12947 to set this font such that the extra stars are @i{almost} invisible, for
12948 example using the color @code{grey90} on a white background.
12950 @item
12951 @vindex org-odd-levels-only
12952 Things become cleaner still if you skip all the even levels and use only odd
12953 levels 1, 3, 5..., effectively adding two stars to go from one outline level
12954 to the next@footnote{When you need to specify a level for a property search
12955 or refile targets, @samp{LEVEL=2} will correspond to 3 stars, etc@.}.  In this
12956 way we get the outline view shown at the beginning of this section.  In order
12957 to make the structure editing and export commands handle this convention
12958 correctly, configure the variable @code{org-odd-levels-only}, or set this on
12959 a per-file basis with one of the following lines:
12961 @example
12962 #+STARTUP: odd
12963 #+STARTUP: oddeven
12964 @end example
12966 You can convert an Org file from single-star-per-level to the
12967 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
12968 RET} in that file.  The reverse operation is @kbd{M-x
12969 org-convert-to-oddeven-levels}.
12970 @end enumerate
12972 @node TTY keys, Interaction, Clean view, Miscellaneous
12973 @section Using Org on a tty
12974 @cindex tty key bindings
12976 Because Org contains a large number of commands, by default many of
12977 Org's core commands are bound to keys that are generally not
12978 accessible on a tty, such as the cursor keys (@key{left}, @key{right},
12979 @key{up}, @key{down}), @key{TAB} and @key{RET}, in particular when used
12980 together with modifiers like @key{Meta} and/or @key{Shift}.  To access
12981 these commands on a tty when special keys are unavailable, the following
12982 alternative bindings can be used.  The tty bindings below will likely be
12983 more cumbersome; you may find for some of the bindings below that a
12984 customized workaround suits you better.  For example, changing a timestamp
12985 is really only fun with @kbd{S-@key{cursor}} keys, whereas on a
12986 tty you would rather use @kbd{C-c .} to re-insert the timestamp.
12988 @multitable @columnfractions 0.15 0.2 0.1 0.2
12989 @item @b{Default} @tab @b{Alternative 1} @tab @b{Speed key} @tab @b{Alternative 2}
12990 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab @kbd{C} @tab
12991 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{l} @tab @kbd{@key{Esc} @key{left}}
12992 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab @kbd{L} @tab
12993 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{r} @tab @kbd{@key{Esc} @key{right}}
12994 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab @kbd{R} @tab
12995 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{ } @tab @kbd{@key{Esc} @key{up}}
12996 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab @kbd{U} @tab
12997 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{ } @tab @kbd{@key{Esc} @key{down}}
12998 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab @kbd{D} @tab
12999 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab @kbd{ } @tab
13000 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{ } @tab @kbd{@key{Esc} @key{RET}}
13001 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab @kbd{ } @tab
13002 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab @kbd{ } @tab
13003 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab @kbd{ } @tab
13004 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab @kbd{ } @tab
13005 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab @kbd{ } @tab
13006 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab @kbd{ } @tab
13007 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab @kbd{ } @tab
13008 @end multitable
13011 @node Interaction,  , TTY keys, Miscellaneous
13012 @section Interaction with other packages
13013 @cindex packages, interaction with other
13014 Org lives in the world of GNU Emacs and interacts in various ways
13015 with other code out there.
13017 @menu
13018 * Cooperation::                 Packages Org cooperates with
13019 * Conflicts::                   Packages that lead to conflicts
13020 @end menu
13022 @node Cooperation, Conflicts, Interaction, Interaction
13023 @subsection Packages that Org cooperates with
13025 @table @asis
13026 @cindex @file{calc.el}
13027 @cindex Gillespie, Dave
13028 @item @file{calc.el} by Dave Gillespie
13029 Org uses the Calc package for implementing spreadsheet
13030 functionality in its tables (@pxref{The spreadsheet}).  Org
13031 checks for the availability of Calc by looking for the function
13032 @code{calc-eval} which will have been autoloaded during setup if Calc has
13033 been installed properly.  As of Emacs 22, Calc is part of the Emacs
13034 distribution.  Another possibility for interaction between the two
13035 packages is using Calc for embedded calculations. @xref{Embedded Mode,
13036 , Embedded Mode, Calc, GNU Emacs Calc Manual}.
13037 @item @file{constants.el} by Carsten Dominik
13038 @cindex @file{constants.el}
13039 @cindex Dominik, Carsten
13040 @vindex org-table-formula-constants
13041 In a table formula (@pxref{The spreadsheet}), it is possible to use
13042 names for natural constants or units.  Instead of defining your own
13043 constants in the variable @code{org-table-formula-constants}, install
13044 the @file{constants} package which defines a large number of constants
13045 and units, and lets you use unit prefixes like @samp{M} for
13046 @samp{Mega}, etc@.  You will need version 2.0 of this package, available
13047 at @url{http://www.astro.uva.nl/~dominik/Tools}. Org checks for
13048 the function @code{constants-get}, which has to be autoloaded in your
13049 setup.  See the installation instructions in the file
13050 @file{constants.el}.
13051 @item @file{cdlatex.el} by Carsten Dominik
13052 @cindex @file{cdlatex.el}
13053 @cindex Dominik, Carsten
13054 Org-mode can make use of the CDLa@TeX{} package to efficiently enter
13055 La@TeX{} fragments into Org files.  See @ref{CDLaTeX mode}.
13056 @item @file{imenu.el} by Ake Stenhoff and Lars Lindberg
13057 @cindex @file{imenu.el}
13058 Imenu allows menu access to an index of items in a file.  Org-mode
13059 supports Imenu---all you need to do to get the index is the following:
13060 @lisp
13061 (add-hook 'org-mode-hook
13062           (lambda () (imenu-add-to-menubar "Imenu")))
13063 @end lisp
13064 @vindex org-imenu-depth
13065 By default the index is two levels deep---you can modify the depth using
13066 the option @code{org-imenu-depth}.
13067 @item @file{remember.el} by John Wiegley
13068 @cindex @file{remember.el}
13069 @cindex Wiegley, John
13070 Org used to use this package for capture, but no longer does.
13071 @item @file{speedbar.el} by Eric M. Ludlam
13072 @cindex @file{speedbar.el}
13073 @cindex Ludlam, Eric M.
13074 Speedbar is a package that creates a special frame displaying files and
13075 index items in files.  Org-mode supports Speedbar and allows you to
13076 drill into Org files directly from the Speedbar.  It also allows you to
13077 restrict the scope of agenda commands to a file or a subtree by using
13078 the command @kbd{<} in the Speedbar frame.
13079 @cindex @file{table.el}
13080 @item @file{table.el} by Takaaki Ota
13081 @kindex C-c C-c
13082 @cindex table editor, @file{table.el}
13083 @cindex @file{table.el}
13084 @cindex Ota, Takaaki
13086 Complex ASCII tables with automatic line wrapping, column- and row-spanning,
13087 and alignment can be created using the Emacs table package by Takaaki Ota
13088 (@uref{http://sourceforge.net/projects/table}, and also part of Emacs 22).
13089 Org-mode will recognize these tables and export them properly.  Because of
13090 interference with other Org-mode functionality, you unfortunately cannot edit
13091 these tables directly in the buffer.  Instead, you need to use the command
13092 @kbd{C-c '} to edit them, similar to source code snippets.
13094 @table @kbd
13095 @kindex C-c '
13096 @item C-c '
13097 Edit a @file{table.el} table.  Works when the cursor is in a table.el table.
13099 @kindex C-c ~
13100 @item C-c ~
13101 Insert a @file{table.el} table.  If there is already a table at point, this
13102 command converts it between the @file{table.el} format and the Org-mode
13103 format.  See the documentation string of the command
13104 @code{org-convert-table} for the restrictions under which this is
13105 possible.
13106 @end table
13107 @file{table.el} is part of Emacs since Emacs 22.
13108 @item @file{footnote.el} by Steven L. Baur
13109 @cindex @file{footnote.el}
13110 @cindex Baur, Steven L.
13111 Org-mode recognizes numerical footnotes as provided by this package.
13112 However, Org-mode also has its own footnote support (@pxref{Footnotes}),
13113 which makes using @file{footnote.el} unnecessary.
13114 @end table
13116 @node Conflicts,  , Cooperation, Interaction
13117 @subsection Packages that lead to conflicts with Org-mode
13119 @table @asis
13121 @cindex @code{shift-selection-mode}
13122 @vindex org-support-shift-select
13123 In Emacs 23, @code{shift-selection-mode} is on by default, meaning that
13124 cursor motions combined with the shift key should start or enlarge regions.
13125 This conflicts with the use of @kbd{S-@key{cursor}} commands in Org to change
13126 timestamps, TODO keywords, priorities, and item bullet types if the cursor is
13127 at such a location.  By default, @kbd{S-@key{cursor}} commands outside
13128 special contexts don't do anything, but you can customize the variable
13129 @code{org-support-shift-select}.  Org-mode then tries to accommodate shift
13130 selection by (i) using it outside of the special contexts where special
13131 commands apply, and by (ii) extending an existing active region even if the
13132 cursor moves across a special context.
13134 @item @file{CUA.el} by Kim. F. Storm
13135 @cindex @file{CUA.el}
13136 @cindex Storm, Kim. F.
13137 @vindex org-replace-disputed-keys
13138 Key bindings in Org conflict with the @kbd{S-<cursor>} keys used by CUA mode
13139 (as well as @code{pc-select-mode} and @code{s-region-mode}) to select and extend the
13140 region.  In fact, Emacs 23 has this built-in in the form of
13141 @code{shift-selection-mode}, see previous paragraph.  If you are using Emacs
13142 23, you probably don't want to use another package for this purpose.  However,
13143 if you prefer to leave these keys to a different package while working in
13144 Org-mode, configure the variable @code{org-replace-disputed-keys}.  When set,
13145 Org will move the following key bindings in Org files, and in the agenda
13146 buffer (but not during date selection).
13148 @example
13149 S-UP      ->  M-p             S-DOWN     ->  M-n
13150 S-LEFT    ->  M--             S-RIGHT    ->  M-+
13151 C-S-LEFT  ->  M-S--           C-S-RIGHT  ->  M-S-+
13152 @end example
13154 @vindex org-disputed-keys
13155 Yes, these are unfortunately more difficult to remember.  If you want
13156 to have other replacement keys, look at the variable
13157 @code{org-disputed-keys}.
13159 @item @file{yasnippet.el}
13160 @cindex @file{yasnippet.el}
13161 The way Org-mode binds the TAB key (binding to @code{[tab]} instead of
13162 @code{"\t"}) overrules yasnippets' access to this key.  The following code
13163 fixed this problem:
13165 @lisp
13166 (add-hook 'org-mode-hook
13167           (lambda ()
13168             (org-set-local 'yas/trigger-key [tab])
13169             (define-key yas/keymap [tab] 'yas/next-field-group)))
13170 @end lisp
13172 @item @file{windmove.el} by Hovav Shacham
13173 @cindex @file{windmove.el}
13174 This package also uses the @kbd{S-<cursor>} keys, so everything written
13175 in the paragraph above about CUA mode also applies here.  If you want make
13176 the windmove function active in locations where Org-mode does not have
13177 special functionality on @kbd{S-@key{cursor}}, add this to your
13178 configuration:
13180 @lisp
13181 ;; Make windmove work in org-mode:
13182 (add-hook 'org-shiftup-final-hook 'windmove-up)
13183 (add-hook 'org-shiftleft-final-hook 'windmove-left)
13184 (add-hook 'org-shiftdown-final-hook 'windmove-down)
13185 (add-hook 'org-shiftright-final-hook 'windmove-right)
13186 @end lisp
13188 @item @file{viper.el} by Michael Kifer
13189 @cindex @file{viper.el}
13190 @kindex C-c /
13191 Viper uses @kbd{C-c /} and therefore makes this key not access the
13192 corresponding Org-mode command @code{org-sparse-tree}.  You need to find
13193 another key for this command, or override the key in
13194 @code{viper-vi-global-user-map} with
13196 @lisp
13197 (define-key viper-vi-global-user-map "C-c /" 'org-sparse-tree)
13198 @end lisp
13200 @end table
13203 @node Hacking, MobileOrg, Miscellaneous, Top
13204 @appendix Hacking
13205 @cindex hacking
13207 This appendix covers some aspects where users can extend the functionality of
13208 Org.
13210 @menu
13211 * Hooks::                       Who to reach into Org's internals
13212 * Add-on packages::             Available extensions
13213 * Adding hyperlink types::      New custom link types
13214 * Context-sensitive commands::  How to add functionality to such commands
13215 * Tables in arbitrary syntax::  Orgtbl for La@TeX{} and other programs
13216 * Dynamic blocks::              Automatically filled blocks
13217 * Special agenda views::        Customized views
13218 * Extracting agenda information::  Postprocessing of agenda information
13219 * Using the property API::      Writing programs that use entry properties
13220 * Using the mapping API::       Mapping over all or selected entries
13221 @end menu
13223 @node Hooks, Add-on packages, Hacking, Hacking
13224 @section Hooks
13225 @cindex hooks
13227 Org has a large number of hook variables that can be used to add
13228 functionality.  This appendix about hacking is going to illustrate the
13229 use of some of them.  A complete list of all hooks with documentation is
13230 maintained by the Worg project and can be found at
13231 @uref{http://orgmode.org/worg/org-configs/org-hooks.php}.
13233 @node Add-on packages, Adding hyperlink types, Hooks, Hacking
13234 @section Add-on packages
13235 @cindex add-on packages
13237 A large number of add-on packages have been written by various authors.
13238 These packages are not part of Emacs, but they are distributed as contributed
13239 packages with the separate release available at the Org-mode home page at
13240 @uref{http://orgmode.org}.  The list of contributed packages, along with
13241 documentation about each package, is maintained by the Worg project at
13242 @uref{http://orgmode.org/worg/org-contrib/}.
13246 @node Adding hyperlink types, Context-sensitive commands, Add-on packages, Hacking
13247 @section Adding hyperlink types
13248 @cindex hyperlinks, adding new types
13250 Org has a large number of hyperlink types built-in
13251 (@pxref{Hyperlinks}).  If you would like to add new link types, Org
13252 provides an interface for doing so.  Let's look at an example file,
13253 @file{org-man.el}, that will add support for creating links like
13254 @samp{[[man:printf][The printf manpage]]} to show Unix manual pages inside
13255 Emacs:
13257 @lisp
13258 ;;; org-man.el - Support for links to manpages in Org
13260 (require 'org)
13262 (org-add-link-type "man" 'org-man-open)
13263 (add-hook 'org-store-link-functions 'org-man-store-link)
13265 (defcustom org-man-command 'man
13266   "The Emacs command to be used to display a man page."
13267   :group 'org-link
13268   :type '(choice (const man) (const woman)))
13270 (defun org-man-open (path)
13271   "Visit the manpage on PATH.
13272 PATH should be a topic that can be thrown at the man command."
13273   (funcall org-man-command path))
13275 (defun org-man-store-link ()
13276   "Store a link to a manpage."
13277   (when (memq major-mode '(Man-mode woman-mode))
13278     ;; This is a man page, we do make this link
13279     (let* ((page (org-man-get-page-name))
13280            (link (concat "man:" page))
13281            (description (format "Manpage for %s" page)))
13282       (org-store-link-props
13283        :type "man"
13284        :link link
13285        :description description))))
13287 (defun org-man-get-page-name ()
13288   "Extract the page name from the buffer name."
13289   ;; This works for both `Man-mode' and `woman-mode'.
13290   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
13291       (match-string 1 (buffer-name))
13292     (error "Cannot create link to this man page")))
13294 (provide 'org-man)
13296 ;;; org-man.el ends here
13297 @end lisp
13299 @noindent
13300 You would activate this new link type in @file{.emacs} with
13302 @lisp
13303 (require 'org-man)
13304 @end lisp
13306 @noindent
13307 Let's go through the file and see what it does.
13308 @enumerate
13309 @item
13310 It does @code{(require 'org)} to make sure that @file{org.el} has been
13311 loaded.
13312 @item
13313 The next line calls @code{org-add-link-type} to define a new link type
13314 with prefix @samp{man}.  The call also contains the name of a function
13315 that will be called to follow such a link.
13316 @item
13317 @vindex org-store-link-functions
13318 The next line adds a function to @code{org-store-link-functions}, in
13319 order to allow the command @kbd{C-c l} to record a useful link in a
13320 buffer displaying a man page.
13321 @end enumerate
13323 The rest of the file defines the necessary variables and functions.
13324 First there is a customization variable that determines which Emacs
13325 command should be used to display man pages.  There are two options,
13326 @code{man} and @code{woman}.  Then the function to follow a link is
13327 defined.  It gets the link path as an argument---in this case the link
13328 path is just a topic for the manual command.  The function calls the
13329 value of @code{org-man-command} to display the man page.
13331 Finally the function @code{org-man-store-link} is defined.  When you try
13332 to store a link with @kbd{C-c l}, this function will be called to
13333 try to make a link.  The function must first decide if it is supposed to
13334 create the link for this buffer type; we do this by checking the value
13335 of the variable @code{major-mode}.  If not, the function must exit and
13336 return the value @code{nil}.  If yes, the link is created by getting the
13337 manual topic from the buffer name and prefixing it with the string
13338 @samp{man:}.  Then it must call the command @code{org-store-link-props}
13339 and set the @code{:type} and @code{:link} properties.  Optionally you
13340 can also set the @code{:description} property to provide a default for
13341 the link description when the link is later inserted into an Org
13342 buffer with @kbd{C-c C-l}.
13344 When is makes sense for your new link type, you may also define a function
13345 @code{org-PREFIX-complete-link} that implements special (e.g. completion)
13346 support for inserting such a link with @kbd{C-c C-l}.  Such a function should
13347 not accept any arguments, and return the full link with prefix.
13349 @node Context-sensitive commands, Tables in arbitrary syntax, Adding hyperlink types, Hacking
13350 @section Context-sensitive commands
13351 @cindex context-sensitive commands, hooks
13352 @cindex add-ons, context-sensitive commands
13353 @vindex org-ctrl-c-ctrl-c-hook
13355 Org has several commands that act differently depending on context.  The most
13356 important example it the @kbd{C-c C-c} (@pxref{The very busy C-c C-c key}).
13357 Also the @kbd{M-cursor} and @kbd{M-S-cursor} keys have this property.
13359 Add-ons can tap into this functionality by providing a function that detects
13360 special context for that add-on and executes functionality appropriate for
13361 the context.  Here is an example from Dan Davison's @file{org-R.el} which
13362 allows you to evaluate commands based on the @file{R} programming language
13363 @footnote{@file{org-R.el} has been replaced by the org-mode functionality
13364 described in @ref{Working With Source Code} and is now obsolete.}.  For this
13365 package, special contexts are lines that start with @code{#+R:} or
13366 @code{#+RR:}.
13368 @lisp
13369 (defun org-R-apply-maybe ()
13370   "Detect if this is context for org-R and execute R commands."
13371   (if (save-excursion
13372         (beginning-of-line 1)
13373         (looking-at "#\\+RR?:"))
13374       (progn (call-interactively 'org-R-apply)
13375              t) ;; to signal that we took action
13376     nil)) ;; to signal that we did not
13378 (add-hook 'org-ctrl-c-ctrl-c-hook 'org-R-apply-maybe)
13379 @end lisp
13381 The function first checks if the cursor is in such a line.  If that is the
13382 case, @code{org-R-apply} is called and the function returns @code{t} to
13383 signal that action was taken, and @kbd{C-c C-c} will stop looking for other
13384 contexts.  If the function finds it should do nothing locally, it returns @code{nil} so that other, similar functions can have a try.
13387 @node Tables in arbitrary syntax, Dynamic blocks, Context-sensitive commands, Hacking
13388 @section Tables and lists in arbitrary syntax
13389 @cindex tables, in other modes
13390 @cindex lists, in other modes
13391 @cindex Orgtbl mode
13393 Since Orgtbl mode can be used as a minor mode in arbitrary buffers, a
13394 frequent feature request has been to make it work with native tables in
13395 specific languages, for example La@TeX{}.  However, this is extremely
13396 hard to do in a general way, would lead to a customization nightmare,
13397 and would take away much of the simplicity of the Orgtbl-mode table
13398 editor.
13400 This appendix describes a different approach.  We keep the Orgtbl mode
13401 table in its native format (the @i{source table}), and use a custom
13402 function to @i{translate} the table to the correct syntax, and to
13403 @i{install} it in the right location (the @i{target table}).  This puts
13404 the burden of writing conversion functions on the user, but it allows
13405 for a very flexible system.
13407 Bastien added the ability to do the same with lists, in Orgstruct mode.  You
13408 can use Org's facilities to edit and structure lists by turning
13409 @code{orgstruct-mode} on, then locally exporting such lists in another format
13410 (HTML, La@TeX{} or Texinfo.)
13413 @menu
13414 * Radio tables::                Sending and receiving radio tables
13415 * A LaTeX example::             Step by step, almost a tutorial
13416 * Translator functions::        Copy and modify
13417 * Radio lists::                 Doing the same for lists
13418 @end menu
13420 @node Radio tables, A LaTeX example, Tables in arbitrary syntax, Tables in arbitrary syntax
13421 @subsection Radio tables
13422 @cindex radio tables
13424 To define the location of the target table, you first need to create two
13425 lines that are comments in the current mode, but contain magic words for
13426 Orgtbl mode to find.  Orgtbl mode will insert the translated table
13427 between these lines, replacing whatever was there before.  For example:
13429 @example
13430 /* BEGIN RECEIVE ORGTBL table_name */
13431 /* END RECEIVE ORGTBL table_name */
13432 @end example
13434 @noindent
13435 Just above the source table, we put a special line that tells
13436 Orgtbl mode how to translate this table and where to install it.  For
13437 example:
13438 @cindex #+ORGTBL
13439 @example
13440 #+ORGTBL: SEND table_name translation_function arguments....
13441 @end example
13443 @noindent
13444 @code{table_name} is the reference name for the table that is also used
13445 in the receiver lines. @code{translation_function} is the Lisp function
13446 that does the translation.  Furthermore, the line can contain a list of
13447 arguments (alternating key and value) at the end.  The arguments will be
13448 passed as a property list to the translation function for
13449 interpretation.  A few standard parameters are already recognized and
13450 acted upon before the translation function is called:
13452 @table @code
13453 @item :skip N
13454 Skip the first N lines of the table.  Hlines do count as separate lines for
13455 this parameter!
13457 @item :skipcols (n1 n2 ...)
13458 List of columns that should be skipped.  If the table has a column with
13459 calculation marks, that column is automatically discarded as well.
13460 Please note that the translator function sees the table @emph{after} the
13461 removal of these columns, the function never knows that there have been
13462 additional columns.
13463 @end table
13465 @noindent
13466 The one problem remaining is how to keep the source table in the buffer
13467 without disturbing the normal workings of the file, for example during
13468 compilation of a C file or processing of a La@TeX{} file.  There are a
13469 number of different solutions:
13471 @itemize @bullet
13472 @item
13473 The table could be placed in a block comment if that is supported by the
13474 language.  For example, in C mode you could wrap the table between
13475 @samp{/*} and @samp{*/} lines.
13476 @item
13477 Sometimes it is possible to put the table after some kind of @i{END}
13478 statement, for example @samp{\bye} in @TeX{} and @samp{\end@{document@}}
13479 in La@TeX{}.
13480 @item
13481 You can just comment the table line-by-line whenever you want to process
13482 the file, and uncomment it whenever you need to edit the table.  This
13483 only sounds tedious---the command @kbd{M-x orgtbl-toggle-comment}
13484 makes this comment-toggling very easy, in particular if you bind it to a
13485 key.
13486 @end itemize
13488 @node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
13489 @subsection A La@TeX{} example of radio tables
13490 @cindex La@TeX{}, and Orgtbl mode
13492 The best way to wrap the source table in La@TeX{} is to use the
13493 @code{comment} environment provided by @file{comment.sty}.  It has to be
13494 activated by placing @code{\usepackage@{comment@}} into the document
13495 header.  Orgtbl mode can insert a radio table skeleton@footnote{By
13496 default this works only for La@TeX{}, HTML, and Texinfo.  Configure the
13497 variable @code{orgtbl-radio-tables} to install templates for other
13498 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
13499 be prompted for a table name, let's say we use @samp{salesfigures}.  You
13500 will then get the following template:
13502 @cindex #+ORGTBL, SEND
13503 @example
13504 % BEGIN RECEIVE ORGTBL salesfigures
13505 % END RECEIVE ORGTBL salesfigures
13506 \begin@{comment@}
13507 #+ORGTBL: SEND salesfigures orgtbl-to-latex
13508 | | |
13509 \end@{comment@}
13510 @end example
13512 @noindent
13513 @vindex La@TeX{}-verbatim-environments
13514 The @code{#+ORGTBL: SEND} line tells Orgtbl mode to use the function
13515 @code{orgtbl-to-latex} to convert the table into La@TeX{} and to put it
13516 into the receiver location with name @code{salesfigures}.  You may now
13517 fill in the table, feel free to use the spreadsheet features@footnote{If
13518 the @samp{#+TBLFM} line contains an odd number of dollar characters,
13519 this may cause problems with font-lock in La@TeX{} mode.  As shown in the
13520 example you can fix this by adding an extra line inside the
13521 @code{comment} environment that is used to balance the dollar
13522 expressions.  If you are using AUC@TeX{} with the font-latex library, a
13523 much better solution is to add the @code{comment} environment to the
13524 variable @code{LaTeX-verbatim-environments}.}:
13526 @example
13527 % BEGIN RECEIVE ORGTBL salesfigures
13528 % END RECEIVE ORGTBL salesfigures
13529 \begin@{comment@}
13530 #+ORGTBL: SEND salesfigures orgtbl-to-latex
13531 | Month | Days | Nr sold | per day |
13532 |-------+------+---------+---------|
13533 | Jan   |   23 |      55 |     2.4 |
13534 | Feb   |   21 |      16 |     0.8 |
13535 | March |   22 |     278 |    12.6 |
13536 #+TBLFM: $4=$3/$2;%.1f
13537 % $ (optional extra dollar to keep font-lock happy, see footnote)
13538 \end@{comment@}
13539 @end example
13541 @noindent
13542 When you are done, press @kbd{C-c C-c} in the table to get the converted
13543 table inserted between the two marker lines.
13545 Now let's assume you want to make the table header by hand, because you
13546 want to control how columns are aligned, etc@.  In this case we make sure
13547 that the table translator skips the first 2 lines of the source
13548 table, and tell the command to work as a @i{splice}, i.e. to not produce
13549 header and footer commands of the target table:
13551 @example
13552 \begin@{tabular@}@{lrrr@}
13553 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
13554 % BEGIN RECEIVE ORGTBL salesfigures
13555 % END RECEIVE ORGTBL salesfigures
13556 \end@{tabular@}
13558 \begin@{comment@}
13559 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
13560 | Month | Days | Nr sold | per day |
13561 |-------+------+---------+---------|
13562 | Jan   |   23 |      55 |     2.4 |
13563 | Feb   |   21 |      16 |     0.8 |
13564 | March |   22 |     278 |    12.6 |
13565 #+TBLFM: $4=$3/$2;%.1f
13566 \end@{comment@}
13567 @end example
13569 The La@TeX{} translator function @code{orgtbl-to-latex} is already part of
13570 Orgtbl mode.  It uses a @code{tabular} environment to typeset the table
13571 and marks horizontal lines with @code{\hline}.  Furthermore, it
13572 interprets the following parameters (see also @pxref{Translator functions}):
13574 @table @code
13575 @item :splice nil/t
13576 When set to t, return only table body lines, don't wrap them into a
13577 tabular environment.  Default is nil.
13579 @item :fmt fmt
13580 A format to be used to wrap each field, it should contain @code{%s} for the
13581 original field value.  For example, to wrap each field value in dollars,
13582 you could use @code{:fmt "$%s$"}.  This may also be a property list with
13583 column numbers and formats. for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
13584 A function of one argument can be used in place of the strings; the
13585 function must return a formatted string.
13587 @item :efmt efmt
13588 Use this format to print numbers with exponentials.  The format should
13589 have @code{%s} twice for inserting mantissa and exponent, for example
13590 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
13591 may also be a property list with column numbers and formats, for example
13592 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
13593 @code{efmt} has been applied to a value, @code{fmt} will also be
13594 applied.  Similar to @code{fmt}, functions of two arguments can be
13595 supplied instead of strings.
13596 @end table
13598 @node Translator functions, Radio lists, A LaTeX example, Tables in arbitrary syntax
13599 @subsection Translator functions
13600 @cindex HTML, and Orgtbl mode
13601 @cindex translator function
13603 Orgtbl mode has several translator functions built-in: @code{orgtbl-to-csv}
13604 (comma-separated values), @code{orgtbl-to-tsv} (TAB-separated values)
13605 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and @code{orgtbl-to-texinfo}.
13606 Except for @code{orgtbl-to-html}@footnote{The HTML translator uses the same
13607 code that produces tables during HTML export.}, these all use a generic
13608 translator, @code{orgtbl-to-generic}.  For example, @code{orgtbl-to-latex}
13609 itself is a very short function that computes the column definitions for the
13610 @code{tabular} environment, defines a few field and line separators and then
13611 hands processing over to the generic translator.  Here is the entire code:
13613 @lisp
13614 @group
13615 (defun orgtbl-to-latex (table params)
13616   "Convert the Orgtbl mode TABLE to LaTeX."
13617   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
13618                                org-table-last-alignment ""))
13619          (params2
13620           (list
13621            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
13622            :tend "\\end@{tabular@}"
13623            :lstart "" :lend " \\\\" :sep " & "
13624            :efmt "%s\\,(%s)" :hline "\\hline")))
13625     (orgtbl-to-generic table (org-combine-plists params2 params))))
13626 @end group
13627 @end lisp
13629 As you can see, the properties passed into the function (variable
13630 @var{PARAMS}) are combined with the ones newly defined in the function
13631 (variable @var{PARAMS2}).  The ones passed into the function (i.e. the
13632 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
13633 would like to use the La@TeX{} translator, but wanted the line endings to
13634 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
13635 overrule the default with
13637 @example
13638 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
13639 @end example
13641 For a new language, you can either write your own converter function in
13642 analogy with the La@TeX{} translator, or you can use the generic function
13643 directly.  For example, if you have a language where a table is started
13644 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
13645 started with @samp{!BL!}, ended with @samp{!EL!}, and where the field
13646 separator is a TAB, you could call the generic translator like this (on
13647 a single line!):
13649 @example
13650 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
13651                               :lstart "!BL! " :lend " !EL!" :sep "\t"
13652 @end example
13654 @noindent
13655 Please check the documentation string of the function
13656 @code{orgtbl-to-generic} for a full list of parameters understood by
13657 that function, and remember that you can pass each of them into
13658 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
13659 using the generic function.
13661 Of course you can also write a completely new function doing complicated
13662 things the generic translator cannot do.  A translator function takes
13663 two arguments.  The first argument is the table, a list of lines, each
13664 line either the symbol @code{hline} or a list of fields.  The second
13665 argument is the property list containing all parameters specified in the
13666 @samp{#+ORGTBL: SEND} line.  The function must return a single string
13667 containing the formatted table.  If you write a generally useful
13668 translator, please post it on @email{emacs-orgmode@@gnu.org} so that
13669 others can benefit from your work.
13671 @node Radio lists,  , Translator functions, Tables in arbitrary syntax
13672 @subsection Radio lists
13673 @cindex radio lists
13674 @cindex org-list-insert-radio-list
13676 Sending and receiving radio lists works exactly the same way than sending and
13677 receiving radio tables (@pxref{Radio tables}).  As for radio tables, you can
13678 insert radio lists templates in HTML, La@TeX{} and Texinfo modes by calling
13679 @code{org-list-insert-radio-list}.
13681 Here are the differences with radio tables:
13683 @itemize @minus
13684 @item
13685 Orgstruct mode must be active.
13686 @item
13687 Use the @code{ORGLST} keyword instead of @code{ORGTBL}.
13688 @item
13689 The available translation functions for radio lists don't take
13690 parameters.
13691 @item
13692 @kbd{C-c C-c} will work when pressed on the first item of the list.
13693 @end itemize
13695 Here is a La@TeX{} example.  Let's say that you have this in your
13696 La@TeX{} file:
13698 @cindex #+ORGLST
13699 @example
13700 % BEGIN RECEIVE ORGLST to-buy
13701 % END RECEIVE ORGLST to-buy
13702 \begin@{comment@}
13703 #+ORGLST: SEND to-buy org-list-to-latex
13704 - a new house
13705 - a new computer
13706   + a new keyboard
13707   + a new mouse
13708 - a new life
13709 \end@{comment@}
13710 @end example
13712 Pressing `C-c C-c' on @code{a new house} and will insert the converted
13713 La@TeX{} list between the two marker lines.
13715 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Hacking
13716 @section Dynamic blocks
13717 @cindex dynamic blocks
13719 Org documents can contain @emph{dynamic blocks}.  These are
13720 specially marked regions that are updated by some user-written function.
13721 A good example for such a block is the clock table inserted by the
13722 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
13724 Dynamic block are enclosed by a BEGIN-END structure that assigns a name
13725 to the block and can also specify parameters for the function producing
13726 the content of the block.
13728 #+BEGIN:dynamic block
13729 @example
13730 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
13732 #+END:
13733 @end example
13735 Dynamic blocks are updated with the following commands
13737 @table @kbd
13738 @kindex C-c C-x C-u
13739 @item C-c C-x C-u
13740 Update dynamic block at point.
13741 @kindex C-u C-c C-x C-u
13742 @item C-u C-c C-x C-u
13743 Update all dynamic blocks in the current file.
13744 @end table
13746 Updating a dynamic block means to remove all the text between BEGIN and
13747 END, parse the BEGIN line for parameters and then call the specific
13748 writer function for this block to insert the new content.  If you want
13749 to use the original content in the writer function, you can use the
13750 extra parameter @code{:content}.
13752 For a block with name @code{myblock}, the writer function is
13753 @code{org-dblock-write:myblock} with as only parameter a property list
13754 with the parameters given in the begin line.  Here is a trivial example
13755 of a block that keeps track of when the block update function was last
13756 run:
13758 @example
13759 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
13761 #+END:
13762 @end example
13764 @noindent
13765 The corresponding block writer function could look like this:
13767 @lisp
13768 (defun org-dblock-write:block-update-time (params)
13769    (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
13770      (insert "Last block update at: "
13771              (format-time-string fmt (current-time)))))
13772 @end lisp
13774 If you want to make sure that all dynamic blocks are always up-to-date,
13775 you could add the function @code{org-update-all-dblocks} to a hook, for
13776 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
13777 written in a way such that it does nothing in buffers that are not in
13778 @code{org-mode}.
13780 @node Special agenda views, Extracting agenda information, Dynamic blocks, Hacking
13781 @section Special agenda views
13782 @cindex agenda views, user-defined
13784 Org provides a special hook that can be used to narrow down the
13785 selection made by any of the agenda views.  You may specify a function
13786 that is used at each match to verify if the match should indeed be part
13787 of the agenda view, and if not, how much should be skipped.
13789 Let's say you want to produce a list of projects that contain a WAITING
13790 tag anywhere in the project tree.  Let's further assume that you have
13791 marked all tree headings that define a project with the TODO keyword
13792 PROJECT.  In this case you would run a TODO search for the keyword
13793 PROJECT, but skip the match unless there is a WAITING tag anywhere in
13794 the subtree belonging to the project line.
13796 To achieve this, you must write a function that searches the subtree for
13797 the tag.  If the tag is found, the function must return @code{nil} to
13798 indicate that this match should not be skipped.  If there is no such
13799 tag, return the location of the end of the subtree, to indicate that
13800 search should continue from there.
13802 @lisp
13803 (defun my-skip-unless-waiting ()
13804   "Skip trees that are not waiting"
13805   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
13806     (if (re-search-forward ":waiting:" subtree-end t)
13807         nil          ; tag found, do not skip
13808       subtree-end))) ; tag not found, continue after end of subtree
13809 @end lisp
13811 Now you may use this function in an agenda custom command, for example
13812 like this:
13814 @lisp
13815 (org-add-agenda-custom-command
13816  '("b" todo "PROJECT"
13817    ((org-agenda-skip-function 'my-skip-unless-waiting)
13818     (org-agenda-overriding-header "Projects waiting for something: "))))
13819 @end lisp
13821 @vindex org-agenda-overriding-header
13822 Note that this also binds @code{org-agenda-overriding-header} to get a
13823 meaningful header in the agenda view.
13825 @vindex org-odd-levels-only
13826 @vindex org-agenda-skip-function
13827 A general way to create custom searches is to base them on a search for
13828 entries with a certain level limit.  If you want to study all entries with
13829 your custom search function, simply do a search for
13830 @samp{LEVEL>0}@footnote{Note that, when using @code{org-odd-levels-only}, a
13831 level number corresponds to order in the hierarchy, not to the number of
13832 stars.}, and then use @code{org-agenda-skip-function} to select the entries
13833 you really want to have.
13835 You may also put a Lisp form into @code{org-agenda-skip-function}.  In
13836 particular, you may use the functions @code{org-agenda-skip-entry-if}
13837 and @code{org-agenda-skip-subtree-if} in this form, for example:
13839 @table @code
13840 @item '(org-agenda-skip-entry-if 'scheduled)
13841 Skip current entry if it has been scheduled.
13842 @item '(org-agenda-skip-entry-if 'notscheduled)
13843 Skip current entry if it has not been scheduled.
13844 @item '(org-agenda-skip-entry-if 'deadline)
13845 Skip current entry if it has a deadline.
13846 @item '(org-agenda-skip-entry-if 'scheduled 'deadline)
13847 Skip current entry if it has a deadline, or if it is scheduled.
13848 @item '(org-agenda-skip-entry-if 'todo '("TODO" "WAITING"))
13849 Skip current entry if the TODO keyword is TODO or WAITING.
13850 @item '(org-agenda-skip-entry-if 'todo 'done)
13851 Skip current entry if the TODO keyword marks a DONE state.
13852 @item '(org-agenda-skip-entry-if 'timestamp)
13853 Skip current entry if it has any timestamp, may also be deadline or scheduled.
13854 @item '(org-agenda-skip-entry 'regexp "regular expression")
13855 Skip current entry if the regular expression matches in the entry.
13856 @item '(org-agenda-skip-entry 'notregexp "regular expression")
13857 Skip current entry unless the regular expression matches.
13858 @item '(org-agenda-skip-subtree-if 'regexp "regular expression")
13859 Same as above, but check and skip the entire subtree.
13860 @end table
13862 Therefore we could also have written the search for WAITING projects
13863 like this, even without defining a special function:
13865 @lisp
13866 (org-add-agenda-custom-command
13867  '("b" todo "PROJECT"
13868    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
13869                                 'regexp ":waiting:"))
13870     (org-agenda-overriding-header "Projects waiting for something: "))))
13871 @end lisp
13873 @node Extracting agenda information, Using the property API, Special agenda views, Hacking
13874 @section Extracting agenda information
13875 @cindex agenda, pipe
13876 @cindex Scripts, for agenda processing
13878 @vindex org-agenda-custom-commands
13879 Org provides commands to access agenda information for the command
13880 line in Emacs batch mode.  This extracted information can be sent
13881 directly to a printer, or it can be read by a program that does further
13882 processing of the data.  The first of these commands is the function
13883 @code{org-batch-agenda}, that produces an agenda view and sends it as
13884 ASCII text to STDOUT.  The command takes a single string as parameter.
13885 If the string has length 1, it is used as a key to one of the commands
13886 you have configured in @code{org-agenda-custom-commands}, basically any
13887 key you can use after @kbd{C-c a}.  For example, to directly print the
13888 current TODO list, you could use
13890 @example
13891 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
13892 @end example
13894 If the parameter is a string with 2 or more characters, it is used as a
13895 tags/TODO match string.  For example, to print your local shopping list
13896 (all items with the tag @samp{shop}, but excluding the tag
13897 @samp{NewYork}), you could use
13899 @example
13900 emacs -batch -l ~/.emacs                                      \
13901       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
13902 @end example
13904 @noindent
13905 You may also modify parameters on the fly like this:
13907 @example
13908 emacs -batch -l ~/.emacs                                      \
13909    -eval '(org-batch-agenda "a"                               \
13910             org-agenda-ndays 30                               \
13911             org-agenda-include-diary nil                      \
13912             org-agenda-files (quote ("~/org/project.org")))'  \
13913    | lpr
13914 @end example
13916 @noindent
13917 which will produce a 30-day agenda, fully restricted to the Org file
13918 @file{~/org/projects.org}, not even including the diary.
13920 If you want to process the agenda data in more sophisticated ways, you
13921 can use the command @code{org-batch-agenda-csv} to get a comma-separated
13922 list of values for each agenda item.  Each line in the output will
13923 contain a number of fields separated by commas.  The fields in a line
13924 are:
13926 @example
13927 category     @r{The category of the item}
13928 head         @r{The headline, without TODO keyword, TAGS and PRIORITY}
13929 type         @r{The type of the agenda entry, can be}
13930                 todo               @r{selected in TODO match}
13931                 tagsmatch          @r{selected in tags match}
13932                 diary              @r{imported from diary}
13933                 deadline           @r{a deadline}
13934                 scheduled          @r{scheduled}
13935                 timestamp          @r{appointment, selected by timestamp}
13936                 closed             @r{entry was closed on date}
13937                 upcoming-deadline  @r{warning about nearing deadline}
13938                 past-scheduled     @r{forwarded scheduled item}
13939                 block              @r{entry has date block including date}
13940 todo         @r{The TODO keyword, if any}
13941 tags         @r{All tags including inherited ones, separated by colons}
13942 date         @r{The relevant date, like 2007-2-14}
13943 time         @r{The time, like 15:00-16:50}
13944 extra        @r{String with extra planning info}
13945 priority-l   @r{The priority letter if any was given}
13946 priority-n   @r{The computed numerical priority}
13947 @end example
13949 @noindent
13950 Time and date will only be given if a timestamp (or deadline/scheduled)
13951 led to the selection of the item.
13953 A CSV list like this is very easy to use in a post-processing script.
13954 For example, here is a Perl program that gets the TODO list from
13955 Emacs/Org and prints all the items, preceded by a checkbox:
13957 @example
13958 #!/usr/bin/perl
13960 # define the Emacs command to run
13961 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
13963 # run it and capture the output
13964 $agenda = qx@{$cmd 2>/dev/null@};
13966 # loop over all lines
13967 foreach $line (split(/\n/,$agenda)) @{
13968   # get the individual values
13969   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
13970    $priority_l,$priority_n) = split(/,/,$line);
13971   # process and print
13972   print "[ ] $head\n";
13974 @end example
13976 @node Using the property API, Using the mapping API, Extracting agenda information, Hacking
13977 @section Using the property API
13978 @cindex API, for properties
13979 @cindex properties, API
13981 Here is a description of the functions that can be used to work with
13982 properties.
13984 @defun org-entry-properties &optional pom which
13985 Get all properties of the entry at point-or-marker POM.@*
13986 This includes the TODO keyword, the tags, time strings for deadline,
13987 scheduled, and clocking, and any additional properties defined in the
13988 entry.  The return value is an alist, keys may occur multiple times
13989 if the property key was used several times.@*
13990 POM may also be nil, in which case the current entry is used.
13991 If WHICH is nil or `all', get all properties.  If WHICH is
13992 `special' or `standard', only get that subclass.
13993 @end defun
13994 @vindex org-use-property-inheritance
13995 @defun org-entry-get pom property &optional inherit
13996 Get value of PROPERTY for entry at point-or-marker POM.  By default,
13997 this only looks at properties defined locally in the entry.  If INHERIT
13998 is non-nil and the entry does not have the property, then also check
13999 higher levels of the hierarchy.  If INHERIT is the symbol
14000 @code{selective}, use inheritance if and only if the setting of
14001 @code{org-use-property-inheritance} selects PROPERTY for inheritance.
14002 @end defun
14004 @defun org-entry-delete pom property
14005 Delete the property PROPERTY from entry at point-or-marker POM.
14006 @end defun
14008 @defun org-entry-put pom property value
14009 Set PROPERTY to VALUE for entry at point-or-marker POM.
14010 @end defun
14012 @defun org-buffer-property-keys &optional include-specials
14013 Get all property keys in the current buffer.
14014 @end defun
14016 @defun org-insert-property-drawer
14017 Insert a property drawer at point.
14018 @end defun
14020 @defun org-entry-put-multivalued-property pom property &rest values
14021 Set PROPERTY at point-or-marker POM to VALUES.  VALUES should be a list of
14022 strings.  They will be concatenated, with spaces as separators.
14023 @end defun
14025 @defun org-entry-get-multivalued-property pom property
14026 Treat the value of the property PROPERTY as a whitespace-separated list of
14027 values and return the values as a list of strings.
14028 @end defun
14030 @defun org-entry-add-to-multivalued-property pom property value
14031 Treat the value of the property PROPERTY as a whitespace-separated list of
14032 values and make sure that VALUE is in this list.
14033 @end defun
14035 @defun org-entry-remove-from-multivalued-property pom property value
14036 Treat the value of the property PROPERTY as a whitespace-separated list of
14037 values and make sure that VALUE is @emph{not} in this list.
14038 @end defun
14040 @defun org-entry-member-in-multivalued-property pom property value
14041 Treat the value of the property PROPERTY as a whitespace-separated list of
14042 values and check if VALUE is in this list.
14043 @end defun
14045 @defopt org-property-allowed-value-functions
14046 Hook for functions supplying allowed values for specific.
14047 The functions must take a single argument, the name of the property, and
14048 return a flat list of allowed values.  If @samp{:ETC} is one of
14049 the values, use the values as completion help, but allow also other values
14050 to be entered.  The functions must return @code{nil} if they are not
14051 responsible for this property.
14052 @end defopt
14054 @node Using the mapping API,  , Using the property API, Hacking
14055 @section Using the mapping API
14056 @cindex API, for mapping
14057 @cindex mapping entries, API
14059 Org has sophisticated mapping capabilities to find all entries satisfying
14060 certain criteria.  Internally, this functionality is used to produce agenda
14061 views, but there is also an API that can be used to execute arbitrary
14062 functions for each or selected entries.  The main entry point for this API
14065 @defun org-map-entries func &optional match scope &rest skip
14066 Call FUNC at each headline selected by MATCH in SCOPE.
14068 FUNC is a function or a Lisp form.  The function will be called without
14069 arguments, with the cursor positioned at the beginning of the headline.
14070 The return values of all calls to the function will be collected and
14071 returned as a list.
14073 The call to FUNC will be wrapped into a save-excursion form, so FUNC
14074 does not need to preserve point.  After evaluation, the cursor will be
14075 moved to the end of the line (presumably of the headline of the
14076 processed entry) and search continues from there.  Under some
14077 circumstances, this may not produce the wanted results.  For example,
14078 if you have removed (e.g. archived) the current (sub)tree it could
14079 mean that the next entry will be skipped entirely.  In such cases, you
14080 can specify the position from where search should continue by making
14081 FUNC set the variable `org-map-continue-from' to the desired buffer
14082 position.
14084 MATCH is a tags/property/todo match as it is used in the agenda match view.
14085 Only headlines that are matched by this query will be considered during
14086 the iteration.  When MATCH is nil or t, all headlines will be
14087 visited by the iteration.
14089 SCOPE determines the scope of this command.  It can be any of:
14091 @example
14092 nil     @r{the current buffer, respecting the restriction if any}
14093 tree    @r{the subtree started with the entry at point}
14094 file    @r{the current buffer, without restriction}
14095 file-with-archives
14096         @r{the current buffer, and any archives associated with it}
14097 agenda  @r{all agenda files}
14098 agenda-with-archives
14099         @r{all agenda files with any archive files associated with them}
14100 (file1 file2 ...)
14101         @r{if this is a list, all files in the list will be scanned}
14102 @end example
14103 @noindent
14104 The remaining args are treated as settings for the skipping facilities of
14105 the scanner.  The following items can be given here:
14107 @vindex org-agenda-skip-function
14108 @example
14109 archive   @r{skip trees with the archive tag}
14110 comment   @r{skip trees with the COMMENT keyword}
14111 function or Lisp form
14112           @r{will be used as value for @code{org-agenda-skip-function},}
14113           @r{so whenever the function returns t, FUNC}
14114           @r{will not be called for that entry and search will}
14115           @r{continue from the point where the function leaves it}
14116 @end example
14117 @end defun
14119 The function given to that mapping routine can really do anything you like.
14120 It can use the property API (@pxref{Using the property API}) to gather more
14121 information about the entry, or in order to change metadata in the entry.
14122 Here are a couple of functions that might be handy:
14124 @defun org-todo &optional arg
14125 Change the TODO state of the entry, see the docstring of the functions for
14126 the many possible values for the argument ARG.
14127 @end defun
14129 @defun org-priority &optional action
14130 Change the priority of the entry, see the docstring of this function for the
14131 possible values for ACTION.
14132 @end defun
14134 @defun org-toggle-tag tag &optional onoff
14135 Toggle the tag TAG in the current entry.  Setting ONOFF to either @code{on}
14136 or @code{off} will not toggle tag, but ensure that it is either on or off.
14137 @end defun
14139 @defun org-promote
14140 Promote the current entry.
14141 @end defun
14143 @defun org-demote
14144 Demote the current entry.
14145 @end defun
14147 Here is a simple example that will turn all entries in the current file with
14148 a tag @code{TOMORROW} into TODO entries with the keyword @code{UPCOMING}.
14149 Entries in comment trees and in archive trees will be ignored.
14151 @lisp
14152 (org-map-entries
14153    '(org-todo "UPCOMING")
14154    "+TOMORROW" 'file 'archive 'comment)
14155 @end lisp
14157 The following example counts the number of entries with TODO keyword
14158 @code{WAITING}, in all agenda files.
14160 @lisp
14161 (length (org-map-entries t "/+WAITING" 'agenda))
14162 @end lisp
14164 @node MobileOrg, History and Acknowledgments, Hacking, Top
14165 @appendix MobileOrg
14166 @cindex iPhone
14167 @cindex MobileOrg
14169 @uref{http://mobileorg.ncogni.to/, MobileOrg} is an application for the
14170 @i{iPhone/iPod Touch} series of devices, developed by Richard Moreland.
14171 @i{MobileOrg} offers offline viewing and capture support for an Org-mode
14172 system rooted on a ``real'' computer.  It does also allow you to record
14173 changes to existing entries.  Android users should check out
14174 @uref{http://wiki.github.com/matburt/mobileorg-android/, MobileOrg Android}
14175 by Matt Jones.
14177 This appendix describes the support Org has for creating agenda views in a
14178 format that can be displayed by @i{MobileOrg}, and for integrating notes
14179 captured and changes made by @i{MobileOrg} into the main system.
14181 For changing tags and TODO states in MobileOrg, you should have set up the
14182 customization variables @code{org-todo-keywords} and @code{org-tags-alist} to
14183 cover all important tags and TODO keywords, even if individual files use only
14184 part of these.  MobileOrg will also offer you states and tags set up with
14185 in-buffer settings, but it will understand the logistics of TODO state
14186 @i{sets} (@pxref{Per-file keywords}) and @i{mutually exclusive} tags
14187 (@pxref{Setting tags}) only for those set in these variables.
14189 @menu
14190 * Setting up the staging area::  Where to interact with the mobile device
14191 * Pushing to MobileOrg::        Uploading Org files and agendas
14192 * Pulling from MobileOrg::      Integrating captured and flagged items
14193 @end menu
14195 @node Setting up the staging area, Pushing to MobileOrg, MobileOrg, MobileOrg
14196 @section Setting up the staging area
14198 MobileOrg needs to interact with Emacs through directory on a
14199 server@footnote{If you are using a public server, you might prefer to encrypt
14200 the files on the server.  This can be done with Org-mode 6.35 and, hopefully,
14201 with MobileOrg 1.4 (please check before trying to use this).  On the Emacs
14202 side, configure the variables @code{org-mobile-use-encryption} and
14203 @code{org-mobile-encryption-password}.}.  The easiest way to create that
14204 directory is to use a free @uref{http://dropbox.com,Dropbox.com}
14205 account@footnote{If you cannot use Dropbox, or if your version of MobileOrg
14206 does not support it, you can use a webdav server.  For more information,
14207 check out the the documentation of MobileOrg and also this
14208 @uref{http://orgmode.org/worg/org-faq.php#mobileorg_webdav, FAQ entry}.}.
14209 When MobileOrg first connects to your Dropbox, it will create a directory
14210 @i{MobileOrg} inside the Dropbox.  After the directory has been created, tell
14211 Emacs about it:
14213 @lisp
14214 (setq org-mobile-directory "~/Dropbox/MobileOrg")
14215 @end lisp
14217 Org-mode has commands to put files for @i{MobileOrg} into that directory,
14218 and to read captured notes from there.
14220 @node Pushing to MobileOrg, Pulling from MobileOrg, Setting up the staging area, MobileOrg
14221 @section Pushing to MobileOrg
14223 This operation copies all files currently listed in @code{org-mobile-files}
14224 to the directory @code{org-mobile-directory}.  By default this list contains
14225 all agenda files (as listed in @code{org-agenda-files}), but additional files
14226 can be included by customizing @code{org-mobiles-files}.  File names will be
14227 staged with path relative to @code{org-directory}, so all files should be
14228 inside this directory.  The push operation also creates a special Org file
14229 @file{agendas.org} with all custom agenda view defined by the
14230 user@footnote{While creating the agendas, Org-mode will force (see the
14231 variable @code{org-mobile-force-id-on-agenda-items}) ID properties on all
14232 referenced entries, so that these entries can be uniquely
14233 identified if @i{MobileOrg} flags them for further action.}.  Finally, Org
14234 writes the file @file{index.org}, containing links to all other files.
14235 @i{MobileOrg} first reads this file from the server, and then downloads all
14236 agendas and Org files listed in it.  To speed up the download, MobileOrg will
14237 only read files whose checksums@footnote{stored automatically in the file
14238 @file{checksums.dat}} have changed.
14240 @node Pulling from MobileOrg,  , Pushing to MobileOrg, MobileOrg
14241 @section Pulling from MobileOrg
14243 When @i{MobileOrg} synchronizes with the server, it not only pulls the Org
14244 files for viewing.  It also appends captured entries and pointers to flagged
14245 and changed entries to the file @file{mobileorg.org} on the server.  Org has
14246 a @emph{pull} operation that integrates this information into an inbox file
14247 and operates on the pointers to flagged entries.  Here is how it works:
14249 @enumerate
14250 @item
14251 Org moves all entries found in
14252 @file{mobileorg.org}@footnote{@file{mobileorg.org} will be empty after this
14253 operation.} and appends them to the file pointed to by the variable
14254 @code{org-mobile-inbox-for-pull}.  Each captured entry and each editing event
14255 will be a top-level entry in the inbox file.
14256 @item
14257 After moving the entries, Org will attempt to implement the changes made in
14258 @i{MobileOrg}.  Some changes are applied directly and without user
14259 interaction.  Examples are all changes to tags, TODO state, headline and body
14260 text that can be cleanly applied.  Entries that have been flagged for further
14261 action will receive a tag @code{:FLAGGED:}, so that they can be easily found
14262 again.  When there is a problem finding an entry or applying the change, the
14263 pointer entry will remain in the inbox and will be marked with an error
14264 message.  You need to later resolve these issues by hand.
14265 @item
14266 Org will then generate an agenda view with all flagged entries.  The user
14267 should then go through these entries and do whatever actions are necessary.
14268 If a note has been stored while flagging an entry in @i{MobileOrg}, that note
14269 will be displayed in the echo area when the cursor is on the corresponding
14270 agenda line.
14271 @table @kbd
14272 @kindex ?
14273 @item ?
14274 Pressing @kbd{?} in that special agenda will display the full flagging note in
14275 another window and also push it onto the kill ring.  So you could use @kbd{?
14276 z C-y C-c C-c} to store that flagging note as a normal note in the entry.
14277 Pressing @kbd{?} twice in succession will offer to remove the
14278 @code{:FLAGGED:} tag along with the recorded flagging note (which is stored
14279 in a property).  In this way you indicate, that the intended processing for
14280 this flagged entry is finished.
14281 @end table
14282 @end enumerate
14284 @kindex C-c a ?
14285 If you are not able to process all flagged entries directly, you can always
14286 return to this agenda view using @kbd{C-c a ?}.  Note, however, that there is
14287 a subtle difference.  The view created automatically by @kbd{M-x
14288 org-mobile-pull @key{RET}} is guaranteed to search all files that have been
14289 addressed by the last pull.  This might include a file that is not currently
14290 in your list of agenda files.  If you later use @kbd{C-c a ?} to regenerate
14291 the view, only the current agenda files will be searched.
14293 @node History and Acknowledgments, Main Index, MobileOrg, Top
14294 @appendix History and acknowledgments
14295 @cindex acknowledgments
14296 @cindex history
14297 @cindex thanks
14299 Org was born in 2003, out of frustration over the user interface of the Emacs
14300 Outline mode.  I was trying to organize my notes and projects, and using
14301 Emacs seemed to be the natural way to go.  However, having to remember eleven
14302 different commands with two or three keys per command, only to hide and show
14303 parts of the outline tree, that seemed entirely unacceptable to me.  Also,
14304 when using outlines to take notes, I constantly wanted to restructure the
14305 tree, organizing it parallel to my thoughts and plans.  @emph{Visibility
14306 cycling} and @emph{structure editing} were originally implemented in the
14307 package @file{outline-magic.el}, but quickly moved to the more general
14308 @file{org.el}.  As this environment became comfortable for project planning,
14309 the next step was adding @emph{TODO entries}, basic @emph{timestamps}, and
14310 @emph{table support}.  These areas highlighted the two main goals that Org
14311 still has today: to be a new, outline-based, plain text mode with innovative
14312 and intuitive editing features, and to incorporate project planning
14313 functionality directly into a notes file.
14315 Since the first release, literally thousands of emails to me or to
14316 @email{emacs-orgmode@@gnu.org} have provided a constant stream of bug
14317 reports, feedback, new ideas, and sometimes patches and add-on code.
14318 Many thanks to everyone who has helped to improve this package.  I am
14319 trying to keep here a list of the people who had significant influence
14320 in shaping one or more aspects of Org.  The list may not be
14321 complete, if I have forgotten someone, please accept my apologies and
14322 let me know.
14324 Before I get to this list, a few special mentions are in order:
14326 @table @i
14327 @item Bastien Guerry
14328 Bastien has written a large number of extensions to Org (most of them
14329 integrated into the core by now), including the LaTeX exporter and the plain
14330 list parser.  His support during the early days, when he basically acted as
14331 co-maintainer, was central to the success of this project.  Bastien also
14332 invented Worg, helped establishing the Web presence of Org, and sponsors
14333 hosting costs for the orgmode.org website.
14334 @item Eric Schulte and Dan Davison
14335 Eric and Dan are jointly responsible for the Org-babel system, which turns
14336 Org into a multi-language environment for evaluating code and doing literate
14337 programming and reproducible research.
14338 @item John Wiegley
14339 John has also contributed a number of great ideas and patches
14340 directly to Org, including the attachment system (@file{org-attach.el}),
14341 integration with Apple Mail (@file{org-mac-message.el}), hierarchical
14342 dependencies of TODO items, habit tracking (@file{org-habits.el}), and
14343 encryption (@file{org-crypt.el}).  Also, the capture system is really an
14344 extended copy of his great @file{remember.el}.
14345 @item Sebastian Rose
14346 Without Sebastian, the HTML/XHTML publishing of Org would be the pitiful work
14347 of an ignorant amateur.  Sebastian has pushed this part of Org onto a much
14348 higher level.  He also wrote @file{org-info.js}, a Java script for displaying
14349 webpages derived from Org using an Info-like or a folding interface with
14350 single-key navigation.
14351 @end table
14353 @noindent OK, now to the full list of contributions!  Again, please let me
14354 know what I am missing here!
14356 @itemize @bullet
14358 @item
14359 @i{Russel Adams} came up with the idea for drawers.
14360 @item
14361 @i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}.
14362 @item
14363 @i{Christophe Bataillon} created the great unicorn logo that we use on the
14364 Org-mode website.
14365 @item
14366 @i{Alex Bochannek} provided a patch for rounding timestamps.
14367 @item
14368 @i{Jan Böcker} wrote @file{org-docview.el}.
14369 @item
14370 @i{Brad Bozarth} showed how to pull RSS feed data into Org-mode files.
14371 @item
14372 @i{Tom Breton} wrote @file{org-choose.el}.
14373 @item
14374 @i{Charles Cave}'s suggestion sparked the implementation of templates
14375 for Remember, which are now templates for capture.
14376 @item
14377 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
14378 specified time.
14379 @item
14380 @i{Gregory Chernov} patched support for Lisp forms into table
14381 calculations and improved XEmacs compatibility, in particular by porting
14382 @file{nouline.el} to XEmacs.
14383 @item
14384 @i{Sacha Chua} suggested copying some linking code from Planner.
14385 @item
14386 @i{Baoqiu Cui} contributed the DocBook exporter.
14387 @item
14388 @i{Eddward DeVilla} proposed and tested checkbox statistics.  He also
14389 came up with the idea of properties, and that there should be an API for
14390 them.
14391 @item
14392 @i{Nick Dokos} tracked down several nasty bugs.
14393 @item
14394 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
14395 inspired some of the early development, including HTML export.  He also
14396 asked for a way to narrow wide table columns.
14397 @item
14398 @i{Thomas S. Dye} contributed documentation on Worg and helped integrating
14399 the Org-Babel documentation into the manual.
14400 @item
14401 @i{Christian Egli} converted the documentation into Texinfo format,
14402 patched CSS formatting into the HTML exporter, and inspired the agenda.
14403 @item
14404 @i{David Emery} provided a patch for custom CSS support in exported
14405 HTML agendas.
14406 @item
14407 @i{Nic Ferrier} contributed mailcap and XOXO support.
14408 @item
14409 @i{Miguel A. Figueroa-Villanueva} implemented hierarchical checkboxes.
14410 @item
14411 @i{John Foerch} figured out how to make incremental search show context
14412 around a match in a hidden outline tree.
14413 @item
14414 @i{Raimar Finken} wrote @file{org-git-line.el}.
14415 @item
14416 @i{Mikael Fornius} works as a mailing list moderator.
14417 @item
14418 @i{Austin Frank} works as a mailing list moderator.
14419 @item
14420 @i{Niels Giesen} had the idea to automatically archive DONE trees.
14421 @item
14422 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
14423 @item
14424 @i{Bernt Hansen} has driven much of the support for auto-repeating tasks,
14425 task state change logging, and the clocktable.  His clear explanations have
14426 been critical when we started to adopt the Git version control system.
14427 @item
14428 @i{Manuel Hermenegildo} has contributed various ideas, small fixes and
14429 patches.
14430 @item
14431 @i{Phil Jackson} wrote @file{org-irc.el}.
14432 @item
14433 @i{Scott Jaderholm} proposed footnotes, control over whitespace between
14434 folded entries, and column view for properties.
14435 @item
14436 @i{Matt Jones} wrote @i{MobileOrg Android}.
14437 @item
14438 @i{Tokuya Kameshima} wrote @file{org-wl.el} and @file{org-mew.el}.
14439 @item
14440 @i{Shidai Liu} ("Leo") asked for embedded La@TeX{} and tested it.  He also
14441 provided frequent feedback and some patches.
14442 @item
14443 @i{Matt Lundin} has proposed last-row references for table formulas and named
14444 invisible anchors.  He has also worked a lot on the FAQ.
14445 @item
14446 @i{David Maus} wrote @file{org-atom.el}, maintains the issues file for Org,
14447 and is a prolific contributor on the mailing list with competent replies,
14448 small fixes and patches.
14449 @item
14450 @i{Jason F. McBrayer} suggested agenda export to CSV format.
14451 @item
14452 @i{Max Mikhanosha} came up with the idea of refiling.
14453 @item
14454 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
14455 basis.
14456 @item
14457 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
14458 happy.
14459 @item
14460 @i{Richard Moreland} wrote @i{MobileOrg} for the iPhone.
14461 @item
14462 @i{Rick Moynihan} proposed allowing multiple TODO sequences in a file
14463 and being able to quickly restrict the agenda to a subtree.
14464 @item
14465 @i{Todd Neal} provided patches for links to Info files and Elisp forms.
14466 @item
14467 @i{Greg Newman} refreshed the unicorn logo into its current form.
14468 @item
14469 @i{Tim O'Callaghan} suggested in-file links, search options for general
14470 file links, and TAGS.
14471 @item
14472 @i{Osamu Okano} wrote @file{orgcard2ref.pl}, a perl program to create a text
14473 version of the reference card.
14474 @item
14475 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
14476 into Japanese.
14477 @item
14478 @i{Oliver Oppitz} suggested multi-state TODO items.
14479 @item
14480 @i{Scott Otterson} sparked the introduction of descriptive text for
14481 links, among other things.
14482 @item
14483 @i{Pete Phillips} helped during the development of the TAGS feature, and
14484 provided frequent feedback.
14485 @item
14486 @i{Martin Pohlack} provided the code snippet to bundle character insertion
14487 into bundles of 20 for undo.
14488 @item
14489 @i{T.V. Raman} reported bugs and suggested improvements.
14490 @item
14491 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
14492 control.
14493 @item
14494 @i{Paul Rivier} provided the basic implementation of named footnotes.  He
14495 also acted as mailing list moderator for some time.
14496 @item
14497 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
14498 @item
14499 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
14500 conflict with @file{allout.el}.
14501 @item
14502 @i{Jason Riedy} generalized the send-receive mechanism for Orgtbl tables with
14503 extensive patches.
14504 @item
14505 @i{Philip Rooke} created the Org reference card, provided lots
14506 of feedback, developed and applied standards to the Org documentation.
14507 @item
14508 @i{Christian Schlauer} proposed angular brackets around links, among
14509 other things.
14510 @item
14511 @i{Paul Sexton} wrote @file{org-ctags.el}.
14512 @item
14513 Linking to VM/BBDB/Gnus was first inspired by @i{Tom Shannon}'s
14514 @file{organizer-mode.el}.
14515 @item
14516 @i{Ilya Shlyakhter} proposed the Archive Sibling, line numbering in literal
14517 examples, and remote highlighting for referenced code lines.
14518 @item
14519 @i{Stathis Sideris} wrote the @file{ditaa.jar} ASCII to PNG converter that is
14520 now packaged into Org's @file{contrib} directory.
14521 @item
14522 @i{Daniel Sinder} came up with the idea of internal archiving by locking
14523 subtrees.
14524 @item
14525 @i{Dale Smith} proposed link abbreviations.
14526 @item
14527 @i{James TD Smith} has contributed a large number of patches for useful
14528 tweaks and features.
14529 @item
14530 @i{Adam Spiers} asked for global linking commands, inspired the link
14531 extension system, added support for mairix, and proposed the mapping API.
14532 @item
14533 @i{Ulf Stegemann} created the table to translate special symbols to HTML,
14534 LaTeX, UTF-8, Latin-1 and ASCII.
14535 @item
14536 @i{Andy Stewart} contributed code to @file{org-w3m.el}, to copy HTML content
14537 with links transformation to Org syntax.
14538 @item
14539 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
14540 chapter about publishing.
14541 @item
14542 @i{Stefan Vollmar} organized a video-recorded talk at the
14543 Max-Planck-Institute for Neurology.  He also inspired the creation of a
14544 concept index for HTML export.
14545 @item
14546 @i{J@"urgen Vollmer} contributed code generating the table of contents
14547 in HTML output.
14548 @item
14549 @i{Samuel Wales} has provided important feedback and bug reports.
14550 @item
14551 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
14552 keyword.
14553 @item
14554 @i{David Wainberg} suggested archiving, and improvements to the linking
14555 system.
14556 @item
14557 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
14558 linking to Gnus.
14559 @item
14560 @i{Roland Winkler} requested additional key bindings to make Org
14561 work on a tty.
14562 @item
14563 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
14564 and contributed various ideas and code snippets.
14565 @end itemize
14568 @node Main Index, Key Index, History and Acknowledgments, Top
14569 @unnumbered Concept index
14571 @printindex cp
14573 @node Key Index, Command and Function Index, Main Index, Top
14574 @unnumbered Key index
14576 @printindex ky
14578 @node Command and Function Index, Variable Index, Key Index, Top
14579 @unnumbered Command and function index
14581 @printindex fn
14583 @node Variable Index,  , Command and Function Index, Top
14584 @unnumbered Variable index
14586 This is not a complete index of variables and faces, only the ones that are
14587 mentioned in the manual.  For a more complete list, use @kbd{M-x
14588 org-customize @key{RET}} and then click yourself through the tree.
14590 @printindex vr
14592 @bye
14594 @ignore
14595         arch-tag: 7893d1Fe-cc57-4d13-b5e5-f494a1CBC7ac
14596 @end ignore
14598 @c Local variables:
14599 @c fill-column: 77
14600 @c End:
14603 @c  LocalWords:  webdavhost pre