New hooks for external support for allowed property values
[rgr-org-mode.git] / doc / org.texi
blob88667042a9457bc022a5962f923fd2030bcf5924
1 \input texinfo
2 @c %**start of header
3 @setfilename ../../info/org
4 @settitle The Org Manual
6 @set VERSION 6.33trans
7 @set DATE November 2009
9 @c Version and Contact Info
10 @set MAINTAINERSITE @uref{http://orgmode.org,maintainers webpage}
11 @set AUTHOR Carsten Dominik
12 @set MAINTAINER Carsten Dominik
13 @set MAINTAINEREMAIL @email{carsten at orgmode dot org}
14 @set MAINTAINERCONTACT @uref{mailto:carsten at orgmode dot org,contact the maintainer}
15 @c %**end of header
16 @finalout
18 @c Macro definitions
19 @iftex
20 @c @hyphenation{time-stamp time-stamps time-stamp-ing time-stamp-ed}
21 @end iftex
22 @macro Ie {}
23 I.e.,
24 @end macro
25 @macro ie {}
26 i.e.,
27 @end macro
28 @macro Eg {}
29 E.g.,
30 @end macro
31 @macro eg {}
32 e.g.,
33 @end macro
35 @c Subheadings inside a table.
36 @macro tsubheading{text}
37 @ifinfo
38 @subsubheading \text\
39 @end ifinfo
40 @ifnotinfo
41 @item @b{\text\}
42 @end ifnotinfo
43 @end macro
45 @copying
46 This manual is for Org version @value{VERSION}.
48 Copyright @copyright{} 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation
50 @quotation
51 Permission is granted to copy, distribute and/or modify this document
52 under the terms of the GNU Free Documentation License, Version 1.3 or
53 any later version published by the Free Software Foundation; with no
54 Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
55 and with the Back-Cover Texts as in (a) below.  A copy of the license
56 is included in the section entitled ``GNU Free Documentation License.''
58 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
59 modify this GNU manual.  Buying copies from the FSF supports it in
60 developing GNU and promoting software freedom.''
62 This document is part of a collection distributed under the GNU Free
63 Documentation License.  If you want to distribute this document
64 separately from the collection, you can do so by adding a copy of the
65 license to the document, as described in section 6 of the license.
66 @end quotation
67 @end copying
69 @dircategory Emacs
70 @direntry
71 * Org Mode: (org).      Outline-based notes management and organizer
72 @end direntry
74 @titlepage
75 @title The Org Manual
77 @subtitle Release @value{VERSION}
78 @author by Carsten Dominik
80 @c The following two commands start the copyright page.
81 @page
82 @vskip 0pt plus 1filll
83 @insertcopying
84 @end titlepage
86 @c Output the table of contents at the beginning.
87 @contents
89 @ifnottex
90 @node Top, Introduction, (dir), (dir)
91 @top Org Mode Manual
93 @insertcopying
94 @end ifnottex
96 @menu
97 * Introduction::                Getting started
98 * Document Structure::          A tree works like your brain
99 * Tables::                      Pure magic for quick formatting
100 * Hyperlinks::                  Notes in context
101 * TODO Items::                  Every tree branch can be a TODO item
102 * Tags::                        Tagging headlines and matching sets of tags
103 * Properties and Columns::      Storing information about an entry
104 * Dates and Times::             Making items useful for planning
105 * Capture - Refile - Archive::  The ins and outs for projects
106 * Agenda Views::                Collecting information into views
107 * Markup::                      Prepare text for rich export
108 * Exporting::                   Sharing and publishing of notes
109 * Publishing::                  Create a web site of linked Org files
110 * Miscellaneous::               All the rest which did not fit elsewhere
111 * Hacking::                     How to hack your way around
112 * MobileOrg::                   Viewing and capture on a mobile device
113 * History and Acknowledgments::  How Org came into being
114 * Main Index::                  An index of Org's concepts and features
115 * Key Index::                   Key bindings and where they are described
116 * Variable Index::              Variables mentioned in the manual
118 @detailmenu
119  --- The Detailed Node Listing ---
121 Introduction
123 * Summary::                     Brief summary of what Org does
124 * Installation::                How to install a downloaded version of Org
125 * Activation::                  How to activate Org for certain buffers
126 * Feedback::                    Bug reports, ideas, patches etc.
127 * Conventions::                 Type-setting conventions in the manual
129 Document Structure
131 * Outlines::                    Org is based on Outline mode
132 * Headlines::                   How to typeset Org tree headlines
133 * Visibility cycling::          Show and hide, much simplified
134 * Motion::                      Jumping to other headlines
135 * Structure editing::           Changing sequence and level of headlines
136 * Sparse trees::                Matches embedded in context
137 * Plain lists::                 Additional structure within an entry
138 * Drawers::                     Tucking stuff away
139 * Blocks::                      Folding blocks
140 * Footnotes::                   How footnotes are defined in Org's syntax
141 * Orgstruct mode::              Structure editing outside Org
143 Tables
145 * Built-in table editor::       Simple tables
146 * Column width and alignment::  Overrule the automatic settings
147 * Column groups::               Grouping to trigger vertical lines
148 * Orgtbl mode::                 The table editor as minor mode
149 * The spreadsheet::             The table editor has spreadsheet capabilities
150 * Org-Plot::                    Plotting from org tables
152 The spreadsheet
154 * References::                  How to refer to another field or range
155 * Formula syntax for Calc::     Using Calc to compute stuff
156 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
157 * Field formulas::              Formulas valid for a single field
158 * Column formulas::             Formulas valid for an entire column
159 * Editing and debugging formulas::  Fixing formulas
160 * Updating the table::          Recomputing all dependent fields
161 * Advanced features::           Field names, parameters and automatic recalc
163 Hyperlinks
165 * Link format::                 How links in Org are formatted
166 * Internal links::              Links to other places in the current file
167 * External links::              URL-like links to the world
168 * Handling links::              Creating, inserting and following
169 * Using links outside Org::     Linking from my C source code?
170 * Link abbreviations::          Shortcuts for writing complex links
171 * Search options::              Linking to a specific location
172 * Custom searches::             When the default search is not enough
174 Internal links
176 * Radio targets::               Make targets trigger links in plain text
178 TODO Items
180 * TODO basics::                 Marking and displaying TODO entries
181 * TODO extensions::             Workflow and assignments
182 * Progress logging::            Dates and notes for progress
183 * Priorities::                  Some things are more important than others
184 * Breaking down tasks::         Splitting a task into manageable pieces
185 * Checkboxes::                  Tick-off lists
187 Extended use of TODO keywords
189 * Workflow states::             From TODO to DONE in steps
190 * TODO types::                  I do this, Fred does the rest
191 * Multiple sets in one file::   Mixing it all, and still finding your way
192 * Fast access to TODO states::  Single letter selection of a state
193 * Per-file keywords::           Different files, different requirements
194 * Faces for TODO keywords::     Highlighting states
195 * TODO dependencies::           When one task needs to wait for others
197 Progress logging
199 * Closing items::               When was this entry marked DONE?
200 * Tracking TODO state changes::  When did the status change?
201 * Tracking your habits::        How consistent have you been?
203 Tags
205 * Tag inheritance::             Tags use the tree structure of the outline
206 * Setting tags::                How to assign tags to a headline
207 * Tag searches::                Searching for combinations of tags
209 Properties and Columns
211 * Property syntax::             How properties are spelled out
212 * Special properties::          Access to other Org mode features
213 * Property searches::           Matching property values
214 * Property inheritance::        Passing values down the tree
215 * Column view::                 Tabular viewing and editing
216 * Property API::                Properties for Lisp programmers
218 Column view
220 * Defining columns::            The COLUMNS format property
221 * Using column view::           How to create and use column view
222 * Capturing column view::       A dynamic block for column view
224 Defining columns
226 * Scope of column definitions::  Where defined, where valid?
227 * Column attributes::           Appearance and content of a column
229 Dates and Times
231 * Timestamps::                  Assigning a time to a tree entry
232 * Creating timestamps::         Commands which insert timestamps
233 * Deadlines and scheduling::    Planning your work
234 * Clocking work time::          Tracking how long you spend on a task
235 * Resolving idle time::         Resolving time if you've been idle
236 * Effort estimates::            Planning work effort in advance
237 * Relative timer::              Notes with a running timer
239 Creating timestamps
241 * The date/time prompt::        How Org mode helps you entering date and time
242 * Custom time format::          Making dates look different
244 Deadlines and scheduling
246 * Inserting deadline/schedule::  Planning items
247 * Repeated tasks::              Items that show up again and again
249 Capture - Refile - Archive
251 * Remember::                    Capture new tasks/ideas with little interruption
252 * Attachments::                 Add files to tasks.
253 * RSS Feeds::                   Getting input from RSS feeds
254 * Protocols::                   External (e.g. Browser) access to Emacs and Org
255 * Refiling notes::              Moving a tree from one place to another
256 * Archiving::                   What to do with finished projects
258 Remember
260 * Setting up Remember for Org::  Some code for .emacs to get things going
261 * Remember templates::          Define the outline of different note types
262 * Storing notes::               Directly get the note to where it belongs
264 Archiving
266 * Moving subtrees::             Moving a tree to an archive file
267 * Internal archiving::          Switch off a tree but keep i in the file
269 Agenda Views
271 * Agenda files::                Files being searched for agenda information
272 * Agenda dispatcher::           Keyboard access to agenda views
273 * Built-in agenda views::       What is available out of the box?
274 * Presentation and sorting::    How agenda items are prepared for display
275 * Agenda commands::             Remote editing of Org trees
276 * Custom agenda views::         Defining special searches and views
277 * Exporting Agenda Views::      Writing a view to a file
278 * Agenda column view::          Using column view for collected entries
280 The built-in agenda views
282 * Weekly/daily agenda::         The calendar page with current tasks
283 * Global TODO list::            All unfinished action items
284 * Matching tags and properties::  Structured information with fine-tuned search
285 * Timeline::                    Time-sorted view for single file
286 * Search view::                 Find entries by searching for text
287 * Stuck projects::              Find projects you need to review
289 Presentation and sorting
291 * Categories::                  Not all tasks are equal
292 * Time-of-day specifications::  How the agenda knows the time
293 * Sorting of agenda items::     The order of things
295 Custom agenda views
297 * Storing searches::            Type once, use often
298 * Block agenda::                All the stuff you need in a single buffer
299 * Setting Options::             Changing the rules
301 Markup for rich export
303 * Structural markup elements::  The basic structure as seen by the exporter
304 * Images and tables::           Tables and Images will be included
305 * Literal examples::            Source code examples with special formatting
306 * Include files::               Include additional files into a document
307 * Macro replacement::           Use macros to create complex output
308 * Embedded LaTeX::              LaTeX can be freely used inside Org documents
310 Structural markup elements
312 * Document title::              Where the title is taken from
313 * Headings and sections::       The document structure as seen by the exporter
314 * Table of contents::           The if and where of the table of contents
315 * Initial text::                Text before the first heading?
316 * Lists::                       Lists
317 * Paragraphs::                  Paragraphs
318 * Footnote markup::             Footnotes
319 * Emphasis and monospace::      Bold, italic, etc.
320 * Horizontal rules::            Make a line
321 * Comment lines::               What will *not* be exported
323 Embedded La@TeX{}
325 * Special symbols::             Greek letters and other symbols
326 * Subscripts and superscripts::  Simple syntax for raising/lowering text
327 * LaTeX fragments::             Complex formulas made easy
328 * Previewing LaTeX fragments::  What will this snippet look like?
329 * CDLaTeX mode::                Speed up entering of formulas
331 Exporting
333 * Selective export::            Using tags to select and exclude trees
334 * Export options::              Per-file export settings
335 * The export dispatcher::       How to access exporter commands
336 * ASCII export::                Exporting to plain ASCII
337 * HTML export::                 Exporting to HTML
338 * LaTeX and PDF export::        Exporting to La@TeX{}, and processing to PDF
339 * DocBook export::              Exporting to DocBook
340 * Freemind export::             Exporting to Freemind mind maps
341 * XOXO export::                 Exporting to XOXO
342 * iCalendar export::            Exporting in iCalendar format
344 HTML export
346 * HTML Export commands::        How to invoke HTML export
347 * Quoting HTML tags::           Using direct HTML in Org mode
348 * Links in HTML export::        How links will be interpreted and formatted
349 * Tables in HTML export::       How to modify the formatting of tables
350 * Images in HTML export::       How to insert figures into HTML output
351 * Text areas in HTML export::   An alternative way to show an example
352 * CSS support::                 Changing the appearance of the output
353 * Javascript support::          Info and Folding in a web browser
355 La@TeX{} and PDF export
357 * LaTeX/PDF export commands::   Which key invokes which commands
358 * Quoting LaTeX code::          Incorporating literal La@TeX{} code
359 * Sectioning structure::        Changing sectioning in La@TeX{} output
360 * Tables in LaTeX export::      Options for exporting tables to La@TeX{}
361 * Images in LaTeX export::      How to insert figures into La@TeX{} output
363 DocBook export
365 * DocBook export commands::     How to invoke DocBook export
366 * Quoting DocBook code::        Incorporating DocBook code in Org files
367 * Recursive sections::          Recursive sections in DocBook
368 * Tables in DocBook export::    Tables are exported as HTML tables
369 * Images in DocBook export::    How to insert figures into DocBook output
370 * Special characters::          How to handle special characters
372 Publishing
374 * Configuration::               Defining projects
375 * Uploading files::             How to get files up on the server
376 * Sample configuration::        Example projects
377 * Triggering publication::      Publication commands
379 Configuration
381 * Project alist::               The central configuration variable
382 * Sources and destinations::    From here to there
383 * Selecting files::             What files are part of the project?
384 * Publishing action::           Setting the function doing the publishing
385 * Publishing options::          Tweaking HTML export
386 * Publishing links::            Which links keep working after publishing?
387 * Project page index::          Publishing a list of project files
389 Sample configuration
391 * Simple example::              One-component publishing
392 * Complex example::             A multi-component publishing example
394 Miscellaneous
396 * Completion::                  M-TAB knows what you need
397 * Speed keys::                  Electic commands at the beginning of a headline
398 * Customization::               Adapting Org to your taste
399 * In-buffer settings::          Overview of the #+KEYWORDS
400 * The very busy C-c C-c key::   When in doubt, press C-c C-c
401 * Clean view::                  Getting rid of leading stars in the outline
402 * TTY keys::                    Using Org on a tty
403 * Interaction::                 Other Emacs packages
405 Interaction with other packages
407 * Cooperation::                 Packages Org cooperates with
408 * Conflicts::                   Packages that lead to conflicts
410 Hacking
412 * Hooks::                       Who to reach into Org's internals
413 * Add-on packages::             Available extensions
414 * Adding hyperlink types::      New custom link types
415 * Context-sensitive commands::  How to add functionality to such commands
416 * Tables in arbitrary syntax::  Orgtbl for La@TeX{} and other programs
417 * Dynamic blocks::              Automatically filled blocks
418 * Special agenda views::        Customized views
419 * Extracting agenda information::  Postprocessing of agenda information
420 * Using the property API::      Writing programs that use entry properties
421 * Using the mapping API::       Mapping over all or selected entries
423 Tables and lists in arbitrary syntax
425 * Radio tables::                Sending and receiving radio tables
426 * A LaTeX example::             Step by step, almost a tutorial
427 * Translator functions::        Copy and modify
428 * Radio lists::                 Doing the same for lists
430 MobileOrg
432 * Setting up the staging area::  Where to interact with the mobile device
433 * Pushing to MobileOrg::        Uploading Org files and agendas
434 * Pulling from MobileOrg::      Integrating captured and flagged items
436 @end detailmenu
437 @end menu
439 @node Introduction, Document Structure, Top, Top
440 @chapter Introduction
441 @cindex introduction
443 @menu
444 * Summary::                     Brief summary of what Org does
445 * Installation::                How to install a downloaded version of Org
446 * Activation::                  How to activate Org for certain buffers
447 * Feedback::                    Bug reports, ideas, patches etc.
448 * Conventions::                 Type-setting conventions in the manual
449 @end menu
451 @node Summary, Installation, Introduction, Introduction
452 @section Summary
453 @cindex summary
455 Org is a mode for keeping notes, maintaining TODO lists, and doing
456 project planning with a fast and effective plain-text system.
458 Org develops organizational tasks around NOTES files that contain
459 lists or information about projects as plain text.  Org is
460 implemented on top of Outline mode, which makes it possible to keep the
461 content of large files well structured.  Visibility cycling and
462 structure editing help to work with the tree.  Tables are easily created
463 with a built-in table editor.  Org supports TODO items, deadlines,
464 timestamps, and scheduling.  It dynamically compiles entries into an
465 agenda that utilizes and smoothly integrates much of the Emacs calendar
466 and diary.  Plain text URL-like links connect to websites, emails,
467 Usenet messages, BBDB entries, and any files related to the projects.
468 For printing and sharing of notes, an Org file can be exported as a
469 structured ASCII file, as HTML, or (TODO and agenda items only) as an
470 iCalendar file.  It can also serve as a publishing tool for a set of
471 linked web pages.
473 An important design aspect that distinguishes Org from, for example,
474 Planner/Muse is that it encourages you to store every piece of information
475 only once.  In Planner, you have project pages, day pages and possibly
476 other files, duplicating some information such as tasks.  In Org,
477 you only have notes files.  In your notes you mark entries as tasks, and
478 label them with tags and timestamps.  All necessary lists, like a
479 schedule for the day, the agenda for a meeting, tasks lists selected by
480 tags, etc., are created dynamically when you need them.
482 Org keeps simple things simple.  When first fired up, it should
483 feel like a straightforward, easy to use outliner.  Complexity is not
484 imposed, but a large amount of functionality is available when you need
485 it.  Org is a toolbox and can be used in different ways, for
486 example as:
488 @example
489 @r{@bullet{} an outline extension with visibility cycling and structure editing}
490 @r{@bullet{} an ASCII system and table editor for taking structured notes}
491 @r{@bullet{} an ASCII table editor with spreadsheet-like capabilities}
492 @r{@bullet{} a TODO list editor}
493 @r{@bullet{} a full agenda and planner with deadlines and work scheduling}
494 @pindex GTD, Getting Things Done
495 @r{@bullet{} an environment to implement David Allen's GTD system}
496 @r{@bullet{} a basic database application}
497 @r{@bullet{} a simple hypertext system, with HTML and La@TeX{} export}
498 @r{@bullet{} a publishing tool to create a set of interlinked webpages}
499 @end example
501 Org's automatic, context-sensitive table editor with spreadsheet
502 capabilities can be integrated into any major mode by activating the
503 minor Orgtbl mode.  Using a translation step, it can be used to maintain
504 tables in arbitrary file types, for example in La@TeX{}.  The structure
505 editing and list creation capabilities can be used outside Org with
506 the minor Orgstruct mode.
508 @cindex FAQ
509 There is a website for Org which provides links to the newest
510 version of Org, as well as additional information, frequently asked
511 questions (FAQ), links to tutorials, etc@.  This page is located at
512 @uref{http://orgmode.org}.
514 @page
517 @node Installation, Activation, Summary, Introduction
518 @section Installation
519 @cindex installation
520 @cindex XEmacs
522 @b{Important:} @i{If you are using a version of Org that is part of the Emacs
523 distribution or an XEmacs package, please skip this section and go directly
524 to @ref{Activation}.}
526 If you have downloaded Org from the Web, either as a distribution @file{.zip}
527 or @file{.tar} file, or as a Git archive, you must take the following steps
528 to install it: go into the unpacked Org distribution directory and edit the
529 top section of the file @file{Makefile}.  You must set the name of the Emacs
530 binary (likely either @file{emacs} or @file{xemacs}), and the paths to the
531 directories where local Lisp and Info files are kept.  If you don't have
532 access to the system-wide directories, you can simply run Org directly from
533 the distribution directory by adding the @file{lisp} subdirectory to the
534 Emacs load path.  To do this, add the following line to @file{.emacs}:
536 @example
537 (setq load-path (cons "~/path/to/orgdir/lisp" load-path))
538 @end example
540 @noindent
541 If you plan to use code from the @file{contrib} subdirectory, do a similar
542 step for this directory:
544 @example
545 (setq load-path (cons "~/path/to/orgdir/contrib/lisp" load-path))
546 @end example
548 @sp 2
549 @cartouche
550 XEmacs users now need to install the file @file{noutline.el} from
551 the @file{xemacs} sub-directory of the Org distribution.  Use the
552 command:
554 @example
555      make install-noutline
556 @end example
557 @end cartouche
558 @sp 2
560 @noindent Now byte-compile the Lisp files with the shell command:
562 @example
563 make
564 @end example
566 @noindent If you are running Org from the distribution directory, this is
567 all.  If you want to install Org into the system directories, use (as
568 administrator)
570 @example
571 make install
572 @end example
574 Installing Info files is system dependent, because of differences in the
575 @file{install-info} program.  In Debian it copies the info files into the
576 correct directory and modifies the info directory file.  In many other
577 systems, the files need to be copied to the correct directory separately, and
578 @file{install-info} then only modifies the directory file.  Check your system
579 documentation to find out which of the following commands you need:
581 @example
582 make install-info
583 make install-info-debian
584 @end example
586 Then add the following line to @file{.emacs}.  It is needed so that
587 Emacs can autoload functions that are located in files not immediately loaded
588 when Org-mode starts.
589 @lisp
590 (require 'org-install)
591 @end lisp
593 Do not forget to activate Org as described in the following section.
594 @page
596 @node Activation, Feedback, Installation, Introduction
597 @section Activation
598 @cindex activation
599 @cindex autoload
600 @cindex global key bindings
601 @cindex key bindings, global
603 @iftex
604 @b{Important:} @i{If you use copy-and-paste to copy Lisp code from the
605 PDF documentation as viewed by some PDF viewers to your @file{.emacs} file, the
606 single-quote character comes out incorrectly and the code will not work.
607 You need to fix the single-quotes by hand, or copy from Info
608 documentation.}
609 @end iftex
611 Add the following lines to your @file{.emacs} file.  The last three lines
612 define @emph{global} keys for the commands @command{org-store-link},
613 @command{org-agenda}, and @command{org-iswitchb}---please choose suitable
614 keys yourself.
616 @lisp
617 ;; The following lines are always needed.  Choose your own keys.
618 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
619 (global-set-key "\C-cl" 'org-store-link)
620 (global-set-key "\C-ca" 'org-agenda)
621 (global-set-key "\C-cb" 'org-iswitchb)
622 @end lisp
624 Furthermore, you must activate @code{font-lock-mode} in Org
625 buffers, because significant functionality depends on font-locking being
626 active.  You can do this with either one of the following two lines
627 (XEmacs users must use the second option):
628 @lisp
629 (global-font-lock-mode 1)                     ; for all buffers
630 (add-hook 'org-mode-hook 'turn-on-font-lock)  ; Org buffers only
631 @end lisp
633 @cindex Org mode, turning on
634 With this setup, all files with extension @samp{.org} will be put
635 into Org mode.  As an alternative, make the first line of a file look
636 like this:
638 @example
639 MY PROJECTS    -*- mode: org; -*-
640 @end example
642 @vindex org-insert-mode-line-in-empty-file
643 @noindent which will select Org mode for this buffer no matter what
644 the file's name is.  See also the variable
645 @code{org-insert-mode-line-in-empty-file}.
647 Many commands in Org work on the region if the region is @i{active}.  To make
648 use of this, you need to have @code{transient-mark-mode}
649 (@code{zmacs-regions} in XEmacs) turned on.  In Emacs 23 this is the default,
650 in Emacs 22 you need to do this yourself with
651 @lisp
652 (transient-mark-mode 1)
653 @end lisp
654 @noindent If you do not like @code{transient-mark-mode}, you can create an
655 active region by using the mouse to select a region, or pressing
656 @kbd{C-@key{SPC}} twice before moving the cursor.
658 @node Feedback, Conventions, Activation, Introduction
659 @section Feedback
660 @cindex feedback
661 @cindex bug reports
662 @cindex maintainer
663 @cindex author
665 If you find problems with Org, or if you have questions, remarks, or ideas
666 about it, please mail to the Org mailing list @email{emacs-orgmode@@gnu.org}.
667 If you are not a member of the mailing list, your mail will be passed to the
668 list after a moderator has approved it.
670 For bug reports, please provide as much information as possible, including
671 the version information of Emacs (@kbd{M-x emacs-version @key{RET}}) and Org
672 (@kbd{M-x org-version @key{RET}}), as well as the Org related setup in
673 @file{.emacs}.  The easiest way to do this is to use the command
674 @example
675 @kbd{M-x org-submit-bug-report}
676 @end example
677 @noindent which will put all this information into an Emacs mail buffer so
678 that you only need to add your description.  If you re not sending the Email
679 from within Emacs, please copy and paste the content into your Email program.
681 If an error occurs, a backtrace can be very useful (see below on how to
682 create one).  Often a small example file helps, along with clear information
683 about:
685 @enumerate
686 @item What exactly did you do?
687 @item What did you expect to happen?
688 @item What happened instead?
689 @end enumerate
690 @noindent Thank you for helping to improve this mode.
692 @subsubheading How to create a useful backtrace
694 @cindex backtrace of an error
695 If working with Org produces an error with a message you don't
696 understand, you may have hit a bug.  The best way to report this is by
697 providing, in addition to what was mentioned above, a @emph{backtrace}.
698 This is information from the built-in debugger about where and how the
699 error occurred.  Here is how to produce a useful backtrace:
701 @enumerate
702 @item
703 Reload uncompiled versions of all Org-mode Lisp files.  The backtrace
704 contains much more information if it is produced with uncompiled code.
705 To do this, use
706 @example
707 C-u M-x org-reload RET
708 @end example
709 @noindent
710 or select @code{Org -> Refresh/Reload -> Reload Org uncompiled} from the
711 menu.
712 @item
713 Go to the @code{Options} menu and select @code{Enter Debugger on Error}
714 (XEmacs has this option in the @code{Troubleshooting} sub-menu).
715 @item
716 Do whatever you have to do to hit the error.  Don't forget to
717 document the steps you take.
718 @item
719 When you hit the error, a @file{*Backtrace*} buffer will appear on the
720 screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
721 attach it to your bug report.
722 @end enumerate
724 @node Conventions,  , Feedback, Introduction
725 @section Typesetting conventions used in this manual
727 Org uses three types of keywords: TODO keywords, tags, and property
728 names.  In this manual we use the following conventions:
730 @table @code
731 @item TODO
732 @itemx WAITING
733 TODO keywords are written with all capitals, even if they are
734 user-defined.
735 @item boss
736 @itemx ARCHIVE
737 User-defined tags are written in lowercase; built-in tags with special
738 meaning are written with all capitals.
739 @item Release
740 @itemx PRIORITY
741 User-defined properties are capitalized; built-in properties with
742 special meaning are written with all capitals.
743 @end table
745 @node Document Structure, Tables, Introduction, Top
746 @chapter Document Structure
747 @cindex document structure
748 @cindex structure of document
750 Org is based on Outline mode and provides flexible commands to
751 edit the structure of the document.
753 @menu
754 * Outlines::                    Org is based on Outline mode
755 * Headlines::                   How to typeset Org tree headlines
756 * Visibility cycling::          Show and hide, much simplified
757 * Motion::                      Jumping to other headlines
758 * Structure editing::           Changing sequence and level of headlines
759 * Sparse trees::                Matches embedded in context
760 * Plain lists::                 Additional structure within an entry
761 * Drawers::                     Tucking stuff away
762 * Blocks::                      Folding blocks
763 * Footnotes::                   How footnotes are defined in Org's syntax
764 * Orgstruct mode::              Structure editing outside Org
765 @end menu
767 @node Outlines, Headlines, Document Structure, Document Structure
768 @section Outlines
769 @cindex outlines
770 @cindex Outline mode
772 Org is implemented on top of Outline mode.  Outlines allow a
773 document to be organized in a hierarchical structure, which (at least
774 for me) is the best representation of notes and thoughts.  An overview
775 of this structure is achieved by folding (hiding) large parts of the
776 document to show only the general document structure and the parts
777 currently being worked on.  Org greatly simplifies the use of
778 outlines by compressing the entire show/hide functionality into a single
779 command, @command{org-cycle}, which is bound to the @key{TAB} key.
781 @node Headlines, Visibility cycling, Outlines, Document Structure
782 @section Headlines
783 @cindex headlines
784 @cindex outline tree
785 @vindex org-special-ctrl-a/e
787 Headlines define the structure of an outline tree.  The headlines in
788 Org start with one or more stars, on the left margin@footnote{See
789 the variable @code{org-special-ctrl-a/e} to configure special behavior
790 of @kbd{C-a} and @kbd{C-e} in headlines.}.  For example:
792 @example
793 * Top level headline
794 ** Second level
795 *** 3rd level
796     some text
797 *** 3rd level
798     more text
800 * Another top level headline
801 @end example
803 @noindent Some people find the many stars too noisy and would prefer an
804 outline that has whitespace followed by a single star as headline
805 starters.  @ref{Clean view}, describes a setup to realize this.
807 @vindex org-cycle-separator-lines
808 An empty line after the end of a subtree is considered part of it and
809 will be hidden when the subtree is folded.  However, if you leave at
810 least two empty lines, one empty line will remain visible after folding
811 the subtree, in order to structure the collapsed view.  See the
812 variable @code{org-cycle-separator-lines} to modify this behavior.
814 @node Visibility cycling, Motion, Headlines, Document Structure
815 @section Visibility cycling
816 @cindex cycling, visibility
817 @cindex visibility cycling
818 @cindex trees, visibility
819 @cindex show hidden text
820 @cindex hide text
822 Outlines make it possible to hide parts of the text in the buffer.
823 Org uses just two commands, bound to @key{TAB} and
824 @kbd{S-@key{TAB}} to change the visibility in the buffer.
826 @cindex subtree visibility states
827 @cindex subtree cycling
828 @cindex folded, subtree visibility state
829 @cindex children, subtree visibility state
830 @cindex subtree, subtree visibility state
831 @table @kbd
832 @kindex @key{TAB}
833 @item @key{TAB}
834 @emph{Subtree cycling}: Rotate current subtree among the states
836 @example
837 ,-> FOLDED -> CHILDREN -> SUBTREE --.
838 '-----------------------------------'
839 @end example
841 @vindex org-cycle-emulate-tab
842 @vindex org-cycle-global-at-bob
843 The cursor must be on a headline for this to work@footnote{see, however,
844 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
845 beginning of the buffer and the first line is not a headline, then
846 @key{TAB} actually runs global cycling (see below)@footnote{see the
847 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
848 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
850 @cindex global visibility states
851 @cindex global cycling
852 @cindex overview, global visibility state
853 @cindex contents, global visibility state
854 @cindex show all, global visibility state
855 @kindex S-@key{TAB}
856 @item S-@key{TAB}
857 @itemx C-u @key{TAB}
858 @emph{Global cycling}: Rotate the entire buffer among the states
860 @example
861 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
862 '--------------------------------------'
863 @end example
865 When @kbd{S-@key{TAB}} is called with a numeric prefix argument N, the
866 CONTENTS view up to headlines of level N will be shown.  Note that inside
867 tables, @kbd{S-@key{TAB}} jumps to the previous field.
869 @cindex show all, command
870 @kindex C-u C-u C-u @key{TAB}
871 @item C-u C-u C-u @key{TAB}
872 Show all, including drawers.
873 @kindex C-c C-r
874 @item C-c C-r
875 Reveal context around point, showing the current entry, the following heading
876 and the hierarchy above.  Useful for working near a location that has been
877 exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda command
878 (@pxref{Agenda commands}).  With a prefix argument show, on each
879 level, all sibling headings.
880 @kindex C-c C-x b
881 @item C-c C-x b
882 Show the current subtree in an indirect buffer@footnote{The indirect
883 buffer
884 @ifinfo
885 (@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
886 @end ifinfo
887 @ifnotinfo
888 (see the Emacs manual for more information about indirect buffers)
889 @end ifnotinfo
890 will contain the entire buffer, but will be narrowed to the current
891 tree.  Editing the indirect buffer will also change the original buffer,
892 but without affecting visibility in that buffer.}.  With a numeric
893 prefix argument N, go up to level N and then take that tree.  If N is
894 negative then go up that many levels.  With a @kbd{C-u} prefix, do not remove
895 the previously used indirect buffer.
896 @end table
898 @vindex org-startup-folded
899 @cindex @code{overview}, STARTUP keyword
900 @cindex @code{content}, STARTUP keyword
901 @cindex @code{showall}, STARTUP keyword
902 @cindex @code{showeverything}, STARTUP keyword
904 When Emacs first visits an Org file, the global state is set to
905 OVERVIEW, i.e. only the top level headlines are visible.  This can be
906 configured through the variable @code{org-startup-folded}, or on a
907 per-file basis by adding one of the following lines anywhere in the
908 buffer:
910 @example
911 #+STARTUP: overview
912 #+STARTUP: content
913 #+STARTUP: showall
914 #+STARTUP: showeverything
915 @end example
917 @cindex property, VISIBILITY
918 @noindent
919 Furthermore, any entries with a @samp{VISIBILITY} property (@pxref{Properties
920 and Columns}) will get their visibility adapted accordingly.  Allowed values
921 for this property are @code{folded}, @code{children}, @code{content}, and
922 @code{all}.
923 @table @kbd
924 @kindex C-u C-u @key{TAB}
925 @item C-u C-u @key{TAB}
926 Switch back to the startup visibility of the buffer, i.e. whatever is
927 requested by startup options and @samp{VISIBILITY} properties in individual
928 entries.
929 @end table
931 @node Motion, Structure editing, Visibility cycling, Document Structure
932 @section Motion
933 @cindex motion, between headlines
934 @cindex jumping, to headlines
935 @cindex headline navigation
936 The following commands jump to other headlines in the buffer.
938 @table @kbd
939 @kindex C-c C-n
940 @item C-c C-n
941 Next heading.
942 @kindex C-c C-p
943 @item C-c C-p
944 Previous heading.
945 @kindex C-c C-f
946 @item C-c C-f
947 Next heading same level.
948 @kindex C-c C-b
949 @item C-c C-b
950 Previous heading same level.
951 @kindex C-c C-u
952 @item C-c C-u
953 Backward to higher level heading.
954 @kindex C-c C-j
955 @item C-c C-j
956 Jump to a different place without changing the current outline
957 visibility.  Shows the document structure in a temporary buffer, where
958 you can use the following keys to find your destination:
959 @vindex org-goto-auto-isearch
960 @example
961 @key{TAB}         @r{Cycle visibility.}
962 @key{down} / @key{up}   @r{Next/previous visible headline.}
963 @key{RET}         @r{Select this location.}
964 @kbd{/}           @r{Do a Sparse-tree search}
965 @r{The following keys work if you turn off @code{org-goto-auto-isearch}}
966 n / p        @r{Next/previous visible headline.}
967 f / b        @r{Next/previous headline same level.}
968 u            @r{One level up.}
969 0-9          @r{Digit argument.}
970 q            @r{Quit}
971 @end example
972 @vindex org-goto-interface
973 @noindent
974 See also the variable @code{org-goto-interface}.
975 @end table
977 @node Structure editing, Sparse trees, Motion, Document Structure
978 @section Structure editing
979 @cindex structure editing
980 @cindex headline, promotion and demotion
981 @cindex promotion, of subtrees
982 @cindex demotion, of subtrees
983 @cindex subtree, cut and paste
984 @cindex pasting, of subtrees
985 @cindex cutting, of subtrees
986 @cindex copying, of subtrees
987 @cindex sorting, of subtrees
988 @cindex subtrees, cut and paste
990 @table @kbd
991 @kindex M-@key{RET}
992 @item M-@key{RET}
993 @vindex org-M-RET-may-split-line
994 Insert new heading with same level as current.  If the cursor is in a
995 plain list item, a new item is created (@pxref{Plain lists}).  To force
996 creation of a new headline, use a prefix argument, or first press @key{RET}
997 to get to the beginning of the next line.  When this command is used in
998 the middle of a line, the line is split and the rest of the line becomes
999 the new headline@footnote{If you do not want the line to be split,
1000 customize the variable @code{org-M-RET-may-split-line}.}.  If the
1001 command is used at the beginning of a headline, the new headline is
1002 created before the current line.  If at the beginning of any other line,
1003 the content of that line is made the new heading.  If the command is
1004 used at the end of a folded subtree (i.e. behind the ellipses at the end
1005 of a headline), then a headline like the current one will be inserted
1006 after the end of the subtree.
1007 @kindex C-@key{RET}
1008 @item C-@key{RET}
1009 Just like @kbd{M-@key{RET}}, except when adding a new heading below the
1010 current heading, the new heading is placed after the body instead of before
1011 it.  This command works from anywhere in the entry.
1012 @kindex M-S-@key{RET}
1013 @item M-S-@key{RET}
1014 @vindex org-treat-insert-todo-heading-as-state-change
1015 Insert new TODO entry with same level as current heading.  See also the
1016 variable @code{org-treat-insert-todo-heading-as-state-change}.
1017 @kindex C-S-@key{RET}
1018 @item C-S-@key{RET}
1019 Insert new TODO entry with same level as current heading.  Like
1020 @kbd{C-@key{RET}}, the new headline will be inserted after the current
1021 subtree.
1022 @kindex @key{TAB}
1023 @item @key{TAB} @r{in new, empty entry}
1024 In a new entry with no text yet, the first @key{TAB} demotes the entry to
1025 become a child of the previous one.  The next @key{TAB} makes it a parent,
1026 and so on, all the way to top level.  Yet another @key{TAB}, and you are back
1027 to the initial level.
1028 @kindex M-@key{left}
1029 @item M-@key{left}
1030 Promote current heading by one level.
1031 @kindex M-@key{right}
1032 @item M-@key{right}
1033 Demote current heading by one level.
1034 @kindex M-S-@key{left}
1035 @item M-S-@key{left}
1036 Promote the current subtree by one level.
1037 @kindex M-S-@key{right}
1038 @item M-S-@key{right}
1039 Demote the current subtree by one level.
1040 @kindex M-S-@key{up}
1041 @item M-S-@key{up}
1042 Move subtree up (swap with previous subtree of same
1043 level).
1044 @kindex M-S-@key{down}
1045 @item M-S-@key{down}
1046 Move subtree down (swap with next subtree of same level).
1047 @kindex C-c C-x C-w
1048 @item C-c C-x C-w
1049 Kill subtree, i.e. remove it from buffer but save in kill ring.
1050 With a numeric prefix argument N, kill N sequential subtrees.
1051 @kindex C-c C-x M-w
1052 @item C-c C-x M-w
1053 Copy subtree to kill ring.  With a numeric prefix argument N, copy the N
1054 sequential subtrees.
1055 @kindex C-c C-x C-y
1056 @item C-c C-x C-y
1057 Yank subtree from kill ring.  This does modify the level of the subtree to
1058 make sure the tree fits in nicely at the yank position.  The yank level can
1059 also be specified with a numeric prefix argument, or by yanking after a
1060 headline marker like @samp{****}.
1061 @kindex C-y
1062 @item C-y
1063 @vindex org-yank-adjusted-subtrees
1064 @vindex org-yank-folded-subtrees
1065 Depending on the variables @code{org-yank-adjusted-subtrees} and
1066 @code{org-yank-folded-subtrees}, Org's internal @code{yank} command will
1067 paste subtrees folded and in a clever way, using the same command as @kbd{C-c
1068 C-x C-y}.  With the default settings, no level adjustment will take place,
1069 but the yanked tree will be folded unless doing so would swallow text
1070 previously visible.  Any prefix argument to this command will force a normal
1071 @code{yank} to be executed, with the prefix passed along.  A good way to
1072 force a normal yank is @kbd{C-u C-y}.  If you use @code{yank-pop} after a
1073 yank, it will yank previous kill items plainly, without adjustment and
1074 folding.
1075 @kindex C-c C-x c
1076 @item C-c C-x c
1077 Clone a subtree by making a number of sibling copies of it.  You will be
1078 prompted for the number of copies to make, and you can also specify if any
1079 timestamps in the entry should be shifted.  This can be useful, for example,
1080 to create a number of tasks related to a series of lectures to prepare.  For
1081 more details, see the docstring of the command
1082 @code{org-clone-subtree-with-time-shift}.
1083 @kindex C-c C-w
1084 @item C-c C-w
1085 Refile entry or region to a different location.  @xref{Refiling notes}.
1086 @kindex C-c ^
1087 @item C-c ^
1088 Sort same-level entries.  When there is an active region, all entries in the
1089 region will be sorted.  Otherwise the children of the current headline are
1090 sorted.  The command prompts for the sorting method, which can be
1091 alphabetically, numerically, by time (first timestamp with active preferred,
1092 creation time, scheduled time, deadline time), by priority, by TODO keyword
1093 (in the sequence the keywords have been defined in the setup) or by the value
1094 of a property.  Reverse sorting is possible as well.  You can also supply
1095 your own function to extract the sorting key.  With a @kbd{C-u} prefix,
1096 sorting will be case-sensitive.  With two @kbd{C-u C-u} prefixes, duplicate
1097 entries will also be removed.
1098 @kindex C-x n s
1099 @item C-x n s
1100 Narrow buffer to current subtree.
1101 @kindex C-x n w
1102 @item C-x n w
1103 Widen buffer to remove narrowing.
1104 @kindex C-c *
1105 @item C-c *
1106 Turn a normal line or plain list item into a headline (so that it becomes a
1107 subheading at its location).  Also turn a headline into a normal line by
1108 removing the stars.  If there is an active region, turn all lines in the
1109 region into headlines.  If the first line in the region was an item, turn
1110 only the item lines into headlines.  Finally, if the first line is a
1111 headline, remove the stars from all headlines in the region.
1112 @end table
1114 @cindex region, active
1115 @cindex active region
1116 @cindex transient mark mode
1117 When there is an active region (Transient Mark mode), promotion and
1118 demotion work on all headlines in the region.  To select a region of
1119 headlines, it is best to place both point and mark at the beginning of a
1120 line, mark at the beginning of the first headline, and point at the line
1121 just after the last headline to change.  Note that when the cursor is
1122 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
1123 functionality.
1126 @node Sparse trees, Plain lists, Structure editing, Document Structure
1127 @section Sparse trees
1128 @cindex sparse trees
1129 @cindex trees, sparse
1130 @cindex folding, sparse trees
1131 @cindex occur, command
1133 @vindex org-show-hierarchy-above
1134 @vindex org-show-following-heading
1135 @vindex org-show-siblings
1136 @vindex org-show-entry-below
1137 An important feature of Org mode is the ability to construct @emph{sparse
1138 trees} for selected information in an outline tree, so that the entire
1139 document is folded as much as possible, but the selected information is made
1140 visible along with the headline structure above it@footnote{See also the
1141 variables @code{org-show-hierarchy-above}, @code{org-show-following-heading},
1142 @code{org-show-siblings}, and @code{org-show-entry-below} for detailed
1143 control on how much context is shown around each match.}.  Just try it out
1144 and you will see immediately how it works.
1146 Org mode contains several commands creating such trees, all these
1147 commands can be accessed through a dispatcher:
1149 @table @kbd
1150 @kindex C-c /
1151 @item C-c /
1152 This prompts for an extra key to select a sparse-tree creating command.
1153 @kindex C-c / r
1154 @item C-c / r
1155 @vindex org-remove-highlights-with-change
1156 Occur.  Prompts for a regexp and shows a sparse tree with all matches.  If
1157 the match is in a headline, the headline is made visible.  If the match is in
1158 the body of an entry, headline and body are made visible.  In order to
1159 provide minimal context, also the full hierarchy of headlines above the match
1160 is shown, as well as the headline following the match.  Each match is also
1161 highlighted; the highlights disappear when the buffer is changed by an
1162 editing command@footnote{This depends on the option
1163 @code{org-remove-highlights-with-change}}, or by pressing @kbd{C-c C-c}.
1164 When called with a @kbd{C-u} prefix argument, previous highlights are kept,
1165 so several calls to this command can be stacked.
1166 @end table
1168 @noindent
1169 @vindex org-agenda-custom-commands
1170 For frequently used sparse trees of specific search strings, you can
1171 use the variable @code{org-agenda-custom-commands} to define fast
1172 keyboard access to specific sparse trees.  These commands will then be
1173 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
1174 For example:
1176 @lisp
1177 (setq org-agenda-custom-commands
1178       '(("f" occur-tree "FIXME")))
1179 @end lisp
1181 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
1182 a sparse tree matching the string @samp{FIXME}.
1184 The other sparse tree commands select headings based on TODO keywords,
1185 tags, or properties and will be discussed later in this manual.
1187 @kindex C-c C-e v
1188 @cindex printing sparse trees
1189 @cindex visible text, printing
1190 To print a sparse tree, you can use the Emacs command
1191 @code{ps-print-buffer-with-faces} which does not print invisible parts
1192 of the document @footnote{This does not work under XEmacs, because
1193 XEmacs uses selective display for outlining, not text properties.}.
1194 Or you can use the command @kbd{C-c C-e v} to export only the visible
1195 part of the document and print the resulting file.
1197 @node Plain lists, Drawers, Sparse trees, Document Structure
1198 @section Plain lists
1199 @cindex plain lists
1200 @cindex lists, plain
1201 @cindex lists, ordered
1202 @cindex ordered lists
1204 Within an entry of the outline tree, hand-formatted lists can provide
1205 additional structure.  They also provide a way to create lists of
1206 checkboxes (@pxref{Checkboxes}).  Org supports editing such lists,
1207 and the HTML exporter (@pxref{Exporting}) parses and formats them.
1209 Org knows ordered lists, unordered lists, and description lists.
1210 @itemize @bullet
1211 @item
1212 @emph{Unordered} list items start with @samp{-}, @samp{+}, or
1213 @samp{*}@footnote{When using @samp{*} as a bullet, lines must be indented or
1214 they will be seen as top-level headlines.  Also, when you are hiding leading
1215 stars to get a clean outline view, plain list items starting with a star are
1216 visually indistinguishable from true headlines.  In short: even though
1217 @samp{*} is supported, it may be better to not use it for plain list items.}
1218 as bullets.
1219 @item
1220 @emph{Ordered} list items start with a numeral followed by either a period or
1221 a right parenthesis, such as @samp{1.} or @samp{1)}.
1222 @item
1223 @emph{Description} list items are unordered list items, and contain the
1224 separator @samp{ :: } to separate the description @emph{term} from the
1225 description.
1226 @end itemize
1228 @vindex org-empty-line-terminates-plain-lists
1229 Items belonging to the same list must have the same indentation on the first
1230 line.  In particular, if an ordered list reaches number @samp{10.}, then the
1231 2--digit numbers must be written left-aligned with the other numbers in the
1232 list.  Indentation also determines the end of a list item.  It ends before
1233 the next line that is indented like the bullet/number, or less.  Empty lines
1234 are part of the previous item, so you can have several paragraphs in one
1235 item.  If you would like an empty line to terminate all currently open plain
1236 lists, configure the variable @code{org-empty-line-terminates-plain-lists}.
1237 Here is an example:
1239 @example
1240 @group
1241 ** Lord of the Rings
1242    My favorite scenes are (in this order)
1243    1. The attack of the Rohirrim
1244    2. Eowyn's fight with the witch king
1245       + this was already my favorite scene in the book
1246       + I really like Miranda Otto.
1247    3. Peter Jackson being shot by Legolas
1248        - on DVD only
1249       He makes a really funny face when it happens.
1250    But in the end, no individual scenes matter but the film as a whole.
1251    Important actors in this film are:
1252    - @b{Elijah Wood} :: He plays Frodo
1253    - @b{Sean Austin} :: He plays Sam, Frodo's friend.  I still remember
1254      him very well from his role as Mikey Walsh in @i{The Goonies}.
1255 @end group
1256 @end example
1258 Org supports these lists by tuning filling and wrapping commands to deal with
1259 them correctly@footnote{Org only changes the filling settings for Emacs.  For
1260 XEmacs, you should use Kyle E. Jones' @file{filladapt.el}.  To turn this on,
1261 put into @file{.emacs}: @code{(require 'filladapt)}}, and by exporting them
1262 properly (@pxref{Exporting}).  Since indentation is what governs the
1263 structure of these lists, many structural constructs like @code{#+BEGIN_...}
1264 blocks can be indented to signal that they should be part of a list item.
1266 The following commands act on items when the cursor is in the first line
1267 of an item (the line with the bullet or number).
1269 @table @kbd
1270 @kindex @key{TAB}
1271 @item @key{TAB}
1272 @vindex org-cycle-include-plain-lists
1273 Items can be folded just like headline levels.  Normally this works only if
1274 the cursor is on a plain list item.  For more details, see the variable
1275 @code{org-cycle-include-plain-lists}. to @code{integrate}, plain list items
1276 will be treated like low-level.  The level of an item is then given by the
1277 indentation of the bullet/number.  Items are always subordinate to real
1278 headlines, however; the hierarchies remain completely separated.
1280 If @code{org-cycle-include-plain-lists} has not been set, @key{TAB}
1281 fixes the indentation of the current line in a heuristic way.
1282 @kindex M-@key{RET}
1283 @item M-@key{RET}
1284 @vindex org-M-RET-may-split-line
1285 Insert new item at current level.  With a prefix argument, force a new
1286 heading (@pxref{Structure editing}).  If this command is used in the middle
1287 of a line, the line is @emph{split} and the rest of the line becomes the new
1288 item@footnote{If you do not want the line to be split, customize the variable
1289 @code{org-M-RET-may-split-line}.}.  If this command is executed in the
1290 @emph{whitespace before a bullet or number}, the new item is created
1291 @emph{before} the current item.  If the command is executed in the white
1292 space before the text that is part of an item but does not contain the
1293 bullet, a bullet is added to the current line.
1294 @kindex M-S-@key{RET}
1295 @item M-S-@key{RET}
1296 Insert a new item with a checkbox (@pxref{Checkboxes}).
1297 @kindex @key{TAB}
1298 @item @key{TAB} @r{in new, empty item}
1299 In a new item with no text yet, the first @key{TAB} demotes the item to
1300 become a child of the previous one.  The next @key{TAB} makes it a parent,
1301 and so on, all the way to the left margin.  Yet another @key{TAB}, and you
1302 are back to the initial level.
1303 @kindex S-@key{up}
1304 @kindex S-@key{down}
1305 @item S-@key{up}
1306 @itemx S-@key{down}
1307 @cindex shift-selection-mode
1308 @vindex org-support-shift-select
1309 Jump to the previous/next item in the current list, but only if
1310 @code{org-support-shift-select} is off.  If not, you can still use paragraph
1311 jumping commands like @kbd{C-@key{up}} and @kbd{C-@key{down}} to quite
1312 similar effect.
1313 @kindex M-S-@key{up}
1314 @kindex M-S-@key{down}
1315 @item M-S-@key{up}
1316 @itemx M-S-@key{down}
1317 Move the item including subitems up/down (swap with previous/next item
1318 of same indentation).  If the list is ordered, renumbering is
1319 automatic.
1320 @kindex M-S-@key{left}
1321 @kindex M-S-@key{right}
1322 @item M-S-@key{left}
1323 @itemx M-S-@key{right}
1324 Decrease/increase the indentation of the item, including subitems.
1325 Initially, the item tree is selected based on current indentation.
1326 When these commands are executed several times in direct succession,
1327 the initially selected region is used, even if the new indentation
1328 would imply a different hierarchy.  To use the new hierarchy, break
1329 the command chain with a cursor motion or so.
1330 @kindex C-c C-c
1331 @item C-c C-c
1332 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1333 state of the checkbox.  If not, this command makes sure that all the
1334 items on this list level use the same bullet.  Furthermore, if this is
1335 an ordered list, make sure the numbering is OK.
1336 @kindex C-c -
1337 @item C-c -
1338 Cycle the entire list level through the different itemize/enumerate bullets
1339 (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}).  With a numeric prefix
1340 argument N, select the Nth bullet from this list.  If there is an active
1341 region when calling this, all lines will be converted to list items.  If the
1342 first line already was a list item, any item markers will be removed from the
1343 list.  Finally, even without an active region, a normal line will be
1344 converted into a list item.
1345 @kindex C-c *
1346 @item C-c *
1347 Turn a plain list item into a headline (so that it becomes a subheading at
1348 its location). @xref{Structure editing}, for a detailed explanation.
1349 @kindex S-@key{left}
1350 @kindex S-@key{right}
1351 @item S-@key{left}/@key{right}
1352 @vindex org-support-shift-select
1353 This command also cycles bullet styles when the cursor in on the bullet or
1354 anywhere in an item line, details depending on
1355 @code{org-support-shift-select}.
1356 @kindex C-c ^
1357 @item C-c ^
1358 Sort the plain list.  You will be prompted for the sorting method:
1359 numerically, alphabetically, by time, or by custom function.
1360 @end table
1362 @node Drawers, Blocks, Plain lists, Document Structure
1363 @section Drawers
1364 @cindex drawers
1365 @cindex #+DRAWERS
1366 @cindex visibility cycling, drawers
1368 @vindex org-drawers
1369 Sometimes you want to keep information associated with an entry, but you
1370 normally don't want to see it.  For this, Org mode has @emph{drawers}.
1371 Drawers need to be configured with the variable
1372 @code{org-drawers}@footnote{You can define drawers on a per-file basis
1373 with a line like @code{#+DRAWERS: HIDDEN PROPERTIES STATE}}.  Drawers
1374 look like this:
1376 @example
1377 ** This is a headline
1378    Still outside the drawer
1379    :DRAWERNAME:
1380       This is inside the drawer.
1381    :END:
1382    After the drawer.
1383 @end example
1385 Visibility cycling (@pxref{Visibility cycling}) on the headline will hide and
1386 show the entry, but keep the drawer collapsed to a single line.  In order to
1387 look inside the drawer, you need to move the cursor to the drawer line and
1388 press @key{TAB} there.  Org mode uses the @code{PROPERTIES} drawer for
1389 storing properties (@pxref{Properties and Columns}), and you can also arrange
1390 for state change notes (@pxref{Tracking TODO state changes}) and clock times
1391 (@pxref{Clocking work time}) to be stored in a drawer @code{LOGBOOK}.
1393 @node Blocks, Footnotes, Drawers, Document Structure
1394 @section Blocks
1396 @vindex org-hide-block-startup
1397 @cindex blocks, folding
1398 Org-mode uses begin...end blocks for various purposes from including source
1399 code examples (@pxref{Literal examples}) to capturing time logging
1400 information (@pxref{Clocking work time}).  These blocks can be folded and
1401 unfolded by pressing TAB in the begin line.  You can also get all blocks
1402 folded at startup by configuring the variable @code{org-hide-block-startup}
1403 or on a per-file basis by using
1405 @cindex @code{hideblocks}, STARTUP keyword
1406 @cindex @code{nohideblocks}, STARTUP keyword
1407 @example
1408 #+STARTUP: hideblocks
1409 #+STARTUP: nohideblocks
1410 @end example
1412 @node Footnotes, Orgstruct mode, Blocks, Document Structure
1413 @section Footnotes
1414 @cindex footnotes
1416 Org mode supports the creation of footnotes.  In contrast to the
1417 @file{footnote.el} package, Org mode's footnotes are designed for work on a
1418 larger document, not only for one-off documents like emails.  The basic
1419 syntax is similar to the one used by @file{footnote.el}, i.e. a footnote is
1420 defined in a paragraph that is started by a footnote marker in square
1421 brackets in column 0, no indentation allowed.  If you need a paragraph break
1422 inside a footnote, use the La@TeX{} idiom @samp{\par}.  The footnote reference
1423 is simply the marker in square brackets, inside text.  For example:
1425 @example
1426 The Org homepage[fn:1] now looks a lot better than it used to.
1428 [fn:1] The link is: http://orgmode.org
1429 @end example
1431 Org mode extends the number-based syntax to @emph{named} footnotes and
1432 optional inline definition.  Using plain numbers as markers (as
1433 @file{footnote.el} does) is supported for backward compatibility, but not
1434 encouraged because of possible conflicts with La@TeX{} snippets (@pxref{Embedded
1435 LaTeX}).  Here are the valid references:
1437 @table @code
1438 @item [1]
1439 A plain numeric footnote marker.  Compatible with @file{footnote.el}, but not
1440 recommended because somthing like @samp{[1]} could easily be part of a code
1441 snippet.
1442 @item [fn:name]
1443 A named footnote reference, where @code{name} is a unique label word, or, for
1444 simplicity of automatic creation, a number.
1445 @item [fn:: This is the inline definition of this footnote]
1446 A La@TeX{}-like anonymous footnote where the definition is given directly at the
1447 reference point.
1448 @item [fn:name: a definition]
1449 An inline definition of a footnote, which also specifies a name for the note.
1450 Since Org allows multiple references to the same note, you can then use
1451 @code{[fn:name]} to create additional references.
1452 @end table
1454 @vindex org-footnote-auto-label
1455 Footnote labels can be created automatically, or you can create names yourself.
1456 This is handled by the variable @code{org-footnote-auto-label} and its
1457 corresponding @code{#+STARTUP} keywords, see the docstring of that variable
1458 for details.
1460 @noindent The following command handles footnotes:
1462 @table @kbd
1463 @kindex C-c C-x f
1464 @item C-c C-x f
1465 The footnote action command.
1467 When the cursor is on a footnote reference, jump to the definition.  When it
1468 is at a definition, jump to the (first) reference.
1470 @vindex org-footnote-define-inline
1471 @vindex org-footnote-section
1472 @vindex org-footnote-auto-adjust
1473 Otherwise, create a new footnote.  Depending on the variable
1474 @code{org-footnote-define-inline}@footnote{The corresponding in-buffer
1475 setting is: @code{#+STARTUP: fninline} or @code{#+STARTUP: nofninline}}, the
1476 definition will be placed right into the text as part of the reference, or
1477 separately into the location determined by the variable
1478 @code{org-footnote-section}.
1480 When this command is called with a prefix argument, a menu of additional
1481 options is offered:
1482 @example
1483 s   @r{Sort the footnote definitions by reference sequence.  During editing,}
1484     @r{Org makes no effort to sort footnote definitions into a particular}
1485     @r{sequence.  If you want them sorted, use this command, which will}
1486     @r{also move entries according to @code{org-footnote-section}.  Automatic}
1487     @r{sorting after each insertion/deletion can be configured using the}
1488     @r{variable @code{org-footnote-auto-adjust}.}
1489 r   @r{Renumber the simple @code{fn:N} footnotes.  Automatic renumbering}
1490     @r{after each insertion/deletion can be configured using the variable}
1491     @r{@code{org-footnote-auto-adjust}.}
1492 S   @r{Short for first @code{r}, then @code{s} action.}
1493 n   @r{Normalize the footnotes by collecting all definitions (including}
1494     @r{inline definitions) into a special section, and then numbering them}
1495     @r{in sequence.  The references will then also be numbers.  This is}
1496     @r{meant to be the final step before finishing a document (e.g. sending}
1497     @r{off an email).  The exporters do this automatically, and so could}
1498     @r{something like @code{message-send-hook}.}
1499 d   @r{Delete the footnote at point, and all definitions of and references}
1500     @r{to it.}
1501 @end example
1502 Depending on the variable @code{org-footnote-auto-adjust}@footnote{the
1503 corresponding in-buffer options are @code{fnadjust} and @code{nofnadjust}.},
1504 renumbering and sorting footnotes can be automatic after each insertion or
1505 deletion.
1507 @kindex C-c C-c
1508 @item C-c C-c
1509 If the cursor is on a footnote reference, jump to the definition.  If it is a
1510 the definition, jump back to the reference.  When called at a footnote
1511 location with a prefix argument, offer the same menu as @kbd{C-c C-x f}.
1512 @kindex C-c C-o
1513 @kindex mouse-1
1514 @kindex mouse-2
1515 @item C-c C-o  @r{or} mouse-1/2
1516 Footnote labels are also links to the corresponding definition/reference, and
1517 you can use the usual commands to follow these links.
1518 @end table
1520 @node Orgstruct mode,  , Footnotes, Document Structure
1521 @section The Orgstruct minor mode
1522 @cindex Orgstruct mode
1523 @cindex minor mode for structure editing
1525 If you like the intuitive way the Org mode structure editing and list
1526 formatting works, you might want to use these commands in other modes like
1527 Text mode or Mail mode as well.  The minor mode @code{orgstruct-mode} makes
1528 this possible.   Toggle the mode with @kbd{M-x orgstruct-mode}, or
1529 turn it on by default, for example in Mail mode, with one of:
1531 @lisp
1532 (add-hook 'mail-mode-hook 'turn-on-orgstruct)
1533 (add-hook 'mail-mode-hook 'turn-on-orgstruct++)
1534 @end lisp
1536 When this mode is active and the cursor is on a line that looks to Org like a
1537 headline or the first line of a list item, most structure editing commands
1538 will work, even if the same keys normally have different functionality in the
1539 major mode you are using.  If the cursor is not in one of those special
1540 lines, Orgstruct mode lurks silently in the shadow.  When you use
1541 @code{orgstruct++-mode}, Org will also export indentation and autofill
1542 settings into that mode, and detect item context after the first line of an
1543 item.
1545 @node Tables, Hyperlinks, Document Structure, Top
1546 @chapter Tables
1547 @cindex tables
1548 @cindex editing tables
1550 Org comes with a fast and intuitive table editor.  Spreadsheet-like
1551 calculations are supported in connection with the Emacs @file{calc}
1552 package
1553 @ifinfo
1554 (@pxref{Top,Calc,,Calc,Gnu Emacs Calculator Manual}).
1555 @end ifinfo
1556 @ifnotinfo
1557 (see the Emacs Calculator manual for more information about the Emacs
1558 calculator).
1559 @end ifnotinfo
1561 @menu
1562 * Built-in table editor::       Simple tables
1563 * Column width and alignment::  Overrule the automatic settings
1564 * Column groups::               Grouping to trigger vertical lines
1565 * Orgtbl mode::                 The table editor as minor mode
1566 * The spreadsheet::             The table editor has spreadsheet capabilities
1567 * Org-Plot::                    Plotting from org tables
1568 @end menu
1570 @node Built-in table editor, Column width and alignment, Tables, Tables
1571 @section The built-in table editor
1572 @cindex table editor, built-in
1574 Org makes it easy to format tables in plain ASCII.  Any line with
1575 @samp{|} as the first non-whitespace character is considered part of a
1576 table.  @samp{|} is also the column separator.  A table might look like
1577 this:
1579 @example
1580 | Name  | Phone | Age |
1581 |-------+-------+-----|
1582 | Peter |  1234 |  17 |
1583 | Anna  |  4321 |  25 |
1584 @end example
1586 A table is re-aligned automatically each time you press @key{TAB} or
1587 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
1588 the next field (@key{RET} to the next row) and creates new table rows
1589 at the end of the table or before horizontal lines.  The indentation
1590 of the table is set by the first line.  Any line starting with
1591 @samp{|-} is considered as a horizontal separator line and will be
1592 expanded on the next re-align to span the whole table width.  So, to
1593 create the above table, you would only type
1595 @example
1596 |Name|Phone|Age|
1598 @end example
1600 @noindent and then press @key{TAB} to align the table and start filling in
1601 fields.  Even faster would be to type @code{|Name|Phone|Age} followed by
1602 @kbd{C-c @key{RET}}.
1604 @vindex org-enable-table-editor
1605 @vindex org-table-auto-blank-field
1606 When typing text into a field, Org treats @key{DEL},
1607 @key{Backspace}, and all character keys in a special way, so that
1608 inserting and deleting avoids shifting other fields.  Also, when
1609 typing @emph{immediately after the cursor was moved into a new field
1610 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
1611 field is automatically made blank.  If this behavior is too
1612 unpredictable for you, configure the variables
1613 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
1615 @table @kbd
1616 @tsubheading{Creation and conversion}
1617 @kindex C-c |
1618 @item C-c |
1619 Convert the active region to table. If every line contains at least one
1620 TAB character, the function assumes that the material is tab separated.
1621 If every line contains a comma, comma-separated values (CSV) are assumed.
1622 If not, lines are split at whitespace into fields.  You can use a prefix
1623 argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
1624 C-u} forces TAB, and a numeric argument N indicates that at least N
1625 consecutive spaces, or alternatively a TAB will be the separator.
1627 If there is no active region, this command creates an empty Org
1628 table.  But it's easier just to start typing, like
1629 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
1631 @tsubheading{Re-aligning and field motion}
1632 @kindex C-c C-c
1633 @item C-c C-c
1634 Re-align the table without moving the cursor.
1636 @kindex @key{TAB}
1637 @item @key{TAB}
1638 Re-align the table, move to the next field.  Creates a new row if
1639 necessary.
1641 @kindex S-@key{TAB}
1642 @item S-@key{TAB}
1643 Re-align, move to previous field.
1645 @kindex @key{RET}
1646 @item @key{RET}
1647 Re-align the table and move down to next row.  Creates a new row if
1648 necessary.  At the beginning or end of a line, @key{RET} still does
1649 NEWLINE, so it can be used to split a table.
1651 @kindex M-a
1652 @item M-a
1653 Move to beginning of the current table field, or on to the previous field.
1654 @kindex M-e
1655 @item M-e
1656 Move to end of the current table field, or on to the next field.
1658 @tsubheading{Column and row editing}
1659 @kindex M-@key{left}
1660 @kindex M-@key{right}
1661 @item M-@key{left}
1662 @itemx M-@key{right}
1663 Move the current column left/right.
1665 @kindex M-S-@key{left}
1666 @item M-S-@key{left}
1667 Kill the current column.
1669 @kindex M-S-@key{right}
1670 @item M-S-@key{right}
1671 Insert a new column to the left of the cursor position.
1673 @kindex M-@key{up}
1674 @kindex M-@key{down}
1675 @item M-@key{up}
1676 @itemx M-@key{down}
1677 Move the current row up/down.
1679 @kindex M-S-@key{up}
1680 @item M-S-@key{up}
1681 Kill the current row or horizontal line.
1683 @kindex M-S-@key{down}
1684 @item M-S-@key{down}
1685 Insert a new row above the current row.  With a prefix argument, the line is
1686 created below the current one.
1688 @kindex C-c -
1689 @item C-c -
1690 Insert a horizontal line below current row.  With a prefix argument, the line
1691 is created above the current line.
1693 @kindex C-c @key{RET}
1694 @item C-c @key{RET}
1695 Insert a horizontal line below current row, and move the cursor into the row
1696 below that line.
1698 @kindex C-c ^
1699 @item C-c ^
1700 Sort the table lines in the region.  The position of point indicates the
1701 column to be used for sorting, and the range of lines is the range
1702 between the nearest horizontal separator lines, or the entire table.  If
1703 point is before the first column, you will be prompted for the sorting
1704 column.  If there is an active region, the mark specifies the first line
1705 and the sorting column, while point should be in the last line to be
1706 included into the sorting.  The command prompts for the sorting type
1707 (alphabetically, numerically, or by time).  When called with a prefix
1708 argument, alphabetic sorting will be case-sensitive.
1710 @tsubheading{Regions}
1711 @kindex C-c C-x M-w
1712 @item C-c C-x M-w
1713 Copy a rectangular region from a table to a special clipboard.  Point and
1714 mark determine edge fields of the rectangle.  If there is no active region,
1715 copy just the current field.  The process ignores horizontal separator lines.
1717 @kindex C-c C-x C-w
1718 @item C-c C-x C-w
1719 Copy a rectangular region from a table to a special clipboard, and
1720 blank all fields in the rectangle.  So this is the ``cut'' operation.
1722 @kindex C-c C-x C-y
1723 @item C-c C-x C-y
1724 Paste a rectangular region into a table.
1725 The upper left corner ends up in the current field.  All involved fields
1726 will be overwritten.  If the rectangle does not fit into the present table,
1727 the table is enlarged as needed.  The process ignores horizontal separator
1728 lines.
1730 @kindex M-@key{RET}
1731 @itemx M-@kbd{RET}
1732 Wrap several fields in a column like a paragraph.  If there is an active
1733 region, and both point and mark are in the same column, the text in the
1734 column is wrapped to minimum width for the given number of lines.  A numeric
1735 prefix argument may be used to change the number of desired lines.  If there
1736 is no region, the current field is split at the cursor position and the text
1737 fragment to the right of the cursor is prepended to the field one line
1738 down. If there is no region, but you specify a prefix argument, the current
1739 field is made blank, and the content is appended to the field above.
1741 @tsubheading{Calculations}
1742 @cindex formula, in tables
1743 @cindex calculations, in tables
1744 @cindex region, active
1745 @cindex active region
1746 @cindex transient mark mode
1747 @kindex C-c +
1748 @item C-c +
1749 Sum the numbers in the current column, or in the rectangle defined by
1750 the active region.  The result is shown in the echo area and can
1751 be inserted with @kbd{C-y}.
1753 @kindex S-@key{RET}
1754 @item S-@key{RET}
1755 @vindex org-table-copy-increment
1756 When current field is empty, copy from first non-empty field above.  When not
1757 empty, copy current field down to next row and move cursor along with it.
1758 Depending on the variable @code{org-table-copy-increment}, integer field
1759 values will be incremented during copy.  Integers that are too large will not
1760 be incremented.  Also, a @code{0} prefix argument temporarily disables the
1761 increment.  This key is also used by shift-selection and related modes
1762 (@pxref{Conflicts}).
1764 @tsubheading{Miscellaneous}
1765 @kindex C-c `
1766 @item C-c `
1767 Edit the current field in a separate window.  This is useful for fields that
1768 are not fully visible (@pxref{Column width and alignment}).  When called with
1769 a @kbd{C-u} prefix, just make the full field visible, so that it can be
1770 edited in place.
1772 @item M-x org-table-import
1773 Import a file as a table.  The table should be TAB or whitespace
1774 separated.  Use, for example, to import a spreadsheet table or data
1775 from a database, because these programs generally can write
1776 TAB-separated text files.  This command works by inserting the file into
1777 the buffer and then converting the region to a table.  Any prefix
1778 argument is passed on to the converter, which uses it to determine the
1779 separator.
1780 @item C-c |
1781 Tables can also be imported by pasting tabular text into the Org
1782 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
1783 @kbd{C-c |} command (see above under @i{Creation and conversion}).
1785 @item M-x org-table-export
1786 @vindex org-table-export-default-format
1787 Export the table, by default as a TAB-separated file.  Use for data
1788 exchange with, for example, spreadsheet or database programs.  The format
1789 used to export the file can be configured in the variable
1790 @code{org-table-export-default-format}.  You may also use properties
1791 @code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
1792 name and the format for table export in a subtree.  Org supports quite
1793 general formats for exported tables.  The exporter format is the same as the
1794 format used by Orgtbl radio tables, see @ref{Translator functions}, for a
1795 detailed description.
1796 @end table
1798 If you don't like the automatic table editor because it gets in your
1799 way on lines which you would like to start with @samp{|}, you can turn
1800 it off with
1802 @lisp
1803 (setq org-enable-table-editor nil)
1804 @end lisp
1806 @noindent Then the only table command that still works is
1807 @kbd{C-c C-c} to do a manual re-align.
1809 @node Column width and alignment, Column groups, Built-in table editor, Tables
1810 @section Column width and alignment
1811 @cindex narrow columns in tables
1812 @cindex alignment in tables
1814 The width of columns is automatically determined by the table editor.  And
1815 also the alignment of a column is determined automatically from the fraction
1816 of number-like versus non-number fields in the column.
1818 Sometimes a single field or a few fields need to carry more text,
1819 leading to inconveniently wide columns.  To limit@footnote{This feature
1820 does not work on XEmacs.} the width of a column, one field anywhere in
1821 the column may contain just the string @samp{<N>} where @samp{N} is an
1822 integer specifying the width of the column in characters.  The next
1823 re-align will then set the width of this column to no more than this
1824 value.
1826 @example
1827 @group
1828 |---+------------------------------|               |---+--------|
1829 |   |                              |               |   | <6>    |
1830 | 1 | one                          |               | 1 | one    |
1831 | 2 | two                          |     ----\     | 2 | two    |
1832 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
1833 | 4 | four                         |               | 4 | four   |
1834 |---+------------------------------|               |---+--------|
1835 @end group
1836 @end example
1838 @noindent
1839 Fields that are wider become clipped and end in the string @samp{=>}.
1840 Note that the full text is still in the buffer, it is only invisible.
1841 To see the full text, hold the mouse over the field---a tool-tip window
1842 will show the full content.  To edit such a field, use the command
1843 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
1844 open a new window with the full field.  Edit it and finish with @kbd{C-c
1845 C-c}.
1847 @vindex org-startup-align-all-tables
1848 When visiting a file containing a table with narrowed columns, the
1849 necessary character hiding has not yet happened, and the table needs to
1850 be aligned before it looks nice.  Setting the option
1851 @code{org-startup-align-all-tables} will realign all tables in a file
1852 upon visiting, but also slow down startup.  You can also set this option
1853 on a per-file basis with:
1855 @example
1856 #+STARTUP: align
1857 #+STARTUP: noalign
1858 @end example
1860 If you would like to overrule the automatic alignment of number-rich columns
1861 to the right and of string-rich column to the left, you and use @samp{<r>} or
1862 @samp{<l>} in a similar fashion.  You may also combine alignment and field
1863 width like this: @samp{<l10>}.
1865 @node Column groups, Orgtbl mode, Column width and alignment, Tables
1866 @section Column groups
1867 @cindex grouping columns in tables
1869 When Org exports tables, it does so by default without vertical
1870 lines because that is visually more satisfying in general.  Occasionally
1871 however, vertical lines can be useful to structure a table into groups
1872 of columns, much like horizontal lines can do for groups of rows.  In
1873 order to specify column groups, you can use a special row where the
1874 first field contains only @samp{/}.  The further fields can either
1875 contain @samp{<} to indicate that this column should start a group,
1876 @samp{>} to indicate the end of a column, or @samp{<>} to make a column
1877 a group of its own.  Boundaries between column groups will upon export be
1878 marked with vertical lines.  Here is an example:
1880 @example
1881 |   |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1882 |---+----+-----+-----+-----+---------+------------|
1883 | / | <> |   < |     |   > |       < |          > |
1884 | # |  1 |   1 |   1 |   1 |       1 |          1 |
1885 | # |  2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
1886 | # |  3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
1887 |---+----+-----+-----+-----+---------+------------|
1888 #+TBLFM: $3=$2^2::$4=$2^3::$5=$2^4::$6=sqrt($2)::$7=sqrt(sqrt(($2)))
1889 @end example
1891 It is also sufficient to just insert the column group starters after
1892 every vertical line you'd like to have:
1894 @example
1895 |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1896 |----+-----+-----+-----+---------+------------|
1897 | /  | <   |     |     | <       |            |
1898 @end example
1900 @node Orgtbl mode, The spreadsheet, Column groups, Tables
1901 @section The Orgtbl minor mode
1902 @cindex Orgtbl mode
1903 @cindex minor mode for tables
1905 If you like the intuitive way the Org table editor works, you
1906 might also want to use it in other modes like Text mode or Mail mode.
1907 The minor mode Orgtbl mode makes this possible.  You can always toggle
1908 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
1909 example in mail mode, use
1911 @lisp
1912 (add-hook 'mail-mode-hook 'turn-on-orgtbl)
1913 @end lisp
1915 Furthermore, with some special setup, it is possible to maintain tables
1916 in arbitrary syntax with Orgtbl mode.  For example, it is possible to
1917 construct La@TeX{} tables with the underlying ease and power of
1918 Orgtbl mode, including spreadsheet capabilities.  For details, see
1919 @ref{Tables in arbitrary syntax}.
1921 @node The spreadsheet, Org-Plot, Orgtbl mode, Tables
1922 @section The spreadsheet
1923 @cindex calculations, in tables
1924 @cindex spreadsheet capabilities
1925 @cindex @file{calc} package
1927 The table editor makes use of the Emacs @file{calc} package to implement
1928 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
1929 derive fields from other fields.  While fully featured, Org's
1930 implementation is not identical to other spreadsheets.  For example,
1931 Org knows the concept of a @emph{column formula} that will be
1932 applied to all non-header fields in a column without having to copy the
1933 formula to each relevant field.
1935 @menu
1936 * References::                  How to refer to another field or range
1937 * Formula syntax for Calc::     Using Calc to compute stuff
1938 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
1939 * Field formulas::              Formulas valid for a single field
1940 * Column formulas::             Formulas valid for an entire column
1941 * Editing and debugging formulas::  Fixing formulas
1942 * Updating the table::          Recomputing all dependent fields
1943 * Advanced features::           Field names, parameters and automatic recalc
1944 @end menu
1946 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
1947 @subsection References
1948 @cindex references
1950 To compute fields in the table from other fields, formulas must
1951 reference other fields or ranges.  In Org, fields can be referenced
1952 by name, by absolute coordinates, and by relative coordinates.  To find
1953 out what the coordinates of a field are, press @kbd{C-c ?} in that
1954 field, or press @kbd{C-c @}} to toggle the display of a grid.
1956 @subsubheading Field references
1957 @cindex field references
1958 @cindex references, to fields
1960 Formulas can reference the value of another field in two ways.  Like in
1961 any other spreadsheet, you may reference fields with a letter/number
1962 combination like @code{B3}, meaning the 2nd field in the 3rd row.
1963 @c Such references are always fixed to that field, they don't change
1964 @c when you copy and paste a formula to a different field.  So
1965 @c Org's @code{B3} behaves like @code{$B$3} in other spreadsheets.
1967 @noindent
1968 Org also uses another, more general operator that looks like this:
1969 @example
1970 @@@var{row}$@var{column}
1971 @end example
1973 @noindent
1974 Column references can be absolute like @samp{1}, @samp{2},...@samp{@var{N}},
1975 or relative to the current column like @samp{+1} or @samp{-2}.
1977 The row specification only counts data lines and ignores horizontal
1978 separator lines (hlines).  You can use absolute row numbers
1979 @samp{1}...@samp{@var{N}}, and row numbers relative to the current row like
1980 @samp{+3} or @samp{-1}.  Or specify the row relative to one of the
1981 hlines: @samp{I} refers to the first hline@footnote{Note that only
1982 hlines are counted that @emph{separate} table lines.  If the table
1983 starts with a hline above the header, it does not count.}, @samp{II} to
1984 the second, etc@.  @samp{-I} refers to the first such line above the
1985 current line, @samp{+I} to the first such line below the current line.
1986 You can also write @samp{III+2} which is the second data line after the
1987 third hline in the table.
1989 @samp{0} refers to the current row and column.  Also, if you omit
1990 either the column or the row part of the reference, the current
1991 row/column is implied.
1993 Org's references with @emph{unsigned} numbers are fixed references
1994 in the sense that if you use the same reference in the formula for two
1995 different fields, the same field will be referenced each time.
1996 Org's references with @emph{signed} numbers are floating
1997 references because the same reference operator can reference different
1998 fields depending on the field being calculated by the formula.
2000 As a special case, references like @samp{$LR5} and @samp{$LR12} can be used
2001 to refer in a stable way to the 5th and 12th field in the last row of the
2002 table.
2004 Here are a few examples:
2006 @example
2007 @@2$3      @r{2nd row, 3rd column}
2008 C2        @r{same as previous}
2009 $5        @r{column 5 in the current row}
2010 E&        @r{same as previous}
2011 @@2        @r{current column, row 2}
2012 @@-1$-3    @r{the field one row up, three columns to the left}
2013 @@-I$2     @r{field just under hline above current row, column 2}
2014 @end example
2016 @subsubheading Range references
2017 @cindex range references
2018 @cindex references, to ranges
2020 You may reference a rectangular range of fields by specifying two field
2021 references connected by two dots @samp{..}.  If both fields are in the
2022 current row, you may simply use @samp{$2..$7}, but if at least one field
2023 is in a different row, you need to use the general @code{@@row$column}
2024 format at least for the first field (i.e the reference must start with
2025 @samp{@@} in order to be interpreted correctly).  Examples:
2027 @example
2028 $1..$3        @r{First three fields in the current row.}
2029 $P..$Q        @r{Range, using column names (see under Advanced)}
2030 @@2$1..@@4$3    @r{6 fields between these two fields.}
2031 A2..C4        @r{Same as above.}
2032 @@-1$-2..@@-1   @r{3 numbers from the column to the left, 2 up to current row}
2033 @end example
2035 @noindent Range references return a vector of values that can be fed
2036 into Calc vector functions.  Empty fields in ranges are normally
2037 suppressed, so that the vector contains only the non-empty fields (but
2038 see the @samp{E} mode switch below).  If there are no non-empty fields,
2039 @samp{[0]} is returned to avoid syntax errors in formulas.
2041 @subsubheading Named references
2042 @cindex named references
2043 @cindex references, named
2044 @cindex name, of column or field
2045 @cindex constants, in calculations
2046 @cindex #+CONSTANTS
2048 @vindex org-table-formula-constants
2049 @samp{$name} is interpreted as the name of a column, parameter or
2050 constant.  Constants are defined globally through the variable
2051 @code{org-table-formula-constants}, and locally (for the file) through a
2052 line like
2054 @example
2055 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
2056 @end example
2058 @noindent
2059 @vindex constants-unit-system
2060 @pindex constants.el
2061 Also properties (@pxref{Properties and Columns}) can be used as
2062 constants in table formulas: for a property @samp{:Xyz:} use the name
2063 @samp{$PROP_Xyz}, and the property will be searched in the current
2064 outline entry and in the hierarchy above it.  If you have the
2065 @file{constants.el} package, it will also be used to resolve constants,
2066 including natural constants like @samp{$h} for Planck's constant, and
2067 units like @samp{$km} for kilometers@footnote{@file{constants.el} can
2068 supply the values of constants in two different unit systems, @code{SI}
2069 and @code{cgs}.  Which one is used depends on the value of the variable
2070 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
2071 @code{constSI} and @code{constcgs} to set this value for the current
2072 buffer.}.  Column names and parameters can be specified in special table
2073 lines.  These are described below, see @ref{Advanced features}.  All
2074 names must start with a letter, and further consist of letters and
2075 numbers.
2077 @subsubheading Remote references
2078 @cindex remote references
2079 @cindex references, remote
2080 @cindex references, to a different table
2081 @cindex name, of column or field
2082 @cindex constants, in calculations
2083 @cindex #+TBLNAME
2085 You may also reference constants, fields and ranges from a different table,
2086 either in the current file or even in a different file.  The syntax is
2088 @example
2089 remote(NAME-OR-ID,REF)
2090 @end example
2092 @noindent
2093 where NAME can be the name of a table in the current file as set by a
2094 @code{#+TBLNAME: NAME} line before the table.  It can also be the ID of an
2095 entry, even in a different file, and the reference then refers to the first
2096 table in that entry.  REF is an absolute field or range reference as
2097 described above for example @code{@@3$3} or @code{$somename}, valid in the
2098 referenced table.
2100 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
2101 @subsection Formula syntax for Calc
2102 @cindex formula syntax, Calc
2103 @cindex syntax, of formulas
2105 A formula can be any algebraic expression understood by the Emacs
2106 @file{Calc} package.  @b{Note that @file{calc} has the
2107 non-standard convention that @samp{/} has lower precedence than
2108 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
2109 evaluation by @code{calc-eval} (@pxref{Calling Calc from
2110 Your Programs,calc-eval,Calling Calc from Your Lisp Programs,Calc,GNU
2111 Emacs Calc Manual}),
2112 @c FIXME:  The link to the Calc manual in HTML does not work.
2113 variable substitution takes place according to the rules described above.
2114 @cindex vectors, in table calculations
2115 The range vectors can be directly fed into the Calc vector functions
2116 like @samp{vmean} and @samp{vsum}.
2118 @cindex format specifier
2119 @cindex mode, for @file{calc}
2120 @vindex org-calc-default-modes
2121 A formula can contain an optional mode string after a semicolon.  This
2122 string consists of flags to influence Calc and other modes during
2123 execution.  By default, Org uses the standard Calc modes (precision
2124 12, angular units degrees, fraction and symbolic modes off).  The display
2125 format, however, has been changed to @code{(float 8)} to keep tables
2126 compact.  The default settings can be configured using the variable
2127 @code{org-calc-default-modes}.
2129 @example
2130 p20           @r{switch the internal precision to 20 digits}
2131 n3 s3 e2 f4   @r{normal, scientific, engineering, or fixed display format}
2132 D R           @r{angle modes: degrees, radians}
2133 F S           @r{fraction and symbolic modes}
2134 N             @r{interpret all fields as numbers, use 0 for non-numbers}
2135 T             @r{force text interpretation}
2136 E             @r{keep empty fields in ranges}
2137 L             @r{literal}
2138 @end example
2140 @noindent
2141 In addition, you may provide a @code{printf} format specifier to
2142 reformat the final result.  A few examples:
2144 @example
2145 $1+$2                @r{Sum of first and second field}
2146 $1+$2;%.2f           @r{Same, format result to two decimals}
2147 exp($2)+exp($1)      @r{Math functions can be used}
2148 $0;%.1f              @r{Reformat current cell to 1 decimal}
2149 ($3-32)*5/9          @r{Degrees F -> C conversion}
2150 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
2151 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
2152 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
2153 vmean($2..$7)        @r{Compute column range mean, using vector function}
2154 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
2155 taylor($3,x=7,2)     @r{taylor series of $3, at x=7, second degree}
2156 @end example
2158 Calc also contains a complete set of logical operations.  For example
2160 @example
2161 if($1<20,teen,string(""))  @r{``teen'' if age $1 less than 20, else empty}
2162 @end example
2164 @node Formula syntax for Lisp, Field formulas, Formula syntax for Calc, The spreadsheet
2165 @subsection Emacs Lisp forms as formulas
2166 @cindex Lisp forms, as table formulas
2168 It is also possible to write a formula in Emacs Lisp; this can be useful
2169 for string manipulation and control structures, if Calc's
2170 functionality is not enough.  If a formula starts with a single-quote
2171 followed by an opening parenthesis, then it is evaluated as a Lisp form.
2172 The evaluation should return either a string or a number.  Just as with
2173 @file{calc} formulas, you can specify modes and a printf format after a
2174 semicolon.  With Emacs Lisp forms, you need to be conscious about the way
2175 field references are interpolated into the form.  By default, a
2176 reference will be interpolated as a Lisp string (in double-quotes)
2177 containing the field.  If you provide the @samp{N} mode switch, all
2178 referenced elements will be numbers (non-number fields will be zero) and
2179 interpolated as Lisp numbers, without quotes.  If you provide the
2180 @samp{L} flag, all fields will be interpolated literally, without quotes.
2181 I.e., if you want a reference to be interpreted as a string by the Lisp
2182 form, enclose the reference operator itself in double-quotes, like
2183 @code{"$3"}.  Ranges are inserted as space-separated fields, so you can
2184 embed them in list or vector syntax.  A few examples, note how the
2185 @samp{N} mode is used when we do computations in Lisp.
2187 @example
2188 @r{Swap the first two characters of the content of column 1}
2189   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
2190 @r{Add columns 1 and 2, equivalent to Calc's @code{$1+$2}}
2191   '(+ $1 $2);N
2192 @r{Compute the sum of columns 1-4, like Calc's @code{vsum($1..$4)}}
2193   '(apply '+ '($1..$4));N
2194 @end example
2196 @node Field formulas, Column formulas, Formula syntax for Lisp, The spreadsheet
2197 @subsection Field formulas
2198 @cindex field formula
2199 @cindex formula, for individual table field
2201 To assign a formula to a particular field, type it directly into the
2202 field, preceded by @samp{:=}, for example @samp{:=$1+$2}.  When you
2203 press @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in
2204 the field, the formula will be stored as the formula for this field,
2205 evaluated, and the current field replaced with the result.
2207 @cindex #+TBLFM
2208 Formulas are stored in a special line starting with @samp{#+TBLFM:}
2209 directly below the table.  If you typed the equation in the 4th field of
2210 the 3rd data line in the table, the formula will look like
2211 @samp{@@3$4=$1+$2}.  When inserting/deleting/swapping column and rows
2212 with the appropriate commands, @i{absolute references} (but not relative
2213 ones) in stored formulas are modified in order to still reference the
2214 same field.  Of course this is not true if you edit the table structure
2215 with normal editing commands---then you must fix the equations yourself.
2216 The left-hand side of a formula may also be a named field (@pxref{Advanced
2217 features}), or a last-row reference like @samp{$LR3}.
2219 Instead of typing an equation into the field, you may also use the
2220 following command
2222 @table @kbd
2223 @kindex C-u C-c =
2224 @item C-u C-c =
2225 Install a new formula for the current field.  The command prompts for a
2226 formula with default taken from the @samp{#+TBLFM:} line, applies
2227 it to the current field, and stores it.
2228 @end table
2230 @node Column formulas, Editing and debugging formulas, Field formulas, The spreadsheet
2231 @subsection Column formulas
2232 @cindex column formula
2233 @cindex formula, for table column
2235 Often in a table, the same formula should be used for all fields in a
2236 particular column.  Instead of having to copy the formula to all fields
2237 in that column, Org allows you to assign a single formula to an entire
2238 column.  If the table contains horizontal separator hlines, everything
2239 before the first such line is considered part of the table @emph{header}
2240 and will not be modified by column formulas.
2242 To assign a formula to a column, type it directly into any field in the
2243 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
2244 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the field,
2245 the formula will be stored as the formula for the current column, evaluated
2246 and the current field replaced with the result.  If the field contains only
2247 @samp{=}, the previously stored formula for this column is used.  For each
2248 column, Org will only remember the most recently used formula.  In the
2249 @samp{#+TBLFM:} line, column formulas will look like @samp{$4=$1+$2}.  The left-hand
2250 side of a column formula cannot currently be the name of column, it
2251 must be the numeric column reference.
2253 Instead of typing an equation into the field, you may also use the
2254 following command:
2256 @table @kbd
2257 @kindex C-c =
2258 @item C-c =
2259 Install a new formula for the current column and replace current field with
2260 the result of the formula.  The command prompts for a formula, with default
2261 taken from the @samp{#+TBLFM} line, applies it to the current field and
2262 stores it.  With a numeric prefix argument(e.g. @kbd{C-5 C-c =}) the command
2263 will apply it to that many consecutive fields in the current column.
2264 @end table
2266 @node Editing and debugging formulas, Updating the table, Column formulas, The spreadsheet
2267 @subsection Editing and debugging formulas
2268 @cindex formula editing
2269 @cindex editing, of table formulas
2271 @vindex org-table-use-standard-references
2272 You can edit individual formulas in the minibuffer or directly in the
2273 field.  Org can also prepare a special buffer with all active
2274 formulas of a table.  When offering a formula for editing, Org
2275 converts references to the standard format (like @code{B3} or @code{D&})
2276 if possible.  If you prefer to only work with the internal format (like
2277 @code{@@3$2} or @code{$4}), configure the variable
2278 @code{org-table-use-standard-references}.
2280 @table @kbd
2281 @kindex C-c =
2282 @kindex C-u C-c =
2283 @item C-c =
2284 @itemx C-u C-c =
2285 Edit the formula associated with the current column/field in the
2286 minibuffer.  See @ref{Column formulas}, and @ref{Field formulas}.
2287 @kindex C-u C-u C-c =
2288 @item C-u C-u C-c =
2289 Re-insert the active formula (either a
2290 field formula, or a column formula) into the current field, so that you
2291 can edit it directly in the field.  The advantage over editing in the
2292 minibuffer is that you can use the command @kbd{C-c ?}.
2293 @kindex C-c ?
2294 @item C-c ?
2295 While editing a formula in a table field, highlight the field(s)
2296 referenced by the reference at the cursor position in the formula.
2297 @kindex C-c @}
2298 @item C-c @}
2299 Toggle the display of row and column numbers for a table, using
2300 overlays.  These are updated each time the table is aligned; you can
2301 force it with @kbd{C-c C-c}.
2302 @kindex C-c @{
2303 @item C-c @{
2304 Toggle the formula debugger on and off.  See below.
2305 @kindex C-c '
2306 @item C-c '
2307 Edit all formulas for the current table in a special buffer, where the
2308 formulas will be displayed one per line.  If the current field has an
2309 active formula, the cursor in the formula editor will mark it.
2310 While inside the special buffer, Org will automatically highlight
2311 any field or range reference at the cursor position.  You may edit,
2312 remove and add formulas, and use the following commands:
2313 @table @kbd
2314 @kindex C-c C-c
2315 @kindex C-x C-s
2316 @item C-c C-c
2317 @itemx C-x C-s
2318 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
2319 prefix, also apply the new formulas to the entire table.
2320 @kindex C-c C-q
2321 @item C-c C-q
2322 Exit the formula editor without installing changes.
2323 @kindex C-c C-r
2324 @item C-c C-r
2325 Toggle all references in the formula editor between standard (like
2326 @code{B3}) and internal (like @code{@@3$2}).
2327 @kindex @key{TAB}
2328 @item @key{TAB}
2329 Pretty-print or indent Lisp formula at point.  When in a line containing
2330 a Lisp formula, format the formula according to Emacs Lisp rules.
2331 Another @key{TAB} collapses the formula back again.  In the open
2332 formula, @key{TAB} re-indents just like in Emacs Lisp mode.
2333 @kindex M-@key{TAB}
2334 @item M-@key{TAB}
2335 Complete Lisp symbols, just like in Emacs Lisp mode.
2336 @kindex S-@key{up}
2337 @kindex S-@key{down}
2338 @kindex S-@key{left}
2339 @kindex S-@key{right}
2340 @item S-@key{up}/@key{down}/@key{left}/@key{right}
2341 Shift the reference at point.  For example, if the reference is
2342 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
2343 This also works for relative references and for hline references.
2344 @kindex M-S-@key{up}
2345 @kindex M-S-@key{down}
2346 @item M-S-@key{up}/@key{down}
2347 Move the test line for column formulas in the Org buffer up and
2348 down.
2349 @kindex M-@key{up}
2350 @kindex M-@key{down}
2351 @item M-@key{up}/@key{down}
2352 Scroll the window displaying the table.
2353 @kindex C-c @}
2354 @item C-c @}
2355 Turn the coordinate grid in the table on and off.
2356 @end table
2357 @end table
2359 Making a table field blank does not remove the formula associated with
2360 the field, because that is stored in a different line (the @samp{#+TBLFM}
2361 line)---during the next recalculation the field will be filled again.
2362 To remove a formula from a field, you have to give an empty reply when
2363 prompted for the formula, or to edit the @samp{#+TBLFM} line.
2365 @kindex C-c C-c
2366 You may edit the @samp{#+TBLFM} directly and re-apply the changed
2367 equations with @kbd{C-c C-c} in that line or with the normal
2368 recalculation commands in the table.
2370 @subsubheading Debugging formulas
2371 @cindex formula debugging
2372 @cindex debugging, of table formulas
2373 When the evaluation of a formula leads to an error, the field content
2374 becomes the string @samp{#ERROR}.  If you would like see what is going
2375 on during variable substitution and calculation in order to find a bug,
2376 turn on formula debugging in the @code{Tbl} menu and repeat the
2377 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
2378 field.  Detailed information will be displayed.
2380 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
2381 @subsection Updating the table
2382 @cindex recomputing table fields
2383 @cindex updating, table
2385 Recalculation of a table is normally not automatic, but needs to be
2386 triggered by a command.  See @ref{Advanced features}, for a way to make
2387 recalculation at least semi-automatic.
2389 In order to recalculate a line of a table or the entire table, use the
2390 following commands:
2392 @table @kbd
2393 @kindex C-c *
2394 @item C-c *
2395 Recalculate the current row by first applying the stored column formulas
2396 from left to right, and all field formulas in the current row.
2398 @kindex C-u C-c *
2399 @item C-u C-c *
2400 @kindex C-u C-c C-c
2401 @itemx C-u C-c C-c
2402 Recompute the entire table, line by line.  Any lines before the first
2403 hline are left alone, assuming that these are part of the table header.
2405 @kindex C-u C-u C-c *
2406 @kindex C-u C-u C-c C-c
2407 @item C-u C-u C-c *
2408 @itemx C-u C-u C-c C-c
2409 Iterate the table by recomputing it until no further changes occur.
2410 This may be necessary if some computed fields use the value of other
2411 fields that are computed @i{later} in the calculation sequence.
2412 @end table
2414 @node Advanced features,  , Updating the table, The spreadsheet
2415 @subsection Advanced features
2417 If you want the recalculation of fields to happen automatically, or if
2418 you want to be able to assign @i{names} to fields and columns, you need
2419 to reserve the first column of the table for special marking characters.
2420 @table @kbd
2421 @kindex C-#
2422 @item C-#
2423 Rotate the calculation mark in first column through the states @samp{ },
2424 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  When there is an active region,
2425 change all marks in the region.
2426 @end table
2428 Here is an example of a table that collects exam results of students and
2429 makes use of these features:
2431 @example
2432 @group
2433 |---+---------+--------+--------+--------+-------+------|
2434 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2435 |---+---------+--------+--------+--------+-------+------|
2436 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2437 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2438 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2439 |---+---------+--------+--------+--------+-------+------|
2440 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
2441 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
2442 |---+---------+--------+--------+--------+-------+------|
2443 |   | Average |        |        |        |  29.7 |      |
2444 | ^ |         |        |        |        |    at |      |
2445 | $ | max=50  |        |        |        |       |      |
2446 |---+---------+--------+--------+--------+-------+------|
2447 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
2448 @end group
2449 @end example
2451 @noindent @b{Important}: please note that for these special tables,
2452 recalculating the table with @kbd{C-u C-c *} will only affect rows that
2453 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
2454 to the field itself.  The column formulas are not applied in rows with
2455 empty first field.
2457 @cindex marking characters, tables
2458 The marking characters have the following meaning:
2459 @table @samp
2460 @item !
2461 The fields in this line define names for the columns, so that you may
2462 refer to a column as @samp{$Tot} instead of @samp{$6}.
2463 @item ^
2464 This row defines names for the fields @emph{above} the row.  With such
2465 a definition, any formula in the table may use @samp{$m1} to refer to
2466 the value @samp{10}.  Also, if you assign a formula to a names field, it
2467 will be stored as @samp{$name=...}.
2468 @item _
2469 Similar to @samp{^}, but defines names for the fields in the row
2470 @emph{below}.
2471 @item $
2472 Fields in this row can define @emph{parameters} for formulas.  For
2473 example, if a field in a @samp{$} row contains @samp{max=50}, then
2474 formulas in this table can refer to the value 50 using @samp{$max}.
2475 Parameters work exactly like constants, only that they can be defined on
2476 a per-table basis.
2477 @item #
2478 Fields in this row are automatically recalculated when pressing
2479 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
2480 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
2481 lines will be left alone by this command.
2482 @item *
2483 Selects this line for global recalculation with @kbd{C-u C-c *}, but
2484 not for automatic recalculation.  Use this when automatic
2485 recalculation slows down editing too much.
2486 @item
2487 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
2488 All lines that should be recalculated should be marked with @samp{#}
2489 or @samp{*}.
2490 @item /
2491 Do not export this line.  Useful for lines that contain the narrowing
2492 @samp{<N>} markers or column group markers.
2493 @end table
2495 Finally, just to whet your appetite for what can be done with the
2496 fantastic @file{calc.el} package, here is a table that computes the Taylor
2497 series of degree @code{n} at location @code{x} for a couple of
2498 functions.
2500 @example
2501 @group
2502 |---+-------------+---+-----+--------------------------------------|
2503 |   | Func        | n | x   | Result                               |
2504 |---+-------------+---+-----+--------------------------------------|
2505 | # | exp(x)      | 1 | x   | 1 + x                                |
2506 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
2507 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
2508 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
2509 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
2510 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
2511 |---+-------------+---+-----+--------------------------------------|
2512 #+TBLFM: $5=taylor($2,$4,$3);n3
2513 @end group
2514 @end example
2516 @node Org-Plot,  , The spreadsheet, Tables
2517 @section Org-Plot
2518 @cindex graph, in tables
2519 @cindex plot tables using gnuplot
2520 @cindex #+PLOT
2522 Org-Plot can produce 2D and 3D graphs of information stored in org tables
2523 using @file{Gnuplot} @uref{http://www.gnuplot.info/} and @file{gnuplot-mode}
2524 @uref{http://cars9.uchicago.edu/~ravel/software/gnuplot-mode.html}.  To see
2525 this in action, ensure that you have both Gnuplot and Gnuplot mode installed
2526 on your system, then call @code{org-plot/gnuplot} on the following table.
2528 @example
2529 @group
2530 #+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
2531 | Sede      | Max cites | H-index |
2532 |-----------+-----------+---------|
2533 | Chile     |    257.72 |   21.39 |
2534 | Leeds     |    165.77 |   19.68 |
2535 | Sao Paolo |     71.00 |   11.50 |
2536 | Stockholm |    134.19 |   14.33 |
2537 | Morelia   |    257.56 |   17.67 |
2538 @end group
2539 @end example
2541 Notice that Org Plot is smart enough to apply the table's headers as labels.
2542 Further control over the labels, type, content, and appearance of plots can
2543 be exercised through the @code{#+PLOT:} lines preceding a table.  See below
2544 for a complete list of Org-plot options.  For more information and examples
2545 see the Org-plot tutorial at
2546 @uref{http://orgmode.org/worg/org-tutorials/org-plot.php}.
2548 @subsubheading Plot Options
2550 @table @code
2551 @item set
2552 Specify any @command{gnuplot} option to be set when graphing.
2554 @item title
2555 Specify the title of the plot.
2557 @item ind
2558 Specify which column of the table to use as the @code{x} axis.
2560 @item deps
2561 Specify the columns to graph as a Lisp style list, surrounded by parentheses
2562 and separated by spaces for example @code{dep:(3 4)} to graph the third and
2563 fourth columns (defaults to graphing all other columns aside from the @code{ind}
2564 column).
2566 @item type
2567 Specify whether the plot will be @code{2d}, @code{3d}, or @code{grid}.
2569 @item with
2570 Specify a @code{with} option to be inserted for every col being plotted
2571 (e.g. @code{lines}, @code{points}, @code{boxes}, @code{impulses}, etc...).
2572 Defaults to @code{lines}.
2574 @item file
2575 If you want to plot to a file, specify @code{"@var{path/to/desired/output-file}"}.
2577 @item labels
2578 List of labels to be used for the deps (defaults to the column headers if
2579 they exist).
2581 @item line
2582 Specify an entire line to be inserted in the Gnuplot script.
2584 @item map
2585 When plotting @code{3d} or @code{grid} types, set this to @code{t} to graph a
2586 flat mapping rather than a @code{3d} slope.
2588 @item timefmt
2589 Specify format of Org-mode timestamps as they will be parsed by Gnuplot.
2590 Defaults to @samp{%Y-%m-%d-%H:%M:%S}.
2592 @item script
2593 If you want total control, you can specify a script file (place the file name
2594 between double-quotes) which will be used to plot.  Before plotting, every
2595 instance of @code{$datafile} in the specified script will be replaced with
2596 the path to the generated data file.  Note: even if you set this option, you
2597 may still want to specify the plot type, as that can impact the content of
2598 the data file.
2599 @end table
2601 @node Hyperlinks, TODO Items, Tables, Top
2602 @chapter Hyperlinks
2603 @cindex hyperlinks
2605 Like HTML, Org provides links inside a file, external links to
2606 other files, Usenet articles, emails, and much more.
2608 @menu
2609 * Link format::                 How links in Org are formatted
2610 * Internal links::              Links to other places in the current file
2611 * External links::              URL-like links to the world
2612 * Handling links::              Creating, inserting and following
2613 * Using links outside Org::     Linking from my C source code?
2614 * Link abbreviations::          Shortcuts for writing complex links
2615 * Search options::              Linking to a specific location
2616 * Custom searches::             When the default search is not enough
2617 @end menu
2619 @node Link format, Internal links, Hyperlinks, Hyperlinks
2620 @section Link format
2621 @cindex link format
2622 @cindex format, of links
2624 Org will recognize plain URL-like links and activate them as
2625 clickable links.  The general link format, however, looks like this:
2627 @example
2628 [[link][description]]       @r{or alternatively}           [[link]]
2629 @end example
2631 @noindent
2632 Once a link in the buffer is complete (all brackets present), Org
2633 will change the display so that @samp{description} is displayed instead
2634 of @samp{[[link][description]]} and @samp{link} is displayed instead of
2635 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
2636 which by default is an underlined face.  You can directly edit the
2637 visible part of a link.  Note that this can be either the @samp{link}
2638 part (if there is no description) or the @samp{description} part.  To
2639 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
2640 cursor on the link.
2642 If you place the cursor at the beginning or just behind the end of the
2643 displayed text and press @key{BACKSPACE}, you will remove the
2644 (invisible) bracket at that location.  This makes the link incomplete
2645 and the internals are again displayed as plain text.  Inserting the
2646 missing bracket hides the link internals again.  To show the
2647 internal structure of all links, use the menu entry
2648 @code{Org->Hyperlinks->Literal links}.
2650 @node Internal links, External links, Link format, Hyperlinks
2651 @section Internal links
2652 @cindex internal links
2653 @cindex links, internal
2654 @cindex targets, for links
2656 @cindex property, CUSTOM_ID
2657 If the link does not look like a URL, it is considered to be internal in the
2658 current file.  The most important case is a link like
2659 @samp{[[#my-custom-id]]} which will link to the entry with the
2660 @code{CUSTOM_ID} property @samp{my-custom-id}.  Such custom IDs are very good
2661 for HTML export (@pxref{HTML export}) where they produce pretty section
2662 links.  You are responsible yourself to make sure these custom IDs are unique
2663 in a file.
2665 Links such as @samp{[[My Target]]} or @samp{[[My Target][Find my target]]}
2666 lead to a text search in the current file.
2668 The link can be followed with @kbd{C-c C-o} when the cursor is on the link,
2669 or with a mouse click (@pxref{Handling links}).  Links to custom IDs will
2670 point to the corresponding headline.  The preferred match for a text link is
2671 a @i{dedicated target}: the same string in double angular brackets.  Targets
2672 may be located anywhere; sometimes it is convenient to put them into a
2673 comment line. For example
2675 @example
2676 # <<My Target>>
2677 @end example
2679 @noindent In HTML export (@pxref{HTML export}), such targets will become
2680 named anchors for direct access through @samp{http} links@footnote{Note that
2681 text before the first headline is usually not exported, so the first such
2682 target should be after the first headline, or in the line directly before the
2683 first headline.}.
2685 If no dedicated target exists, Org will search for the words in the link.  In
2686 the above example the search would be for @samp{my target}.  Links starting
2687 with a star like @samp{*My Target} restrict the search to
2688 headlines@footnote{To insert a link targeting a headline, in-buffer
2689 completion can be used.  Just type a star followed by a few optional letters
2690 into the buffer and press @kbd{M-@key{TAB}}.  All headlines in the current
2691 buffer will be offered as completions.  @xref{Handling links}, for more
2692 commands creating links.}.  When searching, Org mode will first try an
2693 exact match, but then move on to more and more lenient searches.  For
2694 example, the link @samp{[[*My Targets]]} will find any of the following:
2696 @example
2697 ** My targets
2698 ** TODO my targets are bright
2699 ** my 20 targets are
2700 @end example
2703 Following a link pushes a mark onto Org's own mark ring.  You can
2704 return to the previous position with @kbd{C-c &}.  Using this command
2705 several times in direct succession goes back to positions recorded
2706 earlier.
2708 @menu
2709 * Radio targets::               Make targets trigger links in plain text
2710 @end menu
2712 @node Radio targets,  , Internal links, Internal links
2713 @subsection Radio targets
2714 @cindex radio targets
2715 @cindex targets, radio
2716 @cindex links, radio targets
2718 Org can automatically turn any occurrences of certain target names
2719 in normal text into a link.  So without explicitly creating a link, the
2720 text connects to the target radioing its position.  Radio targets are
2721 enclosed by triple angular brackets.  For example, a target @samp{<<<My
2722 Target>>>} causes each occurrence of @samp{my target} in normal text to
2723 become activated as a link.  The Org file is scanned automatically
2724 for radio targets only when the file is first loaded into Emacs.  To
2725 update the target list during editing, press @kbd{C-c C-c} with the
2726 cursor on or at a target.
2728 @node External links, Handling links, Internal links, Hyperlinks
2729 @section External links
2730 @cindex links, external
2731 @cindex external links
2732 @cindex links, external
2733 @cindex Gnus links
2734 @cindex BBDB links
2735 @cindex IRC links
2736 @cindex URL links
2737 @cindex file links
2738 @cindex VM links
2739 @cindex RMAIL links
2740 @cindex WANDERLUST links
2741 @cindex MH-E links
2742 @cindex USENET links
2743 @cindex SHELL links
2744 @cindex Info links
2745 @cindex Elisp links
2747 Org supports links to files, websites, Usenet and email messages,
2748 BBDB database entries and links to both IRC conversations and their
2749 logs.  External links are URL-like locators.  They start with a short
2750 identifying string followed by a colon.  There can be no space after
2751 the colon.  The following list shows examples for each link type.
2753 @example
2754 http://www.astro.uva.nl/~dominik          @r{on the web}
2755 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
2756 /home/dominik/images/jupiter.jpg          @r{same as above}
2757 file:papers/last.pdf                      @r{file, relative path}
2758 ./papers/last.pdf                         @r{same as above}
2759 file:sometextfile::NNN                    @r{file with line number to jump to}
2760 file:projects.org                         @r{another Org file}
2761 file:projects.org::some words             @r{text search in Org file}
2762 file:projects.org::*task title            @r{heading search in Org file}
2763 docview:papers/last.pdf::NNN              @r{open file in doc-view mode at page NNN}
2764 id:B7423F4D-2E8A-471B-8810-C40F074717E9   @r{Link to heading by ID}
2765 news:comp.emacs                           @r{Usenet link}
2766 mailto:adent@@galaxy.net                   @r{Mail link}
2767 vm:folder                                 @r{VM folder link}
2768 vm:folder#id                              @r{VM message link}
2769 vm://myself@@some.where.org/folder#id      @r{VM on remote machine}
2770 wl:folder                                 @r{WANDERLUST folder link}
2771 wl:folder#id                              @r{WANDERLUST message link}
2772 mhe:folder                                @r{MH-E folder link}
2773 mhe:folder#id                             @r{MH-E message link}
2774 rmail:folder                              @r{RMAIL folder link}
2775 rmail:folder#id                           @r{RMAIL message link}
2776 gnus:group                                @r{Gnus group link}
2777 gnus:group#id                             @r{Gnus article link}
2778 bbdb:R.*Stallman                          @r{BBDB link (with regexp)}
2779 irc:/irc.com/#emacs/bob                   @r{IRC link}
2780 shell:ls *.org                            @r{A shell command}
2781 elisp:org-agenda                          @r{Interactive Elisp command}
2782 elisp:(find-file-other-frame "Elisp.org") @r{Elisp form to evaluate}
2783 @end example
2785 A link should be enclosed in double brackets and may contain a
2786 descriptive text to be displayed instead of the URL (@pxref{Link
2787 format}), for example:
2789 @example
2790 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
2791 @end example
2793 @noindent
2794 If the description is a file name or URL that points to an image, HTML
2795 export (@pxref{HTML export}) will inline the image as a clickable
2796 button.  If there is no description at all and the link points to an
2797 image,
2798 that image will be inlined into the exported HTML file.
2800 @cindex square brackets, around links
2801 @cindex plain text external links
2802 Org also finds external links in the normal text and activates them
2803 as links.  If spaces must be part of the link (for example in
2804 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
2805 about the end of the link, enclose them in square brackets.
2807 @node Handling links, Using links outside Org, External links, Hyperlinks
2808 @section Handling links
2809 @cindex links, handling
2811 Org provides methods to create a link in the correct syntax, to
2812 insert it into an Org file, and to follow the link.
2814 @table @kbd
2815 @kindex C-c l
2816 @cindex storing links
2817 @item C-c l
2818 Store a link to the current location.  This is a @emph{global} command (you
2819 must create the key binding yourself) which can be used in any buffer to
2820 create a link.  The link will be stored for later insertion into an Org
2821 buffer (see below).  What kind of link will be created depends on the current
2822 buffer:
2824 @b{Org-mode buffers}@*
2825 For Org files, if there is a @samp{<<target>>} at the cursor, the link points
2826 to the target.  Otherwise it points to the current headline, which will also
2827 be the description.
2829 @vindex org-link-to-org-use-id
2830 @cindex property, CUSTOM_ID
2831 @cindex property, ID
2832 If the headline has a @code{CUSTOM_ID} property, a link to this custom ID
2833 will be stored.  In addition or alternatively (depending on the value of
2834 @code{org-link-to-org-use-id}), a globally unique @code{ID} property will be
2835 created and/or used to construct a link.  So using this command in Org
2836 buffers will potentially create two links: a human-readable from the custom
2837 ID, and one that is globally unique and works even if the entry is moved from
2838 file to file.  Later, when inserting the link, you need to decide which one
2839 to use.
2841 @b{Email/News clients: VM, Rmail, Wanderlust, MH-E, Gnus}@*
2842 Pretty much all Emacs mail clients are supported.  The link will point to the
2843 current article, or, in some GNUS buffers, to the group.  The description is
2844 constructed from the author and the subject.
2846 @b{Web browsers: W3 and W3M}@*
2847 Here the link will be the current URL, with the page title as description.
2849 @b{Contacts: BBDB}@*
2850 Links created in a BBDB buffer will point to the current entry.
2852 @b{Chat: IRC}@*
2853 @vindex org-irc-link-to-logs
2854 For IRC links, if you set the variable @code{org-irc-link-to-logs} to
2855 @code{t}, a @samp{file:/} style link to the relevant point in the logs for
2856 the current conversation is created.  Otherwise an @samp{irc:/} style link to
2857 the user/channel/server under the point will be stored.
2859 @b{Other files}@*
2860 For any other files, the link will point to the file, with a search string
2861 (@pxref{Search options}) pointing to the contents of the current line.  If
2862 there is an active region, the selected words will form the basis of the
2863 search string.  If the automatically created link is not working correctly or
2864 accurately enough, you can write custom functions to select the search string
2865 and to do the search for particular file types---see @ref{Custom searches}.
2866 The key binding @kbd{C-c l} is only a suggestion---see @ref{Installation}.
2868 @b{Agenda view}@*
2869 When the cursor is in an agenda view, the created link points to the
2870 entry referenced by the current line.
2873 @kindex C-c C-l
2874 @cindex link completion
2875 @cindex completion, of links
2876 @cindex inserting links
2877 @item C-c C-l
2878 @vindex org-keep-stored-link-after-insertion
2879 Insert a link@footnote{ Note that you don't have to use this command to
2880 insert a link.  Links in Org are plain text, and you can type or paste them
2881 straight into the buffer.  By using this command, the links are automatically
2882 enclosed in double brackets, and you will be asked for the optional
2883 descriptive text.}.  This prompts for a link to be inserted into the buffer.
2884 You can just type a link, using text for an internal link, or one of the link
2885 type prefixes mentioned in the examples above.  The link will be inserted
2886 into the buffer@footnote{After insertion of a stored link, the link will be
2887 removed from the list of stored links.  To keep it in the list later use, use
2888 a triple @kbd{C-u} prefix argument to @kbd{C-c C-l}, or configure the option
2889 @code{org-keep-stored-link-after-insertion}.}, along with a descriptive text.
2890 If some text was selected when this command is called, the selected text
2891 becomes the default description.
2893 @b{Inserting stored links}@*
2894 All links stored during the
2895 current session are part of the history for this prompt, so you can access
2896 them with @key{up} and @key{down} (or @kbd{M-p/n}).
2898 @b{Completion support}@* Completion with @key{TAB} will help you to insert
2899 valid link prefixes like @samp{http:} or @samp{ftp:}, including the prefixes
2900 defined through link abbreviations (@pxref{Link abbreviations}).  If you
2901 press @key{RET} after inserting only the @var{prefix}, Org will offer
2902 specific completion support for some link types@footnote{This works by
2903 calling a special function @code{org-PREFIX-complete-link}.}  For
2904 example, if you type @kbd{file @key{RET}}, file name completion (alternative
2905 access: @kbd{C-u C-c C-l}, see below) will be offered, and after @kbd{bbdb
2906 @key{RET}} you can complete contact names.
2907 @kindex C-u C-c C-l
2908 @cindex file name completion
2909 @cindex completion, of file names
2910 @item C-u C-c C-l
2911 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
2912 a file will be inserted and you may use file name completion to select
2913 the name of the file.  The path to the file is inserted relative to the
2914 directory of the current Org file, if the linked file is in the current
2915 directory or in a sub-directory of it, or if the path is written relative
2916 to the current directory using @samp{../}.  Otherwise an absolute path
2917 is used, if possible with @samp{~/} for your home directory.  You can
2918 force an absolute path with two @kbd{C-u} prefixes.
2920 @item C-c C-l @r{(with cursor on existing link)}
2921 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
2922 link and description parts of the link.
2924 @cindex following links
2925 @kindex C-c C-o
2926 @kindex RET
2927 @item C-c C-o @r{or} @key{RET}
2928 @vindex org-file-apps
2929 Open link at point.  This will launch a web browser for URLs (using
2930 @command{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB for
2931 the corresponding links, and execute the command in a shell link.  When the
2932 cursor is on an internal link, this commands runs the corresponding search.
2933 When the cursor is on a TAG list in a headline, it creates the corresponding
2934 TAGS view.  If the cursor is on a timestamp, it compiles the agenda for that
2935 date.  Furthermore, it will visit text and remote files in @samp{file:} links
2936 with Emacs and select a suitable application for local non-text files.
2937 Classification of files is based on file extension only.  See option
2938 @code{org-file-apps}.  If you want to override the default application and
2939 visit the file with Emacs, use a @kbd{C-u} prefix.  If you want to avoid
2940 opening in Emacs, use a @kbd{C-u C-u} prefix.@*
2941 If the cursor is on a headline, but not on a link, offer all links in the
2942 headline and entry text.
2944 @kindex mouse-2
2945 @kindex mouse-1
2946 @item mouse-2
2947 @itemx mouse-1
2948 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
2949 would.  Under Emacs 22, @kbd{mouse-1} will also follow a link.
2951 @kindex mouse-3
2952 @item mouse-3
2953 @vindex org-display-internal-link-with-indirect-buffer
2954 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
2955 internal links to be displayed in another window@footnote{See the
2956 variable @code{org-display-internal-link-with-indirect-buffer}}.
2958 @cindex mark ring
2959 @kindex C-c %
2960 @item C-c %
2961 Push the current position onto the mark ring, to be able to return
2962 easily. Commands following an internal link do this automatically.
2964 @cindex links, returning to
2965 @kindex C-c &
2966 @item C-c &
2967 Jump back to a recorded position.  A position is recorded by the
2968 commands following internal links, and by @kbd{C-c %}.  Using this
2969 command several times in direct succession moves through a ring of
2970 previously recorded positions.
2972 @kindex C-c C-x C-n
2973 @kindex C-c C-x C-p
2974 @cindex links, finding next/previous
2975 @item C-c C-x C-n
2976 @itemx C-c C-x C-p
2977 Move forward/backward to the next link in the buffer.  At the limit of
2978 the buffer, the search fails once, and then wraps around.  The key
2979 bindings for this are really too long, you might want to bind this also
2980 to @kbd{C-n} and @kbd{C-p}
2981 @lisp
2982 (add-hook 'org-load-hook
2983   (lambda ()
2984     (define-key 'org-mode-map "\C-n" 'org-next-link)
2985     (define-key 'org-mode-map "\C-p" 'org-previous-link)))
2986 @end lisp
2987 @end table
2989 @node Using links outside Org, Link abbreviations, Handling links, Hyperlinks
2990 @section Using links outside Org
2992 You can insert and follow links that have Org syntax not only in
2993 Org, but in any Emacs buffer.  For this, you should create two
2994 global commands, like this (please select suitable global keys
2995 yourself):
2997 @lisp
2998 (global-set-key "\C-c L" 'org-insert-link-global)
2999 (global-set-key "\C-c o" 'org-open-at-point-global)
3000 @end lisp
3002 @node Link abbreviations, Search options, Using links outside Org, Hyperlinks
3003 @section Link abbreviations
3004 @cindex link abbreviations
3005 @cindex abbreviation, links
3007 Long URLs can be cumbersome to type, and often many similar links are
3008 needed in a document.  For this you can use link abbreviations.  An
3009 abbreviated link looks like this
3011 @example
3012 [[linkword:tag][description]]
3013 @end example
3015 @noindent
3016 @vindex org-link-abbrev-alist
3017 where the tag is optional.  The @i{linkword} must be a word; letter, numbers,
3018 @samp{-}, and @samp{_} are allowed here.  Abbreviations are resolved
3019 according to the information in the variable @code{org-link-abbrev-alist}
3020 that relates the linkwords to replacement text.  Here is an example:
3022 @lisp
3023 @group
3024 (setq org-link-abbrev-alist
3025   '(("bugzilla" . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
3026     ("google"   . "http://www.google.com/search?q=")
3027     ("ads"      . "http://adsabs.harvard.edu/cgi-bin/
3028                    nph-abs_connect?author=%s&db_key=AST")))
3029 @end group
3030 @end lisp
3032 If the replacement text contains the string @samp{%s}, it will be
3033 replaced with the tag.  Otherwise the tag will be appended to the string
3034 in order to create the link.  You may also specify a function that will
3035 be called with the tag as the only argument to create the link.
3037 With the above setting, you could link to a specific bug with
3038 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
3039 @code{[[google:OrgMode]]} and find out what the Org author is
3040 doing besides Emacs hacking with @code{[[ads:Dominik,C]]}.
3042 If you need special abbreviations just for a single Org buffer, you
3043 can define them in the file with
3045 @cindex #+LINK
3046 @example
3047 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
3048 #+LINK: google    http://www.google.com/search?q=%s
3049 @end example
3051 @noindent
3052 In-buffer completion (@pxref{Completion}) can be used after @samp{[} to
3053 complete link abbreviations.  You may also define a function
3054 @code{org-PREFIX-complete-link} that implements special (e.g. completion)
3055 support for inserting such a link with @kbd{C-c C-l}.  Such a function should
3056 not accept any arguments, and return the full link with prefix.
3058 @node Search options, Custom searches, Link abbreviations, Hyperlinks
3059 @section Search options in file links
3060 @cindex search option in file links
3061 @cindex file links, searching
3063 File links can contain additional information to make Emacs jump to a
3064 particular location in the file when following a link.  This can be a
3065 line number or a search option after a double@footnote{For backward
3066 compatibility, line numbers can also follow a single colon.} colon. For
3067 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
3068 links}) to a file, it encodes the words in the current line as a search
3069 string that can be used to find this line back later when following the
3070 link with @kbd{C-c C-o}.
3072 Here is the syntax of the different ways to attach a search to a file
3073 link, together with an explanation:
3075 @example
3076 [[file:~/code/main.c::255]]
3077 [[file:~/xx.org::My Target]]
3078 [[file:~/xx.org::*My Target]]
3079 [[file:~/xx.org::/regexp/]]
3080 @end example
3082 @table @code
3083 @item 255
3084 Jump to line 255.
3085 @item My Target
3086 Search for a link target @samp{<<My Target>>}, or do a text search for
3087 @samp{my target}, similar to the search in internal links, see
3088 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
3089 link will become an HTML reference to the corresponding named anchor in
3090 the linked file.
3091 @item *My Target
3092 In an Org file, restrict search to headlines.
3093 @item /regexp/
3094 Do a regular expression search for @code{regexp}.  This uses the Emacs
3095 command @code{occur} to list all matches in a separate window.  If the
3096 target file is in Org mode, @code{org-occur} is used to create a
3097 sparse tree with the matches.
3098 @c If the target file is a directory,
3099 @c @code{grep} will be used to search all files in the directory.
3100 @end table
3102 As a degenerate case, a file link with an empty file name can be used
3103 to search the current file.  For example, @code{[[file:::find me]]} does
3104 a search for @samp{find me} in the current file, just as
3105 @samp{[[find me]]} would.
3107 @node Custom searches,  , Search options, Hyperlinks
3108 @section Custom Searches
3109 @cindex custom search strings
3110 @cindex search strings, custom
3112 The default mechanism for creating search strings and for doing the
3113 actual search related to a file link may not work correctly in all
3114 cases.  For example, Bib@TeX{} database files have many entries like
3115 @samp{year="1993"} which would not result in good search strings,
3116 because the only unique identification for a Bib@TeX{} entry is the
3117 citation key.
3119 @vindex org-create-file-search-functions
3120 @vindex org-execute-file-search-functions
3121 If you come across such a problem, you can write custom functions to set
3122 the right search string for a particular file type, and to do the search
3123 for the string in the file.  Using @code{add-hook}, these functions need
3124 to be added to the hook variables
3125 @code{org-create-file-search-functions} and
3126 @code{org-execute-file-search-functions}.  See the docstring for these
3127 variables for more information.  Org actually uses this mechanism
3128 for Bib@TeX{} database files, and you can use the corresponding code as
3129 an implementation example.  See the file @file{org-bibtex.el}.
3131 @node TODO Items, Tags, Hyperlinks, Top
3132 @chapter TODO Items
3133 @cindex TODO items
3135 Org mode does not maintain TODO lists as separate documents@footnote{Of
3136 course, you can make a document that contains only long lists of TODO items,
3137 but this is not required.}.  Instead, TODO items are an integral part of the
3138 notes file, because TODO items usually come up while taking notes!  With Org
3139 mode, simply mark any entry in a tree as being a TODO item.  In this way,
3140 information is not duplicated, and the entire context from which the TODO
3141 item emerged is always present.
3143 Of course, this technique for managing TODO items scatters them
3144 throughout your notes file.  Org mode compensates for this by providing
3145 methods to give you an overview of all the things that you have to do.
3147 @menu
3148 * TODO basics::                 Marking and displaying TODO entries
3149 * TODO extensions::             Workflow and assignments
3150 * Progress logging::            Dates and notes for progress
3151 * Priorities::                  Some things are more important than others
3152 * Breaking down tasks::         Splitting a task into manageable pieces
3153 * Checkboxes::                  Tick-off lists
3154 @end menu
3156 @node TODO basics, TODO extensions, TODO Items, TODO Items
3157 @section Basic TODO functionality
3159 Any headline becomes a TODO item when it starts with the word
3160 @samp{TODO}, for example:
3162 @example
3163 *** TODO Write letter to Sam Fortune
3164 @end example
3166 @noindent
3167 The most important commands to work with TODO entries are:
3169 @table @kbd
3170 @kindex C-c C-t
3171 @cindex cycling, of TODO states
3172 @item C-c C-t
3173 Rotate the TODO state of the current item among
3175 @example
3176 ,-> (unmarked) -> TODO -> DONE --.
3177 '--------------------------------'
3178 @end example
3180 The same rotation can also be done ``remotely'' from the timeline and
3181 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
3183 @kindex C-u C-c C-t
3184 @item C-u C-c C-t
3185 Select a specific keyword using completion or (if it has been set up)
3186 the fast selection interface.  For the latter, you need to assign keys
3187 to TODO states, see @ref{Per-file keywords}, and @ref{Setting tags}, for
3188 more information.
3190 @kindex S-@key{right}
3191 @kindex S-@key{left}
3192 @vindex org-treat-S-cursor-todo-selection-as-state-change
3193 @item S-@key{right}
3194 @itemx S-@key{left}
3195 Select the following/preceding TODO state, similar to cycling.  Useful
3196 mostly if more than two TODO states are possible (@pxref{TODO
3197 extensions}).  See also @ref{Conflicts}, for a discussion of the interaction
3198 with @code{shift-selection-mode}.  See also the variable
3199 @code{org-treat-S-cursor-todo-selection-as-state-change}.
3200 @kindex C-c C-v
3201 @kindex C-c / t
3202 @cindex sparse tree, for TODO
3203 @item C-c C-v
3204 @itemx C-c / t
3205 @vindex org-todo-keywords
3206 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds the
3207 entire buffer, but shows all TODO items and the headings hierarchy above
3208 them.  With a prefix argument, search for a specific TODO.  You will be
3209 prompted for the keyword, and you can also give a list of keywords like
3210 @code{KWD1|KWD2|...} to list entries that match any one of these keywords.
3211 With numeric prefix argument N, show the tree for the Nth keyword in the
3212 variable @code{org-todo-keywords}.  With two prefix arguments, find all TODO
3213 and DONE entries.
3214 @kindex C-c a t
3215 @item C-c a t
3216 Show the global TODO list.  Collects the TODO items from all agenda
3217 files (@pxref{Agenda Views}) into a single buffer.  The new buffer will
3218 be in @code{agenda-mode}, which provides commands to examine and
3219 manipulate the TODO entries from the new buffer (@pxref{Agenda
3220 commands}).  @xref{Global TODO list}, for more information.
3221 @kindex S-M-@key{RET}
3222 @item S-M-@key{RET}
3223 Insert a new TODO entry below the current one.
3224 @end table
3226 @noindent
3227 @vindex org-todo-state-tags-triggers
3228 Changing a TODO state can also trigger tag changes.  See the docstring of the
3229 option @code{org-todo-state-tags-triggers} for details.
3231 @node TODO extensions, Progress logging, TODO basics, TODO Items
3232 @section Extended use of TODO keywords
3233 @cindex extended TODO keywords
3235 @vindex org-todo-keywords
3236 By default, marked TODO entries have one of only two states: TODO and
3237 DONE.  Org mode allows you to classify TODO items in more complex ways
3238 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With
3239 special setup, the TODO keyword system can work differently in different
3240 files.
3242 Note that @i{tags} are another way to classify headlines in general and
3243 TODO items in particular (@pxref{Tags}).
3245 @menu
3246 * Workflow states::             From TODO to DONE in steps
3247 * TODO types::                  I do this, Fred does the rest
3248 * Multiple sets in one file::   Mixing it all, and still finding your way
3249 * Fast access to TODO states::  Single letter selection of a state
3250 * Per-file keywords::           Different files, different requirements
3251 * Faces for TODO keywords::     Highlighting states
3252 * TODO dependencies::           When one task needs to wait for others
3253 @end menu
3255 @node Workflow states, TODO types, TODO extensions, TODO extensions
3256 @subsection TODO keywords as workflow states
3257 @cindex TODO workflow
3258 @cindex workflow states as TODO keywords
3260 You can use TODO keywords to indicate different @emph{sequential} states
3261 in the process of working on an item, for example@footnote{Changing
3262 this variable only becomes effective after restarting Org mode in a
3263 buffer.}:
3265 @lisp
3266 (setq org-todo-keywords
3267   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
3268 @end lisp
3270 The vertical bar separates the TODO keywords (states that @emph{need
3271 action}) from the DONE states (which need @emph{no further action}).  If
3272 you don't provide the separator bar, the last state is used as the DONE
3273 state.
3274 @cindex completion, of TODO keywords
3275 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
3276 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED.  You may
3277 also use a numeric prefix argument to quickly select a specific state.  For
3278 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY.
3279 Or you can use @kbd{S-@key{left}} to go backward through the sequence.  If you
3280 define many keywords, you can use in-buffer completion
3281 (@pxref{Completion}) or even a special one-key selection scheme
3282 (@pxref{Fast access to TODO states}) to insert these words into the
3283 buffer.  Changing a TODO state can be logged with a timestamp, see
3284 @ref{Tracking TODO state changes}, for more information.
3286 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
3287 @subsection TODO keywords as types
3288 @cindex TODO types
3289 @cindex names as TODO keywords
3290 @cindex types as TODO keywords
3292 The second possibility is to use TODO keywords to indicate different
3293 @emph{types} of action items.  For example, you might want to indicate
3294 that items are for ``work'' or ``home''.  Or, when you work with several
3295 people on a single project, you might want to assign action items
3296 directly to persons, by using their names as TODO keywords.  This would
3297 be set up like this:
3299 @lisp
3300 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
3301 @end lisp
3303 In this case, different keywords do not indicate a sequence, but rather
3304 different types.  So the normal work flow would be to assign a task to a
3305 person, and later to mark it DONE.  Org mode supports this style by adapting
3306 the workings of the command @kbd{C-c C-t}@footnote{This is also true for the
3307 @kbd{t} command in the timeline and agenda buffers.}.  When used several
3308 times in succession, it will still cycle through all names, in order to first
3309 select the right type for a task.  But when you return to the item after some
3310 time and execute @kbd{C-c C-t} again, it will switch from any name directly
3311 to DONE.  Use prefix arguments or completion to quickly select a specific
3312 name.  You can also review the items of a specific TODO type in a sparse tree
3313 by using a numeric prefix to @kbd{C-c C-v}.  For example, to see all things
3314 Lucy has to do, you would use @kbd{C-3 C-c C-v}.  To collect Lucy's items
3315 from all agenda files into a single buffer, you would use the numeric prefix
3316 argument as well when creating the global TODO list: @kbd{C-3 C-c t}.
3318 @node Multiple sets in one file, Fast access to TODO states, TODO types, TODO extensions
3319 @subsection Multiple keyword sets in one file
3320 @cindex TODO keyword sets
3322 Sometimes you may want to use different sets of TODO keywords in
3323 parallel.  For example, you may want to have the basic
3324 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
3325 separate state indicating that an item has been canceled (so it is not
3326 DONE, but also does not require action).  Your setup would then look
3327 like this:
3329 @lisp
3330 (setq org-todo-keywords
3331       '((sequence "TODO" "|" "DONE")
3332         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
3333         (sequence "|" "CANCELED")))
3334 @end lisp
3336 The keywords should all be different, this helps Org mode to keep track
3337 of which subsequence should be used for a given entry.  In this setup,
3338 @kbd{C-c C-t} only operates within a subsequence, so it switches from
3339 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
3340 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
3341 select the correct sequence.  Besides the obvious ways like typing a
3342 keyword or using completion, you may also apply the following commands:
3344 @table @kbd
3345 @kindex C-S-@key{right}
3346 @kindex C-S-@key{left}
3347 @kindex C-u C-u C-c C-t
3348 @item C-u C-u C-c C-t
3349 @itemx C-S-@key{right}
3350 @itemx C-S-@key{left}
3351 These keys jump from one TODO subset to the next.  In the above example,
3352 @kbd{C-u C-u C-c C-t} or @kbd{C-S-@key{right}} would jump from @code{TODO} or
3353 @code{DONE} to @code{REPORT}, and any of the words in the second row to
3354 @code{CANCELED}.  Note that the @kbd{C-S-} key binding conflict with
3355 @code{shift-selection-mode} (@pxref{Conflicts}).
3356 @kindex S-@key{right}
3357 @kindex S-@key{left}
3358 @item S-@key{right}
3359 @itemx S-@key{left}
3360 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through @emph{all}
3361 keywords from all sets, so for example @kbd{S-@key{<right>}} would switch
3362 from @code{DONE} to @code{REPORT} in the example above.  See also
3363 @ref{Conflicts}, for a discussion of the interaction with
3364 @code{shift-selection-mode}.
3365 @end table
3367 @node Fast access to TODO states, Per-file keywords, Multiple sets in one file, TODO extensions
3368 @subsection Fast access to TODO states
3370 If you would like to quickly change an entry to an arbitrary TODO state
3371 instead of cycling through the states, you can set up keys for
3372 single-letter access to the states.  This is done by adding the section
3373 key after each keyword, in parentheses.  For example:
3375 @lisp
3376 (setq org-todo-keywords
3377       '((sequence "TODO(t)" "|" "DONE(d)")
3378         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
3379         (sequence "|" "CANCELED(c)")))
3380 @end lisp
3382 @vindex org-fast-tag-selection-include-todo
3383 If you then press @code{C-c C-t} followed by the selection key, the entry
3384 will be switched to this state.  @key{SPC} can be used to remove any TODO
3385 keyword from an entry.@footnote{Check also the variable
3386 @code{org-fast-tag-selection-include-todo}, it allows you to change the TODO
3387 state through the tags interface (@pxref{Setting tags}), in case you like to
3388 mingle the two concepts.  Note that this means you need to come up with
3389 unique keys across both sets of keywords.}
3391 @node Per-file keywords, Faces for TODO keywords, Fast access to TODO states, TODO extensions
3392 @subsection Setting up keywords for individual files
3393 @cindex keyword options
3394 @cindex per-file keywords
3395 @cindex #+TODO
3396 @cindex #+TYP_TODO
3397 @cindex #+SEQ_TODO
3399 It can be very useful to use different aspects of the TODO mechanism in
3400 different files.  For file-local settings, you need to add special lines
3401 to the file which set the keywords and interpretation for that file
3402 only.  For example, to set one of the two examples discussed above, you
3403 need one of the following lines, starting in column zero anywhere in the
3404 file:
3406 @example
3407 #+TODO: TODO FEEDBACK VERIFY | DONE CANCELED
3408 @end example
3409 @noindent (you may also write @code{#+SEQ_TODO} to be explicit about the
3410 interpretation, but it means the same as @code{#+TODO}), or
3411 @example
3412 #+TYP_TODO: Fred Sara Lucy Mike | DONE
3413 @end example
3415 A setup for using several sets in parallel would be:
3417 @example
3418 #+TODO: TODO | DONE
3419 #+TODO: REPORT BUG KNOWNCAUSE | FIXED
3420 #+TODO: | CANCELED
3421 @end example
3423 @cindex completion, of option keywords
3424 @kindex M-@key{TAB}
3425 @noindent To make sure you are using the correct keyword, type
3426 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
3428 @cindex DONE, final TODO keyword
3429 Remember that the keywords after the vertical bar (or the last keyword
3430 if no bar is there) must always mean that the item is DONE (although you
3431 may use a different word).  After changing one of these lines, use
3432 @kbd{C-c C-c} with the cursor still in the line to make the changes
3433 known to Org mode@footnote{Org mode parses these lines only when
3434 Org mode is activated after visiting a file.  @kbd{C-c C-c} with the
3435 cursor in a line starting with @samp{#+} is simply restarting Org mode
3436 for the current buffer.}.
3438 @node Faces for TODO keywords, TODO dependencies, Per-file keywords, TODO extensions
3439 @subsection Faces for TODO keywords
3440 @cindex faces, for TODO keywords
3442 @vindex org-todo @r{(face)}
3443 @vindex org-done @r{(face)}
3444 @vindex org-todo-keyword-faces
3445 Org mode highlights TODO keywords with special faces: @code{org-todo}
3446 for keywords indicating that an item still has to be acted upon, and
3447 @code{org-done} for keywords indicating that an item is finished.  If
3448 you are using more than 2 different states, you might want to use
3449 special faces for some of them.  This can be done using the variable
3450 @code{org-todo-keyword-faces}.  For example:
3452 @lisp
3453 @group
3454 (setq org-todo-keyword-faces
3455       '(("TODO"      . org-warning)
3456         ("DEFERRED"  . shadow)
3457         ("CANCELED"  . (:foreground "blue" :weight bold))))
3458 @end group
3459 @end lisp
3461 While using a list with face properties as shown for CANCELED
3462 @emph{should} work, this does not aways seem to be the case.  If
3463 necessary, define a special face and use that.
3465 @node TODO dependencies,  , Faces for TODO keywords, TODO extensions
3466 @subsection TODO dependencies
3467 @cindex TODO dependencies
3468 @cindex dependencies, of TODO states
3470 @vindex org-enforce-todo-dependencies
3471 @cindex property, ORDERED
3472 The structure of Org files (hierarchy and lists) makes it easy to define TODO
3473 dependencies.  Usually, a parent TODO task should not be marked DONE until
3474 all subtasks (defined as children tasks) are marked as DONE.  And sometimes
3475 there is a logical sequence to a number of (sub)tasks, so that one task
3476 cannot be acted upon before all siblings above it are done.  If you customize
3477 the variable @code{org-enforce-todo-dependencies}, Org will block entries
3478 from changing state to DONE while they have children that are not DONE.
3479 Furthermore, if an entry has a property @code{ORDERED}, each of its children
3480 will be blocked until all earlier siblings are marked DONE.  Here is an
3481 example:
3483 @example
3484 * TODO Blocked until (two) is done
3485 ** DONE one
3486 ** TODO two
3488 * Parent
3489   :PROPERTIES:
3490     :ORDERED: t
3491   :END:
3492 ** TODO a
3493 ** TODO b, needs to wait for (a)
3494 ** TODO c, needs to wait for (a) and (b)
3495 @end example
3497 @table @kbd
3498 @kindex C-c C-x o
3499 @item C-c C-x o
3500 @vindex org-track-ordered-property-with-tag
3501 @cindex property, ORDERED
3502 Toggle the @code{ORDERED} property of the current entry.  A property is used
3503 for this behavior because this should be local to the current entry, not
3504 inherited like a tag.  However, if you would like to @i{track} the value of
3505 this property with a tag for better visibility, customize the variable
3506 @code{org-track-ordered-property-with-tag}.
3507 @kindex C-u C-u C-u C-c C-t
3508 @item C-u C-u C-u C-c C-t
3509 Change TODO state, circumventing any state blocking.
3510 @end table
3512 @vindex org-agenda-dim-blocked-tasks
3513 If you set the variable @code{org-agenda-dim-blocked-tasks}, TODO entries
3514 that cannot be closed because of such dependencies will be shown in a dimmed
3515 font or even made invisible in agenda views (@pxref{Agenda Views}).
3517 @cindex checkboxes and TODO dependencies
3518 @vindex org-enforce-todo-dependencies
3519 You can also block changes of TODO states by looking at checkboxes
3520 (@pxref{Checkboxes}).  If you set the variable
3521 @code{org-enforce-todo-checkbox-dependencies}, an entry that has unchecked
3522 checkboxes will be blocked from switching to DONE.
3524 If you need more complex dependency structures, for example dependencies
3525 between entries in different trees or files, check out the contributed
3526 module @file{org-depend.el}.
3528 @page
3529 @node Progress logging, Priorities, TODO extensions, TODO Items
3530 @section Progress logging
3531 @cindex progress logging
3532 @cindex logging, of progress
3534 Org mode can automatically record a timestamp and possibly a note when
3535 you mark a TODO item as DONE, or even each time you change the state of
3536 a TODO item.  This system is highly configurable, settings can be on a
3537 per-keyword basis and can be localized to a file or even a subtree.  For
3538 information on how to clock working time for a task, see @ref{Clocking
3539 work time}.
3541 @menu
3542 * Closing items::               When was this entry marked DONE?
3543 * Tracking TODO state changes::  When did the status change?
3544 * Tracking your habits::        How consistent have you been?
3545 @end menu
3547 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
3548 @subsection Closing items
3550 The most basic logging is to keep track of @emph{when} a certain TODO
3551 item was finished.  This is achieved with@footnote{The corresponding
3552 in-buffer setting is: @code{#+STARTUP: logdone}}.
3554 @lisp
3555 (setq org-log-done 'time)
3556 @end lisp
3558 @noindent
3559 Then each time you turn an entry from a TODO (not-done) state into any
3560 of the DONE states, a line @samp{CLOSED: [timestamp]} will be inserted
3561 just after the headline.  If you turn the entry back into a TODO item
3562 through further state cycling, that line will be removed again.  If you
3563 want to record a note along with the timestamp, use@footnote{The
3564 corresponding in-buffer setting is: @code{#+STARTUP: lognotedone}}
3566 @lisp
3567 (setq org-log-done 'note)
3568 @end lisp
3570 @noindent
3571 You will then be prompted for a note, and that note will be stored below
3572 the entry with a @samp{Closing Note} heading.
3574 In the timeline (@pxref{Timeline}) and in the agenda
3575 (@pxref{Weekly/daily agenda}), you can then use the @kbd{l} key to
3576 display the TODO items with a @samp{CLOSED} timestamp on each day,
3577 giving you an overview of what has been done.
3579 @node Tracking TODO state changes, Tracking your habits, Closing items, Progress logging
3580 @subsection Tracking TODO state changes
3581 @cindex drawer, for state change recording
3583 @vindex org-log-states-order-reversed
3584 @vindex org-log-into-drawer
3585 @cindex property, LOG_INTO_DRAWER
3586 When TODO keywords are used as workflow states (@pxref{Workflow states}), you
3587 might want to keep track of when a state change occurred and maybe take a
3588 note about this change.  You can either record just a timestamp, or a
3589 time-stamped note for a change.  These records will be inserted after the
3590 headline as an itemized list, newest first@footnote{See the variable
3591 @code{org-log-states-order-reversed}}.  When taking a lot of notes, you might
3592 want to get the notes out of the way into a drawer (@pxref{Drawers}).
3593 Customize the variable @code{org-log-into-drawer} to get this
3594 behavior---the recommended drawer for this is called @code{LOGBOOK}.  You can
3595 also overrule the setting of this variable for a subtree by setting a
3596 @code{LOG_INTO_DRAWER} property.
3598 Since it is normally too much to record a note for every state, Org mode
3599 expects configuration on a per-keyword basis for this.  This is achieved by
3600 adding special markers @samp{!} (for a timestamp) and @samp{@@} (for a note)
3601 in parentheses after each keyword.  For example, with the setting
3603 @lisp
3604 (setq org-todo-keywords
3605   '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
3606 @end lisp
3608 @noindent
3609 @vindex org-log-done
3610 you not only define global TODO keywords and fast access keys, but also
3611 request that a time is recorded when the entry is set to
3612 DONE@footnote{It is possible that Org mode will record two timestamps
3613 when you are using both @code{org-log-done} and state change logging.
3614 However, it will never prompt for two notes---if you have configured
3615 both, the state change recording note will take precedence and cancel
3616 the @samp{Closing Note}.}, and that a note is recorded when switching to
3617 WAIT or CANCELED.  The setting for WAIT is even more special: the
3618 @samp{!} after the slash means that in addition to the note taken when
3619 entering the state, a timestamp should be recorded when @i{leaving} the
3620 WAIT state, if and only if the @i{target} state does not configure
3621 logging for entering it.  So it has no effect when switching from WAIT
3622 to DONE, because DONE is configured to record a timestamp only.  But
3623 when switching from WAIT back to TODO, the @samp{/!} in the WAIT
3624 setting now triggers a timestamp even though TODO has no logging
3625 configured.
3627 You can use the exact same syntax for setting logging preferences local
3628 to a buffer:
3629 @example
3630 #+TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
3631 @end example
3633 @cindex property, LOGGING
3634 In order to define logging settings that are local to a subtree or a
3635 single item, define a LOGGING property in this entry.  Any non-empty
3636 LOGGING property resets all logging settings to nil.  You may then turn
3637 on logging for this specific tree using STARTUP keywords like
3638 @code{lognotedone} or @code{logrepeat}, as well as adding state specific
3639 settings like @code{TODO(!)}.  For example
3641 @example
3642 * TODO Log each state with only a time
3643   :PROPERTIES:
3644   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
3645   :END:
3646 * TODO Only log when switching to WAIT, and when repeating
3647   :PROPERTIES:
3648   :LOGGING: WAIT(@@) logrepeat
3649   :END:
3650 * TODO No logging at all
3651   :PROPERTIES:
3652   :LOGGING: nil
3653   :END:
3654 @end example
3656 @node Tracking your habits,  , Tracking TODO state changes, Progress logging
3657 @subsection Tracking your habits
3658 @cindex habits
3660 Org has the ability to track the consistency of a special category of TODOs,
3661 called ``habits''.  A habit has the following properties:
3663 @enumerate
3664 @item
3665 You have enabled the @code{habits} module by customizing the variable
3666 @code{org-modules}.
3667 @item
3668 The habit is a TODO, with a TODO keyword representing an open state.
3669 @item
3670 The property @code{STYLE} is set to the value @code{habit}.
3671 @item
3672 The TODO has a scheduled date, with a @code{.+} style repeat interval.
3673 @item
3674 The TODO may also have minimum and maximum ranges specified by using the
3675 syntax @samp{.+2d/3d}, which says that you want to do the task at least every
3676 three days, but at most every two days.
3677 @item
3678 You must also have state logging for the @code{DONE} state enabled, in order
3679 for historical data to be represented in the consistency graph.  If it's not
3680 enabled it's not an error, but the consistency graphs will be largely
3681 meaningless.
3682 @end enumerate
3684 To give you an idea of what the above rules look like in action, here's an
3685 actual habit with some history:
3687 @example
3688 ** TODO Shave
3689    SCHEDULED: <2009-10-17 Sat .+2d/4d>
3690    - State "DONE"       from "TODO"       [2009-10-15 Thu]
3691    - State "DONE"       from "TODO"       [2009-10-12 Mon]
3692    - State "DONE"       from "TODO"       [2009-10-10 Sat]
3693    - State "DONE"       from "TODO"       [2009-10-04 Sun]
3694    - State "DONE"       from "TODO"       [2009-10-02 Fri]
3695    - State "DONE"       from "TODO"       [2009-09-29 Tue]
3696    - State "DONE"       from "TODO"       [2009-09-25 Fri]
3697    - State "DONE"       from "TODO"       [2009-09-19 Sat]
3698    - State "DONE"       from "TODO"       [2009-09-16 Wed]
3699    - State "DONE"       from "TODO"       [2009-09-12 Sat]
3700    :PROPERTIES:
3701    :STYLE:    habit
3702    :LAST_REPEAT: [2009-10-19 Mon 00:36]
3703    :END:
3704 @end example
3706 What this habit says is: I want to shave at most every 2 days (given by the
3707 @code{SCHEDULED} date and repeat interval) and at least every 4 days.  If
3708 today is the 15th, then the habit first appears in the agenda on Oct 17,
3709 after the minimum of 2 days has elapsed, and will appear overdue on Oct 19,
3710 after four days have elapsed.
3712 What's really useful about habits is that they are displayed along with a
3713 consistency graph, to show how consistent you've been at getting that task
3714 done in the past.  This graph shows every day that the task was done over the
3715 past three weeks, with colors for each day.  The colors used are:
3717 @table @code
3718 @item Blue
3719 If the task wasn't to be done yet on that day.
3720 @item Green
3721 If the task could have been done on that day.
3722 @item Yellow
3723 If the task was going to be overdue the next day.
3724 @item Red
3725 If the task was overdue on that day.
3726 @end table
3728 In addition to coloring each day, the day is also marked with an asterix if
3729 the task was actually done that day, and an exclamation mark to show where
3730 the current day falls in the graph.
3732 There are several configuration variables that can be used to change the way
3733 habits are displayed in the agenda.
3735 @table @code
3736 @item org-habit-graph-column
3737 The buffer column at which the consistency graph should be drawn.  This will
3738 overwrite any text in that column, so it's a good idea to keep your habits'
3739 titles brief and to the point.
3740 @item org-habit-preceding-days
3741 The amount of history, in days before today, to appear in consistency graphs.
3742 @item org-habit-following-days
3743 The number of days after today that will appear in consistency graphs.
3744 @item org-habit-show-habits-only-for-today
3745 If non-nil, only show habits in today's agenda view.  This is set to true by
3746 default.
3747 @end table
3749 Lastly, pressing @kbd{K} in the agenda buffer will cause habits to
3750 temporarily be disabled and they won't appear at all.  Press @kbd{K} again to
3751 bring them back.  They are also subject to tag filtering, if you have habits
3752 which should only be done in certain contexts, for example.
3754 @node Priorities, Breaking down tasks, Progress logging, TODO Items
3755 @section Priorities
3756 @cindex priorities
3758 If you use Org mode extensively, you may end up enough TODO items that
3759 it starts to make sense to prioritize them.  Prioritizing can be done by
3760 placing a @emph{priority cookie} into the headline of a TODO item, like
3761 this
3763 @example
3764 *** TODO [#A] Write letter to Sam Fortune
3765 @end example
3767 @noindent
3768 By default, Org mode supports three priorities: @samp{A}, @samp{B}, and
3769 @samp{C}.  @samp{A} is the highest priority.  An entry without a cookie
3770 is treated as priority @samp{B}.  Priorities make a difference only in
3771 the agenda (@pxref{Weekly/daily agenda}); outside the agenda, they have
3772 no inherent meaning to Org mode.
3774 Priorities can be attached to any outline tree entries; they do not need
3775 to be TODO items.
3777 @table @kbd
3778 @kindex @kbd{C-c ,}
3779 @item @kbd{C-c ,}
3780 Set the priority of the current headline.  The command prompts for a
3781 priority character @samp{A}, @samp{B} or @samp{C}.  When you press
3782 @key{SPC} instead, the priority cookie is removed from the headline.
3783 The priorities can also be changed ``remotely'' from the timeline and
3784 agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
3786 @kindex S-@key{up}
3787 @kindex S-@key{down}
3788 @item S-@key{up}
3789 @itemx S-@key{down}
3790 @vindex org-priority-start-cycle-with-default
3791 Increase/decrease priority of current headline@footnote{See also the option
3792 @code{org-priority-start-cycle-with-default}.}.  Note that these keys are
3793 also used to modify timestamps (@pxref{Creating timestamps}).  See also
3794 @ref{Conflicts}, for a discussion of the interaction with
3795 @code{shift-selection-mode}.
3796 @end table
3798 @vindex org-highest-priority
3799 @vindex org-lowest-priority
3800 @vindex org-default-priority
3801 You can change the range of allowed priorities by setting the variables
3802 @code{org-highest-priority}, @code{org-lowest-priority}, and
3803 @code{org-default-priority}.  For an individual buffer, you may set
3804 these values (highest, lowest, default) like this (please make sure that
3805 the highest priority is earlier in the alphabet than the lowest
3806 priority):
3808 @cindex #+PRIORITIES
3809 @example
3810 #+PRIORITIES: A C B
3811 @end example
3813 @node Breaking down tasks, Checkboxes, Priorities, TODO Items
3814 @section Breaking tasks down into subtasks
3815 @cindex tasks, breaking down
3816 @cindex statistics, for TODO items
3818 @vindex org-agenda-todo-list-sublevels
3819 It is often advisable to break down large tasks into smaller, manageable
3820 subtasks.  You can do this by creating an outline tree below a TODO item,
3821 with detailed subtasks on the tree@footnote{To keep subtasks out of the
3822 global TODO list, see the @code{org-agenda-todo-list-sublevels}.}.  To keep
3823 the overview over the fraction of subtasks that are already completed, insert
3824 either @samp{[/]} or @samp{[%]} anywhere in the headline.  These cookies will
3825 be updates each time the todo status of a child changes, or when pressing
3826 @kbd{C-c C-c} on the cookie.  For example:
3828 @example
3829 * Organize Party [33%]
3830 ** TODO Call people [1/2]
3831 *** TODO Peter
3832 *** DONE Sarah
3833 ** TODO Buy food
3834 ** DONE Talk to neighbor
3835 @end example
3837 @cindex property, COOKIE_DATA
3838 If a heading has both checkboxes and TODO children below it, the meaning of
3839 the statistics cookie become ambiguous.  Set the property
3840 @code{COOKIE_DATA} to either @samp{checkbox} or @samp{todo} to resolve
3841 this issue.
3843 @vindex org-hierarchical-todo-statistics
3844 If you would like to have the statistics cookie count any TODO entries in the
3845 subtree (not just direct children), configure the variable
3846 @code{org-hierarchical-todo-statistics}.  To do this for a single subtree,
3847 include the word @samp{recursive} into the value of the @code{COOKIE_DATA}
3848 property.
3850 @example
3851 * Parent capturing statistics [2/20]
3852   :PROPERTIES:
3853   :COOKIE_DATA: todo recursive
3854   :END:
3855 @end example
3857 If you would like a TODO entry to automatically change to DONE
3858 when all children are done, you can use the following setup:
3860 @example
3861 (defun org-summary-todo (n-done n-not-done)
3862   "Switch entry to DONE when all subentries are done, to TODO otherwise."
3863   (let (org-log-done org-log-states)   ; turn off logging
3864     (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
3866 (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
3867 @end example
3870 Another possibility is the use of checkboxes to identify (a hierarchy of) a
3871 large number of subtasks (@pxref{Checkboxes}).
3874 @node Checkboxes,  , Breaking down tasks, TODO Items
3875 @section Checkboxes
3876 @cindex checkboxes
3878 Every item in a plain list (@pxref{Plain lists}) can be made into a
3879 checkbox by starting it with the string @samp{[ ]}.  This feature is
3880 similar to TODO items (@pxref{TODO Items}), but is more lightweight.
3881 Checkboxes are not included into the global TODO list, so they are often
3882 great to split a task into a number of simple steps.  Or you can use
3883 them in a shopping list.  To toggle a checkbox, use @kbd{C-c C-c}, or
3884 use the mouse (thanks to Piotr Zielinski's @file{org-mouse.el}).
3886 Here is an example of a checkbox list.
3888 @example
3889 * TODO Organize party [2/4]
3890   - [-] call people [1/3]
3891     - [ ] Peter
3892     - [X] Sarah
3893     - [ ] Sam
3894   - [X] order food
3895   - [ ] think about what music to play
3896   - [X] talk to the neighbors
3897 @end example
3899 Checkboxes work hierarchically, so if a checkbox item has children that
3900 are checkboxes, toggling one of the children checkboxes will make the
3901 parent checkbox reflect if none, some, or all of the children are
3902 checked.
3904 @cindex statistics, for checkboxes
3905 @cindex checkbox statistics
3906 @cindex property, COOKIE_DATA
3907 @vindex org-hierarchical-checkbox-statistics
3908 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are cookies
3909 indicating how many checkboxes present in this entry have been checked off,
3910 and the total number of checkboxes present.  This can give you an idea on how
3911 many checkboxes remain, even without opening a folded entry.  The cookies can
3912 be placed into a headline or into (the first line of) a plain list item.
3913 Each cookie covers checkboxes of direct children structurally below the
3914 headline/item on which the cookie appears@footnote{Set the variable
3915 @code{org-hierarchical-checkbox-statistics} if you want such cookies to
3916 represent the all checkboxes below the cookie, not just the direct
3917 children.}.  You have to insert the cookie yourself by typing either
3918 @samp{[/]} or @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m}
3919 result, as in the examples above.  With @samp{[%]} you get information about
3920 the percentage of checkboxes checked (in the above example, this would be
3921 @samp{[50%]} and @samp{[33%]}, respectively).  In a headline, a cookie can
3922 count either checkboxes below the heading or TODO states of children, and it
3923 will display whatever was changed last.  Set the property @code{COOKIE_DATA}
3924 to either @samp{checkbox} or @samp{todo} to resolve this issue.
3926 @cindex blocking, of checkboxes
3927 @cindex checkbox blocking
3928 @cindex property, ORDERED
3929 If the current outline node has an @code{ORDERED} property, checkboxes must
3930 be checked off in sequence, and an error will be thrown if you try to check
3931 off a box while there are unchecked boxes above it.
3933 @noindent The following commands work with checkboxes:
3935 @table @kbd
3936 @kindex C-c C-c
3937 @item C-c C-c
3938 Toggle checkbox status or (with prefix arg) checkbox presence at point.  With
3939 double prefix argument, set it to @samp{[-]}, which is considered to be an
3940 intermediate state.
3941 @kindex C-c C-x C-b
3942 @item C-c C-x C-b
3943 Toggle checkbox status or (with prefix arg) checkbox presence at point.  With
3944 double prefix argument, set it to @samp{[-]}, which is considered to be an
3945 intermediate state.
3946 @itemize @minus
3947 @item
3948 If there is an active region, toggle the first checkbox in the region
3949 and set all remaining boxes to the same status as the first.  With a prefix
3950 arg, add or remove the checkbox for all items in the region.
3951 @item
3952 If the cursor is in a headline, toggle checkboxes in the region between
3953 this headline and the next (so @emph{not} the entire subtree).
3954 @item
3955 If there is no active region, just toggle the checkbox at point.
3956 @end itemize
3957 @kindex M-S-@key{RET}
3958 @item M-S-@key{RET}
3959 Insert a new item with a checkbox.
3960 This works only if the cursor is already in a plain list item
3961 (@pxref{Plain lists}).
3962 @kindex C-c C-x o
3963 @item C-c C-x o
3964 @vindex org-track-ordered-property-with-tag
3965 @cindex property, ORDERED
3966 Toggle the @code{ORDERED} property of the entry, to toggle if checkboxes must
3967 be checked off in sequence.  A property is used for this behavior because
3968 this should be local to the current entry, not inherited like a tag.
3969 However, if you would like to @i{track} the value of this property with a tag
3970 for better visibility, customize the variable
3971 @code{org-track-ordered-property-with-tag}.
3972 @kindex C-c #
3973 @item C-c #
3974 Update the statistics cookie in the current outline entry.  When called with
3975 a @kbd{C-u} prefix, update the entire file.  Checkbox statistic cookies are
3976 updated automatically if you toggle checkboxes with @kbd{C-c C-c} and make
3977 new ones with @kbd{M-S-@key{RET}}.  TODO statistics cookies update when
3978 changing TODO states.  If you delete boxes/entries or add/change them by
3979 hand, use this command to get things back into sync.  Or simply toggle any
3980 entry twice (checkboxes with @kbd{C-c C-c}).
3981 @end table
3983 @node Tags, Properties and Columns, TODO Items, Top
3984 @chapter Tags
3985 @cindex tags
3986 @cindex headline tagging
3987 @cindex matching, tags
3988 @cindex sparse tree, tag based
3990 An excellent way to implement labels and contexts for cross-correlating
3991 information is to assign @i{tags} to headlines.  Org mode has extensive
3992 support for tags.
3994 @vindex org-tag-faces
3995 Every headline can contain a list of tags; they occur at the end of the
3996 headline.  Tags are normal words containing letters, numbers, @samp{_}, and
3997 @samp{@@}.  Tags must be preceded and followed by a single colon, e.g.,
3998 @samp{:work:}.  Several tags can be specified, as in @samp{:work:urgent:}.
3999 Tags will by default be in bold face with the same color as the headline.
4000 You may specify special faces for specific tags using the variable
4001 @code{org-tag-faces}, in much the same way as you can for TODO keywords
4002 (@pxref{Faces for TODO keywords}).
4004 @menu
4005 * Tag inheritance::             Tags use the tree structure of the outline
4006 * Setting tags::                How to assign tags to a headline
4007 * Tag searches::                Searching for combinations of tags
4008 @end menu
4010 @node Tag inheritance, Setting tags, Tags, Tags
4011 @section Tag inheritance
4012 @cindex tag inheritance
4013 @cindex inheritance, of tags
4014 @cindex sublevels, inclusion into tags match
4016 @i{Tags} make use of the hierarchical structure of outline trees.  If a
4017 heading has a certain tag, all subheadings will inherit the tag as
4018 well.  For example, in the list
4020 @example
4021 * Meeting with the French group      :work:
4022 ** Summary by Frank                  :boss:notes:
4023 *** TODO Prepare slides for him      :action:
4024 @end example
4026 @noindent
4027 the final heading will have the tags @samp{:work:}, @samp{:boss:},
4028 @samp{:notes:}, and @samp{:action:} even though the final heading is not
4029 explicitly marked with those tags.  You can also set tags that all entries in
4030 a file should inherit just as if these tags were defined in a hypothetical
4031 level zero that surrounds the entire file.  Use a line like this@footnote{As
4032 with all these in-buffer settings, pressing @kbd{C-c C-c} activates any
4033 changes in the line.}:
4035 @cindex #+FILETAGS
4036 @example
4037 #+FILETAGS: :Peter:Boss:Secret:
4038 @end example
4040 @noindent
4041 @vindex org-use-tag-inheritance
4042 @vindex org-tags-exclude-from-inheritance
4043 To limit tag inheritance to specific tags, or to turn it off entirely, use
4044 the variables @code{org-use-tag-inheritance} and
4045 @code{org-tags-exclude-from-inheritance}.
4047 @vindex org-tags-match-list-sublevels
4048 When a headline matches during a tags search while tag inheritance is turned
4049 on, all the sublevels in the same tree will (for a simple match form) match
4050 as well@footnote{This is only true if the search does not involve more
4051 complex tests including properties (@pxref{Property searches}).}.  The list
4052 of matches may then become very long.  If you only want to see the first tags
4053 match in a subtree, configure the variable
4054 @code{org-tags-match-list-sublevels} (not recommended).
4056 @node Setting tags, Tag searches, Tag inheritance, Tags
4057 @section Setting tags
4058 @cindex setting tags
4059 @cindex tags, setting
4061 @kindex M-@key{TAB}
4062 Tags can simply be typed into the buffer at the end of a headline.
4063 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
4064 also a special command for inserting tags:
4066 @table @kbd
4067 @kindex C-c C-q
4068 @item C-c C-q
4069 @cindex completion, of tags
4070 @vindex org-tags-column
4071 Enter new tags for the current headline.  Org mode will either offer
4072 completion or a special single-key interface for setting tags, see
4073 below.  After pressing @key{RET}, the tags will be inserted and aligned
4074 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
4075 tags in the current buffer will be aligned to that column, just to make
4076 things look nice.  TAGS are automatically realigned after promotion,
4077 demotion, and TODO state changes (@pxref{TODO basics}).
4078 @kindex C-c C-c
4079 @item C-c C-c
4080 When the cursor is in a headline, this does the same as @kbd{C-c C-q}.
4081 @end table
4083 @vindex org-tag-alist
4084 Org will support tag insertion based on a @emph{list of tags}.  By
4085 default this list is constructed dynamically, containing all tags
4086 currently used in the buffer.  You may also globally specify a hard list
4087 of tags with the variable @code{org-tag-alist}.  Finally you can set
4088 the default tags for a given file with lines like
4090 @cindex #+TAGS
4091 @example
4092 #+TAGS: @@work @@home @@tennisclub
4093 #+TAGS: laptop car pc sailboat
4094 @end example
4096 If you have globally defined your preferred set of tags using the
4097 variable @code{org-tag-alist}, but would like to use a dynamic tag list
4098 in a specific file, add an empty TAGS option line to that file:
4100 @example
4101 #+TAGS:
4102 @end example
4104 @vindex org-tag-persistent-alist
4105 If you have a preferred set of tags that you would like to use in every file,
4106 in addition to those defined on a per-file basis by TAGS option lines, then
4107 you may specify a list of tags with the variable
4108 @code{org-tag-persistent-alist}.  You may turn this off on a per-file basis
4109 by adding a STARTUP option line to that file:
4111 @example
4112 #+STARTUP: noptag
4113 @end example
4115 By default Org mode uses the standard minibuffer completion facilities for
4116 entering tags.  However, it also implements another, quicker, tag selection
4117 method called @emph{fast tag selection}.  This allows you to select and
4118 deselect tags with just a single key press.  For this to work well you should
4119 assign unique letters to most of your commonly used tags.  You can do this
4120 globally by configuring the variable @code{org-tag-alist} in your
4121 @file{.emacs} file.  For example, you may find the need to tag many items in
4122 different files with @samp{:@@home:}.  In this case you can set something
4123 like:
4125 @lisp
4126 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
4127 @end lisp
4129 @noindent If the tag is only relevant to the file you are working on, then you
4130 can instead set the TAGS option line as:
4132 @example
4133 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
4134 @end example
4136 @noindent The tags interface will show the available tags in a splash
4137 window.  If you want to start a new line after a specific tag, insert
4138 @samp{\n} into the tag list
4140 @example
4141 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t) \n laptop(l)  pc(p)
4142 @end example
4144 @noindent or write them in two lines:
4146 @example
4147 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)
4148 #+TAGS: laptop(l)  pc(p)
4149 @end example
4151 @noindent
4152 You can also group together tags that are mutually exclusive by using
4153 braces, as in:
4155 @example
4156 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
4157 @end example
4159 @noindent you indicate that at most one of @samp{@@work}, @samp{@@home},
4160 and @samp{@@tennisclub} should be selected.  Multiple such groups are allowed.
4162 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
4163 these lines to activate any changes.
4165 @noindent
4166 To set these mutually exclusive groups in the variable @code{org-tags-alist},
4167 you must use the dummy tags @code{:startgroup} and @code{:endgroup} instead
4168 of the braces.  Similarly, you can use @code{:newline} to indicate a line
4169 break.  The previous example would be set globally by the following
4170 configuration:
4172 @lisp
4173 (setq org-tag-alist '((:startgroup . nil)
4174                       ("@@work" . ?w) ("@@home" . ?h)
4175                       ("@@tennisclub" . ?t)
4176                       (:endgroup . nil)
4177                       ("laptop" . ?l) ("pc" . ?p)))
4178 @end lisp
4180 If at least one tag has a selection key then pressing @kbd{C-c C-c} will
4181 automatically present you with a special interface, listing inherited tags,
4182 the tags of the current headline, and a list of all valid tags with
4183 corresponding keys@footnote{Keys will automatically be assigned to tags which
4184 have no configured keys.}.  In this interface, you can use the following
4185 keys:
4187 @table @kbd
4188 @item a-z...
4189 Pressing keys assigned to tags will add or remove them from the list of
4190 tags in the current line.  Selecting a tag in a group of mutually
4191 exclusive tags will turn off any other tags from that group.
4192 @kindex @key{TAB}
4193 @item @key{TAB}
4194 Enter a tag in the minibuffer, even if the tag is not in the predefined
4195 list.  You will be able to complete on all tags present in the buffer.
4196 @kindex @key{SPC}
4197 @item @key{SPC}
4198 Clear all tags for this line.
4199 @kindex @key{RET}
4200 @item @key{RET}
4201 Accept the modified set.
4202 @item C-g
4203 Abort without installing changes.
4204 @item q
4205 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
4206 @item !
4207 Turn off groups of mutually exclusive tags.  Use this to (as an
4208 exception) assign several tags from such a group.
4209 @item C-c
4210 Toggle auto-exit after the next change (see below).
4211 If you are using expert mode, the first @kbd{C-c} will display the
4212 selection window.
4213 @end table
4215 @noindent
4216 This method lets you assign tags to a headline with very few keys.  With
4217 the above setup, you could clear the current tags and set @samp{@@home},
4218 @samp{laptop} and @samp{pc} tags with just the following keys: @kbd{C-c
4219 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to
4220 @samp{@@work} would be done with @kbd{C-c C-c w @key{RET}} or
4221 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
4222 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
4223 @key{RET} @key{RET}}.
4225 @vindex org-fast-tag-selection-single-key
4226 If you find that most of the time you need only a single key press to
4227 modify your list of tags, set the variable
4228 @code{org-fast-tag-selection-single-key}.  Then you no longer have to
4229 press @key{RET} to exit fast tag selection---it will immediately exit
4230 after the first change.  If you then occasionally need more keys, press
4231 @kbd{C-c} to turn off auto-exit for the current tag selection process
4232 (in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
4233 C-c}).  If you set the variable to the value @code{expert}, the special
4234 window is not even shown for single-key tag selection, it comes up only
4235 when you press an extra @kbd{C-c}.
4237 @vindex org-complete-tags-always-offer-all-agenda-tags
4238 As said before, when setting tags and @code{org-tag-alist} is nil, then the
4239 list of tags in the current buffer is used.  Normally, this behavior is very
4240 convenient, except in org remember buffers (@pxref{Remember}), because there
4241 are no tags that can be calculated dynamically.  Here, you most probably want
4242 to have completion for all tags in all agenda files.  This can be done by
4243 setting @code{org-complete-tags-always-offer-all-agenda-tags} to non-nil in
4244 those buffers.
4246 @lisp
4247 (add-hook 'org-remember-mode-hook
4248           (lambda ()
4249             (set (make-local-variable
4250                   'org-complete-tags-always-offer-all-agenda-tags)
4251                  t)))
4252 @end lisp
4254 Of course, you can also set it to @code{t} globally if you always want to
4255 have completion of all tags in all agenda files.
4257 @node Tag searches,  , Setting tags, Tags
4258 @section Tag searches
4259 @cindex tag searches
4260 @cindex searching for tags
4262 Once a system of tags has been set up, it can be used to collect related
4263 information into special lists.
4265 @table @kbd
4266 @kindex C-c \
4267 @kindex C-c / m
4268 @item C-c \
4269 @itemx C-c / m
4270 Create a sparse tree with all headlines matching a tags search.  With a
4271 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
4272 @kindex C-c a m
4273 @item C-c a m
4274 Create a global list of tag matches from all agenda files.
4275 @xref{Matching tags and properties}.
4276 @kindex C-c a M
4277 @item C-c a M
4278 @vindex org-tags-match-list-sublevels
4279 Create a global list of tag matches from all agenda files, but check
4280 only TODO items and force checking subitems (see variable
4281 @code{org-tags-match-list-sublevels}).
4282 @end table
4284 These commands all prompt for a match string which allows basic Boolean logic
4285 like @samp{+boss+urgent-project1}, to find entries with tags @samp{boss} and
4286 @samp{urgent}, but not @samp{project1}, or @samp{Kathy|Sally} to find entries
4287 which are tagged, like @samp{Kathy} or @samp{Sally}.  The full syntax of the search
4288 string is rich and allows also matching against TODO keywords, entry levels
4289 and properties.  For a complete description with many examples, see
4290 @ref{Matching tags and properties}.
4293 @node Properties and Columns, Dates and Times, Tags, Top
4294 @chapter Properties and Columns
4295 @cindex properties
4297 Properties are a set of key-value pairs associated with an entry.  There
4298 are two main applications for properties in Org mode.  First, properties
4299 are like tags, but with a value.  Second, you can use properties to
4300 implement (very basic) database capabilities in an Org buffer.  For
4301 an example of the first application, imagine maintaining a file where
4302 you document bugs and plan releases for a piece of software.  Instead of
4303 using tags like @code{:release_1:}, @code{:release_2:}, one can use a
4304 property, say @code{:Release:}, that in different subtrees has different
4305 values, such as @code{1.0} or @code{2.0}.  For an example of the second
4306 application of properties, imagine keeping track of your music CDs,
4307 where properties could be things such as the album, artist, date of
4308 release, number of tracks, and so on.
4310 Properties can be conveniently edited and viewed in column view
4311 (@pxref{Column view}).
4313 @menu
4314 * Property syntax::             How properties are spelled out
4315 * Special properties::          Access to other Org mode features
4316 * Property searches::           Matching property values
4317 * Property inheritance::        Passing values down the tree
4318 * Column view::                 Tabular viewing and editing
4319 * Property API::                Properties for Lisp programmers
4320 @end menu
4322 @node Property syntax, Special properties, Properties and Columns, Properties and Columns
4323 @section Property syntax
4324 @cindex property syntax
4325 @cindex drawer, for properties
4327 Properties are key-value pairs.  They need to be inserted into a special
4328 drawer (@pxref{Drawers}) with the name @code{PROPERTIES}.  Each property
4329 is specified on a single line, with the key (surrounded by colons)
4330 first, and the value after it.  Here is an example:
4332 @example
4333 * CD collection
4334 ** Classic
4335 *** Goldberg Variations
4336     :PROPERTIES:
4337     :Title:     Goldberg Variations
4338     :Composer:  J.S. Bach
4339     :Artist:    Glen Gould
4340     :Publisher: Deutsche Grammophon
4341     :NDisks:    1
4342     :END:
4343 @end example
4345 You may define the allowed values for a particular property @samp{:Xyz:}
4346 by setting a property @samp{:Xyz_ALL:}.  This special property is
4347 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
4348 the entire tree.  When allowed values are defined, setting the
4349 corresponding property becomes easier and is less prone to typing
4350 errors.  For the example with the CD collection, we can predefine
4351 publishers and the number of disks in a box like this:
4353 @example
4354 * CD collection
4355   :PROPERTIES:
4356   :NDisks_ALL:  1 2 3 4
4357   :Publisher_ALL: "Deutsche Grammophon" Philips EMI
4358   :END:
4359 @end example
4361 If you want to set properties that can be inherited by any entry in a
4362 file, use a line like
4363 @cindex property, _ALL
4364 @cindex #+PROPERTY
4365 @example
4366 #+PROPERTY: NDisks_ALL 1 2 3 4
4367 @end example
4369 @vindex org-global-properties
4370 Property values set with the global variable
4371 @code{org-global-properties} can be inherited by all entries in all
4372 Org files.
4374 @noindent
4375 The following commands help to work with properties:
4377 @table @kbd
4378 @kindex M-@key{TAB}
4379 @item M-@key{TAB}
4380 After an initial colon in a line, complete property keys.  All keys used
4381 in the current file will be offered as possible completions.
4382 @kindex C-c C-x p
4383 @item C-c C-x p
4384 Set a property.  This prompts for a property name and a value.  If
4385 necessary, the property drawer is created as well.
4386 @item M-x org-insert-property-drawer
4387 Insert a property drawer into the current entry.  The drawer will be
4388 inserted early in the entry, but after the lines with planning
4389 information like deadlines.
4390 @kindex C-c C-c
4391 @item C-c C-c
4392 With the cursor in a property drawer, this executes property commands.
4393 @item C-c C-c s
4394 Set a property in the current entry.  Both the property and the value
4395 can be inserted using completion.
4396 @kindex S-@key{right}
4397 @kindex S-@key{left}
4398 @item S-@key{left}/@key{right}
4399 Switch property at point to the next/previous allowed value.
4400 @item C-c C-c d
4401 Remove a property from the current entry.
4402 @item C-c C-c D
4403 Globally remove a property, from all entries in the current file.
4404 @item C-c C-c c
4405 Compute the property at point, using the operator and scope from the
4406 nearest column format definition.
4407 @end table
4409 @node Special properties, Property searches, Property syntax, Properties and Columns
4410 @section Special properties
4411 @cindex properties, special
4413 Special properties provide an alternative access method to Org mode
4414 features, like the TODO state or the priority of an entry, discussed in the
4415 previous chapters.  This interface exists so that you can include
4416 these states in a column view (@pxref{Column view}), or to use them in
4417 queries.  The following property names are special and should not be
4418 used as keys in the properties drawer:
4420 @cindex property, special, TODO
4421 @cindex property, special, TAGS
4422 @cindex property, special, ALLTAGS
4423 @cindex property, special, CATEGORY
4424 @cindex property, special, PRIORITY
4425 @cindex property, special, DEADLINE
4426 @cindex property, special, SCHEDULED
4427 @cindex property, special, CLOSED
4428 @cindex property, special, TIMESTAMP
4429 @cindex property, special, TIMESTAMP_IA
4430 @cindex property, special, CLOCKSUM
4431 @c guessing that ITEM is needed in this area; also, should this list be sorted?
4432 @cindex property, special, ITEM
4433 @example
4434 TODO         @r{The TODO keyword of the entry.}
4435 TAGS         @r{The tags defined directly in the headline.}
4436 ALLTAGS      @r{All tags, including inherited ones.}
4437 CATEGORY     @r{The category of an entry.}
4438 PRIORITY     @r{The priority of the entry, a string with a single letter.}
4439 DEADLINE     @r{The deadline time string, without the angular brackets.}
4440 SCHEDULED    @r{The scheduling timestamp, without the angular brackets.}
4441 CLOSED       @r{When was this entry closed?}
4442 TIMESTAMP    @r{The first keyword-less timestamp in the entry.}
4443 TIMESTAMP_IA @r{The first inactive timestamp in the entry.}
4444 CLOCKSUM     @r{The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}}
4445              @r{must be run first to compute the values.}
4446 ITEM         @r{The content of the entry.}
4447 @end example
4449 @node Property searches, Property inheritance, Special properties, Properties and Columns
4450 @section Property searches
4451 @cindex properties, searching
4452 @cindex searching, of properties
4454 To create sparse trees and special lists with selection based on properties,
4455 the same commands are used as for tag searches (@pxref{Tag searches}).
4456 @table @kbd
4457 @kindex C-c \
4458 @kindex C-c / m
4459 @item C-c \
4460 @itemx C-c / m
4461 Create a sparse tree with all matching entries.  With a
4462 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
4463 @kindex C-c a m
4464 @item C-c a m
4465 Create a global list of tag/property  matches from all agenda files.
4466 @xref{Matching tags and properties}.
4467 @kindex C-c a M
4468 @item C-c a M
4469 @vindex org-tags-match-list-sublevels
4470 Create a global list of tag matches from all agenda files, but check
4471 only TODO items and force checking of subitems (see variable
4472 @code{org-tags-match-list-sublevels}).
4473 @end table
4475 The syntax for the search string is described in @ref{Matching tags and
4476 properties}.
4478 There is also a special command for creating sparse trees based on a
4479 single property:
4481 @table @kbd
4482 @kindex C-c / p
4483 @item C-c / p
4484 Create a sparse tree based on the value of a property.  This first
4485 prompts for the name of a property, and then for a value.  A sparse tree
4486 is created with all entries that define this property with the given
4487 value.  If you enclose the value into curly braces, it is interpreted as
4488 a regular expression and matched against the property values.
4489 @end table
4491 @node Property inheritance, Column view, Property searches, Properties and Columns
4492 @section Property Inheritance
4493 @cindex properties, inheritance
4494 @cindex inheritance, of properties
4496 @vindex org-use-property-inheritance
4497 The outline structure of Org-mode documents lends itself for an
4498 inheritance model of properties: if the parent in a tree has a certain
4499 property, the children can inherit this property.  Org mode does not
4500 turn this on by default, because it can slow down property searches
4501 significantly and is often not needed.  However, if you find inheritance
4502 useful, you can turn it on by setting the variable
4503 @code{org-use-property-inheritance}.  It may be set to @code{t} to make
4504 all properties inherited from the parent, to a list of properties
4505 that should be inherited, or to a regular expression that matches
4506 inherited properties.
4508 Org mode has a few properties for which inheritance is hard-coded, at
4509 least for the special applications for which they are used:
4511 @cindex property, COLUMNS
4512 @table @code
4513 @item COLUMNS
4514 The @code{:COLUMNS:} property defines the format of column view
4515 (@pxref{Column view}).  It is inherited in the sense that the level
4516 where a @code{:COLUMNS:} property is defined is used as the starting
4517 point for a column view table, independently of the location in the
4518 subtree from where columns view is turned on.
4519 @item CATEGORY
4520 @cindex property, CATEGORY
4521 For agenda view, a category set through a @code{:CATEGORY:} property
4522 applies to the entire subtree.
4523 @item ARCHIVE
4524 @cindex property, ARCHIVE
4525 For archiving, the @code{:ARCHIVE:} property may define the archive
4526 location for the entire subtree (@pxref{Moving subtrees}).
4527 @item LOGGING
4528 @cindex property, LOGGING
4529 The LOGGING property may define logging settings for an entry or a
4530 subtree (@pxref{Tracking TODO state changes}).
4531 @end table
4533 @node Column view, Property API, Property inheritance, Properties and Columns
4534 @section Column view
4536 A great way to view and edit properties in an outline tree is
4537 @emph{column view}.  In column view, each outline node is turned into a
4538 table row.  Columns in this table provide access to properties of the
4539 entries.  Org mode implements columns by overlaying a tabular structure
4540 over the headline of each item.  While the headlines have been turned
4541 into a table row, you can still change the visibility of the outline
4542 tree.  For example, you get a compact table by switching to CONTENTS
4543 view (@kbd{S-@key{TAB} S-@key{TAB}}, or simply @kbd{c} while column view
4544 is active), but you can still open, read, and edit the entry below each
4545 headline.  Or, you can switch to column view after executing a sparse
4546 tree command and in this way get a table only for the selected items.
4547 Column view also works in agenda buffers (@pxref{Agenda Views}) where
4548 queries have collected selected items, possibly from a number of files.
4550 @menu
4551 * Defining columns::            The COLUMNS format property
4552 * Using column view::           How to create and use column view
4553 * Capturing column view::       A dynamic block for column view
4554 @end menu
4556 @node Defining columns, Using column view, Column view, Column view
4557 @subsection Defining columns
4558 @cindex column view, for properties
4559 @cindex properties, column view
4561 Setting up a column view first requires defining the columns.  This is
4562 done by defining a column format line.
4564 @menu
4565 * Scope of column definitions::  Where defined, where valid?
4566 * Column attributes::           Appearance and content of a column
4567 @end menu
4569 @node Scope of column definitions, Column attributes, Defining columns, Defining columns
4570 @subsubsection Scope of column definitions
4572 To define a column format for an entire file, use a line like
4574 @cindex #+COLUMNS
4575 @example
4576 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
4577 @end example
4579 To specify a format that only applies to a specific tree, add a
4580 @code{:COLUMNS:} property to the top node of that tree, for example:
4582 @example
4583 ** Top node for columns view
4584    :PROPERTIES:
4585    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
4586    :END:
4587 @end example
4589 If a @code{:COLUMNS:} property is present in an entry, it defines columns
4590 for the entry itself, and for the entire subtree below it.  Since the
4591 column definition is part of the hierarchical structure of the document,
4592 you can define columns on level 1 that are general enough for all
4593 sublevels, and more specific columns further down, when you edit a
4594 deeper part of the tree.
4596 @node Column attributes,  , Scope of column definitions, Defining columns
4597 @subsubsection Column attributes
4598 A column definition sets the attributes of a column.  The general
4599 definition looks like this:
4601 @example
4602  %[@var{width}]@var{property}[(@var{title})][@{@var{summary-type}@}]
4603 @end example
4605 @noindent
4606 Except for the percent sign and the property name, all items are
4607 optional.  The individual parts have the following meaning:
4609 @example
4610 @var{width}           @r{An integer specifying the width of the column in characters.}
4611                 @r{If omitted, the width will be determined automatically.}
4612 @var{property}        @r{The property that should be edited in this column.}
4613                 @r{Special properties representing meta data are allowed here}
4614                 @r{as well (@pxref{Special properties})}
4615 (title)         @r{The header text for the column. If omitted, the}
4616                 @r{property name is used.}
4617 @{@var{summary-type}@}  @r{The summary type.  If specified, the column values for}
4618                 @r{parent nodes are computed from the children.}
4619                 @r{Supported summary types are:}
4620                 @{+@}       @r{Sum numbers in this column.}
4621                 @{+;%.1f@}  @r{Like @samp{+}, but format result with @samp{%.1f}.}
4622                 @{$@}       @r{Currency, short for @samp{+;%.2f}.}
4623                 @{:@}       @r{Sum times, HH:MM:SS, plain numbers are hours.}
4624                 @{X@}       @r{Checkbox status, @samp{[X]} if all children are @samp{[X]}.}
4625                 @{X/@}      @r{Checkbox status, @samp{[n/m]}.}
4626                 @{X%@}      @r{Checkbox status, @samp{[n%]}.}
4627                 @{min@}     @r{Smallest number in column.}
4628                 @{max@}     @r{Largest number.}
4629                 @{mean@}    @r{Arithmetic mean of numbers.}
4630                 @{:min@}    @r{Smallest time value in column.}
4631                 @{:max@}    @r{Largest time value.}
4632                 @{:mean@}   @r{Arithmetic mean of time values.}
4633                 @{@@min@}   @r{Minimum age (in days/hours/mins/seconds).}
4634                 @{@@max@}   @r{Maximum age (in days/hours/mins/seconds).}
4635                 @{@@mean@}  @r{Arithmetic mean of ages (in days/hours/mins/seconds).}
4636 @end example
4638 @noindent
4639 Be aware that you can only have one summary type for any property you
4640 include. Subsequent columns referencing the same property will all display the
4641 same summary information.
4643 Here is an example for a complete columns definition, along with allowed
4644 values.
4646 @example
4647 :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.}
4648                    %10Time_Estimate@{:@} %CLOCKSUM
4649 :Owner_ALL:    Tammy Mark Karl Lisa Don
4650 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
4651 :Approved_ALL: "[ ]" "[X]"
4652 @end example
4654 @noindent
4655 The first column, @samp{%25ITEM}, means the first 25 characters of the
4656 item itself, i.e. of the headline.  You probably always should start the
4657 column definition with the @samp{ITEM} specifier.  The other specifiers
4658 create columns @samp{Owner} with a list of names as allowed values, for
4659 @samp{Status} with four different possible values, and for a checkbox
4660 field @samp{Approved}.  When no width is given after the @samp{%}
4661 character, the column will be exactly as wide as it needs to be in order
4662 to fully display all values.  The @samp{Approved} column does have a
4663 modified title (@samp{Approved?}, with a question mark).  Summaries will
4664 be created for the @samp{Time_Estimate} column by adding time duration
4665 expressions like HH:MM, and for the @samp{Approved} column, by providing
4666 an @samp{[X]} status if all children have been checked.  The
4667 @samp{CLOCKSUM} column is special, it lists the sum of CLOCK intervals
4668 in the subtree.
4670 @node Using column view, Capturing column view, Defining columns, Column view
4671 @subsection Using column view
4673 @table @kbd
4674 @tsubheading{Turning column view on and off}
4675 @kindex C-c C-x C-c
4676 @item C-c C-x C-c
4677 @vindex org-columns-default-format
4678 Turn on column view.  If the cursor is before the first headline in the file,
4679 column view is turned on for the entire file, using the @code{#+COLUMNS}
4680 definition.  If the cursor is somewhere inside the outline, this command
4681 searches the hierarchy, up from point, for a @code{:COLUMNS:} property that
4682 defines a format.  When one is found, the column view table is established
4683 for the tree starting at the entry that contains the @code{:COLUMNS:}
4684 property.  If no such property is found, the format is taken from the
4685 @code{#+COLUMNS} line or from the variable @code{org-columns-default-format},
4686 and column view is established for the current entry and its subtree.
4687 @kindex r
4688 @item r
4689 Recreate the column view, to include recent changes made in the buffer.
4690 @kindex g
4691 @item g
4692 Same as @kbd{r}.
4693 @kindex q
4694 @item q
4695 Exit column view.
4696 @tsubheading{Editing values}
4697 @item @key{left} @key{right} @key{up} @key{down}
4698 Move through the column view from field to field.
4699 @kindex S-@key{left}
4700 @kindex S-@key{right}
4701 @item  S-@key{left}/@key{right}
4702 Switch to the next/previous allowed value of the field.  For this, you
4703 have to have specified allowed values for a property.
4704 @item 1..9,0
4705 Directly select the nth allowed value, @kbd{0} selects the 10th value.
4706 @kindex n
4707 @kindex p
4708 @itemx  n / p
4709 Same as @kbd{S-@key{left}/@key{right}}
4710 @kindex e
4711 @item e
4712 Edit the property at point.  For the special properties, this will
4713 invoke the same interface that you normally use to change that
4714 property.  For example, when editing a TAGS property, the tag completion
4715 or fast selection interface will pop up.
4716 @kindex C-c C-c
4717 @item C-c C-c
4718 When there is a checkbox at point, toggle it.
4719 @kindex v
4720 @item v
4721 View the full value of this property.  This is useful if the width of
4722 the column is smaller than that of the value.
4723 @kindex a
4724 @item a
4725 Edit the list of allowed values for this property.  If the list is found
4726 in the hierarchy, the modified values is stored there.  If no list is
4727 found, the new value is stored in the first entry that is part of the
4728 current column view.
4729 @tsubheading{Modifying the table structure}
4730 @kindex <
4731 @kindex >
4732 @item < / >
4733 Make the column narrower/wider by one character.
4734 @kindex S-M-@key{right}
4735 @item S-M-@key{right}
4736 Insert a new column, to the left of the current column.
4737 @kindex S-M-@key{left}
4738 @item S-M-@key{left}
4739 Delete the current column.
4740 @end table
4742 @node Capturing column view,  , Using column view, Column view
4743 @subsection Capturing column view
4745 Since column view is just an overlay over a buffer, it cannot be
4746 exported or printed directly.  If you want to capture a column view, use
4747 a @code{columnview} dynamic block (@pxref{Dynamic blocks}).  The frame
4748 of this block looks like this:
4750 @cindex #+BEGIN, columnview
4751 @example
4752 * The column view
4753 #+BEGIN: columnview :hlines 1 :id "label"
4755 #+END:
4756 @end example
4758 @noindent This dynamic block has the following parameters:
4760 @table @code
4761 @item :id
4762 This is the most important parameter.  Column view is a feature that is
4763 often localized to a certain (sub)tree, and the capture block might be
4764 at a different location in the file.  To identify the tree whose view to
4765 capture, you can use 4 values:
4766 @cindex property, ID
4767 @example
4768 local     @r{use the tree in which the capture block is located}
4769 global    @r{make a global view, including all headings in the file}
4770 "file:@var{path-to-file}"
4771           @r{run column view at the top of this file}
4772 "@var{ID}"      @r{call column view in the tree that has an @code{:ID:}}
4773           @r{property with the value @i{label}.  You can use}
4774           @r{@kbd{M-x org-id-copy} to create a globally unique ID for}
4775           @r{the current entry and copy it to the kill-ring.}
4776 @end example
4777 @item :hlines
4778 When @code{t}, insert an hline after every line.  When a number @var{N}, insert
4779 an hline before each headline with level @code{<= @var{N}}.
4780 @item :vlines
4781 When set to @code{t}, force column groups to get vertical lines.
4782 @item :maxlevel
4783 When set to a number, don't capture entries below this level.
4784 @item :skip-empty-rows
4785 When set to @code{t}, skip rows where the only non-empty specifier of the
4786 column view is @code{ITEM}.
4788 @end table
4790 @noindent
4791 The following commands insert or update the dynamic block:
4793 @table @kbd
4794 @kindex C-c C-x i
4795 @item C-c C-x i
4796 Insert a dynamic block capturing a column view.  You will be prompted
4797 for the scope or ID of the view.
4798 @kindex C-c C-c
4799 @item C-c C-c
4800 @kindex C-c C-x C-u
4801 @itemx C-c C-x C-u
4802 Update dynamic block at point.  The cursor needs to be in the
4803 @code{#+BEGIN} line of the dynamic block.
4804 @kindex C-u C-c C-x C-u
4805 @item C-u C-c C-x C-u
4806 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
4807 you have several clock table blocks in a buffer.
4808 @end table
4810 You can add formulas to the column view table and you may add plotting
4811 instructions in front of the table---these will survive an update of the
4812 block.  If there is a @code{#+TBLFM:} after the table, the table will
4813 actually be recalculated automatically after an update.
4815 An alternative way to capture and process property values into a table is
4816 provided by Eric Schulte's @file{org-collector.el} which is a contributed
4817 package@footnote{Contributed packages are not part of Emacs, but are
4818 distributed with the main distribution of Org (visit
4819 @uref{http://orgmode.org}).}.  It provides a general API to collect
4820 properties from entries in a certain scope, and arbitrary Lisp expressions to
4821 process these values before inserting them into a table or a dynamic block.
4823 @node Property API,  , Column view, Properties and Columns
4824 @section The Property API
4825 @cindex properties, API
4826 @cindex API, for properties
4828 There is a full API for accessing and changing properties.  This API can
4829 be used by Emacs Lisp programs to work with properties and to implement
4830 features based on them.  For more information see @ref{Using the
4831 property API}.
4833 @node Dates and Times, Capture - Refile - Archive, Properties and Columns, Top
4834 @chapter Dates and Times
4835 @cindex dates
4836 @cindex times
4837 @cindex timestamp
4838 @cindex date stamp
4840 To assist project planning, TODO items can be labeled with a date and/or
4841 a time.  The specially formatted string carrying the date and time
4842 information is called a @emph{timestamp} in Org mode.  This may be a
4843 little confusing because timestamp is often used as indicating when
4844 something was created or last changed.  However, in Org mode this term
4845 is used in a much wider sense.
4847 @menu
4848 * Timestamps::                  Assigning a time to a tree entry
4849 * Creating timestamps::         Commands which insert timestamps
4850 * Deadlines and scheduling::    Planning your work
4851 * Clocking work time::          Tracking how long you spend on a task
4852 * Resolving idle time::         Resolving time if you've been idle
4853 * Effort estimates::            Planning work effort in advance
4854 * Relative timer::              Notes with a running timer
4855 @end menu
4858 @node Timestamps, Creating timestamps, Dates and Times, Dates and Times
4859 @section Timestamps, deadlines, and scheduling
4860 @cindex timestamps
4861 @cindex ranges, time
4862 @cindex date stamps
4863 @cindex deadlines
4864 @cindex scheduling
4866 A timestamp is a specification of a date (possibly with a time or a range of
4867 times) in a special format, either @samp{<2003-09-16 Tue>} or
4868 @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16 Tue
4869 12:00-12:30>}@footnote{This is inspired by the standard ISO 6801 date/time
4870 format.  To use an alternative format, see @ref{Custom time format}.}.  A
4871 timestamp can appear anywhere in the headline or body of an Org tree entry.
4872 Its presence causes entries to be shown on specific dates in the agenda
4873 (@pxref{Weekly/daily agenda}).  We distinguish:
4875 @table @var
4876 @item Plain timestamp; Event; Appointment
4877 @cindex timestamp
4878 A simple timestamp just assigns a date/time to an item.  This is just
4879 like writing down an appointment or event in a paper agenda.  In the
4880 timeline and agenda displays, the headline of an entry associated with a
4881 plain timestamp will be shown exactly on that date.
4883 @example
4884 * Meet Peter at the movies <2006-11-01 Wed 19:15>
4885 * Discussion on climate change <2006-11-02 Thu 20:00-22:00>
4886 @end example
4888 @item Timestamp with repeater interval
4889 @cindex timestamp, with repeater interval
4890 A timestamp may contain a @emph{repeater interval}, indicating that it
4891 applies not only on the given date, but again and again after a certain
4892 interval of N days (d), weeks (w), months (m), or years (y).  The
4893 following will show up in the agenda every Wednesday:
4895 @example
4896 * Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
4897 @end example
4899 @item Diary-style sexp entries
4900 For more complex date specifications, Org mode supports using the
4901 special sexp diary entries implemented in the Emacs calendar/diary
4902 package.  For example
4904 @example
4905 * The nerd meeting on every 2nd Thursday of the month
4906   <%%(diary-float t 4 2)>
4907 @end example
4909 @item Time/Date range
4910 @cindex timerange
4911 @cindex date range
4912 Two timestamps connected by @samp{--} denote a range.  The headline
4913 will be shown on the first and last day of the range, and on any dates
4914 that are displayed and fall in the range.  Here is an example:
4916 @example
4917 ** Meeting in Amsterdam
4918    <2004-08-23 Mon>--<2004-08-26 Thu>
4919 @end example
4921 @item Inactive timestamp
4922 @cindex timestamp, inactive
4923 @cindex inactive timestamp
4924 Just like a plain timestamp, but with square brackets instead of
4925 angular ones.  These timestamps are inactive in the sense that they do
4926 @emph{not} trigger an entry to show up in the agenda.
4928 @example
4929 * Gillian comes late for the fifth time [2006-11-01 Wed]
4930 @end example
4932 @end table
4934 @node Creating timestamps, Deadlines and scheduling, Timestamps, Dates and Times
4935 @section Creating timestamps
4936 @cindex creating timestamps
4937 @cindex timestamps, creating
4939 For Org mode to recognize timestamps, they need to be in the specific
4940 format.  All commands listed below produce timestamps in the correct
4941 format.
4943 @table @kbd
4944 @kindex C-c .
4945 @item C-c .
4946 Prompt for a date and insert a corresponding timestamp.  When the cursor is
4947 at an existing timestamp in the buffer, the command is used to modify this
4948 timestamp instead of inserting a new one.  When this command is used twice in
4949 succession, a time range is inserted.
4951 @kindex C-c !
4952 @item C-c !
4953 Like @kbd{C-c .}, but insert an inactive timestamp that will not cause
4954 an agenda entry.
4956 @kindex C-u C-c .
4957 @kindex C-u C-c !
4958 @item C-u C-c .
4959 @itemx C-u C-c !
4960 @vindex org-time-stamp-rounding-minutes
4961 Like @kbd{C-c .} and @kbd{C-c !}, but use the alternative format which
4962 contains date and time.  The default time can be rounded to multiples of 5
4963 minutes, see the option @code{org-time-stamp-rounding-minutes}.
4965 @kindex C-c <
4966 @item C-c <
4967 Insert a timestamp corresponding to the cursor date in the Calendar.
4969 @kindex C-c >
4970 @item C-c >
4971 Access the Emacs calendar for the current date.  If there is a
4972 timestamp in the current line, go to the corresponding date
4973 instead.
4975 @kindex C-c C-o
4976 @item C-c C-o
4977 Access the agenda for the date given by the timestamp or -range at
4978 point (@pxref{Weekly/daily agenda}).
4980 @kindex S-@key{left}
4981 @kindex S-@key{right}
4982 @item S-@key{left}
4983 @itemx S-@key{right}
4984 Change date at cursor by one day.  These key bindings conflict with
4985 shift-selection and related modes (@pxref{Conflicts}).
4987 @kindex S-@key{up}
4988 @kindex S-@key{down}
4989 @item S-@key{up}
4990 @itemx S-@key{down}
4991 Change the item under the cursor in a timestamp.  The cursor can be on a
4992 year, month, day, hour or minute.  When the timestamp contains a time range
4993 like @samp{15:30-16:30}, modifying the first time will also shift the second,
4994 shifting the time block with constant length.  To change the length, modify
4995 the second time.  Note that if the cursor is in a headline and not at a
4996 timestamp, these same keys modify the priority of an item.
4997 (@pxref{Priorities}). The key bindings also conflict with shift-selection and
4998 related modes (@pxref{Conflicts}).
5000 @kindex C-c C-y
5001 @cindex evaluate time range
5002 @item C-c C-y
5003 Evaluate a time range by computing the difference between start and end.
5004 With a prefix argument, insert result after the time range (in a table: into
5005 the following column).
5006 @end table
5009 @menu
5010 * The date/time prompt::        How Org mode helps you entering date and time
5011 * Custom time format::          Making dates look different
5012 @end menu
5014 @node The date/time prompt, Custom time format, Creating timestamps, Creating timestamps
5015 @subsection The date/time prompt
5016 @cindex date, reading in minibuffer
5017 @cindex time, reading in minibuffer
5019 @vindex org-read-date-prefer-future
5020 When Org mode prompts for a date/time, the default is shown in default
5021 date/time format, and the prompt therefore seems to ask for a specific
5022 format.  But it will in fact accept any string containing some date and/or
5023 time information, and it is really smart about interpreting your input.  You
5024 can, for example, use @kbd{C-y} to paste a (possibly multi-line) string
5025 copied from an email message.  Org mode will find whatever information is in
5026 there and derive anything you have not specified from the @emph{default date
5027 and time}.  The default is usually the current date and time, but when
5028 modifying an existing timestamp, or when entering the second stamp of a
5029 range, it is taken from the stamp in the buffer.  When filling in
5030 information, Org mode assumes that most of the time you will want to enter a
5031 date in the future: if you omit the month/year and the given day/month is
5032 @i{before} today, it will assume that you mean a future date@footnote{See the
5033 variable @code{org-read-date-prefer-future}.  You may set that variable to
5034 the symbol @code{time} to even make a time before now shift the date to
5035 tomorrow.}.  If the date has been automatically shifted into the future, the
5036 time prompt will show this with @samp{(=>F).}
5038 For example, let's assume that today is @b{June 13, 2006}.  Here is how
5039 various inputs will be interpreted, the items filled in by Org mode are
5040 in @b{bold}.
5042 @example
5043 3-2-5         --> 2003-02-05
5044 14            --> @b{2006}-@b{06}-14
5045 12            --> @b{2006}-@b{07}-12
5046 Fri           --> nearest Friday (defaultdate or later)
5047 sep 15        --> @b{2006}-09-15
5048 feb 15        --> @b{2007}-02-15
5049 sep 12 9      --> 2009-09-12
5050 12:45         --> @b{2006}-@b{06}-@b{13} 12:45
5051 22 sept 0:34  --> @b{2006}-09-22 0:34
5052 w4            --> ISO week for of the current year @b{2006}
5053 2012 w4 fri   --> Friday of ISO week 4 in 2012
5054 2012-w04-5    --> Same as above
5055 @end example
5057 Furthermore you can specify a relative date by giving, as the
5058 @emph{first} thing in the input: a plus/minus sign, a number and a
5059 letter ([dwmy]) to indicate change in days, weeks, months, or years.  With a
5060 single plus or minus, the date is always relative to today.  With a
5061 double plus or minus, it is relative to the default date.  If instead of
5062 a single letter, you use the abbreviation of day name, the date will be
5063 the nth such day.  E.g.
5065 @example
5066 +0            --> today
5067 .             --> today
5068 +4d           --> four days from today
5069 +4            --> same as above
5070 +2w           --> two weeks from today
5071 ++5           --> five days from default date
5072 +2tue         --> second Tuesday from now.
5073 @end example
5075 @vindex parse-time-months
5076 @vindex parse-time-weekdays
5077 The function understands English month and weekday abbreviations.  If
5078 you want to use unabbreviated names and/or other languages, configure
5079 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
5081 @cindex calendar, for selecting date
5082 @vindex org-popup-calendar-for-date-prompt
5083 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
5084 you don't need/want the calendar, configure the variable
5085 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
5086 prompt, either by clicking on a date in the calendar, or by pressing
5087 @key{RET}, the date selected in the calendar will be combined with the
5088 information entered at the prompt.  You can control the calendar fully
5089 from the minibuffer:
5091 @kindex <
5092 @kindex >
5093 @kindex mouse-1
5094 @kindex S-@key{right}
5095 @kindex S-@key{left}
5096 @kindex S-@key{down}
5097 @kindex S-@key{up}
5098 @kindex M-S-@key{right}
5099 @kindex M-S-@key{left}
5100 @kindex @key{RET}
5101 @example
5102 > / <          @r{Scroll calendar forward/backward by one month.}
5103 mouse-1        @r{Select date by clicking on it.}
5104 S-@key{right}/@key{left}     @r{One day forward/backward.}
5105 S-@key{down}/@key{up}     @r{One week forward/backward.}
5106 M-S-@key{right}/@key{left}   @r{One month forward/backward.}
5107 @key{RET}           @r{Choose date in calendar.}
5108 @end example
5110 @vindex org-read-date-display-live
5111 The actions of the date/time prompt may seem complex, but I assure you they
5112 will grow on you, and you will start getting annoyed by pretty much any other
5113 way of entering a date/time out there.  To help you understand what is going
5114 on, the current interpretation of your input will be displayed live in the
5115 minibuffer@footnote{If you find this distracting, turn the display of with
5116 @code{org-read-date-display-live}.}.
5118 @node Custom time format,  , The date/time prompt, Creating timestamps
5119 @subsection Custom time format
5120 @cindex custom date/time format
5121 @cindex time format, custom
5122 @cindex date format, custom
5124 @vindex org-display-custom-times
5125 @vindex org-time-stamp-custom-formats
5126 Org mode uses the standard ISO notation for dates and times as it is
5127 defined in ISO 8601.  If you cannot get used to this and require another
5128 representation of date and time to keep you happy, you can get it by
5129 customizing the variables @code{org-display-custom-times} and
5130 @code{org-time-stamp-custom-formats}.
5132 @table @kbd
5133 @kindex C-c C-x C-t
5134 @item C-c C-x C-t
5135 Toggle the display of custom formats for dates and times.
5136 @end table
5138 @noindent
5139 Org mode needs the default format for scanning, so the custom date/time
5140 format does not @emph{replace} the default format---instead it is put
5141 @emph{over} the default format using text properties.  This has the
5142 following consequences:
5143 @itemize @bullet
5144 @item
5145 You cannot place the cursor onto a timestamp anymore, only before or
5146 after.
5147 @item
5148 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
5149 each component of a timestamp.  If the cursor is at the beginning of
5150 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
5151 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
5152 time will be changed by one minute.
5153 @item
5154 If the timestamp contains a range of clock times or a repeater, these
5155 will not be overlayed, but remain in the buffer as they were.
5156 @item
5157 When you delete a timestamp character-by-character, it will only
5158 disappear from the buffer after @emph{all} (invisible) characters
5159 belonging to the ISO timestamp have been removed.
5160 @item
5161 If the custom timestamp format is longer than the default and you are
5162 using dates in tables, table alignment will be messed up.  If the custom
5163 format is shorter, things do work as expected.
5164 @end itemize
5167 @node Deadlines and scheduling, Clocking work time, Creating timestamps, Dates and Times
5168 @section Deadlines and scheduling
5170 A timestamp may be preceded by special keywords to facilitate planning:
5172 @table @var
5173 @item DEADLINE
5174 @cindex DEADLINE keyword
5176 Meaning: the task (most likely a TODO item, though not necessarily) is supposed
5177 to be finished on that date.
5179 @vindex org-deadline-warning-days
5180 On the deadline date, the task will be listed in the agenda.  In
5181 addition, the agenda for @emph{today} will carry a warning about the
5182 approaching or missed deadline, starting
5183 @code{org-deadline-warning-days} before the due date, and continuing
5184 until the entry is marked DONE.  An example:
5186 @example
5187 *** TODO write article about the Earth for the Guide
5188     The editor in charge is [[bbdb:Ford Prefect]]
5189     DEADLINE: <2004-02-29 Sun>
5190 @end example
5192 You can specify a different lead time for warnings for a specific
5193 deadlines using the following syntax.  Here is an example with a warning
5194 period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.
5196 @item SCHEDULED
5197 @cindex SCHEDULED keyword
5199 Meaning: you are planning to start working on that task on the given
5200 date.
5202 @vindex org-agenda-skip-scheduled-if-done
5203 The headline will be listed under the given date@footnote{It will still
5204 be listed on that date after it has been marked DONE.  If you don't like
5205 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
5206 addition, a reminder that the scheduled date has passed will be present
5207 in the compilation for @emph{today}, until the entry is marked DONE.
5208 I.e. the task will automatically be forwarded until completed.
5210 @example
5211 *** TODO Call Trillian for a date on New Years Eve.
5212     SCHEDULED: <2004-12-25 Sat>
5213 @end example
5215 @noindent
5216 @b{Important:} Scheduling an item in Org mode should @i{not} be
5217 understood in the same way that we understand @i{scheduling a meeting}.
5218 Setting a date for a meeting is just a simple appointment, you should
5219 mark this entry with a simple plain timestamp, to get this item shown
5220 on the date where it applies.  This is a frequent misunderstanding by
5221 Org users.  In Org mode, @i{scheduling} means setting a date when you
5222 want to start working on an action item.
5223 @end table
5225 You may use timestamps with repeaters in scheduling and deadline
5226 entries.  Org mode will issue early and late warnings based on the
5227 assumption that the timestamp represents the @i{nearest instance} of
5228 the repeater.  However, the use of diary sexp entries like
5230 @code{<%%(diary-float t 42)>}
5232 in scheduling and deadline timestamps is limited.  Org mode does not
5233 know enough about the internals of each sexp function to issue early and
5234 late warnings.  However, it will show the item on each day where the
5235 sexp entry matches.
5237 @menu
5238 * Inserting deadline/schedule::  Planning items
5239 * Repeated tasks::              Items that show up again and again
5240 @end menu
5242 @node Inserting deadline/schedule, Repeated tasks, Deadlines and scheduling, Deadlines and scheduling
5243 @subsection Inserting deadlines or schedules
5245 The following commands allow you to quickly insert a deadline or to schedule
5246 an item:
5248 @table @kbd
5250 @kindex C-c C-d
5251 @item C-c C-d
5252 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will happen
5253 in the line directly following the headline.  When called with a prefix arg,
5254 an existing deadline will be removed from the entry.  Depending on the
5255 variable @code{org-log-redeadline}@footnote{with corresponding
5256 @code{#+STARTUP} keywords @code{logredeadline}, @code{lognoteredeadline},
5257 and @code{nologredeadline}}, a note will be taken when changing an existing
5258 deadline.
5259 @c FIXME Any CLOSED timestamp will be removed.????????
5261 @kindex C-c C-s
5262 @item C-c C-s
5263 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
5264 happen in the line directly following the headline.  Any CLOSED timestamp
5265 will be removed.  When called with a prefix argument, remove the scheduling
5266 date from the entry.  Depending on the variable
5267 @code{org-log-reschedule}@footnote{with corresponding @code{#+STARTUP}
5268 keywords @code{logredeadline}, @code{lognoteredeadline}, and
5269 @code{nologredeadline}}, a note will be taken when changing an existing
5270 scheduling time.
5272 @kindex C-c C-x C-k
5273 @kindex k a
5274 @kindex k s
5275 @item C-c C-x C-k
5276 Mark the current entry for agenda action.  After you have marked the entry
5277 like this, you can open the agenda or the calendar to find an appropriate
5278 date.  With the cursor on the selected date, press @kbd{k s} or @kbd{k d} to
5279 schedule the marked item.
5281 @kindex C-c / d
5282 @cindex sparse tree, for deadlines
5283 @item C-c / d
5284 @vindex org-deadline-warning-days
5285 Create a sparse tree with all deadlines that are either past-due, or
5286 which will become due within @code{org-deadline-warning-days}.
5287 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
5288 prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows
5289 all deadlines due tomorrow.
5291 @kindex C-c / b
5292 @item C-c / b
5293 Sparse tree for deadlines and scheduled items before a given date.
5295 @kindex C-c / a
5296 @item C-c / a
5297 Sparse tree for deadlines and scheduled items after a given date.
5298 @end table
5300 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
5301 @subsection Repeated tasks
5302 @cindex tasks, repeated
5303 @cindex repeated tasks
5305 Some tasks need to be repeated again and again.  Org mode helps to
5306 organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
5307 or plain timestamp.  In the following example
5308 @example
5309 ** TODO Pay the rent
5310    DEADLINE: <2005-10-01 Sat +1m>
5311 @end example
5312 @noindent
5313 the @code{+1m} is a repeater; the intended interpretation is that the task
5314 has a deadline on <2005-10-01> and repeats itself every (one) month starting
5315 from that time.  If you need both a repeater and a special warning period in
5316 a deadline entry, the repeater should come first and the warning period last:
5317 @code{DEADLINE: <2005-10-01 Sat +1m -3d>}.
5319 Deadlines and scheduled items produce entries in the agenda when they
5320 are over-due, so it is important to be able to mark such an entry as
5321 completed once you have done so.  When you mark a DEADLINE or a SCHEDULE
5322 with the TODO keyword DONE, it will no longer produce entries in the
5323 agenda.  The problem with this is, however, that then also the
5324 @emph{next} instance of the repeated entry will not be active.  Org mode
5325 deals with this in the following way: When you try to mark such an entry
5326 DONE (using @kbd{C-c C-t}), it will shift the base date of the repeating
5327 timestamp by the repeater interval, and immediately set the entry state
5328 back to TODO.  In the example above, setting the state to DONE would
5329 actually switch the date like this:
5331 @example
5332 ** TODO Pay the rent
5333    DEADLINE: <2005-11-01 Tue +1m>
5334 @end example
5336 @vindex org-log-repeat
5337 A timestamp@footnote{You can change this using the option
5338 @code{org-log-repeat}, or the @code{#+STARTUP} options @code{logrepeat},
5339 @code{lognoterepeat}, and @code{nologrepeat}.  With @code{lognoterepeat}, you
5340 will also be prompted for a note.} will be added under the deadline, to keep
5341 a record that you actually acted on the previous instance of this deadline.
5343 As a consequence of shifting the base date, this entry will no longer be
5344 visible in the agenda when checking past dates, but all future instances
5345 will be visible.
5347 With the @samp{+1m} cookie, the date shift will always be exactly one
5348 month.  So if you have not paid the rent for three months, marking this
5349 entry DONE will still keep it as an overdue deadline.  Depending on the
5350 task, this may not be the best way to handle it.  For example, if you
5351 forgot to call you father for 3 weeks, it does not make sense to call
5352 him 3 times in a single day to make up for it.  Finally, there are tasks
5353 like changing batteries which should always repeat a certain time
5354 @i{after} the last time you did it.  For these tasks, Org mode has
5355 special repeaters markers with @samp{++} and @samp{.+}.  For example:
5357 @example
5358 ** TODO Call Father
5359    DEADLINE: <2008-02-10 Sun ++1w>
5360    Marking this DONE will shift the date by at least one week,
5361    but also by as many weeks as it takes to get this date into
5362    the future.  However, it stays on a Sunday, even if you called
5363    and marked it done on Saturday.
5364 ** TODO Check the batteries in the smoke detectors
5365    DEADLINE: <2005-11-01 Tue .+1m>
5366    Marking this DONE will shift the date to one month after
5367    today.
5368 @end example
5370 You may have both scheduling and deadline information for a specific
5371 task---just make sure that the repeater intervals on both are the same.
5373 An alternative to using a repeater is to create a number of copies of a task
5374 subtree, with dates shifted in each copy.  The command @kbd{C-c C-x c} was
5375 created for this purpose, it is described in @ref{Structure editing}.
5378 @node Clocking work time, Resolving idle time, Deadlines and scheduling, Dates and Times
5379 @section Clocking work time
5381 Org mode allows you to clock the time you spend on specific tasks in a
5382 project.  When you start working on an item, you can start the clock.
5383 When you stop working on that task, or when you mark the task done, the
5384 clock is stopped and the corresponding time interval is recorded.  It
5385 also computes the total time spent on each subtree of a project.  And it
5386 remembers a history or tasks recently clocked, to that you can jump quickly
5387 between a number of tasks absorbing your time.
5389 To save the clock history across Emacs sessions, use
5390 @lisp
5391 (setq org-clock-persist 'history)
5392 (org-clock-persistence-insinuate)
5393 @end lisp
5394 When you clock into a new task after resuming Emacs, the incomplete
5395 clock@footnote{To resume the clock under the assumption that you have worked
5396 on this task while outside Emacs, use @code{(setq org-clock-persist t)}.}
5397 will be found (@pxref{Resolving idle time}) and you will be prompted about
5398 what to do with it.
5400 @table @kbd
5401 @kindex C-c C-x C-i
5402 @item C-c C-x C-i
5403 @vindex org-clock-into-drawer
5404 Start the clock on the current item (clock-in).  This inserts the CLOCK
5405 keyword together with a timestamp.  If this is not the first clocking of
5406 this item, the multiple CLOCK lines will be wrapped into a
5407 @code{:LOGBOOK:} drawer (see also the variable
5408 @code{org-clock-into-drawer}).  When called with a @kbd{C-u} prefix argument,
5409 select the task from a list of recently clocked tasks.  With two @kbd{C-u
5410 C-u} prefixes, clock into the task at point and mark it as the default task.
5411 The default task will always be available when selecting a clocking task,
5412 with letter @kbd{d}.@*
5413 @cindex property: CLOCK_MODELINE_TOTAL
5414 @cindex property: LAST_REPEAT
5415 @vindex org-clock-modeline-total
5416 While the clock is running, the current clocking time is shown in the mode
5417 line, along with the title of the task.  The clock time shown will be all
5418 time ever clocked for this task and its children.  If the task has an effort
5419 estimate (@pxref{Effort estimates}), the mode line displays the current
5420 clocking time against it@footnote{To add an effort estimate ``on the fly'',
5421 hook a function doing this to @code{org-clock-in-prepare-hook}.}  If the task
5422 is a repeating one (@pxref{Repeated tasks}), only the time since the last
5423 reset of the task @footnote{as recorded by the @code{LAST_REPEAT} property}
5424 will be shown.  More control over what time is shown can be exercised with
5425 the @code{CLOCK_MODELINE_TOTAL} property.  It may have the values
5426 @code{current} to show only the current clocking instance, @code{today} to
5427 show all time clocked on this tasks today (see also the variable
5428 @code{org-extend-today-until}), @code{all} to include all time, or
5429 @code{auto} which is the default@footnote{See also the variable
5430 @code{org-clock-modeline-total}.}.@* Clicking with @kbd{mouse-1} onto the
5431 mode line entry will pop up a menu with clocking options.
5432 @kindex C-c C-x C-o
5433 @item C-c C-x C-o
5434 @vindex org-log-note-clock-out
5435 Stop the clock (clock-out).  This inserts another timestamp at the same
5436 location where the clock was last started.  It also directly computes
5437 the resulting time in inserts it after the time range as @samp{=>
5438 HH:MM}.  See the variable @code{org-log-note-clock-out} for the
5439 possibility to record an additional note together with the clock-out
5440 timestamp@footnote{The corresponding in-buffer setting is:
5441 @code{#+STARTUP: lognoteclock-out}}.
5442 @kindex C-c C-x C-e
5443 @item C-c C-x C-e
5444 Update the effort estimate for the current clock task.
5445 @kindex C-c C-y
5446 @kindex C-c C-c
5447 @item C-c C-y @ @ @r{or}@ @ C-c C-c
5448 Recompute the time interval after changing one of the timestamps.  This
5449 is only necessary if you edit the timestamps directly.  If you change
5450 them with @kbd{S-@key{cursor}} keys, the update is automatic.
5451 @kindex C-c C-t
5452 @item C-c C-t
5453 Changing the TODO state of an item to DONE automatically stops the clock
5454 if it is running in this same item.
5455 @kindex C-c C-x C-x
5456 @item C-c C-x C-x
5457 Cancel the current clock.  This is useful if a clock was started by
5458 mistake, or if you ended up working on something else.
5459 @kindex C-c C-x C-j
5460 @item C-c C-x C-j
5461 Jump to the entry that contains the currently running clock.  With a
5462 @kbd{C-u} prefix arg, select the target task from a list of recently clocked
5463 tasks.
5464 @kindex C-c C-x C-d
5465 @item C-c C-x C-d
5466 @vindex org-remove-highlights-with-change
5467 Display time summaries for each subtree in the current buffer.  This
5468 puts overlays at the end of each headline, showing the total time
5469 recorded under that heading, including the time of any subheadings. You
5470 can use visibility cycling to study the tree, but the overlays disappear
5471 when you change the buffer (see variable
5472 @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
5473 @kindex C-c C-x C-r
5474 @item C-c C-x C-r
5475 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
5476 report as an Org-mode table into the current file.  When the cursor is
5477 at an existing clock table, just update it.  When called with a prefix
5478 argument, jump to the first clock report in the current document and
5479 update it.
5480 @cindex #+BEGIN, clocktable
5481 @example
5482 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
5483 #+END: clocktable
5484 @end example
5485 @noindent
5486 If such a block already exists at point, its content is replaced by the
5487 new table.  The @samp{BEGIN} line can specify options:
5488 @example
5489 :maxlevel    @r{Maximum level depth to which times are listed in the table.}
5490 :emphasize   @r{When @code{t}, emphasize level one and level two items.}
5491 :scope       @r{The scope to consider.  This can be any of the following:}
5492              nil        @r{the current buffer or narrowed region}
5493              file       @r{the full current buffer}
5494              subtree    @r{the subtree where the clocktable is located}
5495              tree@var{N}      @r{the surrounding level @var{N} tree, for example @code{tree3}}
5496              tree       @r{the surrounding level 1 tree}
5497              agenda     @r{all agenda files}
5498              ("file"..) @r{scan these files}
5499              file-with-archives    @r{current file and its archives}
5500              agenda-with-archives  @r{all agenda files, including archives}
5501 :block       @r{The time block to consider.  This block is specified either}
5502              @r{absolute, or relative to the current time and may be any of}
5503              @r{these formats:}
5504              2007-12-31    @r{New year eve 2007}
5505              2007-12       @r{December 2007}
5506              2007-W50      @r{ISO-week 50 in 2007}
5507              2007          @r{the year 2007}
5508              today, yesterday, today-@var{N}          @r{a relative day}
5509              thisweek, lastweek, thisweek-@var{N}     @r{a relative week}
5510              thismonth, lastmonth, thismonth-@var{N}  @r{a relative month}
5511              thisyear, lastyear, thisyear-@var{N}     @r{a relative year}
5512              @r{Use @kbd{S-@key{left}/@key{right}} keys to shift the time interval.}
5513 :tstart      @r{A time string specifying when to start considering times.}
5514 :tend        @r{A time string specifying when to stop considering times.}
5515 :step        @r{@code{week} or @code{day}, to split the table into chunks.}
5516              @r{To use this, @code{:block} or @code{:tstart}, @code{:tend} are needed.}
5517 :link        @r{Link the item headlines in the table to their origins.}
5518 :formula     @r{Content of a @code{#+TBLFM} line to be added and evaluated.}
5519              @r{As a special case, @samp{:formula %} adds a column with % time.}
5520              @r{If you do not specify a formula here, any existing formula.}
5521              @r{below the clock table will survive updates and be evaluated.}
5522 :timestamp   @r{A timestamp for the entry, when available.  Look for SCHEDULED,}
5523              @r{DEADLINE, TIMESTAMP and TIMESTAMP_IA, in this order.}
5524 @end example
5525 To get a clock summary of the current level 1 tree, for the current
5526 day, you could write
5527 @example
5528 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
5529 #+END: clocktable
5530 @end example
5531 @noindent
5532 and to use a specific time range you could write@footnote{Note that all
5533 parameters must be specified in a single line---the line is broken here
5534 only to fit it into the manual.}
5535 @example
5536 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
5537                     :tend "<2006-08-10 Thu 12:00>"
5538 #+END: clocktable
5539 @end example
5540 A summary of the current subtree with % times would be
5541 @example
5542 #+BEGIN: clocktable :scope subtree :link t :formula %
5543 #+END: clocktable
5544 @end example
5545 @kindex C-c C-c
5546 @item C-c C-c
5547 @kindex C-c C-x C-u
5548 @itemx C-c C-x C-u
5549 Update dynamic block at point.  The cursor needs to be in the
5550 @code{#+BEGIN} line of the dynamic block.
5551 @kindex C-u C-c C-x C-u
5552 @item C-u C-c C-x C-u
5553 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
5554 you have several clock table blocks in a buffer.
5555 @kindex S-@key{left}
5556 @kindex S-@key{right}
5557 @item S-@key{left}
5558 @itemx S-@key{right}
5559 Shift the current @code{:block} interval and update the table.  The cursor
5560 needs to be in the @code{#+BEGIN: clocktable} line for this command.  If
5561 @code{:block} is @code{today}, it will be shifted to @code{today-1} etc.
5562 @end table
5564 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
5565 the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
5566 worked on or closed during a day.
5568 @node Resolving idle time, Effort estimates, Clocking work time, Dates and Times
5569 @section Resolving idle time
5570 @cindex resolve idle time
5572 @cindex idle, resolve, dangling
5573 If you clock in on a work item, and then walk away from your
5574 computer---perhaps to take a phone call---you often need to ``resolve'' the
5575 time you were away by either subtracting it from the current clock, or
5576 applying it to another one.
5578 @vindex org-clock-idle-time
5579 By customizing the variable @code{org-clock-idle-time} to some integer, such
5580 as 10 or 15, Emacs can alert you when you get back to your computer after
5581 being idle for that many minutes@footnote{On computers using Mac OS X,
5582 idleness is based on actual user idleness, not just Emacs' idle time.  For
5583 X11, you can install a utility program @file{x11idle.c}, available in the
5584 UTILITIES directory of the Org git distribution, to get the same general
5585 treatment of idleness.  On other systems, idle time refers to Emacs idle time
5586 only.}, and ask what you want to do with the idle time.  There will be a
5587 question waiting for you when you get back, indicating how much idle time has
5588 passed (constantly updated with the current amount), as well as a set of
5589 choices to correct the discrepancy:
5591 @table @kbd
5592 @item k
5593 To keep some or all of the minutes and stay clocked in, press @kbd{k}.  Org
5594 will ask how many of the minutes to keep.  Press @key{RET} to keep them all,
5595 effectively changing nothing, or enter a number to keep that many minutes.
5596 @item K
5597 If you use the shift key and press @kbd{K}, it will keep however many minutes
5598 you request and then immediately clock out of that task.  If you keep all of
5599 the minutes, this is the same as just clocking out of the current task.
5600 @item s
5601 To keep none of the minutes, use @kbd{s} to subtract all the away time from
5602 the clock, and then check back in from the moment you returned.
5603 @item S
5604 To keep none of the minutes and just clock out at the start of the away time,
5605 use the shift key and press @kbd{S}.  Remember that using shift will always
5606 leave you clocked out, no matter which option you choose.
5607 @item C
5608 To cancel the clock altogether, use @kbd{C}.  Note that if instead of
5609 cancelling you subtract the away time, and the resulting clock amount is less
5610 than a minute, the clock will still be cancelled rather than clutter up the
5611 log with an empty entry.
5612 @end table
5614 What if you subtracted those away minutes from the current clock, and now
5615 want to apply them to a new clock?  Simply clock in to any task immediately
5616 after the subtraction.  Org will notice that you have subtracted time ``on
5617 the books'', so to speak, and will ask if you want to apply those minutes to
5618 the next task you clock in on.
5620 There is one other instance when this clock resolution magic occurs.  Say you
5621 were clocked in and hacking away, and suddenly your cat chased a mouse who
5622 scared a hamster that crashed into your UPS's power button!  You suddenly
5623 lose all your buffers, but thanks to auto-save you still have your recent Org
5624 mode changes, including your last clock in.
5626 If you restart Emacs and clock into any task, Org will notice that you have a
5627 dangling clock which was never clocked out from your last session.  Using
5628 that clock's starting time as the beginning of the unaccounted-for period,
5629 Org will ask how you want to resolve that time.  The logic and behavior is
5630 identical to dealing with away time due to idleness, it's just happening due
5631 to a recovery event rather than a set amount of idle time.
5633 You can also check all the files visited by your Org agenda for dangling
5634 clocks at any time using @kbd{M-x org-resolve-clocks}.
5636 @node Effort estimates, Relative timer, Resolving idle time, Dates and Times
5637 @section Effort estimates
5638 @cindex effort estimates
5640 @cindex property, Effort
5641 @vindex org-effort-property
5642 If you want to plan your work in a very detailed way, or if you need to
5643 produce offers with quotations of the estimated work effort, you may want to
5644 assign effort estimates to entries.  If you are also clocking your work, you
5645 may later want to compare the planned effort with the actual working time, a
5646 great way to improve planning estimates.  Effort estimates are stored in a
5647 special property @samp{Effort}@footnote{You may change the property being
5648 used with the variable @code{org-effort-property}.}.  You can set the effort
5649 for an entry with the following commands:
5651 @table @kbd
5652 @kindex C-c C-x e
5653 @item C-c C-x e
5654 Set the effort estimate for the current entry.  With a numeric prefix
5655 argument, set it to the NTH allowed value (see below).  This command is also
5656 accessible from the agenda with the @kbd{e} key.
5657 @kindex C-c C-x C-e
5658 @item C-c C-x C-e
5659 Modify the effort estimate of the item currently being clocked.
5660 @end table
5662 Clearly the best way to work with effort estimates is through column view
5663 (@pxref{Column view}).  You should start by setting up discrete values for
5664 effort estimates, and a @code{COLUMNS} format that displays these values
5665 together with clock sums (if you want to clock your time).  For a specific
5666 buffer you can use
5668 @example
5669 #+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00 8:00
5670 #+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort)@{:@} %CLOCKSUM
5671 @end example
5673 @noindent
5674 @vindex org-global-properties
5675 @vindex org-columns-default-format
5676 or, even better, you can set up these values globally by customizing the
5677 variables @code{org-global-properties} and @code{org-columns-default-format}.
5678 In particular if you want to use this setup also in the agenda, a global
5679 setup may be advised.
5681 The way to assign estimates to individual items is then to switch to column
5682 mode, and to use @kbd{S-@key{right}} and @kbd{S-@key{left}} to change the
5683 value.  The values you enter will immediately be summed up in the hierarchy.
5684 In the column next to it, any clocked time will be displayed.
5686 @vindex org-agenda-columns-add-appointments-to-effort-sum
5687 If you switch to column view in the daily/weekly agenda, the effort column
5688 will summarize the estimated work effort for each day@footnote{Please note
5689 the pitfalls of summing hierarchical data in a flat list (@pxref{Agenda
5690 column view}).}, and you can use this to find space in your schedule.  To get
5691 an overview of the entire part of the day that is committed, you can set the
5692 option @code{org-agenda-columns-add-appointments-to-effort-sum}.  The
5693 appointments on a day that take place over a specified time interval will
5694 then also be added to the load estimate of the day.
5696 Effort estimates can be used in secondary agenda filtering that is triggered
5697 with the @kbd{/} key in the agenda (@pxref{Agenda commands}).  If you have
5698 these estimates defined consistently, two or three key presses will narrow
5699 down the list to stuff that fits into an available time slot.
5701 @node Relative timer,  , Effort estimates, Dates and Times
5702 @section Taking notes with a relative timer
5703 @cindex relative timer
5705 When taking notes during, for example, a meeting or a video viewing, it can
5706 be useful to have access to times relative to a starting time.  Org provides
5707 such a relative timer and make it easy to create timed notes.
5709 @table @kbd
5710 @kindex C-c C-x .
5711 @item C-c C-x .
5712 Insert a relative time into the buffer.  The first time you use this, the
5713 timer will be started.  When called with a prefix argument, the timer is
5714 restarted.
5715 @kindex C-c C-x -
5716 @item C-c C-x -
5717 Insert a description list item with the current relative time.  With a prefix
5718 argument, first reset the timer to 0.
5719 @kindex M-@key{RET}
5720 @item M-@key{RET}
5721 Once the timer list is started, you can also use @kbd{M-@key{RET}} to insert
5722 new timer items.
5723 @kindex C-c C-x ,
5724 @item C-c C-x ,
5725 Pause the timer, or continue it if it is already paused.
5726 @c removed the sentence because it is redundant to the following item
5727 @kindex C-u C-c C-x ,
5728 @item C-u C-c C-x ,
5729 Stop the timer.  After this, you can only start a new timer, not continue the
5730 old one.  This command also removes the timer from the mode line.
5731 @kindex C-c C-x 0
5732 @item C-c C-x 0
5733 Reset the timer without inserting anything into the buffer.  By default, the
5734 timer is reset to 0.  When called with a @kbd{C-u} prefix, reset the timer to
5735 specific starting offset.  The user is prompted for the offset, with a
5736 default taken from a timer string at point, if any, So this can be used to
5737 restart taking notes after a break in the process.  When called with a double
5738 prefix argument @kbd{C-c C-u}, change all timer strings in the active region
5739 by a certain amount.  This can be used to fix timer strings if the timer was
5740 not started at exactly the right moment.
5741 @end table
5743 @node Capture - Refile - Archive, Agenda Views, Dates and Times, Top
5744 @chapter Capture - Refile - Archive
5745 @cindex capture
5747 An important part of any organization system is the ability to quickly
5748 capture new ideas and tasks, and to associate reference material with them.
5749 Org uses the @file{remember.el} package to create tasks, and stores files
5750 related to a task (@i{attachments}) in a special directory.  Once in the
5751 system, tasks and projects need to be moved around.  Moving completed project
5752 trees to an archive file keeps the system compact and fast.
5754 @menu
5755 * Remember::                    Capture new tasks/ideas with little interruption
5756 * Attachments::                 Add files to tasks.
5757 * RSS Feeds::                   Getting input from RSS feeds
5758 * Protocols::                   External (e.g. Browser) access to Emacs and Org
5759 * Refiling notes::              Moving a tree from one place to another
5760 * Archiving::                   What to do with finished projects
5761 @end menu
5763 @node Remember, Attachments, Capture - Refile - Archive, Capture - Refile - Archive
5764 @section Remember
5765 @cindex @file{remember.el}
5767 The Remember package by John Wiegley lets you store quick notes with little
5768 interruption of your work flow.  It is an excellent way to add new notes and
5769 tasks to Org files.  The @code{remember.el} package is part of Emacs 23, not
5770 Emacs 22.  See @uref{http://www.emacswiki.org/cgi-bin/wiki/RememberMode} for
5771 more information.
5773 Org significantly expands the possibilities of Remember: you may define
5774 templates for different note types, and associate target files and headlines
5775 with specific templates.  It also allows you to select the location where a
5776 note should be stored interactively, on the fly.
5778 @menu
5779 * Setting up Remember for Org::  Some code for .emacs to get things going
5780 * Remember templates::          Define the outline of different note types
5781 * Storing notes::               Directly get the note to where it belongs
5782 @end menu
5784 @node Setting up Remember for Org, Remember templates, Remember, Remember
5785 @subsection Setting up Remember for Org
5787 The following customization will tell Remember to use Org files as
5788 target, and to create annotations compatible with Org links.
5790 @example
5791 (org-remember-insinuate)
5792 (setq org-directory "~/path/to/my/orgfiles/")
5793 (setq org-default-notes-file (concat org-directory "/notes.org"))
5794 (define-key global-map "\C-cr" 'org-remember)
5795 @end example
5797 @noindent
5798 The last line binds the command @code{org-remember} to a global
5799 key@footnote{Please select your own key, @kbd{C-c r} is only a
5800 suggestion.}.  @code{org-remember} basically just calls Remember,
5801 but it makes a few things easier: if there is an active region, it will
5802 automatically copy the region into the Remember buffer.  It also allows
5803 to jump to the buffer and location where Remember notes are being
5804 stored: just call @code{org-remember} with a prefix argument.  If you
5805 use two prefix arguments, Org jumps to the location where the last
5806 remember note was stored.
5808 The Remember buffer will actually use @code{org-mode} as its major mode, so
5809 that all editing features of Org mode are available.  In addition to this, a
5810 minor mode @code{org-remember-mode} is turned on, for the single purpose that
5811 you can use its keymap @code{org-remember-mode-map} to overwrite some of
5812 Org mode's key bindings.
5814 You can also call @code{org-remember} in a special way from the agenda,
5815 using the @kbd{k r} key combination.  With this access, any timestamps
5816 inserted by the selected Remember template (see below) will default to
5817 the cursor date in the agenda, rather than to the current date.
5819 @node Remember templates, Storing notes, Setting up Remember for Org, Remember
5820 @subsection Remember templates
5821 @cindex templates, for Remember
5823 In combination with Org, you can use templates to generate
5824 different types of Remember notes.  For example, if you would like
5825 to use one template to create general TODO entries, another one for
5826 journal entries, and a third one for collecting random ideas, you could
5827 use:
5829 @example
5830 (setq org-remember-templates
5831  '(("Todo" ?t "* TODO %?\n  %i\n  %a" "~/org/TODO.org" "Tasks")
5832    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org")
5833    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
5834 @end example
5836 @vindex org-remember-default-headline
5837 @vindex org-directory
5838 @noindent In these entries, the first string is just a name, and the
5839 character specifies how to select the template.  It is useful if the
5840 character is also the first letter of the name.  The next string specifies
5841 the template.  Two more (optional) strings give the file in which, and the
5842 headline under which, the new note should be stored.  The file (if not
5843 present or @code{nil}) defaults to @code{org-default-notes-file}, the heading
5844 to @code{org-remember-default-headline}.  If the file name is not an absolute
5845 path, it will be interpreted relative to @code{org-directory}.
5847 The heading can also be the symbols @code{top} or @code{bottom} to send notes
5848 as level 1 entries to the beginning or end of the file, respectively.  It may
5849 also be the symbol @code{date-tree}.  Then, a tree with year on level 1,
5850 month on level 2 and day on level three will be build in the file, and the
5851 entry will be filed into the tree under the current date@footnote{If the file
5852 contains an entry with a @code{DATE_TREE} property, the entire date tree will
5853 be build under that entry.}
5855 An optional sixth element specifies the contexts in which the user can select
5856 the template.  This element can be a list of major modes or a function.
5857 @code{org-remember} will first check whether the function returns @code{t} or
5858 if we are in any of the listed major modes, and exclude templates for which
5859 this condition is not fulfilled.  Templates that do not specify this element
5860 at all, or that use @code{nil} or @code{t} as a value will always be
5861 selectable.
5863 So for example:
5865 @example
5866 (setq org-remember-templates
5867  '(("Bug" ?b "* BUG %?\n  %i\n  %a" "~/org/BUGS.org" "Bugs" (emacs-lisp-mode))
5868    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org" "X" my-check)
5869    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
5870 @end example
5872 @noindent
5873 The first template will only be available when invoking @code{org-remember}
5874 from an buffer in @code{emacs-lisp-mode}.  The second template will only be
5875 available when the function @code{my-check} returns @code{t}.  The third
5876 template will be proposed in any context.
5878 When you call @kbd{M-x org-remember} (or @kbd{M-x remember}) to remember
5879 something, Org will prompt for a key to select the template (if you have
5880 more than one template) and then prepare the buffer like
5881 @example
5882 * TODO
5883   [[file:@var{link to where you called remember}]]
5884 @end example
5886 @noindent
5887 During expansion of the template, special @kbd{%}-escapes@footnote{If you
5888 need one of these sequences literally, escape the @kbd{%} with a backslash.}
5889 allow dynamic insertion of content:
5890 @example
5891 %^@{@var{prompt}@}  @r{prompt the user for a string and replace this sequence with it.}
5892             @r{You may specify a default value and a completion table with}
5893             @r{%^@{prompt|default|completion2|completion3...@}}
5894             @r{The arrow keys access a prompt-specific history.}
5895 %a          @r{annotation, normally the link created with @code{org-store-link}}
5896 %A          @r{like @code{%a}, but prompt for the description part}
5897 %i          @r{initial content, the region when remember is called with C-u.}
5898             @r{The entire text will be indented like @code{%i} itself.}
5899 %t          @r{timestamp, date only}
5900 %T          @r{timestamp with date and time}
5901 %u, %U      @r{like the above, but inactive timestamps}
5902 %^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
5903             @r{You may define a prompt like @code{%^@{Birthday@}t}}
5904 %n          @r{user name (taken from @code{user-full-name})}
5905 %c          @r{Current kill ring head.}
5906 %x          @r{Content of the X clipboard.}
5907 %^C         @r{Interactive selection of which kill or clip to use.}
5908 %^L         @r{Like @code{%^C}, but insert as link.}
5909 %^g         @r{prompt for tags, with completion on tags in target file.}
5910 %k          @r{title of currently clocked task}
5911 %K          @r{link to currently clocked task}
5912 %^G         @r{prompt for tags, with completion all tags in all agenda files.}
5913 %^@{@var{prop}@}p   @r{Prompt the user for a value for property @var{prop}}
5914 %:keyword   @r{specific information for certain link types, see below}
5915 %[@var{file}]     @r{insert the contents of the file given by @var{file}}
5916 %(@var{sexp})     @r{evaluate Elisp @var{sexp} and replace with the result}
5917 %!          @r{immediately store note after completing the template}
5918             @r{(skipping the @kbd{C-c C-c} that normally triggers storing)}
5919 %&          @r{jump to target location immediately after storing note}
5920 @end example
5922 @noindent
5923 For specific link types, the following keywords will be
5924 defined@footnote{If you define your own link types (@pxref{Adding
5925 hyperlink types}), any property you store with
5926 @code{org-store-link-props} can be accessed in remember templates in a
5927 similar way.}:
5929 @vindex org-from-is-user-regexp
5930 @example
5931 Link type          |  Available keywords
5932 -------------------+----------------------------------------------
5933 bbdb               |  %:name %:company
5934 bbdb               |  %::server %:port %:nick
5935 vm, wl, mh, rmail  |  %:type %:subject %:message-id
5936                    |  %:from %:fromname %:fromaddress
5937                    |  %:to   %:toname   %:toaddress
5938                    |  %: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}.}}
5939 gnus               |  %:group, @r{for messages also all email fields}
5940 w3, w3m            |  %:url
5941 info               |  %:file %:node
5942 calendar           |  %:date"
5943 @end example
5945 @noindent
5946 To place the cursor after template expansion use:
5948 @example
5949 %?          @r{After completing the template, position cursor here.}
5950 @end example
5952 @noindent
5953 If you change your mind about which template to use, call
5954 @code{org-remember} in the remember buffer.  You may then select a new
5955 template that will be filled with the previous context information.
5957 @node Storing notes,  , Remember templates, Remember
5958 @subsection Storing notes
5960 @vindex org-remember-clock-out-on-exit
5961 When you are finished preparing a note with Remember, you have to press
5962 @kbd{C-c C-c} to file the note away.  If you have started the clock in the
5963 Remember buffer, you will first be asked if you want to clock out
5964 now@footnote{To avoid this query, configure the variable
5965 @code{org-remember-clock-out-on-exit}.}.  If you answer @kbd{n}, the clock
5966 will continue to run after the note was filed away.
5968 The handler will then store the note in the file and under the headline
5969 specified in the template, or it will use the default file and headline.
5970 The window configuration will be restored, sending you back to the working
5971 context before the call to Remember.  To re-use the location found
5972 during the last call to Remember, exit the Remember buffer with
5973 @kbd{C-0 C-c C-c}, i.e. specify a zero prefix argument to @kbd{C-c C-c}.
5974 Another special case is @kbd{C-2 C-c C-c} which files the note as a child of
5975 the currently clocked item.
5977 @vindex org-remember-store-without-prompt
5978 If you want to store the note directly to a different place, use
5979 @kbd{C-1 C-c C-c} instead to exit Remember@footnote{Configure the
5980 variable @code{org-remember-store-without-prompt} to make this behavior
5981 the default.}.  The handler will then first prompt for a target file---if
5982 you press @key{RET}, the value specified for the template is used.
5983 Then the command offers the headings tree of the selected file, with the
5984 cursor position at the default headline (if you specified one in the
5985 template).  You can either immediately press @key{RET} to get the note
5986 placed there.  Or you can use the following keys to find a different
5987 location:
5988 @example
5989 @key{TAB}         @r{Cycle visibility.}
5990 @key{down} / @key{up}   @r{Next/previous visible headline.}
5991 n / p        @r{Next/previous visible headline.}
5992 f / b        @r{Next/previous headline same level.}
5993 u            @r{One level up.}
5994 @c 0-9          @r{Digit argument.}
5995 @end example
5996 @noindent
5997 Pressing @key{RET} or @key{left} or @key{right}
5998 then leads to the following result.
6000 @vindex org-reverse-note-order
6001 @multitable @columnfractions 0.2 0.15 0.65
6002 @item @b{Cursor position} @tab @b{Key} @tab @b{Note gets inserted}
6003 @item on headline     @tab @key{RET}              @tab as sublevel of the heading at cursor, first or last
6004 @item                 @tab                        @tab depending on @code{org-reverse-note-order}.
6005 @item                 @tab @key{left}/@key{right} @tab as same level, before/after current heading
6006 @item buffer-start    @tab @key{RET} @tab as level 2 heading at end of file or level 1 at beginning
6007 @item                 @tab @tab depending on @code{org-reverse-note-order}.
6008 @item not on headline @tab @key{RET}
6009       @tab at cursor position, level taken from context.
6010 @end multitable
6012 Before inserting the text into a tree, the function ensures that the text has
6013 a headline, i.e. a first line that starts with a @samp{*}.  If not, a
6014 headline is constructed from the current date.  If you have indented the text
6015 of the note below the headline, the indentation will be adapted if inserting
6016 the note into the tree requires demotion from level 1.
6019 @node Attachments, RSS Feeds, Remember, Capture - Refile - Archive
6020 @section Attachments
6021 @cindex attachments
6023 @vindex org-attach-directory
6024 It is often useful to associate reference material with an outline node/task.
6025 Small chunks of plain text can simply be stored in the subtree of a project.
6026 Hyperlinks (@pxref{Hyperlinks}) can be used to establish associations with
6027 files that live elsewhere on your computer or in the cloud, like emails or
6028 source code files belonging to a project.  Another method is @i{attachments},
6029 which are files located in a directory belonging to an outline node.  Org
6030 uses directories named by the unique ID of each entry.  These directories are
6031 located in the @file{data} directory which lives in the same directory where
6032 your Org file lives@footnote{If you move entries or Org files from one
6033 directory to another, you may want to configure @code{org-attach-directory}
6034 to contain an absolute path.}.  If you initialize this directory with
6035 @code{git init}, Org will automatically commit changes when it sees them.
6036 The attachment system has been contributed to Org by John Wiegley.
6038 In cases where it seems better to do so, you can also attach a directory of your
6039 choice to an entry.  You can also make children inherit the attachment
6040 directory from a parent, so that an entire subtree uses the same attached
6041 directory.
6043 @noindent The following commands deal with attachments.
6045 @table @kbd
6047 @kindex C-c C-a
6048 @item C-c C-a
6049 The dispatcher for commands related to the attachment system.  After these
6050 keys, a list of commands is displayed and you need to press an additional key
6051 to select a command:
6053 @table @kbd
6054 @kindex C-c C-a a
6055 @item a
6056 @vindex org-attach-method
6057 Select a file and move it into the task's attachment directory.  The file
6058 will be copied, moved, or linked, depending on @code{org-attach-method}.
6059 Note that hard links are not supported on all systems.
6061 @kindex C-c C-a c
6062 @kindex C-c C-a m
6063 @kindex C-c C-a l
6064 @item c/m/l
6065 Attach a file using the copy/move/link method.
6066 Note that hard links are not supported on all systems.
6068 @kindex C-c C-a n
6069 @item n
6070 Create a new attachment as an Emacs buffer.
6072 @kindex C-c C-a z
6073 @item z
6074 Synchronize the current task with its attachment directory, in case you added
6075 attachments yourself.
6077 @kindex C-c C-a o
6078 @item o
6079 @vindex org-file-apps
6080 Open current task's attachment.  If there are more than one, prompt for a
6081 file name first.  Opening will follow the rules set by @code{org-file-apps}.
6082 For more details, see the information on following hyperlinks
6083 (@pxref{Handling links}).
6085 @kindex C-c C-a O
6086 @item O
6087 Also open the attachment, but force opening the file in Emacs.
6089 @kindex C-c C-a f
6090 @item f
6091 Open the current task's attachment directory.
6093 @kindex C-c C-a F
6094 @item F
6095 Also open the directory, but force using @command{dired} in Emacs.
6097 @kindex C-c C-a d
6098 @item d
6099 Select and delete a single attachment.
6101 @kindex C-c C-a D
6102 @item D
6103 Delete all of a task's attachments.  A safer way is to open the directory in
6104 @command{dired} and delete from there.
6106 @kindex C-c C-a s
6107 @item C-c C-a s
6108 @cindex property, ATTACH_DIR
6109 Set a specific directory as the entry's attachment directory.  This works by
6110 putting the directory path into the @code{ATTACH_DIR} property.
6112 @kindex C-c C-a i
6113 @item C-c C-a i
6114 @cindex property, ATTACH_DIR_INHERIT
6115 Set the @code{ATTACH_DIR_INHERIT} property, so that children will use the
6116 same directory for attachments as the parent does.
6117 @end table
6118 @end table
6120 @node RSS Feeds, Protocols, Attachments, Capture - Refile - Archive
6121 @section RSS feeds
6122 @cindex RSS feeds
6124 Org has the capability to add and change entries based on information found in
6125 RSS feeds.  You could use this to make a task out of each new podcast in a
6126 podcast feed.  Or you could use a phone-based note-creating service on the
6127 web to import tasks into Org.  To access feeds, you need to configure the
6128 variable @code{org-feed-alist}.  The docstring of this variable has detailed
6129 information.  Here is just an example:
6131 @example
6132 (setq org-feed-alist
6133       '(("ReQall" "http://www.reqall.com/user/feeds/rss/a1b2c3....."
6134          "~/org/feeds.org" "ReQall Entries")
6135 @end example
6136 @noindent
6137 will configure that new items from the feed provided by @file{reqall.com}
6138 will result in new entries in the file @file{~/org/feeds.org} under the
6139 heading @samp{ReQall Entries}, whenever the following command is used:
6141 @table @kbd
6142 @kindex C-c C-x g
6143 @item C-c C-x g
6144 Collect items from the feeds configured in @code{org-feed-alist} and act upon
6145 them.
6146 @kindex C-c C-x G
6147 @item C-c C-x G
6148 Prompt for a feed name and go to the inbox configured for this feed.
6149 @end table
6151 Under the same headline, Org will create a drawer @samp{FEEDSTATUS} in which
6152 it will store information about the status of items in the feed, to avoid
6153 adding the same item several times.  You should add @samp{FEEDSTATUS} to the
6154 list of drawers in that file:
6156 @example
6157 #+DRAWERS: LOGBOOK PROPERTIES FEEDSTATUS
6158 @end example
6160 For more information, see @file{org-feed.el} and the docstring of
6161 @code{org-feed-alist}.
6163 @node Protocols, Refiling notes, RSS Feeds, Capture - Refile - Archive
6164 @section Protocols for external access
6165 @cindex protocols, for external access
6166 @cindex emacsserver
6168 You can set up Org for handling protocol calls from outside applications that
6169 are passed to Emacs through the @file{emacsserver}.  For example, you can
6170 configure bookmarks in your web browser to send a link to the current page to
6171 Org and create a note from it using Remember (@pxref{Remember}).  Or you
6172 could create a bookmark that will tell Emacs to open the local source file of
6173 a remote website you are looking at with the browser.  See
6174 @uref{http://orgmode.org/worg/org-contrib/org-protocol.php} for detailed
6175 documentation and setup instructions.
6177 @node Refiling notes, Archiving, Protocols, Capture - Refile - Archive
6178 @section Refiling notes
6179 @cindex refiling notes
6181 When reviewing the captured data, you may want to refile some of the entries
6182 into a different list, for example into a project.  Cutting, finding the
6183 right location, and then pasting the note is cumbersome.  To simplify this
6184 process, you can use the following special command:
6186 @table @kbd
6187 @kindex C-c C-w
6188 @item C-c C-w
6189 @vindex org-reverse-note-order
6190 @vindex org-refile-targets
6191 @vindex org-refile-use-outline-path
6192 @vindex org-outline-path-complete-in-steps
6193 @vindex org-refile-allow-creating-parent-nodes
6194 Refile the entry or region at point.  This command offers possible locations
6195 for refiling the entry and lets you select one with completion.  The item (or
6196 all items in the region) is filed below the target heading as a subitem.
6197 Depending on @code{org-reverse-note-order}, it will be either the first or
6198 last subitem.@*
6199 By default, all level 1 headlines in the current buffer are considered to be
6200 targets, but you can have more complex definitions across a number of files.
6201 See the variable @code{org-refile-targets} for details.  If you would like to
6202 select a location via a file-path-like completion along the outline path, see
6203 the variables @code{org-refile-use-outline-path} and
6204 @code{org-outline-path-complete-in-steps}.  If you would like to be able to
6205 create new nodes as new parents for for refiling on the fly, check the
6206 variable @code{org-refile-allow-creating-parent-nodes}.
6207 @kindex C-u C-c C-w
6208 @item C-u C-c C-w
6209 Use the refile interface to jump to a heading.
6210 @kindex C-u C-u C-c C-w
6211 @item C-u C-u C-c C-w
6212 Jump to the location where @code{org-refile} last moved a tree to.
6213 @item C-2 C-c C-w
6214 Refile as the child of the item currently being clocked.
6215 @end table
6217 @node Archiving,  , Refiling notes, Capture - Refile - Archive
6218 @section Archiving
6219 @cindex archiving
6221 When a project represented by a (sub)tree is finished, you may want
6222 to move the tree out of the way and to stop it from contributing to the
6223 agenda.  Archiving is important to keep your working files compact and global
6224 searches like the construction of agenda views fast.
6226 @table @kbd
6227 @kindex C-c C-x C-a
6228 @item C-c C-x C-a
6229 @vindex org-archive-default-command
6230 Archive the current entry using the command specified in the variable
6231 @code{org-archive-default-command}.
6232 @end table
6234 @menu
6235 * Moving subtrees::             Moving a tree to an archive file
6236 * Internal archiving::          Switch off a tree but keep i in the file
6237 @end menu
6239 @node Moving subtrees, Internal archiving, Archiving, Archiving
6240 @subsection Moving a tree to the archive file
6241 @cindex external archiving
6243 The most common archiving action is to move a project tree to another file,
6244 the archive file.
6246 @table @kbd
6247 @kindex C-c $
6248 @kindex C-c C-x C-s
6249 @item C-c C-x C-s@ @r{or short} @ C-c $
6250 @vindex org-archive-location
6251 Archive the subtree starting at the cursor position to the location
6252 given by @code{org-archive-location}.
6253 @kindex C-u C-c C-x C-s
6254 @item C-u C-c C-x C-s
6255 Check if any direct children of the current headline could be moved to
6256 the archive.  To do this, each subtree is checked for open TODO entries.
6257 If none are found, the command offers to move it to the archive
6258 location.  If the cursor is @emph{not} on a headline when this command
6259 is invoked, the level 1 trees will be checked.
6260 @end table
6262 @cindex archive locations
6263 The default archive location is a file in the same directory as the
6264 current file, with the name derived by appending @file{_archive} to the
6265 current file name.  For information and examples on how to change this,
6266 see the documentation string of the variable
6267 @code{org-archive-location}.  There is also an in-buffer option for
6268 setting this variable, for example@footnote{For backward compatibility,
6269 the following also works: If there are several such lines in a file,
6270 each specifies the archive location for the text below it.  The first
6271 such line also applies to any text before its definition.  However,
6272 using this method is @emph{strongly} deprecated as it is incompatible
6273 with the outline structure of the document.  The correct method for
6274 setting multiple archive locations in a buffer is using properties.}:
6276 @cindex #+ARCHIVE
6277 @example
6278 #+ARCHIVE: %s_done::
6279 @end example
6281 @cindex property, ARCHIVE
6282 @noindent
6283 If you would like to have a special ARCHIVE location for a single entry
6284 or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
6285 location as the value (@pxref{Properties and Columns}).
6287 @vindex org-archive-save-context-info
6288 When a subtree is moved, it receives a number of special properties that
6289 record context information like the file from where the entry came, its
6290 outline path the archiving time etc.  Configure the variable
6291 @code{org-archive-save-context-info} to adjust the amount of information
6292 added.
6295 @node Internal archiving,  , Moving subtrees, Archiving
6296 @subsection Internal archiving
6298 If you want to just switch off (for agenda views) certain subtrees without
6299 moving them to a different file, you can use the @code{ARCHIVE tag}.
6301 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
6302 its location in the outline tree, but behaves in the following way:
6303 @itemize @minus
6304 @item
6305 @vindex org-cycle-open-archived-trees
6306 It does not open when you attempt to do so with a visibility cycling
6307 command (@pxref{Visibility cycling}).  You can force cycling archived
6308 subtrees with @kbd{C-@key{TAB}}, or by setting the option
6309 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
6310 @code{show-all} will open archived subtrees.
6311 @item
6312 @vindex org-sparse-tree-open-archived-trees
6313 During sparse tree construction (@pxref{Sparse trees}), matches in
6314 archived subtrees are not exposed, unless you configure the option
6315 @code{org-sparse-tree-open-archived-trees}.
6316 @item
6317 @vindex org-agenda-skip-archived-trees
6318 During agenda view construction (@pxref{Agenda Views}), the content of
6319 archived trees is ignored unless you configure the option
6320 @code{org-agenda-skip-archived-trees}, in which case these trees will always
6321 be included.  In the agenda you can press @kbd{v a} to get archives
6322 temporarily included.
6323 @item
6324 @vindex org-export-with-archived-trees
6325 Archived trees are not exported (@pxref{Exporting}), only the headline
6326 is.  Configure the details using the variable
6327 @code{org-export-with-archived-trees}.
6328 @item
6329 @vindex org-columns-skip-arrchived-trees
6330 Archived trees are excluded from column view unless the variable
6331 @code{org-columns-skip-arrchived-trees} is configured to @code{nil}.
6332 @end itemize
6334 The following commands help managing the ARCHIVE tag:
6336 @table @kbd
6337 @kindex C-c C-x a
6338 @item C-c C-x a
6339 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
6340 the headline changes to a shadowed face, and the subtree below it is
6341 hidden.
6342 @kindex C-u C-c C-x a
6343 @item C-u C-c C-x a
6344 Check if any direct children of the current headline should be archived.
6345 To do this, each subtree is checked for open TODO entries.  If none are
6346 found, the command offers to set the ARCHIVE tag for the child.  If the
6347 cursor is @emph{not} on a headline when this command is invoked, the
6348 level 1 trees will be checked.
6349 @kindex C-@kbd{TAB}
6350 @item C-@kbd{TAB}
6351 Cycle a tree even if it is tagged with ARCHIVE.
6352 @kindex C-c C-x A
6353 @item C-c C-x A
6354 Move the current entry to the @emph{Archive Sibling}.  This is a sibling of
6355 the entry with the heading @samp{Archive} and the tag @samp{ARCHIVE}.  The
6356 entry becomes a child of that sibling and in this way retains a lot of its
6357 original context, including inherited tags and approximate position in the
6358 outline.
6359 @end table
6362 @node Agenda Views, Markup, Capture - Refile - Archive, Top
6363 @chapter Agenda Views
6364 @cindex agenda views
6366 Due to the way Org works, TODO items, time-stamped items, and
6367 tagged headlines can be scattered throughout a file or even a number of
6368 files.  To get an overview of open action items, or of events that are
6369 important for a particular date, this information must be collected,
6370 sorted and displayed in an organized way.
6372 Org can select items based on various criteria and display them
6373 in a separate buffer.  Seven different view types are provided:
6375 @itemize @bullet
6376 @item
6377 an @emph{agenda} that is like a calendar and shows information
6378 for specific dates,
6379 @item
6380 a @emph{TODO list} that covers all unfinished
6381 action items,
6382 @item
6383 a @emph{match view}, showings headlines based on the tags, properties, and
6384 TODO state associated with them,
6385 @item
6386 a @emph{timeline view} that shows all events in a single Org file,
6387 in time-sorted view,
6388 @item
6389 a @emph{text search view} that shows all entries from multiple files
6390 that contain specified keywords,
6391 @item
6392 a @emph{stuck projects view} showing projects that currently don't move
6393 along, and
6394 @item
6395 @emph{custom views} that are special searches and combinations of different
6396 views.
6397 @end itemize
6399 @noindent
6400 The extracted information is displayed in a special @emph{agenda
6401 buffer}.  This buffer is read-only, but provides commands to visit the
6402 corresponding locations in the original Org files, and even to
6403 edit these files remotely.
6405 @vindex org-agenda-window-setup
6406 @vindex org-agenda-restore-windows-after-quit
6407 Two variables control how the agenda buffer is displayed and whether the
6408 window configuration is restored when the agenda exits:
6409 @code{org-agenda-window-setup} and
6410 @code{org-agenda-restore-windows-after-quit}.
6412 @menu
6413 * Agenda files::                Files being searched for agenda information
6414 * Agenda dispatcher::           Keyboard access to agenda views
6415 * Built-in agenda views::       What is available out of the box?
6416 * Presentation and sorting::    How agenda items are prepared for display
6417 * Agenda commands::             Remote editing of Org trees
6418 * Custom agenda views::         Defining special searches and views
6419 * Exporting Agenda Views::      Writing a view to a file
6420 * Agenda column view::          Using column view for collected entries
6421 @end menu
6423 @node Agenda files, Agenda dispatcher, Agenda Views, Agenda Views
6424 @section Agenda files
6425 @cindex agenda files
6426 @cindex files for agenda
6428 @vindex org-agenda-files
6429 The information to be shown is normally collected from all @emph{agenda
6430 files}, the files listed in the variable
6431 @code{org-agenda-files}@footnote{If the value of that variable is not a
6432 list, but a single file name, then the list of agenda files will be
6433 maintained in that external file.}. If a directory is part of this list,
6434 all files with the extension @file{.org} in this directory will be part
6435 of the list.
6437 Thus, even if you only work with a single Org file, that file should
6438 be put into the list@footnote{When using the dispatcher, pressing
6439 @kbd{<} before selecting a command will actually limit the command to
6440 the current file, and ignore @code{org-agenda-files} until the next
6441 dispatcher command.}.  You can customize @code{org-agenda-files}, but
6442 the easiest way to maintain it is through the following commands
6444 @cindex files, adding to agenda list
6445 @table @kbd
6446 @kindex C-c [
6447 @item C-c [
6448 Add current file to the list of agenda files.  The file is added to
6449 the front of the list.  If it was already in the list, it is moved to
6450 the front.  With a prefix argument, file is added/moved to the end.
6451 @kindex C-c ]
6452 @item C-c ]
6453 Remove current file from the list of agenda files.
6454 @kindex C-,
6455 @kindex C-'
6456 @item C-,
6457 @itemx C-'
6458 Cycle through agenda file list, visiting one file after the other.
6459 @kindex M-x org-iswitchb
6460 @item M-x org-iswitchb
6461 Command to use an @code{iswitchb}-like interface to switch to and between Org
6462 buffers.
6463 @end table
6465 @noindent
6466 The Org menu contains the current list of files and can be used
6467 to visit any of them.
6469 If you would like to focus the agenda temporarily on a file not in
6470 this list, or on just one file in the list, or even on only a subtree in a
6471 file, then this can be done in different ways.  For a single agenda command,
6472 you may press @kbd{<} once or several times in the dispatcher
6473 (@pxref{Agenda dispatcher}).  To restrict the agenda scope for an
6474 extended period, use the following commands:
6476 @table @kbd
6477 @kindex C-c C-x <
6478 @item C-c C-x <
6479 Permanently restrict the agenda to the current subtree.  When with a
6480 prefix argument, or with the cursor before the first headline in a file,
6481 the agenda scope is set to the entire file.  This restriction remains in
6482 effect until removed with @kbd{C-c C-x >}, or by typing either @kbd{<}
6483 or @kbd{>} in the agenda dispatcher.  If there is a window displaying an
6484 agenda view, the new restriction takes effect immediately.
6485 @kindex C-c C-x >
6486 @item C-c C-x >
6487 Remove the permanent restriction created by @kbd{C-c C-x <}.
6488 @end table
6490 @noindent
6491 When working with @file{speedbar.el}, you can use the following commands in
6492 the Speedbar frame:
6493 @table @kbd
6494 @kindex <
6495 @item < @r{in the speedbar frame}
6496 Permanently restrict the agenda to the item---either an Org file or a subtree
6497 in such a file---at the cursor in the Speedbar frame.
6498 If there is a window displaying an agenda view, the new restriction takes
6499 effect immediately.
6500 @kindex >
6501 @item > @r{in the speedbar frame}
6502 Lift the restriction.
6503 @end table
6505 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda Views
6506 @section The agenda dispatcher
6507 @cindex agenda dispatcher
6508 @cindex dispatching agenda commands
6509 The views are created through a dispatcher, which should be bound to a
6510 global key---for example @kbd{C-c a} (@pxref{Installation}).  In the
6511 following we will assume that @kbd{C-c a} is indeed how the dispatcher
6512 is accessed and list keyboard access to commands accordingly.  After
6513 pressing @kbd{C-c a}, an additional letter is required to execute a
6514 command.  The dispatcher offers the following default commands:
6515 @table @kbd
6516 @item a
6517 Create the calendar-like agenda (@pxref{Weekly/daily agenda}).
6518 @item t @r{/} T
6519 Create a list of all TODO items (@pxref{Global TODO list}).
6520 @item m @r{/} M
6521 Create a list of headlines matching a TAGS expression (@pxref{Matching
6522 tags and properties}).
6523 @item L
6524 Create the timeline view for the current buffer (@pxref{Timeline}).
6525 @item s
6526 Create a list of entries selected by a boolean expression of keywords
6527 and/or regular expressions that must or must not occur in the entry.
6528 @item /
6529 @vindex org-agenda-text-search-extra-files
6530 Search for a regular expression in all agenda files and additionally in
6531 the files listed in @code{org-agenda-text-search-extra-files}.  This
6532 uses the Emacs command @code{multi-occur}.  A prefix argument can be
6533 used to specify the number of context lines for each match, default is
6535 @item # @r{/} !
6536 Create a list of stuck projects (@pxref{Stuck projects}).
6537 @item <
6538 Restrict an agenda command to the current buffer@footnote{For backward
6539 compatibility, you can also press @kbd{1} to restrict to the current
6540 buffer.}.  After pressing @kbd{<}, you still need to press the character
6541 selecting the command.
6542 @item < <
6543 If there is an active region, restrict the following agenda command to
6544 the region.  Otherwise, restrict it to the current subtree@footnote{For
6545 backward compatibility, you can also press @kbd{0} to restrict to the
6546 current region/subtree.}.  After pressing @kbd{< <}, you still need to press the
6547 character selecting the command.
6548 @end table
6550 You can also define custom commands that will be accessible through the
6551 dispatcher, just like the default commands.  This includes the
6552 possibility to create extended agenda buffers that contain several
6553 blocks together, for example the weekly agenda, the global TODO list and
6554 a number of special tags matches.  @xref{Custom agenda views}.
6556 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda Views
6557 @section The built-in agenda views
6559 In this section we describe the built-in views.
6561 @menu
6562 * Weekly/daily agenda::         The calendar page with current tasks
6563 * Global TODO list::            All unfinished action items
6564 * Matching tags and properties::  Structured information with fine-tuned search
6565 * Timeline::                    Time-sorted view for single file
6566 * Search view::                 Find entries by searching for text
6567 * Stuck projects::              Find projects you need to review
6568 @end menu
6570 @node Weekly/daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
6571 @subsection The weekly/daily agenda
6572 @cindex agenda
6573 @cindex weekly agenda
6574 @cindex daily agenda
6576 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
6577 paper agenda, showing all the tasks for the current week or day.
6579 @table @kbd
6580 @cindex org-agenda, command
6581 @kindex C-c a a
6582 @item C-c a a
6583 @vindex org-agenda-ndays
6584 Compile an agenda for the current week from a list of Org files.  The agenda
6585 shows the entries for each day.  With a numeric prefix@footnote{For backward
6586 compatibility, the universal prefix @kbd{C-u} causes all TODO entries to be
6587 listed before the agenda.  This feature is deprecated, use the dedicated TODO
6588 list, or a block agenda instead (@pxref{Block agenda}).}  (like @kbd{C-u 2 1
6589 C-c a a}) you may set the number of days to be displayed (see also the
6590 variable @code{org-agenda-ndays})
6591 @end table
6593 Remote editing from the agenda buffer means, for example, that you can
6594 change the dates of deadlines and appointments from the agenda buffer.
6595 The commands available in the Agenda buffer are listed in @ref{Agenda
6596 commands}.
6598 @subsubheading Calendar/Diary integration
6599 @cindex calendar integration
6600 @cindex diary integration
6602 Emacs contains the calendar and diary by Edward M. Reingold.  The
6603 calendar displays a three-month calendar with holidays from different
6604 countries and cultures.  The diary allows you to keep track of
6605 anniversaries, lunar phases, sunrise/set, recurrent appointments
6606 (weekly, monthly) and more.  In this way, it is quite complementary to
6607 Org.  It can be very useful to combine output from Org with
6608 the diary.
6610 In order to include entries from the Emacs diary into Org mode's
6611 agenda, you only need to customize the variable
6613 @lisp
6614 (setq org-agenda-include-diary t)
6615 @end lisp
6617 @noindent After that, everything will happen automatically.  All diary
6618 entries including holidays, anniversaries, etc., will be included in the
6619 agenda buffer created by Org mode.  @key{SPC}, @key{TAB}, and
6620 @key{RET} can be used from the agenda buffer to jump to the diary
6621 file in order to edit existing diary entries.  The @kbd{i} command to
6622 insert new entries for the current date works in the agenda buffer, as
6623 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
6624 Sunrise/Sunset times, show lunar phases and to convert to other
6625 calendars, respectively.  @kbd{c} can be used to switch back and forth
6626 between calendar and agenda.
6628 If you are using the diary only for sexp entries and holidays, it is
6629 faster to not use the above setting, but instead to copy or even move
6630 the entries into an Org file. Org mode evaluates diary-style sexp
6631 entries, and does it faster because there is no overhead for first
6632 creating the diary display.  Note that the sexp entries must start at
6633 the left margin, no whitespace is allowed before them.  For example,
6634 the following segment of an Org file will be processed and entries
6635 will be made in the agenda:
6637 @example
6638 * Birthdays and similar stuff
6639 #+CATEGORY: Holiday
6640 %%(org-calendar-holiday)   ; special function for holiday names
6641 #+CATEGORY: Ann
6642 %%(diary-anniversary 14  5 1956) Arthur Dent is %d years old
6643 %%(diary-anniversary  2 10 1869) Mahatma Gandhi would be %d years old
6644 @end example
6646 @subsubheading Anniversaries from BBDB
6647 @cindex BBDB, anniversaries
6648 @cindex anniversaries, from BBDB
6650 If you are using the Big Brothers Database to store your contacts, you will
6651 very likely prefer to store anniversaries in BBDB rather than in a
6652 separate Org or diary file.  Org supports this and will show BBDB
6653 anniversaries as part of the agenda.  All you need to do is to add the
6654 following to one your your agenda files:
6656 @example
6657 * Anniversaries
6658   :PROPERTIES:
6659   :CATEGORY: Anniv
6660   :END
6661 %%(org-bbdb-anniversaries)
6662 @end example
6664 You can then go ahead and define anniversaries for a BBDB record.  Basically,
6665 you need to press @kbd{C-o anniversary @key{RET}} with the cursor in a BBDB
6666 record and then add the date in the format @code{YYYY-MM-DD}, followed by a
6667 space and the class of the anniversary (@samp{birthday} or @samp{wedding}, or
6668 a format string).  If you omit the class, it will default to @samp{birthday}.
6669 Here are a few examples, the header for the file @file{org-bbdb.el} contains
6670 more detailed information.
6672 @example
6673 1973-06-22
6674 1955-08-02 wedding
6675 2008-04-14 %s released version 6.01 of org-mode, %d years ago
6676 @end example
6678 After a change to BBDB, or for the first agenda display during an Emacs
6679 session, the agenda display will suffer a short delay as Org updates its
6680 hash with anniversaries.  However, from then on things will be very fast---much
6681 faster in fact than a long list of @samp{%%(diary-anniversary)} entries
6682 in an Org or Diary file.
6684 @subsubheading Appointment reminders
6685 @cindex @file{appt.el}
6686 @cindex appointment reminders
6688 Org can interact with Emacs appointments notification facility.  To add all
6689 the appointments of your agenda files, use the command
6690 @code{org-agenda-to-appt}.  This command also lets you filter through the
6691 list of your appointments and add only those belonging to a specific category
6692 or matching a regular expression. See the docstring for details.
6694 @node Global TODO list, Matching tags and properties, Weekly/daily agenda, Built-in agenda views
6695 @subsection The global TODO list
6696 @cindex global TODO list
6697 @cindex TODO list, global
6699 The global TODO list contains all unfinished TODO items formatted and
6700 collected into a single place.
6702 @table @kbd
6703 @kindex C-c a t
6704 @item C-c a t
6705 Show the global TODO list.  This collects the TODO items from all
6706 agenda files (@pxref{Agenda Views}) into a single buffer.  The buffer is in
6707 @code{agenda-mode}, so there are commands to examine and manipulate
6708 the TODO entries directly from that buffer (@pxref{Agenda commands}).
6709 @kindex C-c a T
6710 @item C-c a T
6711 @cindex TODO keyword matching
6712 @vindex org-todo-keywords
6713 Like the above, but allows selection of a specific TODO keyword.  You
6714 can also do this by specifying a prefix argument to @kbd{C-c a t}.  With
6715 a @kbd{C-u} prefix you are prompted for a keyword, and you may also
6716 specify several keywords by separating them with @samp{|} as the boolean OR
6717 operator.  With a numeric prefix, the nth keyword in
6718 @code{org-todo-keywords} is selected.
6719 @kindex r
6720 The @kbd{r} key in the agenda buffer regenerates it, and you can give
6721 a prefix argument to this command to change the selected TODO keyword,
6722 for example @kbd{3 r}.  If you often need a search for a specific
6723 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
6724 Matching specific TODO keywords can also be done as part of a tags
6725 search (@pxref{Tag searches}).
6726 @end table
6728 Remote editing of TODO items means that you can change the state of a
6729 TODO entry with a single key press.  The commands available in the
6730 TODO list are described in @ref{Agenda commands}.
6732 @cindex sublevels, inclusion into TODO list
6733 Normally the global TODO list simply shows all headlines with TODO
6734 keywords.  This list can become very long.  There are two ways to keep
6735 it more compact:
6736 @itemize @minus
6737 @item
6738 @vindex org-agenda-todo-ignore-scheduled
6739 @vindex org-agenda-todo-ignore-deadlines
6740 @vindex org-agenda-todo-ignore-with-date
6741 Some people view a TODO item that has been @emph{scheduled} for execution or
6742 have a @emph{deadline} (@pxref{Timestamps}) as no longer @emph{open}.
6743 Configure the variables @code{org-agenda-todo-ignore-scheduled},
6744 @code{org-agenda-todo-ignore-deadlines}, and/or
6745 @code{org-agenda-todo-ignore-with-date} to exclude such items from the
6746 global TODO list.
6747 @item
6748 @vindex org-agenda-todo-list-sublevels
6749 TODO items may have sublevels to break up the task into subtasks.  In
6750 such cases it may be enough to list only the highest level TODO headline
6751 and omit the sublevels from the global list.  Configure the variable
6752 @code{org-agenda-todo-list-sublevels} to get this behavior.
6753 @end itemize
6755 @node Matching tags and properties, Timeline, Global TODO list, Built-in agenda views
6756 @subsection Matching tags and properties
6757 @cindex matching, of tags
6758 @cindex matching, of properties
6759 @cindex tags view
6760 @cindex match view
6762 If headlines in the agenda files are marked with @emph{tags} (@pxref{Tags}),
6763 or have properties (@pxref{Properties and Columns}), you can select headlines
6764 based on this metadata and collect them into an agenda buffer.  The match
6765 syntax described here also applies when creating sparse trees with @kbd{C-c /
6768 @table @kbd
6769 @kindex C-c a m
6770 @item C-c a m
6771 Produce a list of all headlines that match a given set of tags.  The
6772 command prompts for a selection criterion, which is a boolean logic
6773 expression with tags, like @samp{+work+urgent-withboss} or
6774 @samp{work|home} (@pxref{Tags}).  If you often need a specific search,
6775 define a custom command for it (@pxref{Agenda dispatcher}).
6776 @kindex C-c a M
6777 @item C-c a M
6778 @vindex org-tags-match-list-sublevels
6779 @vindex org-agenda-tags-todo-honor-ignore-options
6780 Like @kbd{C-c a m}, but only select headlines that are also TODO items and
6781 force checking subitems (see variable @code{org-tags-match-list-sublevels}).
6782 To exclude scheduled/deadline items, see the variable
6783 @code{org-agenda-tags-todo-honor-ignore-options}.  Matching specific TODO
6784 keywords together with a tags match is also possible, see @ref{Tag searches}.
6785 @end table
6787 The commands available in the tags list are described in @ref{Agenda
6788 commands}.
6790 @subsubheading Match syntax
6792 @cindex Boolean logic, for tag/property searches
6793 A search string can use Boolean operators @samp{&} for AND and @samp{|} for
6794 OR.  @samp{&} binds more strongly than @samp{|}.  Parentheses are currently
6795 not implemented.  Each element in the search is either a tag, a regular
6796 expression matching tags, or an expression like @code{PROPERTY OPERATOR
6797 VALUE} with a comparison operator, accessing a property value.  Each element
6798 may be preceded by @samp{-}, to select against it, and @samp{+} is syntactic
6799 sugar for positive selection.  The AND operator @samp{&} is optional when
6800 @samp{+} or @samp{-} is present.  Here are some examples, using only tags.
6802 @table @samp
6803 @item +work-boss
6804 Select headlines tagged @samp{:work:}, but discard those also tagged
6805 @samp{:boss:}.
6806 @item work|laptop
6807 Selects lines tagged @samp{:work:} or @samp{:laptop:}.
6808 @item work|laptop+night
6809 Like before, but require the @samp{:laptop:} lines to be tagged also
6810 @samp{:night:}.
6811 @end table
6813 @cindex regular expressions, with tags search
6814 Instead of a tag, you may also specify a regular expression enclosed in curly
6815 braces.  For example,
6816 @samp{work+@{^boss.*@}} matches headlines that contain the tag
6817 @samp{:work:} and any tag @i{starting} with @samp{boss}.
6819 @cindex TODO keyword matching, with tags search
6820 @cindex level, require for tags/property match
6821 @cindex category, require for tags/property match
6822 @vindex org-odd-levels-only
6823 You may also test for properties (@pxref{Properties and Columns}) at the same
6824 time as matching tags.  The properties may be real properties, or special
6825 properties that represent other metadata (@pxref{Special properties}).  For
6826 example, the ``property'' @code{TODO} represents the TODO keyword of the
6827 entry.  Or, the ``property'' @code{LEVEL} represents the level of an entry.
6828 So a search @samp{+LEVEL=3+boss-TODO="DONE"} lists all level three headlines
6829 that have the tag @samp{boss} and are @emph{not} marked with the TODO keyword
6830 DONE.  In buffers with @code{org-odd-levels-only} set, @samp{LEVEL} does not
6831 count the number of stars, but @samp{LEVEL=2} will correspond to 3 stars etc.
6833 Here are more examples:
6834 @table @samp
6835 @item work+TODO="WAITING"
6836 Select @samp{:work:}-tagged TODO lines with the specific TODO
6837 keyword @samp{WAITING}.
6838 @item work+TODO="WAITING"|home+TODO="WAITING"
6839 Waiting tasks both at work and at home.
6840 @end table
6842 When matching properties, a number of different operators can be used to test
6843 the value of a property.  Here is a complex example:
6845 @example
6846 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2         \
6847          +With=@{Sarah\|Denny@}+SCHEDULED>="<2008-10-11>"
6848 @end example
6850 @noindent
6851 The type of comparison will depend on how the comparison value is written:
6852 @itemize @minus
6853 @item
6854 If the comparison value is a plain number, a numerical comparison is done,
6855 and the allowed operators are @samp{<}, @samp{=}, @samp{>}, @samp{<=},
6856 @samp{>=}, and @samp{<>}.
6857 @item
6858 If the comparison value is enclosed in double-quotes,
6859 a string comparison is done, and the same operators are allowed.
6860 @item
6861 If the comparison value is enclosed in double-quotes @emph{and} angular
6862 brackets (like @samp{DEADLINE<="<2008-12-24 18:30>"}), both values are
6863 assumed to be date/time specifications in the standard Org way, and the
6864 comparison will be done accordingly.  Special values that will be recognized
6865 are @code{"<now>"} for now (including time), and @code{"<today>"}, and
6866 @code{"<tomorrow>"} for these days at 0:00 hours, i.e. without a time
6867 specification.  Also strings like @code{"<+5d>"} or @code{"<-2m>"} with units
6868 @code{d}, @code{w}, @code{m}, and @code{y} for day, week, month, and year,
6869 respectively, can be used.
6870 @item
6871 If the comparison value is enclosed
6872 in curly braces, a regexp match is performed, with @samp{=} meaning that the
6873 regexp matches the property value, and @samp{<>} meaning that it does not
6874 match.
6875 @end itemize
6877 So the search string in the example finds entries tagged @samp{:work:} but
6878 not @samp{:boss:}, which also have a priority value @samp{A}, a
6879 @samp{:Coffee:} property with the value @samp{unlimited}, an @samp{Effort}
6880 property that is numerically smaller than 2, a @samp{:With:} property that is
6881 matched by the regular expression @samp{Sarah\|Denny}, and that are scheduled
6882 on or after October 11, 2008.
6884 Accessing TODO, LEVEL, and CATEGORY during a search is fast.  Accessing any
6885 other properties will slow down the search.  However, once you have paid the
6886 price by accessing one property, testing additional properties is cheap
6887 again.
6889 You can configure Org mode to use property inheritance during a search, but
6890 beware that this can slow down searches considerably.  See @ref{Property
6891 inheritance}, for details.
6893 For backward compatibility, and also for typing speed, there is also a
6894 different way to test TODO states in a search.  For this, terminate the
6895 tags/property part of the search string (which may include several terms
6896 connected with @samp{|}) with a @samp{/} and then specify a Boolean
6897 expression just for TODO keywords.  The syntax is then similar to that for
6898 tags, but should be applied with care: for example, a positive
6899 selection on several TODO keywords cannot meaningfully be combined with
6900 boolean AND.  However, @emph{negative selection} combined with AND can be
6901 meaningful.  To make sure that only lines are checked that actually have any
6902 TODO keyword (resulting in a speed-up), use @kbd{C-c a M}, or equivalently
6903 start the TODO part after the slash with @samp{!}.  Examples:
6905 @table @samp
6906 @item work/WAITING
6907 Same as @samp{work+TODO="WAITING"}
6908 @item work/!-WAITING-NEXT
6909 Select @samp{:work:}-tagged TODO lines that are neither @samp{WAITING}
6910 nor @samp{NEXT}
6911 @item work/!+WAITING|+NEXT
6912 Select @samp{:work:}-tagged TODO lines that are either @samp{WAITING} or
6913 @samp{NEXT}.
6914 @end table
6916 @node Timeline, Search view, Matching tags and properties, Built-in agenda views
6917 @subsection Timeline for a single file
6918 @cindex timeline, single file
6919 @cindex time-sorted view
6921 The timeline summarizes all time-stamped items from a single Org mode
6922 file in a @emph{time-sorted view}.  The main purpose of this command is
6923 to give an overview over events in a project.
6925 @table @kbd
6926 @kindex C-c a L
6927 @item C-c a L
6928 Show a time-sorted view of the Org file, with all time-stamped items.
6929 When called with a @kbd{C-u} prefix, all unfinished TODO entries
6930 (scheduled or not) are also listed under the current date.
6931 @end table
6933 @noindent
6934 The commands available in the timeline buffer are listed in
6935 @ref{Agenda commands}.
6937 @node Search view, Stuck projects, Timeline, Built-in agenda views
6938 @subsection Search view
6939 @cindex search view
6940 @cindex text search
6941 @cindex searching, for text
6943 This agenda view is a general text search facility for Org mode entries.
6944 It is particularly useful to find notes.
6946 @table @kbd
6947 @kindex C-c a s
6948 @item C-c a s
6949 This is a special search that lets you select entries by matching a substring
6950 or specific words using a boolean logic.
6951 @end table
6952 For example, the search string @samp{computer equipment} will find entries
6953 that contain @samp{computer equipment} as a substring.  If the two words are
6954 separated by more space or a line break, the search will still match.
6955 Search view can also search for specific keywords in the entry, using Boolean
6956 logic.  The search string @samp{+computer +wifi -ethernet -@{8\.11[bg]@}}
6957 will search for note entries that contain the keywords @code{computer}
6958 and @code{wifi}, but not the keyword @code{ethernet}, and which are also
6959 not matched by the regular expression @code{8\.11[bg]}, meaning to
6960 exclude both 8.11b and 8.11g.
6962 @vindex org-agenda-text-search-extra-files
6963 Note that in addition to the agenda files, this command will also search
6964 the files listed in @code{org-agenda-text-search-extra-files}.
6966 @node Stuck projects,  , Search view, Built-in agenda views
6967 @subsection Stuck projects
6969 If you are following a system like David Allen's GTD to organize your
6970 work, one of the ``duties'' you have is a regular review to make sure
6971 that all projects move along.  A @emph{stuck} project is a project that
6972 has no defined next actions, so it will never show up in the TODO lists
6973 Org mode produces.  During the review, you need to identify such
6974 projects and define next actions for them.
6976 @table @kbd
6977 @kindex C-c a #
6978 @item C-c a #
6979 List projects that are stuck.
6980 @kindex C-c a !
6981 @item C-c a !
6982 @vindex org-stuck-projects
6983 Customize the variable @code{org-stuck-projects} to define what a stuck
6984 project is and how to find it.
6985 @end table
6987 You almost certainly will have to configure this view before it will
6988 work for you.  The built-in default assumes that all your projects are
6989 level-2 headlines, and that a project is not stuck if it has at least
6990 one entry marked with a TODO keyword TODO or NEXT or NEXTACTION.
6992 Let's assume that you, in your own way of using Org mode, identify
6993 projects with a tag PROJECT, and that you use a TODO keyword MAYBE to
6994 indicate a project that should not be considered yet.  Let's further
6995 assume that the TODO keyword DONE marks finished projects, and that NEXT
6996 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
6997 is a next action even without the NEXT tag.  Finally, if the project
6998 contains the special word IGNORE anywhere, it should not be listed
6999 either.  In this case you would start by identifying eligible projects
7000 with a tags/todo match@footnote{@xref{Tag searches}.}
7001 @samp{+PROJECT/-MAYBE-DONE}, and then check for TODO, NEXT, @@SHOP, and
7002 IGNORE in the subtree to identify projects that are not stuck.  The
7003 correct customization for this is
7005 @lisp
7006 (setq org-stuck-projects
7007       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
7008                                "\\<IGNORE\\>"))
7009 @end lisp
7011 Note that if a project is identified as non-stuck, the subtree of this entry
7012 will still be searched for stuck projects.
7014 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda Views
7015 @section Presentation and sorting
7016 @cindex presentation, of agenda items
7018 @vindex org-agenda-prefix-format
7019 Before displaying items in an agenda view, Org mode visually prepares
7020 the items and sorts them.  Each item occupies a single line.  The line
7021 starts with a @emph{prefix} that contains the @emph{category}
7022 (@pxref{Categories}) of the item and other important information.  You can
7023 customize the prefix using the option @code{org-agenda-prefix-format}.
7024 The prefix is followed by a cleaned-up version of the outline headline
7025 associated with the item.
7027 @menu
7028 * Categories::                  Not all tasks are equal
7029 * Time-of-day specifications::  How the agenda knows the time
7030 * Sorting of agenda items::     The order of things
7031 @end menu
7033 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
7034 @subsection Categories
7036 @cindex category
7037 The category is a broad label assigned to each agenda item.  By default,
7038 the category is simply derived from the file name, but you can also
7039 specify it with a special line in the buffer, like this@footnote{For
7040 backward compatibility, the following also works: if there are several
7041 such lines in a file, each specifies the category for the text below it.
7042 The first category also applies to any text before the first CATEGORY
7043 line.  However, using this method is @emph{strongly} deprecated as it is
7044 incompatible with the outline structure of the document.  The correct
7045 method for setting multiple categories in a buffer is using a
7046 property.}:
7048 @example
7049 #+CATEGORY: Thesis
7050 @end example
7052 @noindent
7053 @cindex property, CATEGORY
7054 If you would like to have a special CATEGORY for a single entry or a
7055 (sub)tree, give the entry a @code{:CATEGORY:} property with the
7056 special category you want to apply as the value.
7058 @noindent
7059 The display in the agenda buffer looks best if the category is not
7060 longer than 10 characters.
7062 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
7063 @subsection Time-of-day specifications
7064 @cindex time-of-day specification
7066 Org mode checks each agenda item for a time-of-day specification.  The
7067 time can be part of the timestamp that triggered inclusion into the
7068 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
7069 ranges can be specified with two timestamps, like
7071 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
7073 In the headline of the entry itself, a time(range) may also appear as
7074 plain text (like @samp{12:45} or a @samp{8:30-1pm}).  If the agenda
7075 integrates the Emacs diary (@pxref{Weekly/daily agenda}), time
7076 specifications in diary entries are recognized as well.
7078 For agenda display, Org mode extracts the time and displays it in a
7079 standard 24 hour format as part of the prefix.  The example times in
7080 the previous paragraphs would end up in the agenda like this:
7082 @example
7083     8:30-13:00 Arthur Dent lies in front of the bulldozer
7084    12:45...... Ford Prefect arrives and takes Arthur to the pub
7085    19:00...... The Vogon reads his poem
7086    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
7087 @end example
7089 @cindex time grid
7090 If the agenda is in single-day mode, or for the display of today, the
7091 timed entries are embedded in a time grid, like
7093 @example
7094     8:00...... ------------------
7095     8:30-13:00 Arthur Dent lies in front of the bulldozer
7096    10:00...... ------------------
7097    12:00...... ------------------
7098    12:45...... Ford Prefect arrives and takes Arthur to the pub
7099    14:00...... ------------------
7100    16:00...... ------------------
7101    18:00...... ------------------
7102    19:00...... The Vogon reads his poem
7103    20:00...... ------------------
7104    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
7105 @end example
7107 @vindex org-agenda-use-time-grid
7108 @vindex org-agenda-time-grid
7109 The time grid can be turned on and off with the variable
7110 @code{org-agenda-use-time-grid}, and can be configured with
7111 @code{org-agenda-time-grid}.
7113 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
7114 @subsection Sorting of agenda items
7115 @cindex sorting, of agenda items
7116 @cindex priorities, of agenda items
7117 Before being inserted into a view, the items are sorted.  How this is
7118 done depends on the type of view.
7119 @itemize @bullet
7120 @item
7121 @vindex org-agenda-files
7122 For the daily/weekly agenda, the items for each day are sorted.  The
7123 default order is to first collect all items containing an explicit
7124 time-of-day specification.  These entries will be shown at the beginning
7125 of the list, as a @emph{schedule} for the day.  After that, items remain
7126 grouped in categories, in the sequence given by @code{org-agenda-files}.
7127 Within each category, items are sorted by priority (@pxref{Priorities}),
7128 which is composed of the base priority (2000 for priority @samp{A}, 1000
7129 for @samp{B}, and 0 for @samp{C}), plus additional increments for
7130 overdue scheduled or deadline items.
7131 @item
7132 For the TODO list, items remain in the order of categories, but within
7133 each category, sorting takes place according to priority
7134 (@pxref{Priorities}).  The priority used for sorting derives from the
7135 priority cookie, with additions depending on how close an item is to its due
7136 or scheduled date.
7137 @item
7138 For tags matches, items are not sorted at all, but just appear in the
7139 sequence in which they are found in the agenda files.
7140 @end itemize
7142 @vindex org-agenda-sorting-strategy
7143 Sorting can be customized using the variable
7144 @code{org-agenda-sorting-strategy}, and may also include criteria based on
7145 the estimated effort of an entry (@pxref{Effort estimates}).
7147 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda Views
7148 @section Commands in the agenda buffer
7149 @cindex commands, in agenda buffer
7151 Entries in the agenda buffer are linked back to the Org file or diary
7152 file where they originate.  You are not allowed to edit the agenda
7153 buffer itself, but commands are provided to show and jump to the
7154 original entry location, and to edit the Org files ``remotely'' from
7155 the agenda buffer.  In this way, all information is stored only once,
7156 removing the risk that your agenda and note files may diverge.
7158 Some commands can be executed with mouse clicks on agenda lines.  For
7159 the other commands, the cursor needs to be in the desired line.
7161 @table @kbd
7162 @tsubheading{Motion}
7163 @cindex motion commands in agenda
7164 @kindex n
7165 @item n
7166 Next line (same as @key{up} and @kbd{C-p}).
7167 @kindex p
7168 @item p
7169 Previous line (same as @key{down} and @kbd{C-n}).
7170 @tsubheading{View/Go to Org file}
7171 @kindex mouse-3
7172 @kindex @key{SPC}
7173 @item mouse-3
7174 @itemx @key{SPC}
7175 Display the original location of the item in another window.
7176 With prefix arg, make sure that the entire entry is made visible in the
7177 outline, not only the heading.
7179 @kindex L
7180 @item L
7181 Display original location and recenter that window.
7183 @kindex mouse-2
7184 @kindex mouse-1
7185 @kindex @key{TAB}
7186 @item mouse-2
7187 @itemx mouse-1
7188 @itemx @key{TAB}
7189 Go to the original location of the item in another window.  Under Emacs
7190 22, @kbd{mouse-1} will also works for this.
7192 @kindex @key{RET}
7193 @itemx @key{RET}
7194 Go to the original location of the item and delete other windows.
7196 @kindex F
7197 @item F
7198 @vindex org-agenda-start-with-follow-mode
7199 Toggle Follow mode.  In Follow mode, as you move the cursor through
7200 the agenda buffer, the other window always shows the corresponding
7201 location in the Org file.  The initial setting for this mode in new
7202 agenda buffers can be set with the variable
7203 @code{org-agenda-start-with-follow-mode}.
7205 @kindex C-c C-x b
7206 @item C-c C-x b
7207 Display the entire subtree of the current item in an indirect buffer.  With a
7208 numeric prefix argument N, go up to level N and then take that tree.  If N is
7209 negative, go up that many levels.  With a @kbd{C-u} prefix, do not remove the
7210 previously used indirect buffer.
7212 @kindex C-c C-o
7213 @item C-c C-o
7214 Follow a link in the entry.  This will offer a selection of any links in the
7215 text belonging to the referenced Org node.  If there is only one link, it
7216 will be followed without a selection prompt.
7218 @tsubheading{Change display}
7219 @cindex display changing, in agenda
7220 @kindex o
7221 @item o
7222 Delete other windows.
7224 @kindex v d
7225 @kindex d
7226 @kindex v w
7227 @kindex w
7228 @kindex v m
7229 @kindex v y
7230 @item v d @ @r{or short} @ d
7231 @itemx v w @ @r{or short} @ w
7232 @itemx v m
7233 @itemx v y
7234 Switch to day/week/month/year view.  When switching to day or week view,
7235 this setting becomes the default for subsequent agenda commands.  Since
7236 month and year views are slow to create, they do not become the default.
7237 A numeric prefix argument may be used to jump directly to a specific day
7238 of the year, ISO week, month, or year, respectively.  For example,
7239 @kbd{32 d} jumps to February 1st, @kbd{9 w} to ISO week number 9.  When
7240 setting day, week, or month view, a year may be encoded in the prefix
7241 argument as well.  For example, @kbd{200712 w} will jump to week 12 in
7242 2007.  If such a year specification has only one or two digits, it will
7243 be mapped to the interval 1938-2037.
7245 @kindex f
7246 @item f
7247 @vindex org-agenda-ndays
7248 Go forward in time to display the following @code{org-agenda-ndays} days.
7249 For example, if the display covers a week, switch to the following week.
7250 With prefix arg, go forward that many times @code{org-agenda-ndays} days.
7252 @kindex b
7253 @item b
7254 Go backward in time to display earlier dates.
7256 @kindex .
7257 @item .
7258 Go to today.
7260 @kindex j
7261 @item j
7262 Prompt for a date and go there.
7264 @kindex D
7265 @item D
7266 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
7268 @kindex v l
7269 @kindex l
7270 @item v l @ @r{or short} @ l
7271 @vindex org-log-done
7272 @vindex org-agenda-log-mode-items
7273 Toggle Logbook mode.  In Logbook mode, entries that were marked DONE while
7274 logging was on (variable @code{org-log-done}) are shown in the agenda, as are
7275 entries that have been clocked on that day.  You can configure the entry
7276 types that should be included in log mode using the variable
7277 @code{org-agenda-log-mode-items}.  When called with a @kbd{C-u} prefix, show
7278 all possible logbook entries, including state changes.  When called with two
7279 prefix args @kbd{C-u C-u}, show only logging information, nothing else.
7281 @kindex v [
7282 @kindex [
7283 @item v [ @ @r{or short} @ [
7284 Include inactive timestamps into the current view.  Only for weekly/daily
7285 agenda and timeline views.
7287 @kindex v a
7288 @kindex v A
7289 @item v a
7290 @itemx v A
7291 Toggle Archives mode.  In Archives mode, trees that are marked
7292 @code{ARCHIVED} are also scanned when producing the agenda.  When you use the
7293 capital @kbd{A}, even all archive files are included.  To exit archives mode,
7294 press @kbd{v a} again.
7296 @kindex v R
7297 @kindex R
7298 @item v R @ @r{or short} @ R
7299 @vindex org-agenda-start-with-clockreport-mode
7300 Toggle Clockreport mode.  In Clockreport mode, the daily/weekly agenda will
7301 always show a table with the clocked times for the timespan and file scope
7302 covered by the current agenda view.  The initial setting for this mode in new
7303 agenda buffers can be set with the variable
7304 @code{org-agenda-start-with-clockreport-mode}.
7306 @kindex v E
7307 @kindex E
7308 @item v E @ @r{or short} @ E
7309 @vindex org-agenda-start-with-entry-text-mode
7310 @vindex org-agenda-entry-text-maxlines
7311 Toggle entry text mode.  In entry text mode, a number of lines from the Org
7312 outline node referenced by an agenda line will be displayed below the line.
7313 The maximum number of lines is given by the variable
7314 @code{org-agenda-entry-text-maxlines}.  Calling this command with a numeric
7315 prefix argument will temporarily modify that number to the prefix value.
7317 @kindex G
7318 @item G
7319 @vindex org-agenda-use-time-grid
7320 @vindex org-agenda-time-grid
7321 Toggle the time grid on and off.  See also the variables
7322 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
7324 @kindex r
7325 @item r
7326 Recreate the agenda buffer, for example to reflect the changes after
7327 modification of the timestamps of items with @kbd{S-@key{left}} and
7328 @kbd{S-@key{right}}.  When the buffer is the global TODO list, a prefix
7329 argument is interpreted to create a selective list for a specific TODO
7330 keyword.
7331 @kindex g
7332 @item g
7333 Same as @kbd{r}.
7335 @kindex s
7336 @kindex C-x C-s
7337 @item s
7338 @itemx C-x C-s
7339 Save all Org buffers in the current Emacs session, and also the locations of
7340 IDs.
7342 @kindex C-c C-x C-c
7343 @item C-c C-x C-c
7344 @vindex org-columns-default-format
7345 Invoke column view (@pxref{Column view}) in the agenda buffer.  The column
7346 view format is taken from the entry at point, or (if there is no entry at
7347 point), from the first entry in the agenda view.  So whatever the format for
7348 that entry would be in the original buffer (taken from a property, from a
7349 @code{#+COLUMNS} line, or from the default variable
7350 @code{org-columns-default-format}), will be used in the agenda.
7352 @kindex C-c C-x >
7353 @item C-c C-x >
7354 Remove the restriction lock on the agenda, if it is currently restricted to a
7355 file or subtree (@pxref{Agenda files}).
7357 @tsubheading{Secondary filtering and query editing}
7358 @cindex filtering, by tag and effort, in agenda
7359 @cindex tag filtering, in agenda
7360 @cindex effort filtering, in agenda
7361 @cindex query editing, in agenda
7363 @kindex /
7364 @item /
7365 @vindex org-agenda-filter-preset
7366 Filter the current agenda view with respect to a tag and/or effort estimates.
7367 The difference between this and a custom agenda command is that filtering is
7368 very fast, so that you can switch quickly between different filters without
7369 having to recreate the agenda@footnote{Custom commands can preset a filter by
7370 binding the variable @code{org-agenda-filter-preset} as an option.  This
7371 filter will then be applied to the view and persist as a basic filter through
7372 refreshes and more secondary filtering.}
7374 You will be prompted for a tag selection letter, SPC will mean any tag at
7375 all.  Pressing @key{TAB} at that prompt will offer use completion to select a
7376 tag (including any tags that do not have a selection character).  The command
7377 then hides all entries that do not contain or inherit this tag.  When called
7378 with prefix arg, remove the entries that @emph{do} have the tag.  A second
7379 @kbd{/} at the prompt will turn off the filter and unhide any hidden entries.
7380 If the first key you press is either @kbd{+} or @kbd{-}, the previous filter
7381 will be narrowed by requiring or forbidding the selected additional tag.
7382 Instead of pressing @kbd{+} or @kbd{-} after @kbd{/}, you can also
7383 immediately use the @kbd{\} command.
7385 @vindex org-sort-agenda-noeffort-is-high
7386 In order to filter for effort estimates, you should set-up allowed
7387 efforts globally, for example
7388 @lisp
7389 (setq org-global-properties
7390     '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
7391 @end lisp
7392 You can then filter for an effort by first typing an operator, one of
7393 @kbd{<}, @kbd{>}, and @kbd{=}, and then the one-digit index of an effort
7394 estimate in your array of allowed values, where @kbd{0} means the 10th value.
7395 The filter will then restrict to entries with effort smaller-or-equal, equal,
7396 or larger-or-equal than the selected value.  If the digits 0-9 are not used
7397 as fast access keys to tags, you can also simply press the index digit
7398 directly without an operator.  In this case, @kbd{<} will be assumed.  For
7399 application of the operator, entries without a defined effort will be treated
7400 according to the value of @code{org-sort-agenda-noeffort-is-high}.  To filter
7401 for tasks without effort definition, press @kbd{?} as the operator.
7403 Org also supports automatic, context-aware tag filtering.  If the variable
7404 @code{org-agenda-auto-exclude-function} is set to a user-defined function,
7405 that function can decide which tags should be excluded from the agenda
7406 automatically.  Once this is set, the @kbd{/} command then accepts @kbd{RET}
7407 as a sub-option key and runs the auto exclusion logic.  For example, let's
7408 say you use a @code{Net} tag to identify tasks which need network access, an
7409 @code{Errand} tag for errands in town, and a @code{Call} tag for making phone
7410 calls.  You could auto-exclude these tags based on the availability of the
7411 Internet, and outside of business hours, with something like this:
7413 @lisp
7414 @group
7415 (defun org-my-auto-exclude-function (tag)
7416   (and (cond
7417         ((string= tag "Net")
7418          (/= 0 (call-process "/sbin/ping" nil nil nil
7419                              "-c1" "-q" "-t1" "mail.gnu.org")))
7420         ((or (string= tag "Errand") (string= tag "Call"))
7421          (let ((hour (nth 2 (decode-time))))
7422            (or (< hour 8) (> hour 21)))))
7423        (concat "-" tag)))
7425 (setq org-agenda-auto-exclude-function 'org-my-auto-exclude-function)
7426 @end group
7427 @end lisp
7429 @kindex \
7430 @item \
7431 Narrow the current agenda filter by an additional condition.  When called with
7432 prefix arg, remove the entries that @emph{do} have the tag, or that do match
7433 the effort criterion.  You can achieve the same effect by pressing @kbd{+} or
7434 @kbd{-} as the first key after the @kbd{/} command.
7436 @kindex [
7437 @kindex ]
7438 @kindex @{
7439 @kindex @}
7440 @item [ ] @{ @}
7441 @table @i
7442 @item @r{in} search view
7443 add new search words (@kbd{[} and @kbd{]}) or new regular expressions
7444 (@kbd{@{} and @kbd{@}}) to the query string.  The opening bracket/brace will
7445 add a positive search term prefixed by @samp{+}, indicating that this search
7446 term @i{must} occur/match in the entry.  The closing bracket/brace will add a
7447 negative search term which @i{must not} occur/match in the entry for it to be
7448 selected.
7449 @end table
7451 @page
7452 @tsubheading{Remote editing}
7453 @cindex remote editing, from agenda
7455 @item 0-9
7456 Digit argument.
7458 @cindex undoing remote-editing events
7459 @cindex remote editing, undo
7460 @kindex C-_
7461 @item C-_
7462 Undo a change due to a remote editing command.  The change is undone
7463 both in the agenda buffer and in the remote buffer.
7465 @kindex t
7466 @item t
7467 Change the TODO state of the item, both in the agenda and in the
7468 original org file.
7470 @kindex C-S-@key{right}
7471 @kindex C-S-@key{left}
7472 @item C-S-@key{right}@r{/}@key{left}
7473 Switch to the next/previous set of TODO keywords.
7475 @kindex C-k
7476 @item C-k
7477 @vindex org-agenda-confirm-kill
7478 Delete the current agenda item along with the entire subtree belonging
7479 to it in the original Org file.  If the text to be deleted remotely
7480 is longer than one line, the kill needs to be confirmed by the user.  See
7481 variable @code{org-agenda-confirm-kill}.
7483 @kindex C-c C-w
7484 @item C-c C-w
7485 Refile the entry at point.
7487 @kindex C-c C-x C-a
7488 @kindex a
7489 @item C-c C-x C-a @ @r{or short} @ a
7490 @vindex org-archive-default-command
7491 Archive the subtree corresponding to the entry at point using the default
7492 archiving command set in @code{org-archive-default-command}.  When using the
7493 @code{a} key, confirmation will be required.
7495 @kindex C-c C-x a
7496 @item C-c C-x a
7497 Toggle the ARCHIVE tag for the current headline.
7499 @kindex C-c C-x A
7500 @item C-c C-x A
7501 Move the subtree corresponding to the current entry to its @emph{archive
7502 sibling}.
7504 @kindex $
7505 @kindex C-c C-x C-s
7506 @item C-c C-x C-s @ @r{or short} @ $
7507 Archive the subtree corresponding to the current headline.  This means the
7508 entry will be moved to the configured archive location, most likely a
7509 different file.
7511 @kindex T
7512 @item T
7513 @vindex org-agenda-show-inherited-tags
7514 Show all tags associated with the current item.  This is useful if you have
7515 turned off @code{org-agenda-show-inherited-tags}, but still want to see all
7516 tags of a headline occasionally.
7518 @kindex :
7519 @item :
7520 Set tags for the current headline.  If there is an active region in the
7521 agenda, change a tag for all headings in the region.
7523 @kindex ,
7524 @item ,
7525 Set the priority for the current item.  Org mode prompts for the
7526 priority character. If you reply with @key{SPC}, the priority cookie
7527 is removed from the entry.
7529 @kindex P
7530 @item P
7531 Display weighted priority of current item.
7533 @kindex +
7534 @kindex S-@key{up}
7535 @item +
7536 @itemx S-@key{up}
7537 Increase the priority of the current item.  The priority is changed in
7538 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
7539 key for this.
7541 @kindex -
7542 @kindex S-@key{down}
7543 @item -
7544 @itemx S-@key{down}
7545 Decrease the priority of the current item.
7547 @kindex z
7548 @item z
7549 @vindex org-log-into-drawer
7550 Add a note to the entry.  This note will be recorded, and then files to the
7551 same location where state change notes are put.  Depending on
7552 @code{org-log-into-drawer}, this maybe inside a drawer.
7554 @kindex C-c C-a
7555 @item C-c C-a
7556 Dispatcher for all command related to attachments.
7558 @kindex C-c C-s
7559 @item C-c C-s
7560 Schedule this item
7562 @kindex C-c C-d
7563 @item C-c C-d
7564 Set a deadline for this item.
7566 @kindex k
7567 @item k
7568 Agenda actions, to set dates for selected items to the cursor date.
7569 This command also works in the calendar!  The command prompts for an
7570 additional key:
7571 @example
7572 m   @r{Mark the entry at point for action.  You can also make entries}
7573     @r{in Org files with @kbd{C-c C-x C-k}.}
7574 d   @r{Set the deadline of the marked entry to the date at point.}
7575 s   @r{Schedule the marked entry at the date at point.}
7576 r   @r{Call @code{org-remember} with the cursor date as default date.}
7577 @end example
7578 @noindent
7579 Press @kbd{r} afterward to refresh the agenda and see the effect of the
7580 command.
7582 @kindex S-@key{right}
7583 @item S-@key{right}
7584 Change the timestamp associated with the current line by one day into the
7585 future.  With a numeric prefix argument, change it by that many days.  For
7586 example, @kbd{3 6 5 S-@key{right}} will change it by a year.  With a
7587 @kbd{C-u} prefix, change the time by one hour.  If you immediately repeat the
7588 command, it will continue to change hours even without the prefix arg.  With
7589 a double @kbd{C-u C-u} prefix, do the same for changing minutes.  The stamp
7590 is changed in the original Org file, but the change is not directly reflected
7591 in the agenda buffer.  Use @kbd{r} or @kbd{g} to update the buffer.
7593 @kindex S-@key{left}
7594 @item S-@key{left}
7595 Change the timestamp associated with the current line by one day
7596 into the past.
7598 @kindex >
7599 @item >
7600 Change the timestamp associated with the current line to today.
7601 The key @kbd{>} has been chosen, because it is the same as @kbd{S-.}
7602 on my keyboard.
7604 @kindex I
7605 @item I
7606 Start the clock on the current item.  If a clock is running already, it
7607 is stopped first.
7609 @kindex O
7610 @item O
7611 Stop the previously started clock.
7613 @kindex X
7614 @item X
7615 Cancel the currently running clock.
7617 @kindex J
7618 @item J
7619 Jump to the running clock in another window.
7621 @tsubheading{Bulk remote editing selected entries}
7622 @cindex remote editing, bulk, from agenda
7624 @kindex m
7625 @item s
7626 Mark the entry at point for bulk action.
7628 @kindex u
7629 @item u
7630 Unmark entry for bulk action.
7632 @kindex U
7633 @item U
7634 Unmark all marked entries for bulk action.
7636 @kindex B
7637 @item B
7638 Bulk action: act on all marked entries in the agenda.  This will prompt for
7639 another key to select the action to be applied:
7640 @example
7641 r  @r{Prompt for a single refile target and move all entries.  The entries}
7642    @r{will no longer be in the agenda, refresh (@kbd{g}) to bring them back.}
7643 $  @r{Archive all selected entries.}
7644 A  @r{Archive entries by moving them to their respective archive siblings.}
7645 t  @r{Change TODO state.  This prompts for a single TODO keyword and}
7646    @r{changes the state of all selected entries, bypassing blocking and}
7647    @r{suppressing logging notes (but not time stamps).}
7648 +  @r{Add a tag to all selected entries.}
7649 -  @r{Remove a tag from all selected entries.}
7650 s  @r{Schedule all items to a new date.  To shift existing schedule dates}
7651    @r{by a fixed number of days, use something starting with double plus}
7652    @r{at the prompt, for example @samp{++8d} or @samp{++2w}.}
7653 d  @r{Set deadline to a specific date.}
7654 @end example
7657 @tsubheading{Calendar commands}
7658 @cindex calendar commands, from agenda
7659 @kindex c
7660 @item c
7661 Open the Emacs calendar and move to the date at the agenda cursor.
7663 @item c
7664 When in the calendar, compute and show the Org mode agenda for the
7665 date at the cursor.
7667 @cindex diary entries, creating from agenda
7668 @kindex i
7669 @item i
7670 @vindex org-agenda-diary-file
7671 Insert a new entry into the diary, using the date at the cursor and (for
7672 block entries) the date at the mark.  This will add to the Emacs diary
7673 file@footnote{This file is parsed for the agenda when
7674 @code{org-agenda-include-diary} is set.}, in a way similar to the @kbd{i}
7675 command in the calendar.  The diary file will pop up in another window, where
7676 you can add the entry.
7678 If you configure @code{org-agenda-diary-file} to point to an Org-mode file,
7679 Org will create entries (in org-mode syntax) in that file instead.  Most
7680 entries will be stored in a date-based outline tree that will later make it
7681 easy to archive appointments from previous months/years.  The tree will be
7682 build under an entry with a @code{DATE_TREE} property, or else with years as
7683 top-level entries.  Emacs will prompt you for the entry text - if you specify
7684 it, the entry will be created in @code{org-agenda-diary-file} without further
7685 interaction.  If you directly press @key{RET} at the prompt without typing
7686 text, the target file will be shown in another window for you to finish the
7687 entry there.  See also the @kbd{k r} command.
7689 @kindex M
7690 @item M
7691 Show the phases of the moon for the three months around current date.
7693 @kindex S
7694 @item S
7695 Show sunrise and sunset times.  The geographical location must be set
7696 with calendar variables, see the documentation for the Emacs calendar.
7698 @kindex C
7699 @item C
7700 Convert the date at cursor into many other cultural and historic
7701 calendars.
7703 @kindex H
7704 @item H
7705 Show holidays for three months around the cursor date.
7707 @item M-x org-export-icalendar-combine-agenda-files
7708 Export a single iCalendar file containing entries from all agenda files.
7709 This is a globally available command, and also available in the agenda menu.
7711 @tsubheading{Exporting to a file}
7712 @kindex C-x C-w
7713 @item C-x C-w
7714 @cindex exporting agenda views
7715 @cindex agenda views, exporting
7716 @vindex org-agenda-exporter-settings
7717 Write the agenda view to a file.  Depending on the extension of the selected
7718 file name, the view will be exported as HTML (extension @file{.html} or
7719 @file{.htm}), Postscript (extension @file{.ps}), PDF (extension @file{.pdf}),
7720 and plain text (any other extension).  When called with a @kbd{C-u} prefix
7721 argument, immediately open the newly created file.  Use the variable
7722 @code{org-agenda-exporter-settings} to set options for @file{ps-print} and
7723 for @file{htmlize} to be used during export.
7725 @tsubheading{Quit and Exit}
7726 @kindex q
7727 @item q
7728 Quit agenda, remove the agenda buffer.
7730 @kindex x
7731 @cindex agenda files, removing buffers
7732 @item x
7733 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
7734 for the compilation of the agenda.  Buffers created by the user to
7735 visit Org files will not be removed.
7736 @end table
7739 @node Custom agenda views, Exporting Agenda Views, Agenda commands, Agenda Views
7740 @section Custom agenda views
7741 @cindex custom agenda views
7742 @cindex agenda views, custom
7744 Custom agenda commands serve two purposes: to store and quickly access
7745 frequently used TODO and tags searches, and to create special composite
7746 agenda buffers.  Custom agenda commands will be accessible through the
7747 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
7749 @menu
7750 * Storing searches::            Type once, use often
7751 * Block agenda::                All the stuff you need in a single buffer
7752 * Setting Options::             Changing the rules
7753 @end menu
7755 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
7756 @subsection Storing searches
7758 The first application of custom searches is the definition of keyboard
7759 shortcuts for frequently used searches, either creating an agenda
7760 buffer, or a sparse tree (the latter covering of course only the current
7761 buffer).
7762 @kindex C-c a C
7763 @vindex org-agenda-custom-commands
7764 Custom commands are configured in the variable
7765 @code{org-agenda-custom-commands}.  You can customize this variable, for
7766 example by pressing @kbd{C-c a C}.  You can also directly set it with
7767 Emacs Lisp in @file{.emacs}.  The following example contains all valid
7768 search types:
7770 @lisp
7771 @group
7772 (setq org-agenda-custom-commands
7773       '(("w" todo "WAITING")
7774         ("W" todo-tree "WAITING")
7775         ("u" tags "+boss-urgent")
7776         ("v" tags-todo "+boss-urgent")
7777         ("U" tags-tree "+boss-urgent")
7778         ("f" occur-tree "\\<FIXME\\>")
7779         ("h" . "HOME+Name tags searches") ; description for "h" prefix
7780         ("hl" tags "+home+Lisa")
7781         ("hp" tags "+home+Peter")
7782         ("hk" tags "+home+Kim")))
7783 @end group
7784 @end lisp
7786 @noindent
7787 The initial string in each entry defines the keys you have to press
7788 after the dispatcher command @kbd{C-c a} in order to access the command.
7789 Usually this will be just a single character, but if you have many
7790 similar commands, you can also define two-letter combinations where the
7791 first character is the same in several combinations and serves as a
7792 prefix key@footnote{You can provide a description for a prefix key by
7793 inserting a cons cell with the prefix and the description.}.  The second
7794 parameter is the search type, followed by the string or regular
7795 expression to be used for the matching.  The example above will
7796 therefore define:
7798 @table @kbd
7799 @item C-c a w
7800 as a global search for TODO entries with @samp{WAITING} as the TODO
7801 keyword
7802 @item C-c a W
7803 as the same search, but only in the current buffer and displaying the
7804 results as a sparse tree
7805 @item C-c a u
7806 as a global tags search for headlines marked @samp{:boss:} but not
7807 @samp{:urgent:}
7808 @item C-c a v
7809 as the same search as @kbd{C-c a u}, but limiting the search to
7810 headlines that are also TODO items
7811 @item C-c a U
7812 as the same search as @kbd{C-c a u}, but only in the current buffer and
7813 displaying the result as a sparse tree
7814 @item C-c a f
7815 to create a sparse tree (again: current buffer only) with all entries
7816 containing the word @samp{FIXME}
7817 @item C-c a h
7818 as a prefix command for a HOME tags search where you have to press an
7819 additional key (@kbd{l}, @kbd{p} or @kbd{k}) to select a name (Lisa,
7820 Peter, or Kim) as additional tag to match.
7821 @end table
7823 @node Block agenda, Setting Options, Storing searches, Custom agenda views
7824 @subsection Block agenda
7825 @cindex block agenda
7826 @cindex agenda, with block views
7828 Another possibility is the construction of agenda views that comprise
7829 the results of @emph{several} commands, each of which creates a block in
7830 the agenda buffer.  The available commands include @code{agenda} for the
7831 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
7832 for the global TODO list (as constructed with @kbd{C-c a t}), and the
7833 matching commands discussed above: @code{todo}, @code{tags}, and
7834 @code{tags-todo}.  Here are two examples:
7836 @lisp
7837 @group
7838 (setq org-agenda-custom-commands
7839       '(("h" "Agenda and Home-related tasks"
7840          ((agenda "")
7841           (tags-todo "home")
7842           (tags "garden")))
7843         ("o" "Agenda and Office-related tasks"
7844          ((agenda "")
7845           (tags-todo "work")
7846           (tags "office")))))
7847 @end group
7848 @end lisp
7850 @noindent
7851 This will define @kbd{C-c a h} to create a multi-block view for stuff
7852 you need to attend to at home.  The resulting agenda buffer will contain
7853 your agenda for the current week, all TODO items that carry the tag
7854 @samp{home}, and also all lines tagged with @samp{garden}.  Finally the
7855 command @kbd{C-c a o} provides a similar view for office tasks.
7857 @node Setting Options,  , Block agenda, Custom agenda views
7858 @subsection Setting options for custom commands
7859 @cindex options, for custom agenda views
7861 @vindex org-agenda-custom-commands
7862 Org mode contains a number of variables regulating agenda construction
7863 and display.  The global variables define the behavior for all agenda
7864 commands, including the custom commands.  However, if you want to change
7865 some settings just for a single custom view, you can do so.  Setting
7866 options requires inserting a list of variable names and values at the
7867 right spot in @code{org-agenda-custom-commands}.  For example:
7869 @lisp
7870 @group
7871 (setq org-agenda-custom-commands
7872       '(("w" todo "WAITING"
7873          ((org-agenda-sorting-strategy '(priority-down))
7874           (org-agenda-prefix-format "  Mixed: ")))
7875         ("U" tags-tree "+boss-urgent"
7876          ((org-show-following-heading nil)
7877           (org-show-hierarchy-above nil)))
7878         ("N" search ""
7879          ((org-agenda-files '("~org/notes.org"))
7880           (org-agenda-text-search-extra-files nil)))))
7881 @end group
7882 @end lisp
7884 @noindent
7885 Now the @kbd{C-c a w} command will sort the collected entries only by
7886 priority, and the prefix format is modified to just say @samp{  Mixed: }
7887 instead of giving the category of the entry.  The sparse tags tree of
7888 @kbd{C-c a U} will now turn out ultra-compact, because neither the
7889 headline hierarchy above the match, nor the headline following the match
7890 will be shown.  The command @kbd{C-c a N} will do a text search limited
7891 to only a single file.
7893 @vindex org-agenda-custom-commands
7894 For command sets creating a block agenda,
7895 @code{org-agenda-custom-commands} has two separate spots for setting
7896 options.  You can add options that should be valid for just a single
7897 command in the set, and options that should be valid for all commands in
7898 the set.  The former are just added to the command entry, the latter
7899 must come after the list of command entries.  Going back to the block
7900 agenda example (@pxref{Block agenda}), let's change the sorting strategy
7901 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
7902 the results for GARDEN tags query in the opposite order,
7903 @code{priority-up}.  This would look like this:
7905 @lisp
7906 @group
7907 (setq org-agenda-custom-commands
7908       '(("h" "Agenda and Home-related tasks"
7909          ((agenda)
7910           (tags-todo "home")
7911           (tags "garden"
7912                 ((org-agenda-sorting-strategy '(priority-up)))))
7913          ((org-agenda-sorting-strategy '(priority-down))))
7914         ("o" "Agenda and Office-related tasks"
7915          ((agenda)
7916           (tags-todo "work")
7917           (tags "office")))))
7918 @end group
7919 @end lisp
7921 As you see, the values and parentheses setting is a little complex.
7922 When in doubt, use the customize interface to set this variable---it
7923 fully supports its structure.  Just one caveat: when setting options in
7924 this interface, the @emph{values} are just Lisp expressions.  So if the
7925 value is a string, you need to add the double-quotes around the value
7926 yourself.
7929 @node Exporting Agenda Views, Agenda column view, Custom agenda views, Agenda Views
7930 @section Exporting Agenda Views
7931 @cindex agenda views, exporting
7933 If you are away from your computer, it can be very useful to have a printed
7934 version of some agenda views to carry around.  Org mode can export custom
7935 agenda views as plain text, HTML@footnote{You need to install Hrvoje Niksic's
7936 @file{htmlize.el}.}, Postscript, PDF@footnote{To create PDF output, the
7937 ghostscript @file{ps2pdf} utility must be installed on the system.  Selecting
7938 a PDF file with also create the postscript file.}, and iCalendar files.  If
7939 you want to do this only occasionally, use the command
7941 @table @kbd
7942 @kindex C-x C-w
7943 @item C-x C-w
7944 @cindex exporting agenda views
7945 @cindex agenda views, exporting
7946 @vindex org-agenda-exporter-settings
7947 Write the agenda view to a file.  Depending on the extension of the selected
7948 file name, the view will be exported as HTML (extension @file{.html} or
7949 @file{.htm}), Postscript (extension @file{.ps}), iCalendar (extension
7950 @file{.ics}), or plain text (any other extension).  Use the variable
7951 @code{org-agenda-exporter-settings} to set options for @file{ps-print} and
7952 for @file{htmlize} to be used during export, for example
7954 @vindex org-agenda-add-entry-text-maxlines
7955 @vindex htmlize-output-type
7956 @vindex ps-number-of-columns
7957 @vindex ps-landscape-mode
7958 @lisp
7959 (setq org-agenda-exporter-settings
7960       '((ps-number-of-columns 2)
7961         (ps-landscape-mode t)
7962         (org-agenda-add-entry-text-maxlines 5)
7963         (htmlize-output-type 'css)))
7964 @end lisp
7965 @end table
7967 If you need to export certain agenda views frequently, you can associate
7968 any custom agenda command with a list of output file names
7969 @footnote{If you want to store standard views like the weekly agenda
7970 or the global TODO list as well, you need to define custom commands for
7971 them in order to be able to specify file names.}.  Here is an example
7972 that first defines custom commands for the agenda and the global
7973 TODO list, together with a number of files to which to export them.
7974 Then we define two block agenda commands and specify file names for them
7975 as well.  File names can be relative to the current working directory,
7976 or absolute.
7978 @lisp
7979 @group
7980 (setq org-agenda-custom-commands
7981       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
7982         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
7983         ("h" "Agenda and Home-related tasks"
7984          ((agenda "")
7985           (tags-todo "home")
7986           (tags "garden"))
7987          nil
7988          ("~/views/home.html"))
7989         ("o" "Agenda and Office-related tasks"
7990          ((agenda)
7991           (tags-todo "work")
7992           (tags "office"))
7993          nil
7994          ("~/views/office.ps" "~/calendars/office.ics"))))
7995 @end group
7996 @end lisp
7998 The extension of the file name determines the type of export.  If it is
7999 @file{.html}, Org mode will use the @file{htmlize.el} package to convert
8000 the buffer to HTML and save it to this file name.  If the extension is
8001 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
8002 Postscript output.  If the extension is @file{.ics}, iCalendar export is
8003 run export over all files that were used to construct the agenda, and
8004 limit the export to entries listed in the agenda.  Any other
8005 extension produces a plain ASCII file.
8007 The export files are @emph{not} created when you use one of those
8008 commands interactively because this might use too much overhead.
8009 Instead, there is a special command to produce @emph{all} specified
8010 files in one step:
8012 @table @kbd
8013 @kindex C-c a e
8014 @item C-c a e
8015 Export all agenda views that have export file names associated with
8016 them.
8017 @end table
8019 You can use the options section of the custom agenda commands to also
8020 set options for the export commands.  For example:
8022 @lisp
8023 (setq org-agenda-custom-commands
8024       '(("X" agenda ""
8025          ((ps-number-of-columns 2)
8026           (ps-landscape-mode t)
8027           (org-agenda-prefix-format " [ ] ")
8028           (org-agenda-with-colors nil)
8029           (org-agenda-remove-tags t))
8030          ("theagenda.ps"))))
8031 @end lisp
8033 @noindent
8034 This command sets two options for the Postscript exporter, to make it
8035 print in two columns in landscape format---the resulting page can be cut
8036 in two and then used in a paper agenda.  The remaining settings modify
8037 the agenda prefix to omit category and scheduling information, and
8038 instead include a checkbox to check off items.  We also remove the tags
8039 to make the lines compact, and we don't want to use colors for the
8040 black-and-white printer.  Settings specified in
8041 @code{org-agenda-exporter-settings} will also apply, but the settings
8042 in @code{org-agenda-custom-commands} take precedence.
8044 @noindent
8045 From the command line you may also use
8046 @example
8047 emacs -f org-batch-store-agenda-views -kill
8048 @end example
8049 @noindent
8050 or, if you need to modify some parameters@footnote{Quoting depends on the
8051 system you use, please check the FAQ for examples.}
8052 @example
8053 emacs -eval '(org-batch-store-agenda-views                      \
8054               org-agenda-ndays 30                               \
8055               org-agenda-start-day "2007-11-01"                 \
8056               org-agenda-include-diary nil                      \
8057               org-agenda-files (quote ("~/org/project.org")))'  \
8058       -kill
8059 @end example
8060 @noindent
8061 which will create the agenda views restricted to the file
8062 @file{~/org/project.org}, without diary entries and with a 30-day
8063 extent.
8065 You can also extract agenda information in a way that allows further
8066 processing by other programs.  See @ref{Extracting agenda information}, for
8067 more information.
8070 @node Agenda column view,  , Exporting Agenda Views, Agenda Views
8071 @section Using column view in the agenda
8072 @cindex column view, in agenda
8073 @cindex agenda, column view
8075 Column view (@pxref{Column view}) is normally used to view and edit
8076 properties embedded in the hierarchical structure of an Org file.  It can be
8077 quite useful to use column view also from the agenda, where entries are
8078 collected by certain criteria.
8080 @table @kbd
8081 @kindex C-c C-x C-c
8082 @item C-c C-x C-c
8083 Turn on column view in the agenda.
8084 @end table
8086 To understand how to use this properly, it is important to realize that the
8087 entries in the agenda are no longer in their proper outline environment.
8088 This causes the following issues:
8090 @enumerate
8091 @item
8092 @vindex org-columns-default-format
8093 @vindex org-overriding-columns-format
8094 Org needs to make a decision which @code{COLUMNS} format to use.  Since the
8095 entries in the agenda are collected from different files, and different files
8096 may have different @code{COLUMNS} formats, this is a non-trivial problem.
8097 Org first checks if the variable @code{org-overriding-columns-format} is
8098 currently set, and if so, takes the format from there.  Otherwise it takes
8099 the format associated with the first item in the agenda, or, if that item
8100 does not have a specific format (defined in a property, or in its file), it
8101 uses @code{org-columns-default-format}.
8102 @item
8103 @cindex property, special, CLOCKSUM
8104 If any of the columns has a summary type defined (@pxref{Column attributes}),
8105 turning on column view in the agenda will visit all relevant agenda files and
8106 make sure that the computations of this property are up to date.  This is
8107 also true for the special @code{CLOCKSUM} property.  Org will then sum the
8108 values displayed in the agenda.  In the daily/weekly agenda, the sums will
8109 cover a single day, in all other views they cover the entire block.  It is
8110 vital to realize that the agenda may show the same entry @emph{twice} (for
8111 example as scheduled and as a deadline), and it may show two entries from the
8112 same hierarchy (for example a @emph{parent} and its @emph{child}).  In these
8113 cases, the summation in the agenda will lead to incorrect results because
8114 some values will count double.
8115 @item
8116 When the column view in the agenda shows the @code{CLOCKSUM}, that is always
8117 the entire clocked time for this item.  So even in the daily/weekly agenda,
8118 the clocksum listed in column view may originate from times outside the
8119 current view.  This has the advantage that you can compare these values with
8120 a column listing the planned total effort for a task---one of the major
8121 applications for column view in the agenda.  If you want information about
8122 clocked time in the displayed period use clock table mode (press @kbd{R} in
8123 the agenda).
8124 @end enumerate
8127 @node Markup, Exporting, Agenda Views, Top
8128 @chapter Markup for rich export
8130 When exporting Org-mode documents, the exporter tries to reflect the
8131 structure of the document as accurately as possible in the backend.  Since
8132 export targets like HTML, La@TeX{}, or DocBook allow much richer formatting,
8133 Org mode has rules on how to prepare text for rich export.  This section
8134 summarizes the markup rules used in an Org-mode buffer.
8136 @menu
8137 * Structural markup elements::  The basic structure as seen by the exporter
8138 * Images and tables::           Tables and Images will be included
8139 * Literal examples::            Source code examples with special formatting
8140 * Include files::               Include additional files into a document
8141 * Macro replacement::           Use macros to create complex output
8142 * Embedded LaTeX::              LaTeX can be freely used inside Org documents
8143 @end menu
8145 @node Structural markup elements, Images and tables, Markup, Markup
8146 @section Structural markup elements
8148 @menu
8149 * Document title::              Where the title is taken from
8150 * Headings and sections::       The document structure as seen by the exporter
8151 * Table of contents::           The if and where of the table of contents
8152 * Initial text::                Text before the first heading?
8153 * Lists::                       Lists
8154 * Paragraphs::                  Paragraphs
8155 * Footnote markup::             Footnotes
8156 * Emphasis and monospace::      Bold, italic, etc.
8157 * Horizontal rules::            Make a line
8158 * Comment lines::               What will *not* be exported
8159 @end menu
8161 @node Document title, Headings and sections, Structural markup elements, Structural markup elements
8162 @subheading Document title
8163 @cindex document title, markup rules
8165 @noindent
8166 The title of the exported document is taken from the special line
8168 @cindex #+TITLE
8169 @example
8170 #+TITLE: This is the title of the document
8171 @end example
8173 @noindent
8174 If this line does not exist, the title is derived from the first non-empty,
8175 non-comment line in the buffer.  If no such line exists, or if you have
8176 turned off exporting of the text before the first headline (see below), the
8177 title will be the file name without extension.
8179 @cindex property, EXPORT_TITLE
8180 If you are exporting only a subtree by marking is as the region, the heading
8181 of the subtree will become the title of the document.  If the subtree has a
8182 property @code{EXPORT_TITLE}, that will take precedence.
8184 @node Headings and sections, Table of contents, Document title, Structural markup elements
8185 @subheading Headings and sections
8186 @cindex headings and sections, markup rules
8188 @vindex org-export-headline-levels
8189 The outline structure of the document as described in @ref{Document
8190 Structure}, forms the basis for defining sections of the exported document.
8191 However, since the outline structure is also used for (for example) lists of
8192 tasks, only the first three outline levels will be used as headings.  Deeper
8193 levels will become itemized lists.  You can change the location of this
8194 switch globally by setting the variable @code{org-export-headline-levels}, or on a
8195 per-file basis with a line
8197 @cindex #+OPTIONS
8198 @example
8199 #+OPTIONS: H:4
8200 @end example
8202 @node Table of contents, Initial text, Headings and sections, Structural markup elements
8203 @subheading Table of contents
8204 @cindex table of contents, markup rules
8206 @vindex org-export-with-toc
8207 The table of contents is normally inserted directly before the first headline
8208 of the file.  If you would like to get it to a different location, insert the
8209 string @code{[TABLE-OF-CONTENTS]} on a line by itself at the desired
8210 location.  The depth of the table of contents is by default the same as the
8211 number of headline levels, but you can choose a smaller number, or turn off
8212 the table of contents entirely, by configuring the variable
8213 @code{org-export-with-toc}, or on a per-file basis with a line like
8215 @example
8216 #+OPTIONS: toc:2          (only to two levels in TOC)
8217 #+OPTIONS: toc:nil        (no TOC at all)
8218 @end example
8220 @node Initial text, Lists, Table of contents, Structural markup elements
8221 @subheading Text before the first headline
8222 @cindex text before first headline, markup rules
8223 @cindex #+TEXT
8225 Org mode normally exports the text before the first headline, and even uses
8226 the first line as the document title.  The text will be fully marked up.  If
8227 you need to include literal HTML, La@TeX{}, or DocBook code, use the special
8228 constructs described below in the sections for the individual exporters.
8230 @vindex org-export-skip-text-before-1st-heading
8231 Some people like to use the space before the first headline for setup and
8232 internal links and therefore would like to control the exported text before
8233 the first headline in a different way.  You can do so by setting the variable
8234 @code{org-export-skip-text-before-1st-heading} to @code{t}.  On a per-file
8235 basis, you can get the same effect with @samp{#+OPTIONS: skip:t}.
8237 @noindent
8238 If you still want to have some text before the first headline, use the
8239 @code{#+TEXT} construct:
8241 @example
8242 #+OPTIONS: skip:t
8243 #+TEXT: This text will go before the *first* headline.
8244 #+TEXT: [TABLE-OF-CONTENTS]
8245 #+TEXT: This goes between the table of contents and the first headline
8246 @end example
8248 @node Lists, Paragraphs, Initial text, Structural markup elements
8249 @subheading Lists
8250 @cindex lists, markup rules
8252 Plain lists as described in @ref{Plain lists}, are translated to the backend's
8253 syntax for such lists.  Most backends support unordered, ordered, and
8254 description lists.
8256 @node Paragraphs, Footnote markup, Lists, Structural markup elements
8257 @subheading Paragraphs, line breaks, and quoting
8258 @cindex paragraphs, markup rules
8260 Paragraphs are separated by at least one empty line.  If you need to enforce
8261 a line break within a paragraph, use @samp{\\} at the end of a line.
8263 To keep the line breaks in a region, but otherwise use normal formatting, you
8264 can use this construct, which can also be used to format poetry.
8266 @cindex #+BEGIN_VERSE
8267 @example
8268 #+BEGIN_VERSE
8269  Great clouds overhead
8270  Tiny black birds rise and fall
8271  Snow covers Emacs
8273      -- AlexSchroeder
8274 #+END_VERSE
8275 @end example
8277 When quoting a passage from another document, it is customary to format this
8278 as a paragraph that is indented on both the left and the right margin.  You
8279 can include quotations in Org-mode documents like this:
8281 @cindex #+BEGIN_QUOTE
8282 @example
8283 #+BEGIN_QUOTE
8284 Everything should be made as simple as possible,
8285 but not any simpler -- Albert Einstein
8286 #+END_QUOTE
8287 @end example
8289 If you would like to center some text, do it like this:
8290 @cindex #+BEGIN_CENTER
8291 @example
8292 #+BEGIN_CENTER
8293 Everything should be made as simple as possible, \\
8294 but not any simpler
8295 #+END_CENTER
8296 @end example
8299 @node Footnote markup, Emphasis and monospace, Paragraphs, Structural markup elements
8300 @subheading Footnote markup
8301 @cindex footnotes, markup rules
8302 @cindex @file{footnote.el}
8304 Footnotes defined in the way described in @ref{Footnotes}, will be exported by
8305 all backends.  Org allows multiple references to the same note, and
8306 different backends support this to varying degrees.
8308 @node Emphasis and monospace, Horizontal rules, Footnote markup, Structural markup elements
8309 @subheading Emphasis and monospace
8311 @cindex underlined text, markup rules
8312 @cindex bold text, markup rules
8313 @cindex italic text, markup rules
8314 @cindex verbatim text, markup rules
8315 @cindex code text, markup rules
8316 @cindex strike-through text, markup rules
8317 You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
8318 and @code{~verbatim~}, and, if you must, @samp{+strike-through+}.  Text
8319 in the code and verbatim string is not processed for Org-mode specific
8320 syntax, it is exported verbatim.
8322 @node Horizontal rules, Comment lines, Emphasis and monospace, Structural markup elements
8323 @subheading  Horizontal rules
8324 @cindex horizontal rules, markup rules
8325 A line consisting of only dashes, and at least 5 of them, will be
8326 exported as a horizontal line (@samp{<hr/>} in HTML).
8328 @node Comment lines,  , Horizontal rules, Structural markup elements
8329 @subheading Comment lines
8330 @cindex comment lines
8331 @cindex exporting, not
8332 @cindex #+BEGIN_COMMENT
8334 Lines starting with @samp{#} in column zero are treated as comments and will
8335 never be exported. If you want an indented line to be treated as a comment,
8336 start it with @samp{#+ }.  Also entire subtrees starting with the word
8337 @samp{COMMENT} will never be exported.  Finally, regions surrounded by
8338 @samp{#+BEGIN_COMMENT} ... @samp{#+END_COMMENT} will not be exported.
8340 @table @kbd
8341 @kindex C-c ;
8342 @item C-c ;
8343 Toggle the COMMENT keyword at the beginning of an entry.
8344 @end table
8347 @node Images and tables, Literal examples, Structural markup elements, Markup
8348 @section Images and Tables
8350 @cindex tables, markup rules
8351 @cindex #+CAPTION
8352 @cindex #+LABEL
8353 Both the native Org mode tables (@pxref{Tables}) and tables formatted with
8354 the @file{table.el} package will be exported properly.  For Org mode tables,
8355 the lines before the first horizontal separator line will become table header
8356 lines.  You can use the following lines somewhere before the table to assign
8357 a caption and a label for cross references:
8359 @example
8360 #+CAPTION: This is the caption for the next table (or link)
8361 #+LABEL:   tbl:basic-data
8362    | ... | ...|
8363    |-----|----|
8364 @end example
8366 @cindex inlined images, markup rules
8367 Some backends (HTML, La@TeX{}, and DocBook) allow you to directly include
8368 images into the exported document.  Org does this, if a link to an image
8369 files does not have a description part, for example @code{[[./img/a.jpg]]}.
8370 If you wish to define a caption for the image and maybe a label for internal
8371 cross references, you sure that the link is on a line by itself precede it
8372 with:
8374 @example
8375 #+CAPTION: This is the caption for the next figure link (or table)
8376 #+LABEL:   fig:SED-HR4049
8377 [[./img/a.jpg]]
8378 @end example
8380 You may also define additional attributes for the figure.  As this is
8381 backend-specific, see the sections about the individual backends for more
8382 information.
8385 @node Literal examples, Include files, Images and tables, Markup
8386 @section Literal examples
8387 @cindex literal examples, markup rules
8388 @cindex code line references, markup rules
8390 You can include literal examples that should not be subjected to
8391 markup.  Such examples will be typeset in monospace, so this is well suited
8392 for source code and similar examples.
8393 @cindex #+BEGIN_EXAMPLE
8395 @example
8396 #+BEGIN_EXAMPLE
8397 Some example from a text file.
8398 #+END_EXAMPLE
8399 @end example
8401 Note that such blocks may be @i{indented} in order to align nicely with
8402 indented text and in particular with plain list structure (@pxref{Plain
8403 lists}).  For simplicity when using small examples, you can also start the
8404 example lines with a colon followed by a space.  There may also be additional
8405 whitespace before the colon:
8407 @example
8408 Here is an example
8409    : Some example from a text file.
8410 @end example
8412 @cindex formatting source code, markup rules
8413 If the example is source code from a programming language, or any other text
8414 that can be marked up by font-lock in Emacs, you can ask for the example to
8415 look like the fontified Emacs buffer@footnote{Currently this works for the
8416 HTML backend, and requires the @file{htmlize.el} package version 1.34 or
8417 later.  It also works for LaTeX with the listings package, if you turn on the
8418 option @code{org-export-latex-listings} and make sure that the listings
8419 package is included by the LaTeX header.}.  This is done with the @samp{src}
8420 block, where you also need to specify the name of the major mode that should
8421 be used to fontify the example:
8422 @cindex #+BEGIN_SRC
8424 @example
8425 #+BEGIN_SRC emacs-lisp
8426 (defun org-xor (a b)
8427    "Exclusive or."
8428    (if a (not b) b))
8429 #+END_SRC
8430 @end example
8432 Both in @code{example} and in @code{src} snippets, you can add a @code{-n}
8433 switch to the end of the @code{BEGIN} line, to get the lines of the example
8434 numbered.  If you use a @code{+n} switch, the numbering from the previous
8435 numbered snippet will be continued in the current one.  In literal examples,
8436 Org will interpret strings like @samp{(ref:name)} as labels, and use them as
8437 targets for special hyperlinks like @code{[[(name)]]} (i.e. the reference name
8438 enclosed in single parenthesis).  In HTML, hovering the mouse over such a
8439 link will remote-highlight the corresponding code line, which is kind of
8440 cool.
8442 You can also add a @code{-r} switch which @i{removes} the labels from the
8443 source code@footnote{Adding @code{-k} to @code{-n -r} will @i{keep} the
8444 labels in the source code while using line numbers for the links, which might
8445 be useful to explain those in an org-mode example code.}.  With the @code{-n}
8446 switch, links to these references will be labeled by the line numbers from
8447 the code listing, otherwise links will use the labels with no parentheses.
8448 Here is an example:
8450 @example
8451 #+BEGIN_SRC emacs-lisp -n -r
8452 (save-excursion                  (ref:sc)
8453    (goto-char (point-min))       (ref:jump)
8454 #+END_SRC
8455 In line [[(sc)]] we remember the current position.  [[(jump)][Line (jump)]]
8456 jumps to point-min.
8457 @end example
8459 @vindex org-coderef-label-format
8460 If the syntax for the label format conflicts with the language syntax, use a
8461 @code{-l} switch to change the format, for example @samp{#+BEGIN_SRC pascal
8462 -n -r -l "((%s))"}.  See also the variable @code{org-coderef-label-format}.
8464 HTML export also allows examples to be published as text areas, @xref{Text
8465 areas in HTML export}.
8467 @table @kbd
8468 @kindex C-c '
8469 @item C-c '
8470 Edit the source code example at point in its native mode.  This works by
8471 switching to a temporary buffer with the source code.  You need to exit by
8472 pressing @kbd{C-c '} again@footnote{Upon exit, lines starting with @samp{*}
8473 or @samp{#} will get a comma prepended, to keep them from being interpreted
8474 by Org as outline nodes or special comments.  These commas will be striped
8475 for editing with @kbd{C-c '}, and also for export.}, the edited version will
8476 then replace the old version in the Org buffer.  Fixed-width regions
8477 (where each line starts with a colon followed by a space) will be edited
8478 using @code{artist-mode}@footnote{You may select a different-mode with the
8479 variable @code{org-edit-fixed-width-region-mode}.} to allow creating ASCII
8480 drawings easily.  Using this command in an empty line will create a new
8481 fixed-width region.
8482 @kindex C-c l
8483 @item C-c l
8484 Calling @code{org-store-link} while editing a source code example in a
8485 temporary buffer created with @kbd{C-c '} will prompt for a label, make sure
8486 that it is unique in the current buffer, and insert it with the proper
8487 formatting like @samp{(ref:label)} at the end of the current line.  Then the
8488 label is stored as a link @samp{(label)}, for retrieval with @kbd{C-c C-l}.
8489 @end table
8492 @node Include files, Macro replacement, Literal examples, Markup
8493 @section Include files
8494 @cindex include files, markup rules
8496 During export, you can include the content of another file.  For example, to
8497 include your @file{.emacs} file, you could use:
8498 @cindex #+INCLUDE
8500 @example
8501 #+INCLUDE: "~/.emacs" src emacs-lisp
8502 @end example
8503 @noindent
8504 The optional second and third parameter are the markup (e.g. @samp{quote},
8505 @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
8506 language for formatting the contents.  The markup is optional, if it is not
8507 given, the text will be assumed to be in Org mode format and will be
8508 processed normally.  The include line will also allow additional keyword
8509 parameters @code{:prefix1} and @code{:prefix} to specify prefixes for the
8510 first line and for each following line, as well as any options accepted by
8511 the selected markup.  For example, to include a file as an item, use
8513 @example
8514 #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
8515 @end example
8517 @table @kbd
8518 @kindex C-c '
8519 @item C-c '
8520 Visit the include file at point.
8521 @end table
8524 @node Macro replacement, Embedded LaTeX, Include files, Markup
8525 @section Macro replacement
8526 @cindex macro replacement, during export
8527 @cindex #+MACRO
8529 You can define text snippets with
8531 @example
8532 #+MACRO: name   replacement text $1, $2 are arguments
8533 @end example
8535 @noindent which can be referenced anywhere in the document (even in
8536 code examples) with @code{@{@{@{name(arg1,arg2)@}@}@}}.  In addition to
8537 defined macros, @code{@{@{@{title@}@}@}}, @code{@{@{@{author@}@}@}}, etc.,
8538 will reference information set by the @code{#+TITLE:}, @code{#+AUTHOR:}, and
8539 similar lines.  Also, @code{@{@{@{date(@var{FORMAT})@}@}@}} and
8540 @code{@{@{@{modification-time(@var{FORMAT})@}@}@}} refer to current date time
8541 and to the modification time of the file being exported, respectively.
8542 @var{FORMAT} should be a format string understood by
8543 @code{format-time-string}.
8545 Macro expansion takes place during export, and some people use it to
8546 construct complex HTML code.
8549 @node Embedded LaTeX,  , Macro replacement, Markup
8550 @section Embedded La@TeX{}
8551 @cindex @TeX{} interpretation
8552 @cindex La@TeX{} interpretation
8554 Plain ASCII is normally sufficient for almost all note taking.  One
8555 exception, however, are scientific notes which need to be able to contain
8556 mathematical symbols and the occasional formula.  La@TeX{}@footnote{La@TeX{}
8557 is a macro system based on Donald E. Knuth's @TeX{} system.  Many of the
8558 features described here as ``La@TeX{}'' are really from @TeX{}, but for
8559 simplicity I am blurring this distinction.}  is widely used to typeset
8560 scientific documents. Org mode supports embedding La@TeX{} code into its
8561 files, because many academics are used to reading La@TeX{} source code, and
8562 because it can be readily processed into images for HTML production.
8564 It is not necessary to mark La@TeX{} macros and code in any special way.
8565 If you observe a few conventions, Org mode knows how to find it and what
8566 to do with it.
8568 @menu
8569 * Special symbols::             Greek letters and other symbols
8570 * Subscripts and superscripts::  Simple syntax for raising/lowering text
8571 * LaTeX fragments::             Complex formulas made easy
8572 * Previewing LaTeX fragments::  What will this snippet look like?
8573 * CDLaTeX mode::                Speed up entering of formulas
8574 @end menu
8576 @node Special symbols, Subscripts and superscripts, Embedded LaTeX, Embedded LaTeX
8577 @subsection Special symbols
8578 @cindex math symbols
8579 @cindex special symbols
8580 @cindex @TeX{} macros
8581 @cindex La@TeX{} fragments, markup rules
8582 @cindex HTML entities
8583 @cindex La@TeX{} entities
8585 You can use La@TeX{} macros to insert special symbols like @samp{\alpha} to
8586 indicate the Greek letter, or @samp{\to} to indicate an arrow.  Completion
8587 for these macros is available, just type @samp{\} and maybe a few letters,
8588 and press @kbd{M-@key{TAB}} to see possible completions.  Unlike La@TeX{}
8589 code, Org mode allows these macros to be present without surrounding math
8590 delimiters, for example:
8592 @example
8593 Angles are written as Greek letters \alpha, \beta and \gamma.
8594 @end example
8596 @vindex org-html-entities
8597 During export, these symbols will be transformed into the native format of
8598 the exporter backend.  Strings like @code{\alpha} will be exported as
8599 @code{&alpha;} in the HTML output, and as @code{$\alpha$} in the La@TeX{}
8600 output.  Similarly, @code{\nbsp} will become @code{&nbsp;} in HTML and
8601 @code{~} in La@TeX{}.  If you need such a symbol inside a word, terminate it
8602 like this: @samp{\Aacute@{@}stor}.
8604 A large number of entities is provided, with names taken from both HTML and
8605 La@TeX{}, see the variable @code{org-html-entities} for the complete list.
8606 @samp{\-} is treated as a shy hyphen, and @samp{--}, @samp{---}, and
8607 @samp{...} are all converted into special commands creating hyphens of
8608 different lengths or a compact set of dots.
8610 @node Subscripts and superscripts, LaTeX fragments, Special symbols, Embedded LaTeX
8611 @subsection Subscripts and superscripts
8612 @cindex subscript
8613 @cindex superscript
8615 Just like in La@TeX{}, @samp{^} and @samp{_} are used to indicate super-
8616 and subscripts.  Again, these can be used without embedding them in
8617 math-mode delimiters.  To increase the readability of ASCII text, it is
8618 not necessary (but OK) to surround multi-character sub- and superscripts
8619 with curly braces.  For example
8621 @example
8622 The mass if the sun is M_sun = 1.989 x 10^30 kg.  The radius of
8623 the sun is R_@{sun@} = 6.96 x 10^8 m.
8624 @end example
8626 @vindex org-export-with-sub-superscripts
8627 To avoid interpretation as raised or lowered text, you can quote @samp{^} and
8628 @samp{_} with a backslash: @samp{\^} and @samp{\_}.  If you write a text
8629 where the underscore is often used in a different context, Org's convention
8630 to always interpret these as subscripts can get in your way.  Configure the
8631 variable @code{org-export-with-sub-superscripts} to globally change this
8632 convention, or use, on a per-file basis:
8634 @example
8635 #+OPTIONS: ^:@{@}
8636 @end example
8639 @node LaTeX fragments, Previewing LaTeX fragments, Subscripts and superscripts, Embedded LaTeX
8640 @subsection La@TeX{} fragments
8641 @cindex La@TeX{} fragments
8643 @vindex org-format-latex-header
8644 With symbols, sub- and superscripts, HTML is pretty much at its end when
8645 it comes to representing mathematical formulas@footnote{Yes, there is
8646 MathML, but that is not yet fully supported by many browsers, and there
8647 is no decent converter for turning La@TeX{} or ASCII representations of
8648 formulas into MathML. So for the time being, converting formulas into
8649 images seems the way to go.}. More complex expressions need a dedicated
8650 formula processor. To this end, Org mode can contain arbitrary La@TeX{}
8651 fragments. It provides commands to preview the typeset result of these
8652 fragments, and upon export to HTML, all fragments will be converted to
8653 images and inlined into the HTML document@footnote{The La@TeX{} export
8654 will not use images for displaying La@TeX{} fragments but include these
8655 fragments directly into the La@TeX{} code.}. For this to work you
8656 need to be on a system with a working La@TeX{} installation. You also
8657 need the @file{dvipng} program, available at
8658 @url{http://sourceforge.net/projects/dvipng/}. The La@TeX{} header that
8659 will be used when processing a fragment can be configured with the
8660 variable @code{org-format-latex-header}.
8662 La@TeX{} fragments don't need any special marking at all.  The following
8663 snippets will be identified as La@TeX{} source code:
8664 @itemize @bullet
8665 @item
8666 Environments of any kind.  The only requirement is that the
8667 @code{\begin} statement appears on a new line, preceded by only
8668 whitespace.
8669 @item
8670 Text within the usual La@TeX{} math delimiters.  To avoid conflicts with
8671 currency specifications, single @samp{$} characters are only recognized as
8672 math delimiters if the enclosed text contains at most two line breaks, is
8673 directly attached to the @samp{$} characters with no whitespace in between,
8674 and if the closing @samp{$} is followed by whitespace, punctuation or a dash.
8675 For the other delimiters, there is no such restriction, so when in doubt, use
8676 @samp{\(...\)} as inline math delimiters.
8677 @end itemize
8679 @noindent For example:
8681 @example
8682 \begin@{equation@}                          % arbitrary environments,
8683 x=\sqrt@{b@}                                % even tables, figures
8684 \end@{equation@}                            % etc
8686 If $a^2=b$ and \( b=2 \), then the solution must be
8687 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
8688 @end example
8690 @noindent
8691 @vindex org-format-latex-options
8692 If you need any of the delimiter ASCII sequences for other purposes, you
8693 can configure the option @code{org-format-latex-options} to deselect the
8694 ones you do not wish to have interpreted by the La@TeX{} converter.
8696 @node Previewing LaTeX fragments, CDLaTeX mode, LaTeX fragments, Embedded LaTeX
8697 @subsection Previewing LaTeX fragments
8698 @cindex LaTeX fragments, preview
8700 La@TeX{} fragments can be processed to produce preview images of the
8701 typeset expressions:
8703 @table @kbd
8704 @kindex C-c C-x C-l
8705 @item C-c C-x C-l
8706 Produce a preview image of the La@TeX{} fragment at point and overlay it
8707 over the source code.  If there is no fragment at point, process all
8708 fragments in the current entry (between two headlines).  When called
8709 with a prefix argument, process the entire subtree.  When called with
8710 two prefix arguments, or when the cursor is before the first headline,
8711 process the entire buffer.
8712 @kindex C-c C-c
8713 @item C-c C-c
8714 Remove the overlay preview images.
8715 @end table
8717 @vindex org-format-latex-options
8718 You can customize the variable @code{org-format-latex-options} to influence
8719 some aspects of the preview. In particular, the @code{:scale} (and for HTML
8720 export, @code{:html-scale}) property can be used to adjust the size of the
8721 preview images.
8723 During HTML export (@pxref{HTML export}), all La@TeX{} fragments are
8724 converted into images and inlined into the document if the following
8725 setting is active:
8727 @lisp
8728 (setq org-export-with-LaTeX-fragments t)
8729 @end lisp
8731 @node CDLaTeX mode,  , Previewing LaTeX fragments, Embedded LaTeX
8732 @subsection Using CDLa@TeX{} to enter math
8733 @cindex CDLa@TeX{}
8735 CDLa@TeX{} mode is a minor mode that is normally used in combination with a
8736 major La@TeX{} mode like AUC@TeX{} in order to speed-up insertion of
8737 environments and math templates.  Inside Org mode, you can make use of
8738 some of the features of CDLa@TeX{} mode.  You need to install
8739 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
8740 AUC@TeX{}) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
8741 Don't use CDLa@TeX{} mode itself under Org mode, but use the light
8742 version @code{org-cdlatex-mode} that comes as part of Org mode.  Turn it
8743 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
8744 Org files with
8746 @lisp
8747 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
8748 @end lisp
8750 When this mode is enabled, the following features are present (for more
8751 details see the documentation of CDLa@TeX{} mode):
8752 @itemize @bullet
8753 @kindex C-c @{
8754 @item
8755 Environment templates can be inserted with @kbd{C-c @{}.
8756 @item
8757 @kindex @key{TAB}
8758 The @key{TAB} key will do template expansion if the cursor is inside a
8759 La@TeX{} fragment@footnote{Org mode has a method to test if the cursor is
8760 inside such a fragment, see the documentation of the function
8761 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
8762 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
8763 correctly inside the first brace.  Another @key{TAB} will get you into
8764 the second brace.  Even outside fragments, @key{TAB} will expand
8765 environment abbreviations at the beginning of a line.  For example, if
8766 you write @samp{equ} at the beginning of a line and press @key{TAB},
8767 this abbreviation will be expanded to an @code{equation} environment.
8768 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
8769 @item
8770 @kindex _
8771 @kindex ^
8772 @vindex cdlatex-simplify-sub-super-scripts
8773 Pressing @kbd{_} and @kbd{^} inside a La@TeX{} fragment will insert these
8774 characters together with a pair of braces.  If you use @key{TAB} to move
8775 out of the braces, and if the braces surround only a single character or
8776 macro, they are removed again (depending on the variable
8777 @code{cdlatex-simplify-sub-super-scripts}).
8778 @item
8779 @kindex `
8780 Pressing the backquote @kbd{`} followed by a character inserts math
8781 macros, also outside La@TeX{} fragments.  If you wait more than 1.5 seconds
8782 after the backquote, a help window will pop up.
8783 @item
8784 @kindex '
8785 Pressing the single-quote @kbd{'} followed by another character modifies
8786 the symbol before point with an accent or a font.  If you wait more than
8787 1.5 seconds after the backquote, a help window will pop up.  Character
8788 modification will work only inside La@TeX{} fragments, outside the quote
8789 is normal.
8790 @end itemize
8792 @node Exporting, Publishing, Markup, Top
8793 @chapter Exporting
8794 @cindex exporting
8796 Org-mode documents can be exported into a variety of other formats.  For
8797 printing and sharing of notes, ASCII export produces a readable and simple
8798 version of an Org file.  HTML export allows you to publish a notes file on
8799 the web, while the XOXO format provides a solid base for exchange with a
8800 broad range of other applications. La@TeX{} export lets you use Org mode and
8801 its structured editing functions to easily create La@TeX{} files.  DocBook
8802 export makes it possible to convert Org files to many other formats using
8803 DocBook tools.  To incorporate entries with associated times like deadlines
8804 or appointments into a desktop calendar program like iCal, Org mode can also
8805 produce extracts in the iCalendar format.  Currently Org mode only supports
8806 export, not import of these different formats.
8808 Org supports export of selected regions when @code{transient-mark-mode} is
8809 enabled (default in Emacs 23).
8811 @menu
8812 * Selective export::            Using tags to select and exclude trees
8813 * Export options::              Per-file export settings
8814 * The export dispatcher::       How to access exporter commands
8815 * ASCII export::                Exporting to plain ASCII
8816 * HTML export::                 Exporting to HTML
8817 * LaTeX and PDF export::        Exporting to La@TeX{}, and processing to PDF
8818 * DocBook export::              Exporting to DocBook
8819 * Freemind export::             Exporting to Freemind mind maps
8820 * XOXO export::                 Exporting to XOXO
8821 * iCalendar export::            Exporting in iCalendar format
8822 @end menu
8824 @node Selective export, Export options, Exporting, Exporting
8825 @section Selective export
8826 @cindex export, selective by tags
8828 @vindex org-export-select-tags
8829 @vindex org-export-exclude-tags
8830 You may use tags to select the parts of a document that should be exported,
8831 or to exclude parts from export.  This behavior is governed by two variables:
8832 @code{org-export-select-tags} and @code{org-export-exclude-tags}.
8834 Org first checks if any of the @emph{select} tags is present in the buffer.
8835 If yes, all trees that do not carry one of these tags will be excluded.  If a
8836 selected tree is a subtree, the heading hierarchy above it will also be
8837 selected for export, but not the text below those headings.
8839 @noindent
8840 If none of the select tags is found, the whole buffer will be selected for
8841 export.
8843 @noindent
8844 Finally, all subtrees that are marked by any of the @emph{exclude} tags will
8845 be removed from the export buffer.
8847 @node Export options, The export dispatcher, Selective export, Exporting
8848 @section Export options
8849 @cindex options, for export
8851 @cindex completion, of option keywords
8852 The exporter recognizes special lines in the buffer which provide
8853 additional information.  These lines may be put anywhere in the file.
8854 The whole set of lines can be inserted into the buffer with @kbd{C-c
8855 C-e t}.  For individual lines, a good way to make sure the keyword is
8856 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
8857 (@pxref{Completion}).   For a summary of other in-buffer settings not
8858 specifically related to export, see @ref{In-buffer settings}.
8859 In particular, note that you can place commonly-used (export) options in
8860 a separate file which can be included using @code{#+SETUPFILE}.
8862 @table @kbd
8863 @kindex C-c C-e t
8864 @item C-c C-e t
8865 Insert template with export options, see example below.
8866 @end table
8868 @cindex #+TITLE
8869 @cindex #+AUTHOR
8870 @cindex #+DATE
8871 @cindex #+EMAIL
8872 @cindex #+DESCRIPTION
8873 @cindex #+KEYWORDS
8874 @cindex #+LANGUAGE
8875 @cindex #+TEXT
8876 @cindex #+OPTIONS
8877 @cindex #+BIND
8878 @cindex #+LINK_UP
8879 @cindex #+LINK_HOME
8880 @cindex #+EXPORT_SELECT_TAGS
8881 @cindex #+EXPORT_EXCLUDE_TAGS
8882 @cindex #+LATEX_HEADER
8883 @vindex user-full-name
8884 @vindex user-mail-address
8885 @vindex org-export-default-language
8886 @example
8887 #+TITLE:       the title to be shown (default is the buffer name)
8888 #+AUTHOR:      the author (default taken from @code{user-full-name})
8889 #+DATE:        a date, fixed, of a format string for @code{format-time-string}
8890 #+EMAIL:       his/her email address (default from @code{user-mail-address})
8891 #+DESCRIPTION: the page description, e.g. for the XHTML meta tag
8892 #+KEYWORDS:    the page keywords, e.g. for the XHTML meta tag
8893 #+LANGUAGE:    language for HTML, e.g. @samp{en} (@code{org-export-default-language})
8894 #+TEXT:        Some descriptive text to be inserted at the beginning.
8895 #+TEXT:        Several lines may be given.
8896 #+OPTIONS:     H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
8897 #+BIND:        lisp-var lisp-val, e.g.: org-export-latex-low-levels itemize
8898                @r{You need to confirm using these, or configure @code{org-export-allow-BIND}}
8899 #+LINK_UP:     the ``up'' link of an exported page
8900 #+LINK_HOME:   the ``home'' link of an exported page
8901 #+LATEX_HEADER: extra line(s) for the LaTeX header, like \usepackage@{xyz@}
8902 #+EXPORT_SELECT_TAGS:   Tags that select a tree for export
8903 #+EXPORT_EXCLUDE_TAGS:  Tags that exclude a tree from export
8904 @end example
8906 @noindent
8907 The OPTIONS line is a compact@footnote{If you want to configure many options
8908 this way, you can use several OPTIONS lines.} form to specify export settings.  Here
8909 you can:
8910 @cindex headline levels
8911 @cindex section-numbers
8912 @cindex table of contents
8913 @cindex line-break preservation
8914 @cindex quoted HTML tags
8915 @cindex fixed-width sections
8916 @cindex tables
8917 @cindex @TeX{}-like syntax for sub- and superscripts
8918 @cindex footnotes
8919 @cindex special strings
8920 @cindex emphasized text
8921 @cindex @TeX{} macros
8922 @cindex La@TeX{} fragments
8923 @cindex author info, in export
8924 @cindex time info, in export
8925 @example
8926 H:         @r{set the number of headline levels for export}
8927 num:       @r{turn on/off section-numbers}
8928 toc:       @r{turn on/off table of contents, or set level limit (integer)}
8929 \n:        @r{turn on/off line-break-preservation (DOES NOT WORK)}
8930 @@:         @r{turn on/off quoted HTML tags}
8931 ::         @r{turn on/off fixed-width sections}
8932 |:         @r{turn on/off tables}
8933 ^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
8934            @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
8935            @r{the simple @code{a_b} will be left as it is.}
8936 -:         @r{turn on/off conversion of special strings.}
8937 f:         @r{turn on/off footnotes like this[1].}
8938 todo:      @r{turn on/off inclusion of TODO keywords into exported text}
8939 pri:       @r{turn on/off priority cookies}
8940 tags:      @r{turn on/off inclusion of tags, may also be @code{not-in-toc}}
8941 <:         @r{turn on/off inclusion of any time/date stamps like DEADLINES}
8942 *:         @r{turn on/off emphasized text (bold, italic, underlined)}
8943 TeX:       @r{turn on/off simple @TeX{} macros in plain text}
8944 LaTeX:     @r{turn on/off La@TeX{} fragments}
8945 skip:      @r{turn on/off skipping the text before the first heading}
8946 author:    @r{turn on/off inclusion of author name/email into exported file}
8947 creator:   @r{turn on/off inclusion of creator info into exported file}
8948 timestamp: @r{turn on/off inclusion creation time into exported file}
8949 d:         @r{turn on/off inclusion of drawers}
8950 @end example
8951 @noindent
8952 These options take effect in both the HTML and La@TeX{} export, except
8953 for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
8954 @code{nil} for the La@TeX{} export.
8956 When exporting only a single subtree by selecting it with @kbd{C-c @@} before
8957 calling an export command, the subtree can overrule some of the file's export
8958 settings with properties @code{EXPORT_FILE_NAME}, @code{EXPORT_TITLE},
8959 @code{EXPORT_TEXT}, @code{EXPORT_AUTHOR}, @code{EXPORT_DATE}, and
8960 @code{EXPORT_OPTIONS}.
8962 @node The export dispatcher, ASCII export, Export options, Exporting
8963 @section The export dispatcher
8964 @cindex dispatcher, for export commands
8966 All export commands can be reached using the export dispatcher, which is a
8967 prefix key that prompts for an additional key specifying the command.
8968 Normally the entire file is exported, but if there is an active region that
8969 contains one outline tree, the first heading is used as document title and
8970 the subtrees are exported.
8972 @table @kbd
8973 @kindex C-c C-e
8974 @item C-c C-e
8975 @vindex org-export-run-in-background
8976 Dispatcher for export and publishing commands.  Displays a help-window
8977 listing the additional key(s) needed to launch an export or publishing
8978 command.  The prefix arg is passed through to the exporter.  A double prefix
8979 @kbd{C-u C-u} causes most commands to be executed in the background, in a
8980 separate Emacs process@footnote{To make this behavior the default, customize
8981 the variable @code{org-export-run-in-background}.}.
8982 @kindex C-c C-e v
8983 @item C-c C-e v
8984 Like @kbd{C-c C-e}, but only export the text that is currently visible
8985 (i.e. not hidden by outline visibility).
8986 @kindex C-u C-u C-c C-e
8987 @item C-u C-u C-c C-e
8988 @vindex org-export-run-in-background
8989 Call an the exporter, but reverse the setting of
8990 @code{org-export-run-in-background}, i.e. request background processing if
8991 not set, or force processing in the current Emacs process if set.
8992 @end table
8994 @node ASCII export, HTML export, The export dispatcher, Exporting
8995 @section ASCII export
8996 @cindex ASCII export
8998 ASCII export produces a simple and very readable version of an Org-mode
8999 file.
9001 @cindex region, active
9002 @cindex active region
9003 @cindex transient-mark-mode
9004 @table @kbd
9005 @kindex C-c C-e a
9006 @item C-c C-e a
9007 @cindex property, EXPORT_FILE_NAME
9008 Export as ASCII file.  For an Org file, @file{myfile.org}, the ASCII file
9009 will be @file{myfile.txt}.  The file will be overwritten without
9010 warning.  If there is an active region@footnote{This requires
9011 @code{transient-mark-mode} be turned on.}, only the region will be
9012 exported. If the selected region is a single tree@footnote{To select the
9013 current subtree, use @kbd{C-c @@}.}, the tree head will
9014 become the document title.  If the tree head entry has or inherits an
9015 @code{EXPORT_FILE_NAME} property, that name will be used for the
9016 export.
9017 @kindex C-c C-e A
9018 @item C-c C-e A
9019 Export to a temporary buffer, do not create a file.
9020 @kindex C-c C-e v a
9021 @item C-c C-e v a
9022 Export only the visible part of the document.
9023 @end table
9025 @cindex headline levels, for exporting
9026 In the exported version, the first 3 outline levels will become
9027 headlines, defining a general document structure.  Additional levels
9028 will be exported as itemized lists.  If you want that transition to occur
9029 at a different level, specify it with a prefix argument.  For example,
9031 @example
9032 @kbd{C-1 C-c C-e a}
9033 @end example
9035 @noindent
9036 creates only top level headlines and does the rest as items.  When
9037 headlines are converted to items, the indentation of the text following
9038 the headline is changed to fit nicely under the item.  This is done with
9039 the assumption that the first body line indicates the base indentation of
9040 the body text.  Any indentation larger than this is adjusted to preserve
9041 the layout relative to the first line.  Should there be lines with less
9042 indentation than the first, these are left alone.
9044 @vindex org-export-ascii-links-to-notes
9045 Links will be exported in a footnote-like style, with the descriptive part in
9046 the text and the link in a note before the next heading.  See the variable
9047 @code{org-export-ascii-links-to-notes} for details and other options.
9049 @node HTML export, LaTeX and PDF export, ASCII export, Exporting
9050 @section HTML export
9051 @cindex HTML export
9053 Org mode contains an HTML (XHTML 1.0 strict) exporter with extensive
9054 HTML formatting, in ways similar to John Gruber's @emph{markdown}
9055 language, but with additional support for tables.
9057 @menu
9058 * HTML Export commands::        How to invoke HTML export
9059 * Quoting HTML tags::           Using direct HTML in Org mode
9060 * Links in HTML export::        How links will be interpreted and formatted
9061 * Tables in HTML export::       How to modify the formatting of tables
9062 * Images in HTML export::       How to insert figures into HTML output
9063 * Text areas in HTML export::   An alternative way to show an example
9064 * CSS support::                 Changing the appearance of the output
9065 * Javascript support::          Info and Folding in a web browser
9066 @end menu
9068 @node HTML Export commands, Quoting HTML tags, HTML export, HTML export
9069 @subsection HTML export commands
9071 @cindex region, active
9072 @cindex active region
9073 @cindex transient-mark-mode
9074 @table @kbd
9075 @kindex C-c C-e h
9076 @item C-c C-e h
9077 @cindex property, EXPORT_FILE_NAME
9078 Export as HTML file @file{myfile.html}.  For an Org file @file{myfile.org},
9079 the ASCII file will be @file{myfile.html}.  The file will be overwritten
9080 without warning.  If there is an active region@footnote{This requires
9081 @code{transient-mark-mode} be turned on.}, only the region will be
9082 exported. If the selected region is a single tree@footnote{To select the
9083 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
9084 title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
9085 property, that name will be used for the export.
9086 @kindex C-c C-e b
9087 @item C-c C-e b
9088 Export as HTML file and immediately open it with a browser.
9089 @kindex C-c C-e H
9090 @item C-c C-e H
9091 Export to a temporary buffer, do not create a file.
9092 @kindex C-c C-e R
9093 @item C-c C-e R
9094 Export the active region to a temporary buffer.  With a prefix argument, do
9095 not produce the file header and footer, but just the plain HTML section for
9096 the region.  This is good for cut-and-paste operations.
9097 @kindex C-c C-e v h
9098 @kindex C-c C-e v b
9099 @kindex C-c C-e v H
9100 @kindex C-c C-e v R
9101 @item C-c C-e v h
9102 @item C-c C-e v b
9103 @item C-c C-e v H
9104 @item C-c C-e v R
9105 Export only the visible part of the document.
9106 @item M-x org-export-region-as-html
9107 Convert the region to HTML under the assumption that it was Org-mode
9108 syntax before.  This is a global command that can be invoked in any
9109 buffer.
9110 @item M-x org-replace-region-by-HTML
9111 Replace the active region (assumed to be in Org-mode syntax) by HTML
9112 code.
9113 @end table
9115 @cindex headline levels, for exporting
9116 In the exported version, the first 3 outline levels will become headlines,
9117 defining a general document structure.  Additional levels will be exported as
9118 itemized lists.  If you want that transition to occur at a different level,
9119 specify it with a numeric prefix argument.  For example,
9121 @example
9122 @kbd{C-2 C-c C-e b}
9123 @end example
9125 @noindent
9126 creates two levels of headings and does the rest as items.
9128 @node Quoting HTML tags, Links in HTML export, HTML Export commands, HTML export
9129 @subsection Quoting HTML tags
9131 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
9132 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
9133 which should be interpreted as such, mark them with @samp{@@} as in
9134 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
9135 simple tags.  For more extensive HTML that should be copied verbatim to
9136 the exported file use either
9138 @cindex #+HTML
9139 @cindex #+BEGIN_HTML
9140 @example
9141 #+HTML: Literal HTML code for export
9142 @end example
9144 @noindent or
9145 @cindex #+BEGIN_HTML
9147 @example
9148 #+BEGIN_HTML
9149 All lines between these markers are exported literally
9150 #+END_HTML
9151 @end example
9154 @node Links in HTML export, Tables in HTML export, Quoting HTML tags, HTML export
9155 @subsection Links in HTML export
9157 @cindex links, in HTML export
9158 @cindex internal links, in HTML export
9159 @cindex external links, in HTML export
9160 Internal links (@pxref{Internal links}) will continue to work in HTML.  This
9161 includes automatic links created by radio targets (@pxref{Radio
9162 targets}).  Links to external files will still work if the target file is on
9163 the same @i{relative} path as the published Org file.  Links to other
9164 @file{.org} files will be translated into HTML links under the assumption
9165 that an HTML version also exists of the linked file, at the same relative
9166 path.  @samp{id:} links can then be used to jump to specific entries across
9167 files.  For information related to linking files while publishing them to a
9168 publishing directory see @ref{Publishing links}.
9170 If you want to specify attributes for links, you can do so using a special
9171 @code{#+ATTR_HTML} line to define attributes that will be added to the
9172 @code{<a>} or @code{<img>} tags.  Here is an example that sets @code{title}
9173 and @code{style} attributes for a link:
9175 @cindex #+ATTR_HTML
9176 @example
9177 #+ATTR_HTML: title="The Org-mode homepage" style="color:red;"
9178 [[http://orgmode.org]]
9179 @end example
9181 @node Tables in HTML export, Images in HTML export, Links in HTML export, HTML export
9182 @subsection Tables
9183 @cindex tables, in HTML
9184 @vindex org-export-html-table-tag
9186 Org-mode tables are exported to HTML using the table tag defined in
9187 @code{org-export-html-table-tag}.  The default setting makes tables without
9188 cell borders and frame.  If you would like to change this for individual
9189 tables, place somthing like the following before the table:
9191 @cindex #+CAPTION
9192 @cindex #+ATTR_HTML
9193 @example
9194 #+CAPTION: This is a table with lines around and between cells
9195 #+ATTR_HTML: border="2" rules="all" frame="all"
9196 @end example
9198 @node Images in HTML export, Text areas in HTML export, Tables in HTML export, HTML export
9199 @subsection Images in HTML export
9201 @cindex images, inline in HTML
9202 @cindex inlining images in HTML
9203 @vindex org-export-html-inline-images
9204 HTML export can inline images given as links in the Org file, and
9205 it can make an image the clickable part of a link.  By
9206 default@footnote{But see the variable
9207 @code{org-export-html-inline-images}.}, images are inlined if a link does
9208 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
9209 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
9210 @samp{the image} that points to the image.  If the description part
9211 itself is a @code{file:} link or a @code{http:} URL pointing to an
9212 image, this image will be inlined and activated so that clicking on the
9213 image will activate the link.  For example, to include a thumbnail that
9214 will link to a high resolution version of the image, you could use:
9216 @example
9217 [[file:highres.jpg][file:thumb.jpg]]
9218 @end example
9220 If you need to add attributes to an inlines image, use a @code{#+ATTR_HTML}.
9221 In the example below we specify the @code{alt} and @code{title} attributes to
9222 support text viewers and accessibility, and align it to the right.
9224 @cindex #+CAPTION
9225 @cindex #+ATTR_HTML
9226 @example
9227 #+CAPTION: A black cat stalking a spider
9228 #+ATTR_HTML: alt="cat/spider image" title="Action!" align="right"
9229 [[./img/a.jpg]]
9230 @end example
9232 @noindent
9233 and you could use @code{http} addresses just as well.
9235 @node Text areas in HTML export, CSS support, Images in HTML export, HTML export
9236 @subsection Text areas in HTML export
9238 @cindex text areas, in HTML
9239 An alternative way to publish literal code examples in HTML is to use text
9240 areas, where the example can even be edited before pasting it into an
9241 application.  It is triggered by a @code{-t} switch at an @code{example} or
9242 @code{src} block.  Using this switch disables any options for syntax and
9243 label highlighting, and line numbering, which may be present.  You may also
9244 use @code{-h} and @code{-w} switches to specify the height and width of the
9245 text area, which default to the number of lines in the example, and 80,
9246 respectively.  For example
9248 @example
9249 #+BEGIN_EXAMPLE -t -w 40
9250 (defun org-xor (a b)
9251    "Exclusive or."
9252    (if a (not b) b))
9253 #+END_EXAMPLE
9254 @end example
9257 @node CSS support, Javascript support, Text areas in HTML export, HTML export
9258 @subsection CSS support
9259 @cindex CSS, for HTML export
9260 @cindex HTML export, CSS
9262 @vindex org-export-html-todo-kwd-class-prefix
9263 @vindex org-export-html-tag-class-prefix
9264 You can also give style information for the exported file.  The HTML exporter
9265 assigns the following special CSS classes@footnote{If the classes on TODO
9266 keywords and tags lead to conflicts, use the variables
9267 @code{org-export-html-todo-kwd-class-prefix} and
9268 @code{org-export-html-tag-class-prefix} to make them unique.} to appropriate
9269 parts of the document---your style specifications may change these, in
9270 addition to any of the standard classes like for headlines, tables, etc.
9271 @example
9272 p.author            @r{author information, including email}
9273 p.date              @r{publishing date}
9274 p.creator           @r{creator info, about org-mode version}
9275 .title              @r{document title}
9276 .todo               @r{TODO keywords, all not-done states}
9277 .done               @r{the DONE keywords, all stated the count as done}
9278 .WAITING            @r{each TODO keyword also uses a class named after itself}
9279 .timestamp          @r{timestamp}
9280 .timestamp-kwd      @r{keyword associated with a timestamp, like SCHEDULED}
9281 .timestamp-wrapper  @r{span around keyword plus timestamp}
9282 .tag                @r{tag in a headline}
9283 ._HOME              @r{each tag uses itself as a class, "@@" replaced by "_"}
9284 .target             @r{target for links}
9285 .linenr             @r{the line number in a code example}
9286 .code-highlighted   @r{for highlighting referenced code lines}
9287 div.outline-N       @r{div for outline level N (headline plus text))}
9288 div.outline-text-N  @r{extra div for text at outline level N}
9289 .section-number-N   @r{section number in headlines, different for each level}
9290 div.figure          @r{how to format an inlined image}
9291 pre.src             @r{formatted source code}
9292 pre.example         @r{normal example}
9293 p.verse             @r{verse paragraph}
9294 div.footnotes       @r{footnote section headline}
9295 p.footnote          @r{footnote definition paragraph, containing a footnote}
9296 .footref            @r{a footnote reference number (always a <sup>)}
9297 .footnum            @r{footnote number in footnote definition (always <sup>)}
9298 @end example
9300 @vindex org-export-html-style-default
9301 @vindex org-export-html-style-include-default
9302 @vindex org-export-html-style
9303 @vindex org-export-html-extra
9304 @vindex org-export-html-style-default
9305 Each exported file contains a compact default style that defines these
9306 classes in a basic way@footnote{This style is defined in the constant
9307 @code{org-export-html-style-default}, which you should not modify.  To turn
9308 inclusion of these defaults off, customize
9309 @code{org-export-html-style-include-default}}.  You may overwrite these
9310 settings, or add to them by using the variables @code{org-export-html-style}
9311 (for Org-wide settings) and @code{org-export-html-style-extra} (for more
9312 granular settings, like file-local settings).  To set the latter variable
9313 individually for each file, you can use
9315 @cindex #+STYLE
9316 @example
9317 #+STYLE: <link rel="stylesheet" type="text/css" href="stylesheet.css" />
9318 @end example
9320 @noindent
9321 For longer style definitions, you can use several such lines.  You could also
9322 directly write a @code{<style>} @code{</style>} section in this way, without
9323 referring to an external file.
9325 @c FIXME: More about header and footer styles
9326 @c FIXME: Talk about links and targets.
9328 @node Javascript support,  , CSS support, HTML export
9329 @subsection Javascript supported display of web pages
9331 @cindex Rose, Sebastian
9332 Sebastian Rose has written a JavaScript program especially designed to
9333 enhance the web viewing experience of HTML files created with Org.  This
9334 program allows you to view large files in two different ways.  The first one
9335 is an @emph{Info}-like mode where each section is displayed separately and
9336 navigation can be done with the @kbd{n} and @kbd{p} keys (and some other keys
9337 as well, press @kbd{?} for an overview of the available keys).  The second
9338 view type is a @emph{folding} view much like Org provides inside Emacs.  The
9339 script is available at @url{http://orgmode.org/org-info.js} and you can find
9340 the documentation for it at @url{http://orgmode.org/worg/code/org-info-js/}.
9341 We host the script at our site, but if you use it a lot, you might
9342 not want to be dependent on @url{orgmode.org} and prefer to install a local
9343 copy on your own web server.
9345 To use the script, you need to make sure that the @file{org-jsinfo.el} module
9346 gets loaded.  It should be loaded by default, but you can try @kbd{M-x
9347 customize-variable @key{RET} org-modules @key{RET}} to convince yourself that
9348 this is indeed the case.  All it then takes to make use of the program is
9349 adding a single line to the Org file:
9351 @cindex #+INFOJS_OPT
9352 @example
9353 #+INFOJS_OPT: view:info toc:nil
9354 @end example
9356 @noindent
9357 If this line is found, the HTML header will automatically contain the code
9358 needed to invoke the script.  Using the line above, you can set the following
9359 viewing options:
9361 @example
9362 path:    @r{The path to the script.  The default is to grab the script from}
9363          @r{@url{http://orgmode.org/org-info.js}, but you might want to have}
9364          @r{a local copy and use a path like @samp{../scripts/org-info.js}.}
9365 view:    @r{Initial view when website is first shown.  Possible values are:}
9366          info      @r{Info-like interface with one section per page.}
9367          overview  @r{Folding interface, initially showing only top-level.}
9368          content   @r{Folding interface, starting with all headlines visible.}
9369          showall   @r{Folding interface, all headlines and text visible.}
9370 sdepth:  @r{Maximum headline level that will still become an independent}
9371          @r{section for info and folding modes.  The default is taken from}
9372          @r{@code{org-export-headline-levels} (= the @code{H} switch in @code{#+OPTIONS}).}
9373          @r{If this is smaller than in @code{org-export-headline-levels}, each}
9374          @r{info/folding section can still contain child headlines.}
9375 toc:     @r{Should the table of content @emph{initially} be visible?}
9376          @r{Even when @code{nil}, you can always get to the "toc" with @kbd{i}.}
9377 tdepth:  @r{The depth of the table of contents.  The defaults are taken from}
9378          @r{the variables @code{org-export-headline-levels} and @code{org-export-with-toc}.}
9379 ftoc:    @r{Does the css of the page specify a fixed position for the "toc"?}
9380          @r{If yes, the toc will never be displayed as a section.}
9381 ltoc:    @r{Should there be short contents (children) in each section?}
9382          @r{Make this @code{above} if the section should be above initial text.}
9383 mouse:   @r{Headings are highlighted when the mouse is over them.  Should be}
9384          @r{@samp{underline} (default) or a background color like @samp{#cccccc}.}
9385 buttons: @r{Should view-toggle buttons be everywhere?  When @code{nil} (the}
9386          @r{default), only one such button will be present.}
9387 @end example
9388 @noindent
9389 @vindex org-infojs-options
9390 @vindex org-export-html-use-infojs
9391 You can choose default values for these options by customizing the variable
9392 @code{org-infojs-options}.  If you always want to apply the script to your
9393 pages, configure the variable @code{org-export-html-use-infojs}.
9395 @node LaTeX and PDF export, DocBook export, HTML export, Exporting
9396 @section La@TeX{} and PDF export
9397 @cindex La@TeX{} export
9398 @cindex PDF export
9399 @cindex Guerry, Bastien
9401 Org mode contains a La@TeX{} exporter written by Bastien Guerry.  With
9402 further processing, this backend is also used to produce PDF output.  Since
9403 the La@TeX{} output uses @file{hyperref} to implement links and cross
9404 references, the PDF output file will be fully linked.
9406 @menu
9407 * LaTeX/PDF export commands::   Which key invokes which commands
9408 * Quoting LaTeX code::          Incorporating literal La@TeX{} code
9409 * Sectioning structure::        Changing sectioning in La@TeX{} output
9410 * Tables in LaTeX export::      Options for exporting tables to La@TeX{}
9411 * Images in LaTeX export::      How to insert figures into La@TeX{} output
9412 @end menu
9414 @node LaTeX/PDF export commands, Quoting LaTeX code, LaTeX and PDF export, LaTeX and PDF export
9415 @subsection La@TeX{} export commands
9417 @cindex region, active
9418 @cindex active region
9419 @cindex transient-mark-mode
9420 @table @kbd
9421 @kindex C-c C-e l
9422 @item C-c C-e l
9423 @cindex property EXPORT_FILE_NAME
9424 Export as La@TeX{} file @file{myfile.tex}.  For an Org file
9425 @file{myfile.org}, the ASCII file will be @file{myfile.tex}.  The file will
9426 be overwritten without warning.  If there is an active region@footnote{This
9427 requires @code{transient-mark-mode} be turned on.}, only the region will be
9428 exported. If the selected region is a single tree@footnote{To select the
9429 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
9430 title.  If the tree head entry has or inherits an @code{EXPORT_FILE_NAME}
9431 property, that name will be used for the export.
9432 @kindex C-c C-e L
9433 @item C-c C-e L
9434 Export to a temporary buffer, do not create a file.
9435 @kindex C-c C-e v l
9436 @kindex C-c C-e v L
9437 @item C-c C-e v l
9438 @item C-c C-e v L
9439 Export only the visible part of the document.
9440 @item M-x org-export-region-as-latex
9441 Convert the region to La@TeX{} under the assumption that it was Org mode
9442 syntax before.  This is a global command that can be invoked in any
9443 buffer.
9444 @item M-x org-replace-region-by-latex
9445 Replace the active region (assumed to be in Org mode syntax) by La@TeX{}
9446 code.
9447 @kindex C-c C-e p
9448 @item C-c C-e p
9449 Export as La@TeX{} and then process to PDF.
9450 @kindex C-c C-e d
9451 @item C-c C-e d
9452 Export as La@TeX{} and then process to PDF, then open the resulting PDF file.
9453 @end table
9455 @cindex headline levels, for exporting
9456 @vindex org-latex-low-levels
9457 In the exported version, the first 3 outline levels will become
9458 headlines, defining a general document structure.  Additional levels
9459 will be exported as description lists.  The exporter can ignore them or
9460 convert them to a custom string depending on
9461 @code{org-latex-low-levels}.
9463 If you want that transition to occur at a different level, specify it
9464 with a numeric prefix argument. For example,
9466 @example
9467 @kbd{C-2 C-c C-e l}
9468 @end example
9470 @noindent
9471 creates two levels of headings and does the rest as items.
9473 @node Quoting LaTeX code, Sectioning structure, LaTeX/PDF export commands, LaTeX and PDF export
9474 @subsection Quoting La@TeX{} code
9476 Embedded La@TeX{} as described in @ref{Embedded LaTeX}, will be correctly
9477 inserted into the La@TeX{} file.  This includes simple macros like
9478 @samp{\ref@{LABEL@}} to create a cross reference to a figure.  Furthermore,
9479 you can add special code that should only be present in La@TeX{} export with
9480 the following constructs:
9482 @cindex #+LaTeX
9483 @cindex #+BEGIN_LaTeX
9484 @example
9485 #+LaTeX: Literal LaTeX code for export
9486 @end example
9488 @noindent or
9489 @cindex #+BEGIN_LaTeX
9491 @example
9492 #+BEGIN_LaTeX
9493 All lines between these markers are exported literally
9494 #+END_LaTeX
9495 @end example
9497 @node  Sectioning structure, Tables in LaTeX export, Quoting LaTeX code, LaTeX and PDF export
9498 @subsection Sectioning structure
9499 @cindex La@TeX{} class
9500 @cindex La@TeX{} sectioning structure
9502 By default, the La@TeX{} output uses the class @code{article}.
9504 @vindex org-export-latex-default-class
9505 @vindex org-export-latex-classes
9506 @cindex #+LATEX_HEADER
9507 @cindex #+LATEX_CLASS
9508 @cindex #+LATEX_CLASS_OPTIONS
9509 @cindex property, LATEX_CLASS
9510 @cindex property, LATEX_CLASS_OPTIONS
9511 You can change this globally by setting a different value for
9512 @code{org-export-latex-default-class} or locally by adding an option like
9513 @code{#+LaTeX_CLASS: myclass} in your file, or with a @code{:LaTeX_CLASS:}
9514 property that applies when exporting a region containing only this (sub)tree.
9515 The class should be listed in @code{org-export-latex-classes}, where you can
9516 also define the sectioning structure for each class, as well as defining
9517 additional classes.  In a similar way, @code{#+LaTeX_CLASS_OPTIONS} or a
9518 @code{LaTeX_CLASS_OPTIONS} property can specify the options for the
9519 @code{\documentclass} macro.  You can also use @code{#+LATEX_HEADER:
9520 \usepackage@{xyz@}} to add lines to the header.
9522 @node Tables in LaTeX export, Images in LaTeX export, Sectioning structure, LaTeX and PDF export
9523 @subsection Tables in La@TeX{} export
9524 @cindex tables, in La@TeX{} export
9526 For La@TeX{} export of a table, you can specify a label and a caption
9527 (@pxref{Images and tables}).  You can also use the @code{ATTR_LaTeX} line to
9528 request a longtable environment for the table, so that it may span several
9529 pages.  Finally, you can set the alignment string:
9531 @cindex #+CAPTION
9532 @cindex #+LABEL
9533 @cindex #+ATTR_LaTeX
9534 @example
9535 #+CAPTION: A long table
9536 #+LABEL: tbl:long
9537 #+ATTR_LaTeX: longtable align=l|lp@{3cm@}r|l
9538 | ..... | ..... |
9539 | ..... | ..... |
9540 @end example
9543 @node Images in LaTeX export,  , Tables in LaTeX export, LaTeX and PDF export
9544 @subsection Images in La@TeX{} export
9545 @cindex images, inline in La@TeX{}
9546 @cindex inlining images in La@TeX{}
9548 Images that are linked to without a description part in the link, like
9549 @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]} will be inserted into the PDF
9550 output file resulting from La@TeX{} processing.  Org will use an
9551 @code{\includegraphics} macro to insert the image.  If you have specified a
9552 caption and/or a label as described in @ref{Images and tables}, the figure
9553 will be wrapped into a @code{figure} environment and thus become a floating
9554 element.  You can use an @code{#+ATTR_LaTeX:} line to specify the various
9555 options that can be used in the optional argument of the
9556 @code{\includegraphics} macro.  To modify the placement option of the
9557 @code{figure} environment, add something like @samp{placement=[h!]} to the
9558 Attributes.
9560 If you'd like to let text flow around the image, add the word @samp{wrap} to
9561 the @code{#+ATTR_LaTeX:} line, which will make the figure occupy the left
9562 half of the page.  To fine-tune, the @code{placement} field will be the
9563 set of additional arguments needed by the @code{wrapfigure} environment.
9564 Note that if you change the size of the image, you need to use compatible
9565 settings for @code{\includegraphics} and @code{wrapfigure}.
9567 @cindex #+CAPTION
9568 @cindex #+LABEL
9569 @cindex #+ATTR_LaTeX
9570 @example
9571 #+CAPTION:    The black-body emission of the disk around HR 4049
9572 #+LABEL:      fig:SED-HR4049
9573 #+ATTR_LaTeX: width=5cm,angle=90
9574 [[./img/sed-hr4049.pdf]]
9576 #+ATTR_LaTeX: width=0.38\textwidth wrap placement=@{r@}@{0.4\textwidth@}
9577 [[./img/hst.png]]
9578 @end example
9580 If you need references to a label created in this way, write
9581 @samp{\ref@{fig:SED-HR4049@}} just like in La@TeX{}.
9583 @node DocBook export, Freemind export, LaTeX and PDF export, Exporting
9584 @section DocBook export
9585 @cindex DocBook export
9586 @cindex PDF export
9587 @cindex Cui, Baoqui
9589 Org contains a DocBook exporter written by Baoqiu Cui.  Once an Org file is
9590 exported to DocBook format, it can be further processed to produce other
9591 formats, including PDF, HTML, man pages, etc., using many available DocBook
9592 tools and stylesheets.
9594 Currently DocBook exporter only supports DocBook V5.0.
9596 @menu
9597 * DocBook export commands::     How to invoke DocBook export
9598 * Quoting DocBook code::        Incorporating DocBook code in Org files
9599 * Recursive sections::          Recursive sections in DocBook
9600 * Tables in DocBook export::    Tables are exported as HTML tables
9601 * Images in DocBook export::    How to insert figures into DocBook output
9602 * Special characters::          How to handle special characters
9603 @end menu
9605 @node DocBook export commands, Quoting DocBook code, DocBook export, DocBook export
9606 @subsection DocBook export commands
9608 @cindex region, active
9609 @cindex active region
9610 @cindex transient-mark-mode
9611 @table @kbd
9612 @kindex C-c C-e D
9613 @item C-c C-e D
9614 @cindex property EXPORT_FILE_NAME
9615 Export as DocBook file.  For an Org file, @file{myfile.org}, the DocBook XML
9616 file will be @file{myfile.xml}.  The file will be overwritten without
9617 warning.  If there is an active region@footnote{This requires
9618 @code{transient-mark-mode} to be turned on}, only the region will be
9619 exported.  If the selected region is a single tree@footnote{To select the
9620 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
9621 title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
9622 property, that name will be used for the export.
9623 @kindex C-c C-e V
9624 @item C-c C-e V
9625 Export as DocBook file, process to PDF, then open the resulting PDF file.
9627 @vindex org-export-docbook-xslt-proc-command
9628 @vindex org-export-docbook-xsl-fo-proc-command
9629 Note that, in order to produce PDF output based on exported DocBook file, you
9630 need to have XSLT processor and XSL-FO processor software installed on your
9631 system.  Check variables @code{org-export-docbook-xslt-proc-command} and
9632 @code{org-export-docbook-xsl-fo-proc-command}.
9634 @kindex C-c C-e v D
9635 @item C-c C-e v D
9636 Export only the visible part of the document.
9637 @end table
9639 @node Quoting DocBook code, Recursive sections, DocBook export commands, DocBook export
9640 @subsection Quoting DocBook code
9642 You can quote DocBook code in Org files and copy it verbatim into exported
9643 DocBook file with the following constructs:
9645 @cindex #+DOCBOOK
9646 @cindex #+BEGIN_DOCBOOK
9647 @example
9648 #+DOCBOOK: Literal DocBook code for export
9649 @end example
9651 @noindent or
9652 @cindex #+BEGIN_DOCBOOK
9654 @example
9655 #+BEGIN_DOCBOOK
9656 All lines between these markers are exported by DocBook exporter
9657 literally.
9658 #+END_DOCBOOK
9659 @end example
9661 For example, you can use the following lines to include a DocBook warning
9662 admonition.  As to what this warning says, you should pay attention to the
9663 document context when quoting DocBook code in Org files.  You may make
9664 exported DocBook XML files invalid by not quoting DocBook code correctly.
9666 @example
9667 #+BEGIN_DOCBOOK
9668 <warning>
9669   <para>You should know what you are doing when quoting DocBook XML code
9670   in your Org file.  Invalid DocBook XML file may be generated by
9671   DocBook exporter if you are not careful!</para>
9672 </warning>
9673 #+END_DOCBOOK
9674 @end example
9676 @node Recursive sections, Tables in DocBook export, Quoting DocBook code, DocBook export
9677 @subsection Recursive sections
9678 @cindex DocBook recursive sections
9680 DocBook exporter exports Org files as articles using the @code{article}
9681 element in DocBook.  Recursive sections, i.e. @code{section} elements, are
9682 used in exported articles.  Top level headlines in Org files are exported as
9683 top level sections, and lower level headlines are exported as nested
9684 sections.  The entire structure of Org files will be exported completely, no
9685 matter how many nested levels of headlines there are.
9687 Using recursive sections makes it easy to port and reuse exported DocBook
9688 code in other DocBook document types like @code{book} or @code{set}.
9690 @node Tables in DocBook export, Images in DocBook export, Recursive sections, DocBook export
9691 @subsection Tables in DocBook export
9692 @cindex tables, in DocBook export
9694 Tables in Org files are exported as HTML tables, which have been supported since
9695 DocBook V4.3.
9697 If a table does not have a caption, an informal table is generated using the
9698 @code{informaltable} element; otherwise, a formal table will be generated
9699 using the @code{table} element.
9701 @node Images in DocBook export, Special characters, Tables in DocBook export, DocBook export
9702 @subsection Images in DocBook export
9703 @cindex images, inline in DocBook
9704 @cindex inlining images in DocBook
9706 Images that are linked to without a description part in the link, like
9707 @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]}, will be exported to DocBook
9708 using @code{mediaobject} elements.  Each @code{mediaobject} element contains
9709 an @code{imageobject} that wraps an @code{imagedata} element.  If you have
9710 specified a caption for an image as described in @ref{Images and tables}, a
9711 @code{caption} element will be added in @code{mediaobject}.  If a label is
9712 also specified, it will be exported as an @code{xml:id} attribute of the
9713 @code{mediaobject} element.
9715 @vindex org-export-docbook-default-image-attributes
9716 Image attributes supported by the @code{imagedata} element, like @code{align}
9717 or @code{width}, can be specified in two ways: you can either customize
9718 variable @code{org-export-docbook-default-image-attributes} or use the
9719 @code{#+ATTR_DOCBOOK:} line.  Attributes specified in variable
9720 @code{org-export-docbook-default-image-attributes} are applied to all inline
9721 images in the Org file to be exported (unless they are overwritten by image
9722 attributes specified in @code{#+ATTR_DOCBOOK:} lines).
9724 The @code{#+ATTR_DOCBOOK:} line can be used to specify additional image
9725 attributes or overwrite default image attributes for individual images.  If
9726 the same attribute appears in both the @code{#+ATTR_DOCBOOK:} line and
9727 variable @code{org-export-docbook-default-image-attributes}, the former
9728 overwrites the latter.  Here is an example about how image attributes can be
9729 set:
9731 @cindex #+CAPTION
9732 @cindex #+LABEL
9733 @cindex #+ATTR_DOCBOOK
9734 @example
9735 #+CAPTION:    The logo of Org mode
9736 #+LABEL:      unicorn-svg
9737 #+ATTR_DOCBOOK: scalefit="1" width="100%" depth="100%"
9738 [[./img/org-mode-unicorn.svg]]
9739 @end example
9741 @vindex org-export-docbook-inline-image-extensions
9742 By default, DocBook exporter recognizes the following image file types:
9743 @file{jpeg}, @file{jpg}, @file{png}, @file{gif}, and @file{svg}.  You can
9744 customize variable @code{org-export-docbook-inline-image-extensions} to add
9745 more types to this list as long as DocBook supports them.
9747 @node Special characters,  , Images in DocBook export, DocBook export
9748 @subsection Special characters in DocBook export
9749 @cindex Special characters in DocBook export
9751 @vindex org-export-docbook-doctype
9752 @vindex org-html-entities
9753 Special characters that are written in @TeX{}-like syntax, such as @code{\alpha},
9754 @code{\Gamma}, and @code{\Zeta}, are supported by DocBook exporter.  These
9755 characters are rewritten to XML entities, like @code{&alpha;},
9756 @code{&Gamma;}, and @code{&Zeta;}, based on the list saved in variable
9757 @code{org-html-entities}.  As long as the generated DocBook file includes the
9758 corresponding entities, these special characters are recognized.
9760 You can customize variable @code{org-export-docbook-doctype} to include the
9761 entities you need.  For example, you can set variable
9762 @code{org-export-docbook-doctype} to the following value to recognize all
9763 special characters included in XHTML entities:
9765 @example
9766 "<!DOCTYPE article [
9767 <!ENTITY % xhtml1-symbol PUBLIC
9768 \"-//W3C//ENTITIES Symbol for HTML//EN//XML\"
9769 \"http://www.w3.org/2003/entities/2007/xhtml1-symbol.ent\"
9771 %xhtml1-symbol;
9774 @end example
9776 @node Freemind export, XOXO export, DocBook export, Exporting
9777 @section Freemind export
9778 @cindex Freemind export
9779 @cindex mind map
9781 The freemind exporter was written by Lennart Borgman.
9783 @table @kbd
9784 @kindex C-c C-e m
9785 @item C-c C-e m
9786 Export as Freemind mind map @file{myfile.mm}.
9787 @end table
9789 @node XOXO export, iCalendar export, Freemind export, Exporting
9790 @section XOXO export
9791 @cindex XOXO export
9793 Org mode contains an exporter that produces XOXO-style output.
9794 Currently, this exporter only handles the general outline structure and
9795 does not interpret any additional Org-mode features.
9797 @table @kbd
9798 @kindex C-c C-e x
9799 @item C-c C-e x
9800 Export as XOXO file @file{myfile.html}.
9801 @kindex C-c C-e v
9802 @item C-c C-e v x
9803 Export only the visible part of the document.
9804 @end table
9806 @node iCalendar export,  , XOXO export, Exporting
9807 @section iCalendar export
9808 @cindex iCalendar export
9810 @vindex org-icalendar-include-todo
9811 @vindex org-icalendar-use-deadline
9812 @vindex org-icalendar-use-scheduled
9813 @vindex org-icalendar-categories
9814 Some people use Org mode for keeping track of projects, but still prefer a
9815 standard calendar application for anniversaries and appointments.  In this
9816 case it can be useful to show deadlines and other time-stamped items in Org
9817 files in the calendar application.  Org mode can export calendar information
9818 in the standard iCalendar format.  If you also want to have TODO entries
9819 included in the export, configure the variable
9820 @code{org-icalendar-include-todo}.  Plain timestamps are exported as VEVENT,
9821 and TODO items as VTODO.  It will also create events from deadlines that are
9822 in non-TODO items.  Deadlines and scheduling dates in TODO items will be used
9823 to set the start and due dates for the TODO entry@footnote{See the variables
9824 @code{org-icalendar-use-deadline} and @code{org-icalendar-use-scheduled}.}.
9825 As categories, it will use the tags locally defined in the heading, and the
9826 file/tree category@footnote{To add inherited tags or the TODO state,
9827 configure the variable @code{org-icalendar-categories}.}.
9829 @vindex org-icalendar-store-UID
9830 @cindex property, ID
9831 The iCalendar standard requires each entry to have a globally unique
9832 identifier (UID).  Org creates these identifiers during export.  If you set
9833 the variable @code{org-icalendar-store-UID}, the UID will be stored in the
9834 @code{:ID:} property of the entry and re-used next time you report this
9835 entry.  Since a single entry can give rise to multiple iCalendar entries (as
9836 a timestamp, a deadline, a scheduled item, and as a TODO item), Org adds
9837 prefixes to the UID, depending on what triggered the inclusion of the entry.
9838 In this way the UID remains unique, but a synchronization program can still
9839 figure out from which entry all the different instances originate.
9841 @table @kbd
9842 @kindex C-c C-e i
9843 @item C-c C-e i
9844 Create iCalendar entries for the current file and store them in the same
9845 directory, using a file extension @file{.ics}.
9846 @kindex C-c C-e I
9847 @item C-c C-e I
9848 @vindex org-agenda-files
9849 Like @kbd{C-c C-e i}, but do this for all files in
9850 @code{org-agenda-files}.  For each of these files, a separate iCalendar
9851 file will be written.
9852 @kindex C-c C-e c
9853 @item C-c C-e c
9854 @vindex org-combined-agenda-icalendar-file
9855 Create a single large iCalendar file from all files in
9856 @code{org-agenda-files} and write it to the file given by
9857 @code{org-combined-agenda-icalendar-file}.
9858 @end table
9860 @vindex org-use-property-inheritance
9861 @vindex org-icalendar-include-body
9862 @cindex property, SUMMARY
9863 @cindex property, DESCRIPTION
9864 @cindex property, LOCATION
9865 The export will honor SUMMARY, DESCRIPTION and LOCATION@footnote{The LOCATION
9866 property can be inherited from higher in the hierarchy if you configure
9867 @code{org-use-property-inheritance} accordingly.} properties if the selected
9868 entries have them.  If not, the summary will be derived from the headline,
9869 and the description from the body (limited to
9870 @code{org-icalendar-include-body} characters).
9872 How this calendar is best read and updated, depends on the application
9873 you are using.  The FAQ covers this issue.
9875 @node Publishing, Miscellaneous, Exporting, Top
9876 @chapter Publishing
9877 @cindex publishing
9878 @cindex O'Toole, David
9880 Org includes a publishing management system that allows you to configure
9881 automatic HTML conversion of @emph{projects} composed of interlinked org
9882 files.  You can also configure Org to automatically upload your exported HTML
9883 pages and related attachments, such as images and source code files, to a web
9884 server.
9886 You can also use Org to convert files into PDF, or even combine HTML and PDF
9887 conversion so that files are available in both formats on the server.
9889 Publishing has been contributed to Org by David O'Toole.
9891 @menu
9892 * Configuration::               Defining projects
9893 * Uploading files::             How to get files up on the server
9894 * Sample configuration::        Example projects
9895 * Triggering publication::      Publication commands
9896 @end menu
9898 @node Configuration, Uploading files, Publishing, Publishing
9899 @section Configuration
9901 Publishing needs significant configuration to specify files, destination
9902 and many other properties of a project.
9904 @menu
9905 * Project alist::               The central configuration variable
9906 * Sources and destinations::    From here to there
9907 * Selecting files::             What files are part of the project?
9908 * Publishing action::           Setting the function doing the publishing
9909 * Publishing options::          Tweaking HTML export
9910 * Publishing links::            Which links keep working after publishing?
9911 * Project page index::          Publishing a list of project files
9912 @end menu
9914 @node Project alist, Sources and destinations, Configuration, Configuration
9915 @subsection The variable @code{org-publish-project-alist}
9916 @cindex org-publish-project-alist
9917 @cindex projects, for publishing
9919 @vindex org-publish-project-alist
9920 Publishing is configured almost entirely through setting the value of one
9921 variable, called @code{org-publish-project-alist}.  Each element of the list
9922 configures one project, and may be in one of the two following forms:
9924 @lisp
9925    ("project-name" :property value :property value ...)
9926 @r{or}
9927    ("project-name" :components ("project-name" "project-name" ...))
9929 @end lisp
9931 In both cases, projects are configured by specifying property values.  A
9932 project defines the set of files that will be published, as well as the
9933 publishing configuration to use when publishing those files.  When a project
9934 takes the second form listed above, the individual members of the
9935 @code{:components} property are taken to be sub-projects, which group
9936 together files requiring different publishing options.  When you publish such
9937 a ``meta-project'', all the components will also be published, in the
9938 sequence given.
9940 @node Sources and destinations, Selecting files, Project alist, Configuration
9941 @subsection Sources and destinations for files
9942 @cindex directories, for publishing
9944 Most properties are optional, but some should always be set.  In
9945 particular, Org needs to know where to look for source files,
9946 and where to put published files.
9948 @multitable @columnfractions 0.3 0.7
9949 @item @code{:base-directory}
9950 @tab Directory containing publishing source files
9951 @item @code{:publishing-directory}
9952 @tab Directory where output files will be published.  You can directly
9953 publish to a webserver using a file name syntax appropriate for
9954 the Emacs @file{tramp} package.  Or you can publish to a local directory and
9955 use external tools to upload your website (@pxref{Uploading files}).
9956 @item @code{:preparation-function}
9957 @tab Function called before starting the publishing process, for example, to
9958 run @code{make} for updating files to be published.
9959 @item @code{:completion-function}
9960 @tab Function called after finishing the publishing process, for example, to
9961 change permissions of the resulting files.
9962 @end multitable
9963 @noindent
9965 @node Selecting files, Publishing action, Sources and destinations, Configuration
9966 @subsection Selecting files
9967 @cindex files, selecting for publishing
9969 By default, all files with extension @file{.org} in the base directory
9970 are considered part of the project.  This can be modified by setting the
9971 properties
9972 @multitable @columnfractions 0.25 0.75
9973 @item @code{:base-extension}
9974 @tab Extension (without the dot!) of source files.  This actually is a
9975 regular expression.  Set this to the symbol @code{any} if you want to get all
9976 files in @code{:base-directory}, even without extension.
9978 @item @code{:exclude}
9979 @tab Regular expression to match file names that should not be
9980 published, even though they have been selected on the basis of their
9981 extension.
9983 @item @code{:include}
9984 @tab List of files to be included regardless of @code{:base-extension}
9985 and @code{:exclude}.
9986 @end multitable
9988 @node Publishing action, Publishing options, Selecting files, Configuration
9989 @subsection Publishing action
9990 @cindex action, for publishing
9992 Publishing means that a file is copied to the destination directory and
9993 possibly transformed in the process.  The default transformation is to export
9994 Org files as HTML files, and this is done by the function
9995 @code{org-publish-org-to-html} which calls the HTML exporter (@pxref{HTML
9996 export}).  But you also can publish your content as PDF files using
9997 @code{org-publish-org-to-pdf}.  If you want to publish the Org file itself,
9998 but with @i{archived}, @i{commented}, and @i{tag-excluded} trees removed, use
9999 @code{org-publish-org-to-org} and set the parameters @code{:plain-source}
10000 and/or @code{:htmlized-source}.  This will produce @file{file.org} and
10001 @file{file.org.html} in the publishing
10002 directory@footnote{@file{file-source.org} and @file{file-source.org.html} if
10003 source and publishing directories are equal.  Note that with this kind of
10004 setup, you need to add @code{:exclude "-source\\.org"} to the project
10005 definition in @code{org-publish-project-alist} to avoid that the published
10006 source files will be considered as new org files the next time the project is
10007 published.}.  Other files like images only
10008 need to be copied to the publishing destination, for this you may use
10009 @code{org-publish-attachment}.  For non-Org files, you always need to
10010 specify the publishing function:
10012 @multitable @columnfractions 0.3 0.7
10013 @item @code{:publishing-function}
10014 @tab Function executing the publication of a file.  This may also be a
10015 list of functions, which will all be called in turn.
10016 @item @code{:plain-source}
10017 @tab Non-nil means, publish plain source.
10018 @item @code{:htmlized-source}
10019 @tab Non-nil means, publish htmlized source.
10020 @end multitable
10022 The function must accept two arguments: a property list containing at least a
10023 @code{:publishing-directory} property, and the name of the file to be
10024 published.  It should take the specified file, make the necessary
10025 transformation (if any) and place the result into the destination folder.
10027 @node Publishing options, Publishing links, Publishing action, Configuration
10028 @subsection Options for the HTML/La@TeX{} exporters
10029 @cindex options, for publishing
10031 The property list can be used to set many export options for the HTML
10032 and La@TeX{} exporters.  In most cases, these properties correspond to user
10033 variables in Org.  The table below lists these properties along
10034 with the variable they belong to.  See the documentation string for the
10035 respective variable for details.
10037 @vindex org-export-html-link-up
10038 @vindex org-export-html-link-home
10039 @vindex org-export-default-language
10040 @vindex org-display-custom-times
10041 @vindex org-export-headline-levels
10042 @vindex org-export-with-section-numbers
10043 @vindex org-export-section-number-format
10044 @vindex org-export-with-toc
10045 @vindex org-export-preserve-breaks
10046 @vindex org-export-with-archived-trees
10047 @vindex org-export-with-emphasize
10048 @vindex org-export-with-sub-superscripts
10049 @vindex org-export-with-special-strings
10050 @vindex org-export-with-footnotes
10051 @vindex org-export-with-drawers
10052 @vindex org-export-with-tags
10053 @vindex org-export-with-todo-keywords
10054 @vindex org-export-with-priority
10055 @vindex org-export-with-TeX-macros
10056 @vindex org-export-with-LaTeX-fragments
10057 @vindex org-export-skip-text-before-1st-heading
10058 @vindex org-export-with-fixed-width
10059 @vindex org-export-with-timestamps
10060 @vindex org-export-author-info
10061 @vindex org-export-creator-info
10062 @vindex org-export-with-tables
10063 @vindex org-export-highlight-first-table-line
10064 @vindex org-export-html-style-include-default
10065 @vindex org-export-html-style
10066 @vindex org-export-html-style-extra
10067 @vindex org-export-html-link-org-files-as-html
10068 @vindex org-export-html-inline-images
10069 @vindex org-export-html-extension
10070 @vindex org-export-html-table-tag
10071 @vindex org-export-html-expand
10072 @vindex org-export-html-with-timestamp
10073 @vindex org-export-publishing-directory
10074 @vindex org-export-html-preamble
10075 @vindex org-export-html-postamble
10076 @vindex org-export-html-auto-preamble
10077 @vindex org-export-html-auto-postamble
10078 @vindex user-full-name
10079 @vindex user-mail-address
10080 @vindex org-export-select-tags
10081 @vindex org-export-exclude-tags
10083 @multitable @columnfractions 0.32 0.68
10084 @item @code{:link-up}               @tab @code{org-export-html-link-up}
10085 @item @code{:link-home}             @tab @code{org-export-html-link-home}
10086 @item @code{:language}              @tab @code{org-export-default-language}
10087 @item @code{:customtime}            @tab @code{org-display-custom-times}
10088 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
10089 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
10090 @item @code{:section-number-format} @tab @code{org-export-section-number-format}
10091 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
10092 @item @code{:preserve-breaks}       @tab @code{org-export-preserve-breaks}
10093 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
10094 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
10095 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
10096 @item @code{:special-strings}       @tab @code{org-export-with-special-strings}
10097 @item @code{:footnotes}             @tab @code{org-export-with-footnotes}
10098 @item @code{:drawers}               @tab @code{org-export-with-drawers}
10099 @item @code{:tags}                  @tab @code{org-export-with-tags}
10100 @item @code{:todo-keywords}         @tab @code{org-export-with-todo-keywords}
10101 @item @code{:priority}              @tab @code{org-export-with-priority}
10102 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
10103 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
10104 @item @code{:latex-listings}        @tab @code{org-export-latex-listings}
10105 @item @code{:skip-before-1st-heading} @tab @code{org-export-skip-text-before-1st-heading}
10106 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
10107 @item @code{:timestamps}            @tab @code{org-export-with-timestamps}
10108 @item @code{:author-info}           @tab @code{org-export-author-info}
10109 @item @code{:creator-info}          @tab @code{org-export-creator-info}
10110 @item @code{:tables}                @tab @code{org-export-with-tables}
10111 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
10112 @item @code{:style-include-default} @tab @code{org-export-html-style-include-default}
10113 @item @code{:style}                 @tab @code{org-export-html-style}
10114 @item @code{:style-extra}           @tab @code{org-export-html-style-extra}
10115 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
10116 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
10117 @item @code{:html-extension}        @tab @code{org-export-html-extension}
10118 @item @code{:xml-declaration}       @tab @code{org-export-html-xml-declaration}
10119 @item @code{:html-table-tag}        @tab @code{org-export-html-table-tag}
10120 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
10121 @item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
10122 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
10123 @item @code{:preamble}              @tab @code{org-export-html-preamble}
10124 @item @code{:postamble}             @tab @code{org-export-html-postamble}
10125 @item @code{:auto-preamble}         @tab @code{org-export-html-auto-preamble}
10126 @item @code{:auto-postamble}        @tab @code{org-export-html-auto-postamble}
10127 @item @code{:author}                @tab @code{user-full-name}
10128 @item @code{:email}                 @tab @code{user-mail-address} : @code{addr;addr;..}
10129 @item @code{:select-tags}           @tab @code{org-export-select-tags}
10130 @item @code{:exclude-tags}          @tab @code{org-export-exclude-tags}
10131 @item @code{:latex-image-options}   @tab @code{org-export-latex-image-default-option}
10132 @end multitable
10134 Most of the @code{org-export-with-*} variables have the same effect in
10135 both HTML and La@TeX{} exporters, except for @code{:TeX-macros} and
10136 @code{:LaTeX-fragments}, respectively @code{nil} and @code{t} in the
10137 La@TeX{} export.
10139 @vindex org-publish-project-alist
10140 When a property is given a value in @code{org-publish-project-alist},
10141 its setting overrides the value of the corresponding user variable (if
10142 any) during publishing.  Options set within a file (@pxref{Export
10143 options}), however, override everything.
10145 @node Publishing links, Project page index, Publishing options, Configuration
10146 @subsection Links between published files
10147 @cindex links, publishing
10149 To create a link from one Org file to another, you would use
10150 something like @samp{[[file:foo.org][The foo]]} or simply
10151 @samp{file:foo.org.} (@pxref{Hyperlinks}).  When published, this link
10152 becomes a link to @file{foo.html}.  In this way, you can interlink the
10153 pages of your "org web" project and the links will work as expected when
10154 you publish them to HTML.  If you also publish the Org source file and want
10155 to link to that, use an @code{http:} link instead of a @code{file:} link,
10156 because @code{file:} links are converted to link to the corresponding
10157 @file{html} file.
10159 You may also link to related files, such as images. Provided you are careful
10160 with relative file names, and provided you have also configured Org to upload
10161 the related files, these links will work too. See @ref{Complex example}, for
10162 an example of this usage.
10164 Sometimes an Org file to be published may contain links that are
10165 only valid in your production environment, but not in the publishing
10166 location.  In this case, use the property
10168 @multitable @columnfractions 0.4 0.6
10169 @item @code{:link-validation-function}
10170 @tab Function to validate links
10171 @end multitable
10173 @noindent
10174 to define a function for checking link validity.  This function must
10175 accept two arguments, the file name and a directory relative to which
10176 the file name is interpreted in the production environment.  If this
10177 function returns @code{nil}, then the HTML generator will only insert a
10178 description into the HTML file, but no link.  One option for this
10179 function is @code{org-publish-validate-link} which checks if the given
10180 file is part of any project in @code{org-publish-project-alist}.
10182 @node Project page index,  , Publishing links, Configuration
10183 @subsection Project page index
10184 @cindex index, of published pages
10186 The following properties may be used to control publishing of an
10187 index of files or a summary page for a given project.
10189 @multitable @columnfractions 0.25 0.75
10190 @item @code{:auto-index}
10191 @tab When non-nil, publish an index during @code{org-publish-current-project}
10192 or @code{org-publish-all}.
10194 @item @code{:index-filename}
10195 @tab Filename for output of index. Defaults to @file{sitemap.org} (which
10196 becomes @file{sitemap.html}).
10198 @item @code{:index-title}
10199 @tab Title of index page. Defaults to name of file.
10201 @item @code{:index-function}
10202 @tab Plug-in function to use for generation of index.
10203 Defaults to @code{org-publish-org-index}, which generates a plain list
10204 of links to all files in the project.
10205 @end multitable
10207 @node Uploading files, Sample configuration, Configuration, Publishing
10208 @section Uploading files
10209 @cindex rsync
10210 @cindex unison
10212 For those people already utilizing third party sync tools such as
10213 @command{rsync} or @command{unison}, it might be preferable not to use the built in
10214 @i{remote} publishing facilities of Org mode which rely heavily on
10215 Tramp.  Tramp, while very useful and powerful, tends not to be
10216 so efficient for multiple file transfer and has been known to cause problems
10217 under heavy usage.
10219 Specialized synchronization utilities offer several advantages.  In addition
10220 to timestamp comparison, they also do content and permissions/attribute
10221 checks.  For this reason you might prefer to publish your web to a local
10222 directory (possibly even @i{in place} with your Org files) and then use
10223 @file{unison} or @file{rsync} to do the synchronization with the remote host.
10225 Since Unison (for example) can be configured as to which files to transfer to
10226 a certain remote destination, it can greatly simplify the project publishing
10227 definition.  Simply keep all files in the correct location, process your Org
10228 files with @code{org-publish} and let the synchronization tool do the rest.
10229 You do not need, in this scenario, to include attachments such as @file{jpg},
10230 @file{css} or @file{gif} files in the project definition since the 3rd party
10231 tool syncs them.
10233 Publishing to a local directory is also much faster than to a remote one, so
10234 that you can afford more easily to republish entire projects.  If you set
10235 @code{org-publish-use-timestamps-flag} to @code{nil}, you gain the main
10236 benefit of re-including any changed external files such as source example
10237 files you might include with @code{#+INCLUDE}.  The timestamp mechanism in
10238 Org is not smart enough to detect if included files have been modified.
10240 @node Sample configuration, Triggering publication, Uploading files, Publishing
10241 @section Sample configuration
10243 Below we provide two example configurations.  The first one is a simple
10244 project publishing only a set of Org files.  The second example is
10245 more complex, with a multi-component project.
10247 @menu
10248 * Simple example::              One-component publishing
10249 * Complex example::             A multi-component publishing example
10250 @end menu
10252 @node Simple example, Complex example, Sample configuration, Sample configuration
10253 @subsection Example: simple publishing configuration
10255 This example publishes a set of Org files to the @file{public_html}
10256 directory on the local machine.
10258 @lisp
10259 (setq org-publish-project-alist
10260       '(("org"
10261          :base-directory "~/org/"
10262          :publishing-directory "~/public_html"
10263          :section-numbers nil
10264          :table-of-contents nil
10265          :style "<link rel=\"stylesheet\"
10266                 href=\"../other/mystyle.css\"
10267                 type=\"text/css\"/>")))
10268 @end lisp
10270 @node Complex example,  , Simple example, Sample configuration
10271 @subsection Example: complex publishing configuration
10273 This more complicated example publishes an entire website, including
10274 Org files converted to HTML, image files, Emacs Lisp source code, and
10275 style sheets. The publishing directory is remote and private files are
10276 excluded.
10278 To ensure that links are preserved, care should be taken to replicate
10279 your directory structure on the web server, and to use relative file
10280 paths. For example, if your Org files are kept in @file{~/org} and your
10281 publishable images in @file{~/images}, you'd link to an image with
10283 @example
10284 file:../images/myimage.png
10285 @end example
10287 On the web server, the relative path to the image should be the
10288 same. You can accomplish this by setting up an "images" folder in the
10289 right place on the web server, and publishing images to it.
10291 @lisp
10292 (setq org-publish-project-alist
10293       '(("orgfiles"
10294           :base-directory "~/org/"
10295           :base-extension "org"
10296           :publishing-directory "/ssh:user@@host:~/html/notebook/"
10297           :publishing-function org-publish-org-to-html
10298           :exclude "PrivatePage.org"   ;; regexp
10299           :headline-levels 3
10300           :section-numbers nil
10301           :table-of-contents nil
10302           :style "<link rel=\"stylesheet\"
10303                   href=\"../other/mystyle.css\" type=\"text/css\"/>"
10304           :auto-preamble t
10305           :auto-postamble nil)
10307          ("images"
10308           :base-directory "~/images/"
10309           :base-extension "jpg\\|gif\\|png"
10310           :publishing-directory "/ssh:user@@host:~/html/images/"
10311           :publishing-function org-publish-attachment)
10313          ("other"
10314           :base-directory "~/other/"
10315           :base-extension "css\\|el"
10316           :publishing-directory "/ssh:user@@host:~/html/other/"
10317           :publishing-function org-publish-attachment)
10318          ("website" :components ("orgfiles" "images" "other"))))
10319 @end lisp
10321 @node Triggering publication,  , Sample configuration, Publishing
10322 @section Triggering publication
10324 Once properly configured, Org can publish with the following commands:
10326 @table @kbd
10327 @kindex C-c C-e C
10328 @item C-c C-e C
10329 Prompt for a specific project and publish all files that belong to it.
10330 @kindex C-c C-e P
10331 @item C-c C-e P
10332 Publish the project containing the current file.
10333 @kindex C-c C-e F
10334 @item C-c C-e F
10335 Publish only the current file.
10336 @kindex C-c C-e E
10337 @item C-c C-e E
10338 Publish every project.
10339 @end table
10341 @vindex org-publish-use-timestamps-flag
10342 Org uses timestamps to track when a file has changed. The above functions
10343 normally only publish changed files. You can override this and force
10344 publishing of all files by giving a prefix argument to any of the commands
10345 above, or by customizing the variable @code{org-publish-use-timestamps-flag}.
10346 This may be necessary in particular if files include other files via
10347 @code{#+SETUPFILE:} or @code{#+INCLUDE:}.
10349 @node Miscellaneous, Hacking, Publishing, Top
10350 @chapter Miscellaneous
10352 @menu
10353 * Completion::                  M-TAB knows what you need
10354 * Speed keys::                  Electic commands at the beginning of a headline
10355 * Customization::               Adapting Org to your taste
10356 * In-buffer settings::          Overview of the #+KEYWORDS
10357 * The very busy C-c C-c key::   When in doubt, press C-c C-c
10358 * Clean view::                  Getting rid of leading stars in the outline
10359 * TTY keys::                    Using Org on a tty
10360 * Interaction::                 Other Emacs packages
10361 @end menu
10364 @node Completion, Speed keys, Miscellaneous, Miscellaneous
10365 @section Completion
10366 @cindex completion, of @TeX{} symbols
10367 @cindex completion, of TODO keywords
10368 @cindex completion, of dictionary words
10369 @cindex completion, of option keywords
10370 @cindex completion, of tags
10371 @cindex completion, of property keys
10372 @cindex completion, of link abbreviations
10373 @cindex @TeX{} symbol completion
10374 @cindex TODO keywords completion
10375 @cindex dictionary word completion
10376 @cindex option keyword completion
10377 @cindex tag completion
10378 @cindex link abbreviations, completion of
10380 Emacs would not be Emacs without completion, and Org-mode uses it whenever it
10381 makes sense.  If you prefer an @i{iswitchb}- or @i{ido}-like interface for
10382 some of the completion prompts, you can specify your preference by setting at
10383 most one of the variables @code{org-completion-use-iswitchb}
10384 @code{org-completion-use-ido}.
10386 Org supports in-buffer completion.  This type of completion does
10387 not make use of the minibuffer.  You simply type a few letters into
10388 the buffer and use the key to complete text right there.
10390 @table @kbd
10391 @kindex M-@key{TAB}
10392 @item M-@key{TAB}
10393 Complete word at point
10394 @itemize @bullet
10395 @item
10396 At the beginning of a headline, complete TODO keywords.
10397 @item
10398 After @samp{\}, complete @TeX{} symbols supported by the exporter.
10399 @item
10400 After @samp{*}, complete headlines in the current buffer so that they
10401 can be used in search links like @samp{[[*find this headline]]}.
10402 @item
10403 After @samp{:} in a headline, complete tags.  The list of tags is taken
10404 from the variable @code{org-tag-alist} (possibly set through the
10405 @samp{#+TAGS} in-buffer option, @pxref{Setting tags}), or it is created
10406 dynamically from all tags used in the current buffer.
10407 @item
10408 After @samp{:} and not in a headline, complete property keys.  The list
10409 of keys is constructed dynamically from all keys used in the current
10410 buffer.
10411 @item
10412 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
10413 @item
10414 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
10415 @samp{OPTIONS} which set file-specific options for Org mode.  When the
10416 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
10417 will insert example settings for this keyword.
10418 @item
10419 In the line after @samp{#+STARTUP: }, complete startup keywords,
10420 i.e. valid keys for this line.
10421 @item
10422 Elsewhere, complete dictionary words using Ispell.
10423 @end itemize
10424 @end table
10426 @node Speed keys, Customization, Completion, Miscellaneous
10427 @section Speed keys
10428 @cindex speed keys
10429 @vindex org-use-speed-commands
10430 @vindex org-speed-commands-user
10432 Single keys can be made to execute commands when the cursor is at the
10433 beginning of a headline, i.e. before the first star.  Configure the variable
10434 @code{org-use-speed-commands} to activate this feature.  There is a
10435 pre-defined list of commands, and you can add more such commands using the
10436 variable @code{org-speed-commands-user}.  Speed keys do not only speed up
10437 navigation and other commands, but they also provide an alternative way to
10438 execute commands bound to keys that are not or not easily available on a tty,
10439 or on a small mobile device with a limited keyboard.
10441 To see which commands are available, activate the feature and press @kbd{?}
10442 with the cursor at the beginning of a headline.
10444 @node Customization, In-buffer settings, Speed keys, Miscellaneous
10445 @section Customization
10446 @cindex customization
10447 @cindex options, for customization
10448 @cindex variables, for customization
10450 There are more than 180 variables that can be used to customize
10451 Org.  For the sake of compactness of the manual, I am not
10452 describing the variables here.  A structured overview of customization
10453 variables is available with @kbd{M-x org-customize}.  Or select
10454 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
10455 settings can also be activated on a per-file basis, by putting special
10456 lines into the buffer (@pxref{In-buffer settings}).
10458 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
10459 @section Summary of in-buffer settings
10460 @cindex in-buffer settings
10461 @cindex special keywords
10463 Org mode uses special lines in the buffer to define settings on a
10464 per-file basis.  These lines start with a @samp{#+} followed by a
10465 keyword, a colon, and then individual words defining a setting.  Several
10466 setting words can be in the same line, but you can also have multiple
10467 lines for the keyword.  While these settings are described throughout
10468 the manual, here is a summary.  After changing any of those lines in the
10469 buffer, press @kbd{C-c C-c} with the cursor still in the line to
10470 activate the changes immediately.  Otherwise they become effective only
10471 when the file is visited again in a new Emacs session.
10473 @vindex org-archive-location
10474 @table @kbd
10475 @item #+ARCHIVE: %s_done::
10476 This line sets the archive location for the agenda file.  It applies for
10477 all subsequent lines until the next @samp{#+ARCHIVE} line, or the end
10478 of the file.  The first such line also applies to any entries before it.
10479 The corresponding variable is @code{org-archive-location}.
10480 @item #+CATEGORY:
10481 This line sets the category for the agenda file.  The category applies
10482 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
10483 end of the file.  The first such line also applies to any entries before it.
10484 @item #+COLUMNS: %25ITEM .....
10485 @cindex property, COLUMNS
10486 Set the default format for columns view.  This format applies when
10487 columns view is invoked in locations where no @code{COLUMNS} property
10488 applies.
10489 @item #+CONSTANTS: name1=value1 ...
10490 @vindex org-table-formula-constants
10491 @vindex org-table-formula
10492 Set file-local values for constants to be used in table formulas.  This
10493 line set the local variable @code{org-table-formula-constants-local}.
10494 The global version of this variable is
10495 @code{org-table-formula-constants}.
10496 @item #+FILETAGS: :tag1:tag2:tag3:
10497 Set tags that can be inherited by any entry in the file, including the
10498 top-level entries.
10499 @item #+DRAWERS: NAME1 .....
10500 @vindex org-drawers
10501 Set the file-local set of drawers.  The corresponding global variable is
10502 @code{org-drawers}.
10503 @item #+LINK:  linkword replace
10504 @vindex org-link-abbrev-alist
10505 These lines (several are allowed) specify link abbreviations.
10506 @xref{Link abbreviations}.  The corresponding variable is
10507 @code{org-link-abbrev-alist}.
10508 @item #+PRIORITIES: highest lowest default
10509 @vindex org-highest-priority
10510 @vindex org-lowest-priority
10511 @vindex org-default-priority
10512 This line sets the limits and the default for the priorities.  All three
10513 must be either letters A-Z or numbers 0-9.  The highest priority must
10514 have a lower ASCII number that the lowest priority.
10515 @item #+PROPERTY: Property_Name Value
10516 This line sets a default inheritance value for entries in the current
10517 buffer, most useful for specifying the allowed values of a property.
10518 @cindex #+SETUPFILE
10519 @item #+SETUPFILE: file
10520 This line defines a file that holds more in-buffer setup.  Normally this is
10521 entirely ignored.  Only when the buffer is parsed for option-setting lines
10522 (i.e. when starting Org mode for a file, when pressing @kbd{C-c C-c} in a
10523 settings line, or when exporting), then the contents of this file are parsed
10524 as if they had been included in the buffer.  In particular, the file can be
10525 any other Org mode file with internal setup.  You can visit the file the
10526 cursor is in the line with @kbd{C-c '}.
10527 @item #+STARTUP:
10528 @cindex #+STARTUP:
10529 This line sets options to be used at startup of Org mode, when an
10530 Org file is being visited.
10532 The first set of options deals with the initial visibility of the outline
10533 tree.  The corresponding variable for global default settings is
10534 @code{org-startup-folded}, with a default value @code{t}, which means
10535 @code{overview}.
10536 @vindex org-startup-folded
10537 @cindex @code{overview}, STARTUP keyword
10538 @cindex @code{content}, STARTUP keyword
10539 @cindex @code{showall}, STARTUP keyword
10540 @cindex @code{showeverything}, STARTUP keyword
10541 @example
10542 overview         @r{top-level headlines only}
10543 content          @r{all headlines}
10544 showall          @r{no folding of any entries}
10545 showeverything   @r{show even drawer contents}
10546 @end example
10548 @vindex org-startup-indented
10549 @cindex @code{indent}, STARTUP keyword
10550 @cindex @code{noindent}, STARTUP keyword
10551 Dynamic virtual indentation is controlled by the variable
10552 @code{org-startup-indented}@footnote{Emacs 23 and Org-mode 6.29 are required}
10553 @example
10554 indent     @r{start with @code{org-indent-mode} turned on}
10555 noindent   @r{start with @code{org-indent-mode} turned off}
10556 @end example
10558 @vindex org-startup-align-all-tables
10559 Then there are options for aligning tables upon visiting a file.  This
10560 is useful in files containing narrowed table columns.  The corresponding
10561 variable is @code{org-startup-align-all-tables}, with a default value
10562 @code{nil}.
10563 @cindex @code{align}, STARTUP keyword
10564 @cindex @code{noalign}, STARTUP keyword
10565 @example
10566 align      @r{align all tables}
10567 noalign    @r{don't align tables on startup}
10568 @end example
10569 @vindex org-log-done
10570 @vindex org-log-note-clock-out
10571 @vindex org-log-repeat
10572 Logging the closing and reopening of TODO items and clock intervals can be
10573 configured using these options (see variables @code{org-log-done},
10574 @code{org-log-note-clock-out} and @code{org-log-repeat})
10575 @cindex @code{logdone}, STARTUP keyword
10576 @cindex @code{lognotedone}, STARTUP keyword
10577 @cindex @code{nologdone}, STARTUP keyword
10578 @cindex @code{lognoteclock-out}, STARTUP keyword
10579 @cindex @code{nolognoteclock-out}, STARTUP keyword
10580 @cindex @code{logrepeat}, STARTUP keyword
10581 @cindex @code{lognoterepeat}, STARTUP keyword
10582 @cindex @code{nologrepeat}, STARTUP keyword
10583 @cindex @code{logreschedule}, STARTUP keyword
10584 @cindex @code{lognotereschedule}, STARTUP keyword
10585 @cindex @code{nologreschedule}, STARTUP keyword
10586 @cindex @code{logredeadline}, STARTUP keyword
10587 @cindex @code{lognoteredeadline}, STARTUP keyword
10588 @cindex @code{nologredeadline}, STARTUP keyword
10589 @example
10590 logdone            @r{record a timestamp when an item is marked DONE}
10591 lognotedone        @r{record timestamp and a note when DONE}
10592 nologdone          @r{don't record when items are marked DONE}
10593 logrepeat          @r{record a time when reinstating a repeating item}
10594 lognoterepeat      @r{record a note when reinstating a repeating item}
10595 nologrepeat        @r{do not record when reinstating repeating item}
10596 lognoteclock-out   @r{record a note when clocking out}
10597 nolognoteclock-out @r{don't record a note when clocking out}
10598 logreschedule      @r{record a timestamp when scheduling time changes}
10599 lognotereschedule  @r{record a note when scheduling time changes}
10600 nologreschedule    @r{do not record when a scheduling date changes}
10601 logredeadline      @r{record a timestamp when deadline changes}
10602 lognoteredeadline  @r{record a note when deadline changes}
10603 nologredeadline    @r{do not record when a deadline date changes}
10604 @end example
10605 @vindex org-hide-leading-stars
10606 @vindex org-odd-levels-only
10607 Here are the options for hiding leading stars in outline headings, and for
10608 indenting outlines.  The corresponding variables are
10609 @code{org-hide-leading-stars} and @code{org-odd-levels-only}, both with a
10610 default setting @code{nil} (meaning @code{showstars} and @code{oddeven}).
10611 @cindex @code{hidestars}, STARTUP keyword
10612 @cindex @code{showstars}, STARTUP keyword
10613 @cindex @code{odd}, STARTUP keyword
10614 @cindex @code{even}, STARTUP keyword
10615 @example
10616 hidestars  @r{make all but one of the stars starting a headline invisible.}
10617 showstars  @r{show all stars starting a headline}
10618 indent     @r{virtual indentation according to outline level}
10619 noindent   @r{no virtual indentation according to outline level}
10620 odd        @r{allow only odd outline levels (1,3,...)}
10621 oddeven    @r{allow all outline levels}
10622 @end example
10623 @vindex org-put-time-stamp-overlays
10624 @vindex org-time-stamp-overlay-formats
10625 To turn on custom format overlays over timestamps (variables
10626 @code{org-put-time-stamp-overlays} and
10627 @code{org-time-stamp-overlay-formats}), use
10628 @cindex @code{customtime}, STARTUP keyword
10629 @example
10630 customtime @r{overlay custom time format}
10631 @end example
10632 @vindex constants-unit-system
10633 The following options influence the table spreadsheet (variable
10634 @code{constants-unit-system}).
10635 @cindex @code{constcgs}, STARTUP keyword
10636 @cindex @code{constSI}, STARTUP keyword
10637 @example
10638 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
10639 constSI    @r{@file{constants.el} should use the SI unit system}
10640 @end example
10641 @vindex org-footnote-define-inline
10642 @vindex org-footnote-auto-label
10643 @vindex org-footnote-auto-adjust
10644 To influence footnote settings, use the following keywords.  The
10645 corresponding variables are @code{org-footnote-define-inline},
10646 @code{org-footnote-auto-label}, and @code{org-footnote-auto-adjust}.
10647 @cindex @code{fninline}, STARTUP keyword
10648 @cindex @code{nofninline}, STARTUP keyword
10649 @cindex @code{fnlocal}, STARTUP keyword
10650 @cindex @code{fnprompt}, STARTUP keyword
10651 @cindex @code{fnauto}, STARTUP keyword
10652 @cindex @code{fnconfirm}, STARTUP keyword
10653 @cindex @code{fnplain}, STARTUP keyword
10654 @cindex @code{fnadjust}, STARTUP keyword
10655 @cindex @code{nofnadjust}, STARTUP keyword
10656 @example
10657 fninline    @r{define footnotes inline}
10658 fnnoinline  @r{define footnotes in separate section}
10659 fnlocal     @r{define footnotes near first reference, but not inline}
10660 fnprompt    @r{prompt for footnote labels}
10661 fnauto      @r{create [fn:1]-like labels automatically (default)}
10662 fnconfirm   @r{offer automatic label for editing or confirmation}
10663 fnplain     @r{create [1]-like labels automatically}
10664 fnadjust    @r{automatically renumber and sort footnotes}
10665 nofnadjust  @r{do not renumber and sort automatically}
10666 @end example
10667 @cindex org-hide-block-startup
10668 To hide blocks on startup, use these keywords. The corresponding variable is
10669 @code{org-hide-block-startup}.
10670 @cindex @code{hideblocks}, STARTUP keyword
10671 @cindex @code{nohideblocks}, STARTUP keyword
10672 @example
10673 hideblocks   @r{Hide all begin/end blocks on startup}
10674 nohideblocks @r{Do not hide blocks on startup}
10675 @end example
10676 @item #+TAGS:  TAG1(c1) TAG2(c2)
10677 @vindex org-tag-alist
10678 These lines (several such lines are allowed) specify the valid tags in
10679 this file, and (potentially) the corresponding @emph{fast tag selection}
10680 keys.  The corresponding variable is @code{org-tag-alist}.
10681 @item #+TBLFM:
10682 This line contains the formulas for the table directly above the line.
10683 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+DATE:,
10684 @itemx #+OPTIONS:, #+BIND:
10685 @itemx #+DESCRIPTION:, #+KEYWORDS:
10686 @itemx #+LATEX_HEADER:, #+STYLE:, #+LINK_UP:, #+LINK_HOME:,
10687 @itemx #+EXPORT_SELECT_TAGS:, #+EXPORT_EXCLUDE_TAGS:
10688 These lines provide settings for exporting files.  For more details see
10689 @ref{Export options}.
10690 @item #+TODO:    #+SEQ_TODO:   #+TYP_TODO:
10691 @vindex org-todo-keywords
10692 These lines set the TODO keywords and their interpretation in the
10693 current file.  The corresponding variable is @code{org-todo-keywords}.
10694 @end table
10696 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
10697 @section The very busy C-c C-c key
10698 @kindex C-c C-c
10699 @cindex C-c C-c, overview
10701 The key @kbd{C-c C-c} has many purposes in Org, which are all
10702 mentioned scattered throughout this manual.  One specific function of
10703 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
10704 other circumstances it means something like @emph{``Hey Org, look
10705 here and update according to what you see here''}.  Here is a summary of
10706 what this means in different contexts.
10708 @itemize @minus
10709 @item
10710 If there are highlights in the buffer from the creation of a sparse
10711 tree, or from clock display, remove these highlights.
10712 @item
10713 If the cursor is in one of the special @code{#+KEYWORD} lines, this
10714 triggers scanning the buffer for these lines and updating the
10715 information.
10716 @item
10717 If the cursor is inside a table, realign the table.  This command
10718 works even if the automatic table editor has been turned off.
10719 @item
10720 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
10721 the entire table.
10722 @item
10723 If the cursor is inside a table created by the @file{table.el} package,
10724 activate that table.
10725 @item
10726 If the current buffer is a Remember buffer, close the note and file it.
10727 With a prefix argument, file it, without further interaction, to the
10728 default location.
10729 @item
10730 If the cursor is on a @code{<<<target>>>}, update radio targets and
10731 corresponding links in this buffer.
10732 @item
10733 If the cursor is in a property line or at the start or end of a property
10734 drawer, offer property commands.
10735 @item
10736 If the cursor is at a footnote reference, go to the corresponding
10737 definition, and vice versa.
10738 @item
10739 If the cursor is on a statistics cookie, update it.
10740 @item
10741 If the cursor is in a plain list item with a checkbox, toggle the status
10742 of the checkbox.
10743 @item
10744 If the cursor is on a numbered item in a plain list, renumber the
10745 ordered list.
10746 @item
10747 If the cursor is on the @code{#+BEGIN} line of a dynamic block, the
10748 block is updated.
10749 @end itemize
10751 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
10752 @section A cleaner outline view
10753 @cindex hiding leading stars
10754 @cindex dynamic indentation
10755 @cindex odd-levels-only outlines
10756 @cindex clean outline view
10758 Some people find it noisy and distracting that the Org headlines start with a
10759 potentially large number of stars, and that text below the headlines is not
10760 indented.  While this is no problem when writing a @emph{book-like} document
10761 where the outline headings are really section headings, in a more
10762 @emph{list-oriented} outline, indented structure is a lot cleaner:
10764 @example
10765 @group
10766 * Top level headline             |    * Top level headline
10767 ** Second level                  |      * Second level
10768 *** 3rd level                    |        * 3rd level
10769 some text                        |          some text
10770 *** 3rd level                    |        * 3rd level
10771 more text                        |          more text
10772 * Another top level headline     |    * Another top level headline
10773 @end group
10774 @end example
10776 @noindent
10777 If you are using at least Emacs 23.1.50.3 and version 6.29 of Org, this kind
10778 of view can be achieved dynamically at display time using
10779 @code{org-indent-mode}.  In this minor mode, all lines are prefixed for
10780 display with the necessary amount of space.  Also headlines are prefixed with
10781 additional stars, so that the amount of indentation shifts by
10782 two@footnote{See the variable @code{org-indent-indentation-per-level}.}
10783 spaces per level.  All headline stars but the last one are made invisible
10784 using the @code{org-hide} face@footnote{Turning on @code{org-indent-mode}
10785 sets @code{org-hide-leading-stars} to @code{t} and
10786 @code{org-adapt-indentation} to @code{nil}.} - see below under @samp{2.} for
10787 more information on how this works.  You can turn on @code{org-indent-mode}
10788 for all files by customizing the variable @code{org-startup-indented}, or you
10789 can turn it on for individual files using
10791 @example
10792 #+STARTUP: indent
10793 @end example
10795 If you want a similar effect in earlier version of Emacs and/or Org, or if
10796 you want the indentation to be hard space characters so that the plain text
10797 file looks as similar as possible to the Emacs display, Org supports you in
10798 the following way:
10800 @enumerate
10801 @item
10802 @emph{Indentation of text below headlines}@*
10803 You may indent text below each headline to make the left boundary line up
10804 with the headline, like
10806 @example
10807 *** 3rd level
10808     more text, now indented
10809 @end example
10811 @vindex org-adapt-indentation
10812 Org supports this with paragraph filling, line wrapping, and structure
10813 editing@footnote{See also the variable @code{org-adapt-indentation}.},
10814 preserving or adapting the indentation as appropriate.
10816 @item
10817 @vindex org-hide-leading-stars
10818 @emph{Hiding leading stars}@* You can modify the display in such a way that
10819 all leading stars become invisible.  To do this in a global way, configure
10820 the variable @code{org-hide-leading-stars} or change this on a per-file basis
10821 with
10823 @example
10824 #+STARTUP: hidestars
10825 #+STARTUP: showstars
10826 @end example
10828 With hidden stars, the tree becomes:
10830 @example
10831 @group
10832 * Top level headline
10833  * Second level
10834   * 3rd level
10835   ...
10836 @end group
10837 @end example
10839 @noindent
10840 @vindex org-hide @r{(face)}
10841 The leading stars are not truly replaced by whitespace, they are only
10842 fontified with the face @code{org-hide} that uses the background color as
10843 font color.  If you are not using either white or black background, you may
10844 have to customize this face to get the wanted effect.  Another possibility is
10845 to set this font such that the extra stars are @i{almost} invisible, for
10846 example using the color @code{grey90} on a white background.
10848 @item
10849 @vindex org-odd-levels-only
10850 Things become cleaner still if you skip all the even levels and use only odd
10851 levels 1, 3, 5..., effectively adding two stars to go from one outline level
10852 to the next@footnote{When you need to specify a level for a property search
10853 or refile targets, @samp{LEVEL=2} will correspond to 3 stars, etc@.}.  In this
10854 way we get the outline view shown at the beginning of this section.  In order
10855 to make the structure editing and export commands handle this convention
10856 correctly, configure the variable @code{org-odd-levels-only}, or set this on
10857 a per-file basis with one of the following lines:
10859 @example
10860 #+STARTUP: odd
10861 #+STARTUP: oddeven
10862 @end example
10864 You can convert an Org file from single-star-per-level to the
10865 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
10866 RET} in that file.  The reverse operation is @kbd{M-x
10867 org-convert-to-oddeven-levels}.
10868 @end enumerate
10870 @node TTY keys, Interaction, Clean view, Miscellaneous
10871 @section Using Org on a tty
10872 @cindex tty key bindings
10874 Because Org contains a large number of commands, by default many of
10875 Org's core commands are bound to keys that are generally not
10876 accessible on a tty, such as the cursor keys (@key{left}, @key{right},
10877 @key{up}, @key{down}), @key{TAB} and @key{RET}, in particular when used
10878 together with modifiers like @key{Meta} and/or @key{Shift}.  To access
10879 these commands on a tty when special keys are unavailable, the following
10880 alternative bindings can be used.  The tty bindings below will likely be
10881 more cumbersome; you may find for some of the bindings below that a
10882 customized workaround suits you better.  For example, changing a timestamp
10883 is really only fun with @kbd{S-@key{cursor}} keys, whereas on a
10884 tty you would rather use @kbd{C-c .} to re-insert the timestamp.
10886 @multitable @columnfractions 0.15 0.2 0.1 0.2
10887 @item @b{Default} @tab @b{Alternative 1} @tab @b{Speed key} @tab @b{Alternative 2} 
10888 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab @kbd{C} @tab                            
10889 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{l} @tab @kbd{@key{Esc} @key{left}} 
10890 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab @kbd{L} @tab                            
10891 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{r} @tab @kbd{@key{Esc} @key{right}}
10892 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab @kbd{R} @tab                           
10893 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{ } @tab @kbd{@key{Esc} @key{up}}  
10894 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab @kbd{U} @tab                           
10895 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{ } @tab @kbd{@key{Esc} @key{down}}
10896 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab @kbd{D} @tab                            
10897 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab @kbd{ } @tab
10898 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{ } @tab @kbd{@key{Esc} @key{RET}}
10899 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab @kbd{ } @tab
10900 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab @kbd{ } @tab
10901 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab @kbd{ } @tab
10902 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab @kbd{ } @tab
10903 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab @kbd{ } @tab
10904 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab @kbd{ } @tab
10905 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab @kbd{ } @tab
10906 @end multitable
10909 @node Interaction,  , TTY keys, Miscellaneous
10910 @section Interaction with other packages
10911 @cindex packages, interaction with other
10912 Org lives in the world of GNU Emacs and interacts in various ways
10913 with other code out there.
10915 @menu
10916 * Cooperation::                 Packages Org cooperates with
10917 * Conflicts::                   Packages that lead to conflicts
10918 @end menu
10920 @node Cooperation, Conflicts, Interaction, Interaction
10921 @subsection Packages that Org cooperates with
10923 @table @asis
10924 @cindex @file{calc.el}
10925 @cindex Gillespie, Dave
10926 @item @file{calc.el} by Dave Gillespie
10927 Org uses the Calc package for implementing spreadsheet
10928 functionality in its tables (@pxref{The spreadsheet}).  Org
10929 checks for the availability of Calc by looking for the function
10930 @code{calc-eval} which will have been autoloaded during setup if Calc has
10931 been installed properly.  As of Emacs 22, Calc is part of the Emacs
10932 distribution.  Another possibility for interaction between the two
10933 packages is using Calc for embedded calculations. @xref{Embedded Mode,
10934 , Embedded Mode, Calc, GNU Emacs Calc Manual}.
10935 @item @file{constants.el} by Carsten Dominik
10936 @cindex @file{constants.el}
10937 @cindex Dominik, Carsten
10938 @vindex org-table-formula-constants
10939 In a table formula (@pxref{The spreadsheet}), it is possible to use
10940 names for natural constants or units.  Instead of defining your own
10941 constants in the variable @code{org-table-formula-constants}, install
10942 the @file{constants} package which defines a large number of constants
10943 and units, and lets you use unit prefixes like @samp{M} for
10944 @samp{Mega}, etc@.  You will need version 2.0 of this package, available
10945 at @url{http://www.astro.uva.nl/~dominik/Tools}. Org checks for
10946 the function @code{constants-get}, which has to be autoloaded in your
10947 setup.  See the installation instructions in the file
10948 @file{constants.el}.
10949 @item @file{cdlatex.el} by Carsten Dominik
10950 @cindex @file{cdlatex.el}
10951 @cindex Dominik, Carsten
10952 Org mode can make use of the CDLa@TeX{} package to efficiently enter
10953 La@TeX{} fragments into Org files.  See @ref{CDLaTeX mode}.
10954 @item @file{imenu.el} by Ake Stenhoff and Lars Lindberg
10955 @cindex @file{imenu.el}
10956 Imenu allows menu access to an index of items in a file.  Org mode
10957 supports Imenu---all you need to do to get the index is the following:
10958 @lisp
10959 (add-hook 'org-mode-hook
10960           (lambda () (imenu-add-to-menubar "Imenu")))
10961 @end lisp
10962 @vindex org-imenu-depth
10963 By default the index is two levels deep---you can modify the depth using
10964 the option @code{org-imenu-depth}.
10965 @item @file{remember.el} by John Wiegley
10966 @cindex @file{remember.el}
10967 @cindex Wiegley, John
10968 Org cooperates with remember, see @ref{Remember}.
10969 @file{Remember.el} is not part of Emacs, find it on the web.
10970 @item @file{speedbar.el} by Eric M. Ludlam
10971 @cindex @file{speedbar.el}
10972 @cindex Ludlam, Eric M.
10973 Speedbar is a package that creates a special frame displaying files and
10974 index items in files.  Org mode supports Speedbar and allows you to
10975 drill into Org files directly from the Speedbar.  It also allows you to
10976 restrict the scope of agenda commands to a file or a subtree by using
10977 the command @kbd{<} in the Speedbar frame.
10978 @cindex @file{table.el}
10979 @item @file{table.el} by Takaaki Ota
10980 @kindex C-c C-c
10981 @cindex table editor, @file{table.el}
10982 @cindex @file{table.el}
10983 @cindex Ota, Takaaki
10985 Complex ASCII tables with automatic line wrapping, column- and
10986 row-spanning, and alignment can be created using the Emacs table
10987 package by Takaaki Ota (@uref{http://sourceforge.net/projects/table},
10988 and also part of Emacs 22).
10989 When @key{TAB} or @kbd{C-c C-c} is pressed in such a table, Org mode
10990 will call @command{table-recognize-table} and move the cursor into the
10991 table.  Inside a table, the keymap of Org mode is inactive.  In order
10992 to execute Org mode-related commands, leave the table.
10994 @table @kbd
10995 @kindex C-c C-c
10996 @item C-c C-c
10997 Recognize @file{table.el} table.  Works when the cursor is in a
10998 table.el table.
11000 @kindex C-c ~
11001 @item C-c ~
11002 Insert a @file{table.el} table.  If there is already a table at point, this
11003 command converts it between the @file{table.el} format and the Org-mode
11004 format.  See the documentation string of the command
11005 @code{org-convert-table} for the restrictions under which this is
11006 possible.
11007 @end table
11008 @file{table.el} is part of Emacs 22.
11009 @item @file{footnote.el} by Steven L. Baur
11010 @cindex @file{footnote.el}
11011 @cindex Baur, Steven L.
11012 Org mode recognizes numerical footnotes as provided by this package.
11013 However, Org mode also has its own footnote support (@pxref{Footnotes}),
11014 which makes using @file{footnote.el} unnecessary.
11015 @end table
11017 @node Conflicts,  , Cooperation, Interaction
11018 @subsection Packages that lead to conflicts with Org mode
11020 @table @asis
11022 @cindex @code{shift-selection-mode}
11023 @vindex org-support-shift-select
11024 In Emacs 23, @code{shift-selection-mode} is on by default, meaning that
11025 cursor motions combined with the shift key should start or enlarge regions.
11026 This conflicts with the use of @kbd{S-@key{cursor}} commands in Org to change
11027 timestamps, TODO keywords, priorities, and item bullet types if the cursor is
11028 at such a location.  By default, @kbd{S-@key{cursor}} commands outside
11029 special contexts don't do anything, but you can customize the variable
11030 @code{org-support-shift-select}.  Org mode then tries to accommodate shift
11031 selection by (i) using it outside of the special contexts where special
11032 commands apply, and by (ii) extending an existing active region even if the
11033 cursor moves across a special context.
11035 @item @file{CUA.el} by Kim. F. Storm
11036 @cindex @file{CUA.el}
11037 @cindex Storm, Kim. F.
11038 @vindex org-replace-disputed-keys
11039 Key bindings in Org conflict with the @kbd{S-<cursor>} keys used by CUA mode
11040 (as well as @code{pc-select-mode} and @code{s-region-mode}) to select and extend the
11041 region.  In fact, Emacs 23 has this built-in in the form of
11042 @code{shift-selection-mode}, see previous paragraph.  If you are using Emacs
11043 23, you probably don't want to use another package for this purpose.  However,
11044 if you prefer to leave these keys to a different package while working in
11045 Org mode, configure the variable @code{org-replace-disputed-keys}.  When set,
11046 Org will move the following key bindings in Org files, and in the agenda
11047 buffer (but not during date selection).
11049 @example
11050 S-UP      ->  M-p             S-DOWN     ->  M-n
11051 S-LEFT    ->  M--             S-RIGHT    ->  M-+
11052 C-S-LEFT  ->  M-S--           C-S-RIGHT  ->  M-S-+
11053 @end example
11055 @vindex org-disputed-keys
11056 Yes, these are unfortunately more difficult to remember.  If you want
11057 to have other replacement keys, look at the variable
11058 @code{org-disputed-keys}.
11060 @item @file{yasnippet.el}
11061 @cindex @file{yasnippet.el}
11062 The way Org-mode binds the TAB key (binding to @code{[tab]} instead of
11063 @code{"\t"}) overrules yasnippets' access to this key.  The following code
11064 fixed this problem:
11066 @lisp
11067 (add-hook 'org-mode-hook
11068           (lambda ()
11069             (org-set-local 'yas/trigger-key [tab])
11070             (define-key yas/keymap [tab] 'yas/next-field-group)))
11071 @end lisp
11073 @item @file{windmove.el} by Hovav Shacham
11074 @cindex @file{windmove.el}
11075 This package also uses the @kbd{S-<cursor>} keys, so everything written
11076 in the paragraph above about CUA mode also applies here.
11078 @item @file{viper.el} by Michael Kifer
11079 @cindex @file{viper.el}
11080 @kindex C-c /
11081 Viper uses @kbd{C-c /} and therefore makes this key not access the
11082 corresponding Org-mode command @code{org-sparse-tree}.  You need to find
11083 another key for this command, or override the key in
11084 @code{viper-vi-global-user-map} with
11086 @lisp
11087 (define-key viper-vi-global-user-map "C-c /" 'org-sparse-tree)
11088 @end lisp
11090 @end table
11093 @node Hacking, MobileOrg, Miscellaneous, Top
11094 @appendix Hacking
11095 @cindex hacking
11097 This appendix covers some aspects where users can extend the functionality of
11098 Org.
11100 @menu
11101 * Hooks::                       Who to reach into Org's internals
11102 * Add-on packages::             Available extensions
11103 * Adding hyperlink types::      New custom link types
11104 * Context-sensitive commands::  How to add functionality to such commands
11105 * Tables in arbitrary syntax::  Orgtbl for La@TeX{} and other programs
11106 * Dynamic blocks::              Automatically filled blocks
11107 * Special agenda views::        Customized views
11108 * Extracting agenda information::  Postprocessing of agenda information
11109 * Using the property API::      Writing programs that use entry properties
11110 * Using the mapping API::       Mapping over all or selected entries
11111 @end menu
11113 @node Hooks, Add-on packages, Hacking, Hacking
11114 @section Hooks
11115 @cindex hooks
11117 Org has a large number of hook variables that can be used to add
11118 functionality.  This appendix about hacking is going to illustrate the
11119 use of some of them.  A complete list of all hooks with documentation is
11120 maintained by the Worg project and can be found at
11121 @uref{http://orgmode.org/worg/org-configs/org-hooks.php}.
11123 @node Add-on packages, Adding hyperlink types, Hooks, Hacking
11124 @section Add-on packages
11125 @cindex add-on packages
11127 A large number of add-on packages have been written by various authors.
11128 These packages are not part of Emacs, but they are distributed as contributed
11129 packages with the separate release available at the Org mode home page at
11130 @uref{http://orgmode.org}.  The list of contributed packages, along with
11131 documentation about each package, is maintained by the Worg project at
11132 @uref{http://orgmode.org/worg/org-contrib/}.
11136 @node Adding hyperlink types, Context-sensitive commands, Add-on packages, Hacking
11137 @section Adding hyperlink types
11138 @cindex hyperlinks, adding new types
11140 Org has a large number of hyperlink types built-in
11141 (@pxref{Hyperlinks}).  If you would like to add new link types, Org
11142 provides an interface for doing so.  Let's look at an example file,
11143 @file{org-man.el}, that will add support for creating links like
11144 @samp{[[man:printf][The printf manpage]]} to show Unix manual pages inside
11145 Emacs:
11147 @lisp
11148 ;;; org-man.el - Support for links to manpages in Org
11150 (require 'org)
11152 (org-add-link-type "man" 'org-man-open)
11153 (add-hook 'org-store-link-functions 'org-man-store-link)
11155 (defcustom org-man-command 'man
11156   "The Emacs command to be used to display a man page."
11157   :group 'org-link
11158   :type '(choice (const man) (const woman)))
11160 (defun org-man-open (path)
11161   "Visit the manpage on PATH.
11162 PATH should be a topic that can be thrown at the man command."
11163   (funcall org-man-command path))
11165 (defun org-man-store-link ()
11166   "Store a link to a manpage."
11167   (when (memq major-mode '(Man-mode woman-mode))
11168     ;; This is a man page, we do make this link
11169     (let* ((page (org-man-get-page-name))
11170            (link (concat "man:" page))
11171            (description (format "Manpage for %s" page)))
11172       (org-store-link-props
11173        :type "man"
11174        :link link
11175        :description description))))
11177 (defun org-man-get-page-name ()
11178   "Extract the page name from the buffer name."
11179   ;; This works for both `Man-mode' and `woman-mode'.
11180   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
11181       (match-string 1 (buffer-name))
11182     (error "Cannot create link to this man page")))
11184 (provide 'org-man)
11186 ;;; org-man.el ends here
11187 @end lisp
11189 @noindent
11190 You would activate this new link type in @file{.emacs} with
11192 @lisp
11193 (require 'org-man)
11194 @end lisp
11196 @noindent
11197 Let's go through the file and see what it does.
11198 @enumerate
11199 @item
11200 It does @code{(require 'org)} to make sure that @file{org.el} has been
11201 loaded.
11202 @item
11203 The next line calls @code{org-add-link-type} to define a new link type
11204 with prefix @samp{man}.  The call also contains the name of a function
11205 that will be called to follow such a link.
11206 @item
11207 @vindex org-store-link-functions
11208 The next line adds a function to @code{org-store-link-functions}, in
11209 order to allow the command @kbd{C-c l} to record a useful link in a
11210 buffer displaying a man page.
11211 @end enumerate
11213 The rest of the file defines the necessary variables and functions.
11214 First there is a customization variable that determines which Emacs
11215 command should be used to display man pages.  There are two options,
11216 @code{man} and @code{woman}.  Then the function to follow a link is
11217 defined.  It gets the link path as an argument---in this case the link
11218 path is just a topic for the manual command.  The function calls the
11219 value of @code{org-man-command} to display the man page.
11221 Finally the function @code{org-man-store-link} is defined.  When you try
11222 to store a link with @kbd{C-c l}, this function will be called to
11223 try to make a link.  The function must first decide if it is supposed to
11224 create the link for this buffer type; we do this by checking the value
11225 of the variable @code{major-mode}.  If not, the function must exit and
11226 return the value @code{nil}.  If yes, the link is created by getting the
11227 manual topic from the buffer name and prefixing it with the string
11228 @samp{man:}.  Then it must call the command @code{org-store-link-props}
11229 and set the @code{:type} and @code{:link} properties.  Optionally you
11230 can also set the @code{:description} property to provide a default for
11231 the link description when the link is later inserted into an Org
11232 buffer with @kbd{C-c C-l}.
11234 When is makes sense for your new link type, you may also define a function
11235 @code{org-PREFIX-complete-link} that implements special (e.g. completion)
11236 support for inserting such a link with @kbd{C-c C-l}.  Such a function should
11237 not accept any arguments, and return the full link with prefix.
11239 @node Context-sensitive commands, Tables in arbitrary syntax, Adding hyperlink types, Hacking
11240 @section Context-sensitive commands
11241 @cindex context-sensitive commands, hooks
11242 @cindex add-ons, context-sensitive commands
11243 @vindex org-ctrl-c-ctrl-c-hook
11245 Org has several commands that act differently depending on context.  The most
11246 important example it the @kbd{C-c C-c} (@pxref{The very busy C-c C-c key}).
11247 Also the @kbd{M-cursor} and @kbd{M-S-cursor} keys have this property.
11249 Add-ons can tap into this functionality by providing a function that detects
11250 special context for that add-on and executes functionality appropriate for
11251 the context.  Here is an example from Dan Davison's @file{org-R.el} which
11252 allows you to evaluate commands based on the @file{R} programming language.  For
11253 this package, special contexts are lines that start with @code{#+R:} or
11254 @code{#+RR:}.
11256 @lisp
11257 (defun org-R-apply-maybe ()
11258   "Detect if this is context for org-R and execute R commands."
11259   (if (save-excursion
11260         (beginning-of-line 1)
11261         (looking-at "#\\+RR?:"))
11262       (progn (call-interactively 'org-R-apply)
11263              t) ;; to signal that we took action
11264     nil)) ;; to signal that we did not
11266 (add-hook 'org-ctrl-c-ctrl-c-hook 'org-R-apply-maybe)
11267 @end lisp
11269 The function first checks if the cursor is in such a line.  If that is the
11270 case, @code{org-R-apply} is called and the function returns @code{t} to
11271 signal that action was taken, and @kbd{C-c C-c} will stop looking for other
11272 contexts.  If the function finds it should do nothing locally, it returns @code{nil} so that other, similar functions can have a try.
11275 @node Tables in arbitrary syntax, Dynamic blocks, Context-sensitive commands, Hacking
11276 @section Tables and lists in arbitrary syntax
11277 @cindex tables, in other modes
11278 @cindex lists, in other modes
11279 @cindex Orgtbl mode
11281 Since Orgtbl mode can be used as a minor mode in arbitrary buffers, a
11282 frequent feature request has been to make it work with native tables in
11283 specific languages, for example La@TeX{}.  However, this is extremely
11284 hard to do in a general way, would lead to a customization nightmare,
11285 and would take away much of the simplicity of the Orgtbl-mode table
11286 editor.
11289 This appendix describes a different approach.  We keep the Orgtbl mode
11290 table in its native format (the @i{source table}), and use a custom
11291 function to @i{translate} the table to the correct syntax, and to
11292 @i{install} it in the right location (the @i{target table}).  This puts
11293 the burden of writing conversion functions on the user, but it allows
11294 for a very flexible system.
11296 Bastien added the ability to do the same with lists.  You can use Org's
11297 facilities to edit and structure lists by turning @code{orgstruct-mode}
11298 on, then locally exporting such lists in another format (HTML, La@TeX{}
11299 or Texinfo.)
11302 @menu
11303 * Radio tables::                Sending and receiving radio tables
11304 * A LaTeX example::             Step by step, almost a tutorial
11305 * Translator functions::        Copy and modify
11306 * Radio lists::                 Doing the same for lists
11307 @end menu
11309 @node Radio tables, A LaTeX example, Tables in arbitrary syntax, Tables in arbitrary syntax
11310 @subsection Radio tables
11311 @cindex radio tables
11313 To define the location of the target table, you first need to create two
11314 lines that are comments in the current mode, but contain magic words for
11315 Orgtbl mode to find.  Orgtbl mode will insert the translated table
11316 between these lines, replacing whatever was there before.  For example:
11318 @example
11319 /* BEGIN RECEIVE ORGTBL table_name */
11320 /* END RECEIVE ORGTBL table_name */
11321 @end example
11323 @noindent
11324 Just above the source table, we put a special line that tells
11325 Orgtbl mode how to translate this table and where to install it.  For
11326 example:
11327 @cindex #+ORGTBL
11328 @example
11329 #+ORGTBL: SEND table_name translation_function arguments....
11330 @end example
11332 @noindent
11333 @code{table_name} is the reference name for the table that is also used
11334 in the receiver lines. @code{translation_function} is the Lisp function
11335 that does the translation.  Furthermore, the line can contain a list of
11336 arguments (alternating key and value) at the end.  The arguments will be
11337 passed as a property list to the translation function for
11338 interpretation.  A few standard parameters are already recognized and
11339 acted upon before the translation function is called:
11341 @table @code
11342 @item :skip N
11343 Skip the first N lines of the table.  Hlines do count as separate lines for
11344 this parameter!
11346 @item :skipcols (n1 n2 ...)
11347 List of columns that should be skipped.  If the table has a column with
11348 calculation marks, that column is automatically discarded as well.
11349 Please note that the translator function sees the table @emph{after} the
11350 removal of these columns, the function never knows that there have been
11351 additional columns.
11352 @end table
11354 @noindent
11355 The one problem remaining is how to keep the source table in the buffer
11356 without disturbing the normal workings of the file, for example during
11357 compilation of a C file or processing of a La@TeX{} file.  There are a
11358 number of different solutions:
11360 @itemize @bullet
11361 @item
11362 The table could be placed in a block comment if that is supported by the
11363 language.  For example, in C mode you could wrap the table between
11364 @samp{/*} and @samp{*/} lines.
11365 @item
11366 Sometimes it is possible to put the table after some kind of @i{END}
11367 statement, for example @samp{\bye} in @TeX{} and @samp{\end@{document@}}
11368 in La@TeX{}.
11369 @item
11370 You can just comment the table line-by-line whenever you want to process
11371 the file, and uncomment it whenever you need to edit the table.  This
11372 only sounds tedious---the command @kbd{M-x orgtbl-toggle-comment}
11373 makes this comment-toggling very easy, in particular if you bind it to a
11374 key.
11375 @end itemize
11377 @node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
11378 @subsection A La@TeX{} example of radio tables
11379 @cindex La@TeX{}, and Orgtbl mode
11381 The best way to wrap the source table in La@TeX{} is to use the
11382 @code{comment} environment provided by @file{comment.sty}.  It has to be
11383 activated by placing @code{\usepackage@{comment@}} into the document
11384 header.  Orgtbl mode can insert a radio table skeleton@footnote{By
11385 default this works only for La@TeX{}, HTML, and Texinfo.  Configure the
11386 variable @code{orgtbl-radio-tables} to install templates for other
11387 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
11388 be prompted for a table name, let's say we use @samp{salesfigures}.  You
11389 will then get the following template:
11391 @cindex #+ORGTBL, SEND
11392 @example
11393 % BEGIN RECEIVE ORGTBL salesfigures
11394 % END RECEIVE ORGTBL salesfigures
11395 \begin@{comment@}
11396 #+ORGTBL: SEND salesfigures orgtbl-to-latex
11397 | | |
11398 \end@{comment@}
11399 @end example
11401 @noindent
11402 @vindex La@TeX{}-verbatim-environments
11403 The @code{#+ORGTBL: SEND} line tells Orgtbl mode to use the function
11404 @code{orgtbl-to-latex} to convert the table into La@TeX{} and to put it
11405 into the receiver location with name @code{salesfigures}.  You may now
11406 fill in the table, feel free to use the spreadsheet features@footnote{If
11407 the @samp{#+TBLFM} line contains an odd number of dollar characters,
11408 this may cause problems with font-lock in La@TeX{} mode.  As shown in the
11409 example you can fix this by adding an extra line inside the
11410 @code{comment} environment that is used to balance the dollar
11411 expressions.  If you are using AUC@TeX{} with the font-latex library, a
11412 much better solution is to add the @code{comment} environment to the
11413 variable @code{LaTeX-verbatim-environments}.}:
11415 @example
11416 % BEGIN RECEIVE ORGTBL salesfigures
11417 % END RECEIVE ORGTBL salesfigures
11418 \begin@{comment@}
11419 #+ORGTBL: SEND salesfigures orgtbl-to-latex
11420 | Month | Days | Nr sold | per day |
11421 |-------+------+---------+---------|
11422 | Jan   |   23 |      55 |     2.4 |
11423 | Feb   |   21 |      16 |     0.8 |
11424 | March |   22 |     278 |    12.6 |
11425 #+TBLFM: $4=$3/$2;%.1f
11426 % $ (optional extra dollar to keep font-lock happy, see footnote)
11427 \end@{comment@}
11428 @end example
11430 @noindent
11431 When you are done, press @kbd{C-c C-c} in the table to get the converted
11432 table inserted between the two marker lines.
11434 Now let's assume you want to make the table header by hand, because you
11435 want to control how columns are aligned, etc@.  In this case we make sure
11436 that the table translator skips the first 2 lines of the source
11437 table, and tell the command to work as a @i{splice}, i.e. to not produce
11438 header and footer commands of the target table:
11440 @example
11441 \begin@{tabular@}@{lrrr@}
11442 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
11443 % BEGIN RECEIVE ORGTBL salesfigures
11444 % END RECEIVE ORGTBL salesfigures
11445 \end@{tabular@}
11447 \begin@{comment@}
11448 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
11449 | Month | Days | Nr sold | per day |
11450 |-------+------+---------+---------|
11451 | Jan   |   23 |      55 |     2.4 |
11452 | Feb   |   21 |      16 |     0.8 |
11453 | March |   22 |     278 |    12.6 |
11454 #+TBLFM: $4=$3/$2;%.1f
11455 \end@{comment@}
11456 @end example
11458 The La@TeX{} translator function @code{orgtbl-to-latex} is already part of
11459 Orgtbl mode.  It uses a @code{tabular} environment to typeset the table
11460 and marks horizontal lines with @code{\hline}.  Furthermore, it
11461 interprets the following parameters (see also @pxref{Translator functions}):
11463 @table @code
11464 @item :splice nil/t
11465 When set to t, return only table body lines, don't wrap them into a
11466 tabular environment.  Default is nil.
11468 @item :fmt fmt
11469 A format to be used to wrap each field, it should contain @code{%s} for the
11470 original field value.  For example, to wrap each field value in dollars,
11471 you could use @code{:fmt "$%s$"}.  This may also be a property list with
11472 column numbers and formats. for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
11473 A function of one argument can be used in place of the strings; the
11474 function must return a formatted string.
11476 @item :efmt efmt
11477 Use this format to print numbers with exponentials.  The format should
11478 have @code{%s} twice for inserting mantissa and exponent, for example
11479 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
11480 may also be a property list with column numbers and formats, for example
11481 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
11482 @code{efmt} has been applied to a value, @code{fmt} will also be
11483 applied.  Similar to @code{fmt}, functions of two arguments can be
11484 supplied instead of strings.
11485 @end table
11487 @node Translator functions, Radio lists, A LaTeX example, Tables in arbitrary syntax
11488 @subsection Translator functions
11489 @cindex HTML, and Orgtbl mode
11490 @cindex translator function
11492 Orgtbl mode has several translator functions built-in: @code{orgtbl-to-csv}
11493 (comma-separated values), @code{orgtbl-to-tsv} (TAB-separated values)
11494 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and @code{orgtbl-to-texinfo}.
11495 Except for @code{orgtbl-to-html}@footnote{The HTML translator uses the same
11496 code that produces tables during HTML export.}, these all use a generic
11497 translator, @code{orgtbl-to-generic}.  For example, @code{orgtbl-to-latex}
11498 itself is a very short function that computes the column definitions for the
11499 @code{tabular} environment, defines a few field and line separators and then
11500 hands processing over to the generic translator.  Here is the entire code:
11502 @lisp
11503 @group
11504 (defun orgtbl-to-latex (table params)
11505   "Convert the Orgtbl mode TABLE to LaTeX."
11506   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
11507                                org-table-last-alignment ""))
11508          (params2
11509           (list
11510            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
11511            :tend "\\end@{tabular@}"
11512            :lstart "" :lend " \\\\" :sep " & "
11513            :efmt "%s\\,(%s)" :hline "\\hline")))
11514     (orgtbl-to-generic table (org-combine-plists params2 params))))
11515 @end group
11516 @end lisp
11518 As you can see, the properties passed into the function (variable
11519 @var{PARAMS}) are combined with the ones newly defined in the function
11520 (variable @var{PARAMS2}).  The ones passed into the function (i.e. the
11521 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
11522 would like to use the La@TeX{} translator, but wanted the line endings to
11523 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
11524 overrule the default with
11526 @example
11527 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
11528 @end example
11530 For a new language, you can either write your own converter function in
11531 analogy with the La@TeX{} translator, or you can use the generic function
11532 directly.  For example, if you have a language where a table is started
11533 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
11534 started with @samp{!BL!}, ended with @samp{!EL!}, and where the field
11535 separator is a TAB, you could call the generic translator like this (on
11536 a single line!):
11538 @example
11539 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
11540                               :lstart "!BL! " :lend " !EL!" :sep "\t"
11541 @end example
11543 @noindent
11544 Please check the documentation string of the function
11545 @code{orgtbl-to-generic} for a full list of parameters understood by
11546 that function, and remember that you can pass each of them into
11547 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
11548 using the generic function.
11550 Of course you can also write a completely new function doing complicated
11551 things the generic translator cannot do.  A translator function takes
11552 two arguments.  The first argument is the table, a list of lines, each
11553 line either the symbol @code{hline} or a list of fields.  The second
11554 argument is the property list containing all parameters specified in the
11555 @samp{#+ORGTBL: SEND} line.  The function must return a single string
11556 containing the formatted table.  If you write a generally useful
11557 translator, please post it on @email{emacs-orgmode@@gnu.org} so that
11558 others can benefit from your work.
11560 @node  Radio lists,  , Translator functions, Tables in arbitrary syntax
11561 @subsection Radio lists
11562 @cindex radio lists
11563 @cindex org-list-insert-radio-list
11565 Sending and receiving radio lists works exactly the same way than sending and
11566 receiving radio tables (@pxref{Radio tables}).  As for radio tables, you can
11567 insert radio lists templates in HTML, La@TeX{} and Texinfo modes by calling
11568 @code{org-list-insert-radio-list}.
11570 Here are the differences with radio tables:
11572 @itemize @minus
11573 @item
11574 Use @code{ORGLST} instead of @code{ORGTBL}.
11575 @item
11576 The available translation functions for radio lists don't take
11577 parameters.
11578 @item
11579 @kbd{C-c C-c} will work when pressed on the first item of the list.
11580 @end itemize
11582 Here is a La@TeX{} example.  Let's say that you have this in your
11583 La@TeX{} file:
11585 @cindex #+ORGLIST
11586 @example
11587 % BEGIN RECEIVE ORGLST to-buy
11588 % END RECEIVE ORGLST to-buy
11589 \begin@{comment@}
11590 #+ORGLIST: SEND to-buy orgtbl-to-latex
11591 - a new house
11592 - a new computer
11593   + a new keyboard
11594   + a new mouse
11595 - a new life
11596 \end@{comment@}
11597 @end example
11599 Pressing `C-c C-c' on @code{a new house} and will insert the converted
11600 La@TeX{} list between the two marker lines.
11602 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Hacking
11603 @section Dynamic blocks
11604 @cindex dynamic blocks
11606 Org documents can contain @emph{dynamic blocks}.  These are
11607 specially marked regions that are updated by some user-written function.
11608 A good example for such a block is the clock table inserted by the
11609 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
11611 Dynamic block are enclosed by a BEGIN-END structure that assigns a name
11612 to the block and can also specify parameters for the function producing
11613 the content of the block.
11615 #+BEGIN:dynamic block
11616 @example
11617 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
11619 #+END:
11620 @end example
11622 Dynamic blocks are updated with the following commands
11624 @table @kbd
11625 @kindex C-c C-x C-u
11626 @item C-c C-x C-u
11627 Update dynamic block at point.
11628 @kindex C-u C-c C-x C-u
11629 @item C-u C-c C-x C-u
11630 Update all dynamic blocks in the current file.
11631 @end table
11633 Updating a dynamic block means to remove all the text between BEGIN and
11634 END, parse the BEGIN line for parameters and then call the specific
11635 writer function for this block to insert the new content.  If you want
11636 to use the original content in the writer function, you can use the
11637 extra parameter @code{:content}.
11639 For a block with name @code{myblock}, the writer function is
11640 @code{org-dblock-write:myblock} with as only parameter a property list
11641 with the parameters given in the begin line.  Here is a trivial example
11642 of a block that keeps track of when the block update function was last
11643 run:
11645 @example
11646 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
11648 #+END:
11649 @end example
11651 @noindent
11652 The corresponding block writer function could look like this:
11654 @lisp
11655 (defun org-dblock-write:block-update-time (params)
11656    (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
11657      (insert "Last block update at: "
11658              (format-time-string fmt (current-time)))))
11659 @end lisp
11661 If you want to make sure that all dynamic blocks are always up-to-date,
11662 you could add the function @code{org-update-all-dblocks} to a hook, for
11663 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
11664 written in a way such that it does nothing in buffers that are not in
11665 @code{org-mode}.
11667 @node Special agenda views, Extracting agenda information, Dynamic blocks, Hacking
11668 @section Special agenda views
11669 @cindex agenda views, user-defined
11671 Org provides a special hook that can be used to narrow down the
11672 selection made by any of the agenda views.  You may specify a function
11673 that is used at each match to verify if the match should indeed be part
11674 of the agenda view, and if not, how much should be skipped.
11676 Let's say you want to produce a list of projects that contain a WAITING
11677 tag anywhere in the project tree.  Let's further assume that you have
11678 marked all tree headings that define a project with the TODO keyword
11679 PROJECT.  In this case you would run a TODO search for the keyword
11680 PROJECT, but skip the match unless there is a WAITING tag anywhere in
11681 the subtree belonging to the project line.
11683 To achieve this, you must write a function that searches the subtree for
11684 the tag.  If the tag is found, the function must return @code{nil} to
11685 indicate that this match should not be skipped.  If there is no such
11686 tag, return the location of the end of the subtree, to indicate that
11687 search should continue from there.
11689 @lisp
11690 (defun my-skip-unless-waiting ()
11691   "Skip trees that are not waiting"
11692   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
11693     (if (re-search-forward ":waiting:" subtree-end t)
11694         nil          ; tag found, do not skip
11695       subtree-end))) ; tag not found, continue after end of subtree
11696 @end lisp
11698 Now you may use this function in an agenda custom command, for example
11699 like this:
11701 @lisp
11702 (org-add-agenda-custom-command
11703  '("b" todo "PROJECT"
11704    ((org-agenda-skip-function 'my-skip-unless-waiting)
11705     (org-agenda-overriding-header "Projects waiting for something: "))))
11706 @end lisp
11708 @vindex org-agenda-overriding-header
11709 Note that this also binds @code{org-agenda-overriding-header} to get a
11710 meaningful header in the agenda view.
11712 @vindex org-odd-levels-only
11713 @vindex org-agenda-skip-function
11714 A general way to create custom searches is to base them on a search for
11715 entries with a certain level limit.  If you want to study all entries with
11716 your custom search function, simply do a search for
11717 @samp{LEVEL>0}@footnote{Note that, when using @code{org-odd-levels-only}, a
11718 level number corresponds to order in the hierarchy, not to the number of
11719 stars.}, and then use @code{org-agenda-skip-function} to select the entries
11720 you really want to have.
11722 You may also put a Lisp form into @code{org-agenda-skip-function}.  In
11723 particular, you may use the functions @code{org-agenda-skip-entry-if}
11724 and @code{org-agenda-skip-subtree-if} in this form, for example:
11726 @table @code
11727 @item '(org-agenda-skip-entry-if 'scheduled)
11728 Skip current entry if it has been scheduled.
11729 @item '(org-agenda-skip-entry-if 'notscheduled)
11730 Skip current entry if it has not been scheduled.
11731 @item '(org-agenda-skip-entry-if 'deadline)
11732 Skip current entry if it has a deadline.
11733 @item '(org-agenda-skip-entry-if 'scheduled 'deadline)
11734 Skip current entry if it has a deadline, or if it is scheduled.
11735 @item '(org-agenda-skip-entry-if 'timestamp)
11736 Skip current entry if it has any timestamp, may also be deadline or scheduled.
11737 @item '(org-agenda-skip-entry 'regexp "regular expression")
11738 Skip current entry if the regular expression matches in the entry.
11739 @item '(org-agenda-skip-entry 'notregexp "regular expression")
11740 Skip current entry unless the regular expression matches.
11741 @item '(org-agenda-skip-subtree-if 'regexp "regular expression")
11742 Same as above, but check and skip the entire subtree.
11743 @end table
11745 Therefore we could also have written the search for WAITING projects
11746 like this, even without defining a special function:
11748 @lisp
11749 (org-add-agenda-custom-command
11750  '("b" todo "PROJECT"
11751    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
11752                                 'regexp ":waiting:"))
11753     (org-agenda-overriding-header "Projects waiting for something: "))))
11754 @end lisp
11756 @node Extracting agenda information, Using the property API, Special agenda views, Hacking
11757 @section Extracting agenda information
11758 @cindex agenda, pipe
11759 @cindex Scripts, for agenda processing
11761 @vindex org-agenda-custom-commands
11762 Org provides commands to access agenda information for the command
11763 line in Emacs batch mode.  This extracted information can be sent
11764 directly to a printer, or it can be read by a program that does further
11765 processing of the data.  The first of these commands is the function
11766 @code{org-batch-agenda}, that produces an agenda view and sends it as
11767 ASCII text to STDOUT.  The command takes a single string as parameter.
11768 If the string has length 1, it is used as a key to one of the commands
11769 you have configured in @code{org-agenda-custom-commands}, basically any
11770 key you can use after @kbd{C-c a}.  For example, to directly print the
11771 current TODO list, you could use
11773 @example
11774 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
11775 @end example
11777 If the parameter is a string with 2 or more characters, it is used as a
11778 tags/TODO match string.  For example, to print your local shopping list
11779 (all items with the tag @samp{shop}, but excluding the tag
11780 @samp{NewYork}), you could use
11782 @example
11783 emacs -batch -l ~/.emacs                                      \
11784       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
11785 @end example
11787 @noindent
11788 You may also modify parameters on the fly like this:
11790 @example
11791 emacs -batch -l ~/.emacs                                      \
11792    -eval '(org-batch-agenda "a"                               \
11793             org-agenda-ndays 30                               \
11794             org-agenda-include-diary nil                      \
11795             org-agenda-files (quote ("~/org/project.org")))'  \
11796    | lpr
11797 @end example
11799 @noindent
11800 which will produce a 30-day agenda, fully restricted to the Org file
11801 @file{~/org/projects.org}, not even including the diary.
11803 If you want to process the agenda data in more sophisticated ways, you
11804 can use the command @code{org-batch-agenda-csv} to get a comma-separated
11805 list of values for each agenda item.  Each line in the output will
11806 contain a number of fields separated by commas.  The fields in a line
11807 are:
11809 @example
11810 category     @r{The category of the item}
11811 head         @r{The headline, without TODO keyword, TAGS and PRIORITY}
11812 type         @r{The type of the agenda entry, can be}
11813                 todo               @r{selected in TODO match}
11814                 tagsmatch          @r{selected in tags match}
11815                 diary              @r{imported from diary}
11816                 deadline           @r{a deadline}
11817                 scheduled          @r{scheduled}
11818                 timestamp          @r{appointment, selected by timestamp}
11819                 closed             @r{entry was closed on date}
11820                 upcoming-deadline  @r{warning about nearing deadline}
11821                 past-scheduled     @r{forwarded scheduled item}
11822                 block              @r{entry has date block including date}
11823 todo         @r{The TODO keyword, if any}
11824 tags         @r{All tags including inherited ones, separated by colons}
11825 date         @r{The relevant date, like 2007-2-14}
11826 time         @r{The time, like 15:00-16:50}
11827 extra        @r{String with extra planning info}
11828 priority-l   @r{The priority letter if any was given}
11829 priority-n   @r{The computed numerical priority}
11830 @end example
11832 @noindent
11833 Time and date will only be given if a timestamp (or deadline/scheduled)
11834 led to the selection of the item.
11836 A CSV list like this is very easy to use in a post-processing script.
11837 For example, here is a Perl program that gets the TODO list from
11838 Emacs/Org and prints all the items, preceded by a checkbox:
11840 @example
11841 #!/usr/bin/perl
11843 # define the Emacs command to run
11844 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
11846 # run it and capture the output
11847 $agenda = qx@{$cmd 2>/dev/null@};
11849 # loop over all lines
11850 foreach $line (split(/\n/,$agenda)) @{
11851   # get the individual values
11852   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
11853    $priority_l,$priority_n) = split(/,/,$line);
11854   # process and print
11855   print "[ ] $head\n";
11857 @end example
11859 @node Using the property API, Using the mapping API, Extracting agenda information, Hacking
11860 @section Using the property API
11861 @cindex API, for properties
11862 @cindex properties, API
11864 Here is a description of the functions that can be used to work with
11865 properties.
11867 @defun org-entry-properties &optional pom which
11868 Get all properties of the entry at point-or-marker POM.@*
11869 This includes the TODO keyword, the tags, time strings for deadline,
11870 scheduled, and clocking, and any additional properties defined in the
11871 entry.  The return value is an alist, keys may occur multiple times
11872 if the property key was used several times.@*
11873 POM may also be nil, in which case the current entry is used.
11874 If WHICH is nil or `all', get all properties.  If WHICH is
11875 `special' or `standard', only get that subclass.
11876 @end defun
11877 @vindex org-use-property-inheritance
11878 @defun org-entry-get pom property &optional inherit
11879 Get value of PROPERTY for entry at point-or-marker POM.  By default,
11880 this only looks at properties defined locally in the entry.  If INHERIT
11881 is non-nil and the entry does not have the property, then also check
11882 higher levels of the hierarchy.  If INHERIT is the symbol
11883 @code{selective}, use inheritance if and only if the setting of
11884 @code{org-use-property-inheritance} selects PROPERTY for inheritance.
11885 @end defun
11887 @defun org-entry-delete pom property
11888 Delete the property PROPERTY from entry at point-or-marker POM.
11889 @end defun
11891 @defun org-entry-put pom property value
11892 Set PROPERTY to VALUE for entry at point-or-marker POM.
11893 @end defun
11895 @defun org-buffer-property-keys &optional include-specials
11896 Get all property keys in the current buffer.
11897 @end defun
11899 @defun org-insert-property-drawer
11900 Insert a property drawer at point.
11901 @end defun
11903 @defun org-entry-put-multivalued-property pom property &rest values
11904 Set PROPERTY at point-or-marker POM to VALUES.  VALUES should be a list of
11905 strings.  They will be concatenated, with spaces as separators.
11906 @end defun
11908 @defun org-entry-get-multivalued-property pom property
11909 Treat the value of the property PROPERTY as a whitespace-separated list of
11910 values and return the values as a list of strings.
11911 @end defun
11913 @defun org-entry-add-to-multivalued-property pom property value
11914 Treat the value of the property PROPERTY as a whitespace-separated list of
11915 values and make sure that VALUE is in this list.
11916 @end defun
11918 @defun org-entry-remove-from-multivalued-property pom property value
11919 Treat the value of the property PROPERTY as a whitespace-separated list of
11920 values and make sure that VALUE is @emph{not} in this list.
11921 @end defun
11923 @defun org-entry-member-in-multivalued-property pom property value
11924 Treat the value of the property PROPERTY as a whitespace-separated list of
11925 values and check if VALUE is in this list.
11926 @end defun
11928 @node Using the mapping API,  , Using the property API, Hacking
11929 @section Using the mapping API
11930 @cindex API, for mapping
11931 @cindex mapping entries, API
11933 Org has sophisticated mapping capabilities to find all entries satisfying
11934 certain criteria.  Internally, this functionality is used to produce agenda
11935 views, but there is also an API that can be used to execute arbitrary
11936 functions for each or selected entries.  The main entry point for this API
11939 @defun org-map-entries func &optional match scope &rest skip
11940 Call FUNC at each headline selected by MATCH in SCOPE.
11942 FUNC is a function or a Lisp form.  The function will be called without
11943 arguments, with the cursor positioned at the beginning of the headline.
11944 The return values of all calls to the function will be collected and
11945 returned as a list.
11947 The call to FUNC will be wrapped into a save-excursion form, so FUNC
11948 does not need to preserve point.  After evaluation, the cursor will be
11949 moved to the end of the line (presumably of the headline of the
11950 processed entry) and search continues from there.  Under some
11951 circumstances, this may not produce the wanted results.  For example,
11952 if you have removed (e.g. archived) the current (sub)tree it could
11953 mean that the next entry will be skipped entirely.  In such cases, you
11954 can specify the position from where search should continue by making
11955 FUNC set the variable `org-map-continue-from' to the desired buffer
11956 position.
11958 MATCH is a tags/property/todo match as it is used in the agenda match view.
11959 Only headlines that are matched by this query will be considered during
11960 the iteration.  When MATCH is nil or t, all headlines will be
11961 visited by the iteration.
11963 SCOPE determines the scope of this command.  It can be any of:
11965 @example
11966 nil     @r{the current buffer, respecting the restriction if any}
11967 tree    @r{the subtree started with the entry at point}
11968 file    @r{the current buffer, without restriction}
11969 file-with-archives
11970         @r{the current buffer, and any archives associated with it}
11971 agenda  @r{all agenda files}
11972 agenda-with-archives
11973         @r{all agenda files with any archive files associated with them}
11974 (file1 file2 ...)
11975         @r{if this is a list, all files in the list will be scanned}
11976 @end example
11977 @noindent
11978 The remaining args are treated as settings for the skipping facilities of
11979 the scanner.  The following items can be given here:
11981 @vindex org-agenda-skip-function
11982 @example
11983 archive   @r{skip trees with the archive tag}
11984 comment   @r{skip trees with the COMMENT keyword}
11985 function or Lisp form
11986           @r{will be used as value for @code{org-agenda-skip-function},}
11987           @r{so whenever the function returns t, FUNC}
11988           @r{will not be called for that entry and search will}
11989           @r{continue from the point where the function leaves it}
11990 @end example
11991 @end defun
11993 The function given to that mapping routine can really do anything you like.
11994 It can use the property API (@pxref{Using the property API}) to gather more
11995 information about the entry, or in order to change metadata in the entry.
11996 Here are a couple of functions that might be handy:
11998 @defun org-todo &optional arg
11999 Change the TODO state of the entry, see the docstring of the functions for
12000 the many possible values for the argument ARG.
12001 @end defun
12003 @defun org-priority &optional action
12004 Change the priority of the entry, see the docstring of this function for the
12005 possible values for ACTION.
12006 @end defun
12008 @defun org-toggle-tag tag &optional onoff
12009 Toggle the tag TAG in the current entry.  Setting ONOFF to either @code{on}
12010 or @code{off} will not toggle tag, but ensure that it is either on or off.
12011 @end defun
12013 @defun org-promote
12014 Promote the current entry.
12015 @end defun
12017 @defun org-demote
12018 Demote the current entry.
12019 @end defun
12021 Here is a simple example that will turn all entries in the current file with
12022 a tag @code{TOMORROW} into TODO entries with the keyword @code{UPCOMING}.
12023 Entries in comment trees and in archive trees will be ignored.
12025 @lisp
12026 (org-map-entries
12027    '(org-todo "UPCOMING")
12028    "+TOMORROW" 'file 'archive 'comment)
12029 @end lisp
12031 The following example counts the number of entries with TODO keyword
12032 @code{WAITING}, in all agenda files.
12034 @lisp
12035 (length (org-map-entries t "/+WAITING" 'agenda))
12036 @end lisp
12038 @node MobileOrg, History and Acknowledgments, Hacking, Top
12039 @appendix MobileOrg
12040 @cindex iPhone
12041 @cindex MobileOrg
12043 @i{MobileOrg} is an application for the @i{iPhone/iPod Touch} series of
12044 devices, developed by Richard Moreland.  @i{MobileOrg} offers offline viewing
12045 and capture support for an Org-mode system rooted on a ``real'' computer.  It
12046 does also allow you to record changes to existing entries.  For information
12047 about @i{MobileOrg}, see @uref{http://mobileorg.ncogni.to/}).
12049 This appendix describes the support Org has for creating agenda views in a
12050 format that can be displayed by @i{MobileOrg}, and for integrating notes
12051 captured and changes made by @i{MobileOrg} into the main system.
12053 For changing tags and TODO states in MobileOrg, you should have set up the
12054 customization variables @code{org-todo-keywords} and @code{org-tags-alist} to
12055 cover all important tags and todo keywords, even if individual files use only
12056 part of these.  MobileOrg will also offer you states and tags set up with
12057 in-buffer settings, but it will understand the logistics of todo state
12058 @i{sets} (@pxref{Per-file keywords}) and @i{mutually exclusive} tags
12059 (@pxref{Setting tags}) only for those set in these variables.
12061 @menu
12062 * Setting up the staging area::  Where to interact with the mobile device
12063 * Pushing to MobileOrg::        Uploading Org files and agendas
12064 * Pulling from MobileOrg::      Integrating captured and flagged items
12065 @end menu
12067 @node Setting up the staging area, Pushing to MobileOrg, MobileOrg, MobileOrg
12068 @section Setting up the staging area
12070 Org-mode has commands to prepare a directory with files for @i{MobileOrg},
12071 and to read captured notes from there.  If Emacs can directly write to the
12072 WebDAV directory accessed by @i{MobileOrg}, just point to this directory
12073 using the variable @code{org-mobile-directory}.  Using the @file{tramp}
12074 method, @code{org-mobile-directory} may point to a remote directory
12075 accessible through, for example, 
12076 @file{ssh/scp}:
12078 @smallexample
12079 (setq org-mobile-directory "/scpc:user@@remote.host:org/webdav/")
12080 @end smallexample
12082 If Emacs cannot access the WebDAV directory directly using a @file{tramp}
12083 method, or you prefer to maintain a local copy, you can use a local directory
12084 for staging.  Other means must then be used to keep this directory in sync
12085 with the WebDAV directory.  In the following example, files are staged in
12086 @file{~/stage}, and Org-mode hooks take care of moving files to and from the
12087 WebDAV directory using @file{scp}.
12089 @smallexample
12090 (setq org-mobile-directory "~/stage/")
12091 (add-hook 'org-mobile-post-push-hook
12092   (lambda () (shell-command "scp -r ~/stage/* user@@wdhost:mobile/")))
12093 (add-hook 'org-mobile-pre-pull-hook
12094   (lambda () (shell-command "scp user@@wdhost:mobile/mobileorg.org ~/stage/ ")))
12095 (add-hook 'org-mobile-post-pull-hook
12096   (lambda () (shell-command "scp ~/stage/mobileorg.org user@@wdhost:mobile/")))
12097 @end smallexample
12099 @node Pushing to MobileOrg, Pulling from MobileOrg, Setting up the staging area, MobileOrg
12100 @section Pushing to MobileOrg
12102 This operation copies all files currently listed in @code{org-mobile-files}
12103 to the directory @code{org-mobile-directory}.  By default this list contains
12104 all agenda files (as listed in @code{org-agenda-files}), but additional files
12105 can be included by customizing @code{org-mobiles-files}.  File names will be
12106 staged with path relative to @code{org-directory}, so all files should be
12107 inside this directory.  The push operation also creates (in the same
12108 directory) a special Org file @file{agendas.org}.  This file is an Org-mode
12109 style outline, containing every custom agenda view defined by the user.
12110 While creating the agendas, Org-mode will force@footnote{See the variable
12111 @code{org-mobile-force-id-on-agenda-items}.}  an ID property on all entries
12112 referenced by the agendas, so that these entries can be uniquely identified
12113 if @i{MobileOrg} flags them for further action.  Finally, Org writes the file
12114 @file{index.org}, containing links to all other files.  If @i{MobileOrg} is
12115 configured to request this file from the WebDAV server, all agendas and Org
12116 files will be downloaded to the device.  To speed up the download, MobileOrg
12117 will only read files whose checksums@footnote{stored automatically in the
12118 file @file{checksums.dat}} have changed.
12120 @node Pulling from MobileOrg,  , Pushing to MobileOrg, MobileOrg
12121 @section Pulling from MobileOrg
12123 When @i{MobileOrg} synchronizes with the WebDAV server, it not only pulls the
12124 Org files for viewing.  It also appends captured entries and pointers to
12125 flagged and changed entries to the file @file{mobileorg.org} on the server.
12126 Org has a @emph{pull} operation that integrates this information into an
12127 inbox file and operates on the pointers to flagged entries.  Here is how it
12128 works:
12130 @enumerate
12131 @item
12132 Org moves all entries found in
12133 @file{mobileorg.org}@footnote{@file{mobileorg.org} will be empty after this
12134 operation.} and appends them to the file pointed to by the variable
12135 @code{org-mobile-inbox-for-pull}.  Each captured entry and each editing event
12136 will be a top-level entry in the inbox file.
12137 @item
12138 After moving the entries, Org will attempt to implement the changes made in
12139 @i{MobileOrg}.  Some changes are applied directly and without user
12140 interaction.  Examples are all changes to tags, TODO state, headline and body
12141 text that can be cleanly applied.  Entries that have been flagged for further
12142 action will receive a tag @code{:FLAGGED:}, so that they can be easily found
12143 again.  When there is a problem finding an entry or applying the change, the
12144 pointer entry will remain in the inbox and will be marked with an error
12145 message.  You need to later resolve these issues by hand.
12146 @item
12147 Org will then generate an agenda view with all flagged entries.  The user
12148 should then go through these entries and do whatever actions are necessary.
12149 If a note has been stored while flagging an entry in @i{MobileOrg}, that note
12150 will be displayed in the echo area when the cursor is on the corresponding
12151 agenda line.
12152 @table @kbd
12153 @kindex ?
12154 @item ?
12155 Pressing @kbd{?} in that special agenda will display the full flagging note in
12156 another window and also push it onto the kill ring.  So you could use @kbd{?
12157 z C-y C-c C-c} to store that flagging note as a normal note in the entry.
12158 Pressing @kbd{?} twice in succession will offer to remove the
12159 @code{:FLAGGED:} tag along with the recorded flagging note (which is stored
12160 in a property).  In this way you indicate, that the intended processing for
12161 this flagged entry is finished.
12162 @end table
12163 @end enumerate
12165 @kindex C-c a ?
12166 If you are not able to process all flagged entries directly, you can always
12167 return to this agenda view using @kbd{C-c a ?}.  Note, however, that there is
12168 a subtle difference.  The view created automatically by @kbd{M-x
12169 org-mobile-pull RET} is guaranteed to search all files that have been
12170 addressed by the last pull.  This might include a file that is not currently
12171 in your list of agenda files.  If you later use @kbd{C-c a ?} to regenerate
12172 the view, only the current agenda files will be searched.
12174 @node History and Acknowledgments, Main Index, MobileOrg, Top
12175 @appendix History and Acknowledgments
12176 @cindex acknowledgements
12177 @cindex history
12178 @cindex thanks
12180 Org was born in 2003, out of frustration over the user interface
12181 of the Emacs Outline mode.  I was trying to organize my notes and
12182 projects, and using Emacs seemed to be the natural way to go.  However,
12183 having to remember eleven different commands with two or three keys per
12184 command, only to hide and show parts of the outline tree, that seemed
12185 entirely unacceptable to me.  Also, when using outlines to take notes, I
12186 constantly wanted to restructure the tree, organizing it parallel to my
12187 thoughts and plans.  @emph{Visibility cycling} and @emph{structure
12188 editing} were originally implemented in the package
12189 @file{outline-magic.el}, but quickly moved to the more general
12190 @file{org.el}.  As this environment became comfortable for project
12191 planning, the next step was adding @emph{TODO entries}, basic
12192 @emph{timestamps}, and @emph{table support}.  These areas highlighted the two main
12193 goals that Org still has today: to be a new, outline-based,
12194 plain text mode with innovative and intuitive editing features, and to
12195 incorporate project planning functionality directly into a notes file.
12197 A special thanks goes to @i{Bastien Guerry} who has not only written a large
12198 number of extensions to Org (most of them integrated into the core by now),
12199 but who has also helped in the development and maintenance of Org so much that he
12200 should be considered the main co-contributor to this package.
12202 Since the first release, literally thousands of emails to me or to
12203 @email{emacs-orgmode@@gnu.org} have provided a constant stream of bug
12204 reports, feedback, new ideas, and sometimes patches and add-on code.
12205 Many thanks to everyone who has helped to improve this package.  I am
12206 trying to keep here a list of the people who had significant influence
12207 in shaping one or more aspects of Org.  The list may not be
12208 complete, if I have forgotten someone, please accept my apologies and
12209 let me know.
12211 @itemize @bullet
12213 @item
12214 @i{Russel Adams} came up with the idea for drawers.
12215 @item
12216 @i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}.
12217 @item
12218 @i{Christophe Bataillon} created the great unicorn logo that we use on the
12219 Org-mode website.
12220 @item
12221 @i{Alex Bochannek} provided a patch for rounding timestamps.
12222 @item
12223 @i{Brad Bozarth} showed how to pull RSS feed data into Org-mode files.
12224 @item
12225 @i{Tom Breton} wrote @file{org-choose.el}.
12226 @item
12227 @i{Charles Cave}'s suggestion sparked the implementation of templates
12228 for Remember.
12229 @item
12230 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
12231 specified time.
12232 @item
12233 @i{Gregory Chernov} patched support for Lisp forms into table
12234 calculations and improved XEmacs compatibility, in particular by porting
12235 @file{nouline.el} to XEmacs.
12236 @item
12237 @i{Sacha Chua} suggested copying some linking code from Planner.
12238 @item
12239 @i{Baoqiu Cui} contributed the DocBook exporter.
12240 @item
12241 @i{Dan Davison} wrote (together with @i{Eric Schulte}) Org Babel.
12242 @item
12243 @i{Eddward DeVilla} proposed and tested checkbox statistics.  He also
12244 came up with the idea of properties, and that there should be an API for
12245 them.
12246 @item
12247 @i{Nick Dokos} tracked down several nasty bugs.
12248 @item
12249 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
12250 inspired some of the early development, including HTML export.  He also
12251 asked for a way to narrow wide table columns.
12252 @item
12253 @i{Christian Egli} converted the documentation into Texinfo format,
12254 patched CSS formatting into the HTML exporter, and inspired the agenda.
12255 @item
12256 @i{David Emery} provided a patch for custom CSS support in exported
12257 HTML agendas.
12258 @item
12259 @i{Nic Ferrier} contributed mailcap and XOXO support.
12260 @item
12261 @i{Miguel A. Figueroa-Villanueva} implemented hierarchical checkboxes.
12262 @item
12263 @i{John Foerch} figured out how to make incremental search show context
12264 around a match in a hidden outline tree.
12265 @item
12266 @i{Raimar Finken} wrote @file{org-git-line.el}.
12267 @item
12268 @i{Mikael Fornius} works as a mailing list moderator.
12269 @item
12270 @i{Austin Frank} works as a mailing list moderator.
12271 @item
12272 @i{Niels Giesen} had the idea to automatically archive DONE trees.
12273 @item
12274 @i{Bastien Guerry} wrote the La@TeX{} exporter and @file{org-bibtex.el}, and
12275 has been prolific with patches, ideas, and bug reports.
12276 @item
12277 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
12278 @item
12279 @i{Bernt Hansen} has driven much of the support for auto-repeating tasks,
12280 task state change logging, and the clocktable.  His clear explanations have
12281 been critical when we started to adopt the Git version control system.
12282 @item
12283 @i{Manuel Hermenegildo} has contributed various ideas, small fixes and
12284 patches.
12285 @item
12286 @i{Phil Jackson} wrote @file{org-irc.el}.
12287 @item
12288 @i{Scott Jaderholm} proposed footnotes, control over whitespace between
12289 folded entries, and column view for properties.
12290 @item
12291 @i{Tokuya Kameshima} wrote @file{org-wl.el} and @file{org-mew.el}.
12292 @item
12293 @i{Shidai Liu} ("Leo") asked for embedded La@TeX{} and tested it.  He also
12294 provided frequent feedback and some patches.
12295 @item
12296 @i{Matt Lundin} has proposed last-row references for table formulas and named
12297 invisible anchors.  He has also worked a lot on the FAQ.
12298 @item
12299 @i{Jason F. McBrayer} suggested agenda export to CSV format.
12300 @item
12301 @i{Max Mikhanosha} came up with the idea of refiling.
12302 @item
12303 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
12304 basis.
12305 @item
12306 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
12307 happy.
12308 @item
12309 @i{Richard Moreland} wrote @i{MobileOrg} for the iPhone.
12310 @item
12311 @i{Rick Moynihan} proposed allowing multiple TODO sequences in a file
12312 and being able to quickly restrict the agenda to a subtree.
12313 @item
12314 @i{Todd Neal} provided patches for links to Info files and Elisp forms.
12315 @item
12316 @i{Greg Newman} refreshed the unicorn logo into its current form.
12317 @item
12318 @i{Tim O'Callaghan} suggested in-file links, search options for general
12319 file links, and TAGS.
12320 @item
12321 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
12322 into Japanese.
12323 @item
12324 @i{Oliver Oppitz} suggested multi-state TODO items.
12325 @item
12326 @i{Scott Otterson} sparked the introduction of descriptive text for
12327 links, among other things.
12328 @item
12329 @i{Pete Phillips} helped during the development of the TAGS feature, and
12330 provided frequent feedback.
12331 @item
12332 @i{Martin Pohlack} provided the code snippet to bundle character insertion
12333 into bundles of 20 for undo.
12334 @item
12335 @i{T.V. Raman} reported bugs and suggested improvements.
12336 @item
12337 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
12338 control.
12339 @item
12340 @i{Paul Rivier} provided the basic implementation of named footnotes.  He
12341 also acted as mailing list moderator for some time.
12342 @item
12343 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
12344 @item
12345 @i{Sebastian Rose} wrote @file{org-info.js}, a Java script for displaying
12346 webpages derived from Org using an Info-like or a folding interface with
12347 single-key navigation.
12348 @item
12349 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
12350 conflict with @file{allout.el}.
12351 @item
12352 @i{Jason Riedy} generalized the send-receive mechanism for Orgtbl tables with
12353 extensive patches.
12354 @item
12355 @i{Philip Rooke} created the Org reference card, provided lots
12356 of feedback, developed and applied standards to the Org documentation.
12357 @item
12358 @i{Christian Schlauer} proposed angular brackets around links, among
12359 other things.
12360 @item
12361 @i{Eric Schulte} wrote @file{org-plot.el} and (together with @i{Dan Davison})
12362 Org Babel, and contributed various patches, small features and modules.
12363 @item
12364 Linking to VM/BBDB/Gnus was first inspired by @i{Tom Shannon}'s
12365 @file{organizer-mode.el}.
12366 @item
12367 @i{Ilya Shlyakhter} proposed the Archive Sibling, line numbering in literal
12368 examples, and remote highlighting for referenced code lines.
12369 @item
12370 @i{Stathis Sideris} wrote the @file{ditaa.jar} ASCII to PNG converter that is
12371 now packaged into Org's @file{contrib} directory.
12372 @item
12373 @i{Daniel Sinder} came up with the idea of internal archiving by locking
12374 subtrees.
12375 @item
12376 @i{Dale Smith} proposed link abbreviations.
12377 @item
12378 @i{James TD Smith} has contributed a large number of patches for useful
12379 tweaks and features.
12380 @item
12381 @i{Adam Spiers} asked for global linking commands, inspired the link
12382 extension system, added support for mairix, and proposed the mapping API.
12383 @item
12384 @i{Andy Stewart} contributed code to @file{org-w3m.el}, to copy HTML content
12385 with links transformation to Org syntax.
12386 @item
12387 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
12388 chapter about publishing.
12389 @item
12390 @i{J@"urgen Vollmer} contributed code generating the table of contents
12391 in HTML output.
12392 @item
12393 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
12394 keyword.
12395 @item
12396 @i{David Wainberg} suggested archiving, and improvements to the linking
12397 system.
12398 @item
12399 @i{John Wiegley} wrote @file{emacs-wiki.el}, @file{planner.el}, and
12400 @file{muse.el}, which have some overlap with Org.  Initially the development
12401 of Org was fully independent because I was not aware of the existence of
12402 these packages.  But with time I have occasionally looked at John's code and
12403 learned a lot from it.  John has also contributed a number of great ideas and
12404 patches directly to Org, including the attachment system
12405 (@file{org-attach.el}), integration with Apple Mail
12406 (@file{org-mac-message.el}), hierarchical dependencies of TODO items, habit
12407 tracking (@file{org-habits.el}) and support for pcomplete.
12408 @item
12409 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
12410 linking to Gnus.
12411 @item
12412 @i{Roland Winkler} requested additional key bindings to make Org
12413 work on a tty.
12414 @item
12415 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
12416 and contributed various ideas and code snippets.
12417 @end itemize
12420 @node Main Index, Key Index, History and Acknowledgments, Top
12421 @unnumbered Concept Index
12423 @printindex cp
12425 @node Key Index, Variable Index, Main Index, Top
12426 @unnumbered Key Index
12428 @printindex ky
12430 @node Variable Index,  , Key Index, Top
12431 @unnumbered Variable Index
12433 This is not a complete index of variables and faces, only the ones that are
12434 mentioned in the manual.  For a more complete list, use @kbd{M-x
12435 org-customize @key{RET}} and then click yourself through the tree.
12437 @printindex vr
12439 @bye
12441 @ignore
12442         arch-tag: 7893d1Fe-cc57-4d13-b5e5-f494a1CBC7ac
12443 @end ignore
12445 @c Local variables:
12446 @c ispell-local-dictionary: "en_US-w_accents"
12447 @c ispell-local-pdict: "./.aspell.org.pws"
12448 @c fill-column: 77
12449 @c End:
12452 @c  LocalWords:  webdavhost pre