Release 6.19e
[org-mode.git] / doc / org.texi
blobf12087f11817a147af1c7797ad3c43a9c357793d
1 \input texinfo
2 @c %**start of header
3 @setfilename ../../info/org
4 @settitle The Org Manual
6 @set VERSION 6.19e
7 @set DATE January 2009
9 @dircategory Emacs
10 @direntry
11 * Org Mode: (org).      Outline-based notes management and organizer
12 @end direntry
14 @c Version and Contact Info
15 @set MAINTAINERSITE @uref{http://orgmode.org,maintainers webpage}
16 @set AUTHOR Carsten Dominik
17 @set MAINTAINER Carsten Dominik
18 @set MAINTAINEREMAIL @email{carsten at orgmode dot org}
19 @set MAINTAINERCONTACT @uref{mailto:carsten at orgmode dot org,contact the maintainer}
20 @c %**end of header
21 @finalout
23 @c Macro definitions
25 @c Subheadings inside a table.
26 @macro tsubheading{text}
27 @ifinfo
28 @subsubheading \text\
29 @end ifinfo
30 @ifnotinfo
31 @item @b{\text\}
32 @end ifnotinfo
33 @end macro
35 @copying
36 This manual is for Org (version @value{VERSION}).
38 Copyright @copyright{} 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation
40 @quotation
41 Permission is granted to copy, distribute and/or modify this document
42 under the terms of the GNU Free Documentation License, Version 1.3 or
43 any later version published by the Free Software Foundation; with no
44 Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
45 and with the Back-Cover Texts as in (a) below.  A copy of the license
46 is included in the section entitled ``GNU Free Documentation License.''
48 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
49 modify this GNU manual.  Buying copies from the FSF supports it in
50 developing GNU and promoting software freedom.''
52 This document is part of a collection distributed under the GNU Free
53 Documentation License.  If you want to distribute this document
54 separately from the collection, you can do so by adding a copy of the
55 license to the document, as described in section 6 of the license.
56 @end quotation
57 @end copying
59 @titlepage
60 @title The Org Manual
62 @subtitle Release @value{VERSION}
63 @author by Carsten Dominik
65 @c The following two commands start the copyright page.
66 @page
67 @vskip 0pt plus 1filll
68 @insertcopying
69 @end titlepage
71 @c Output the table of contents at the beginning.
72 @contents
74 @ifnottex
75 @node Top, Introduction, (dir), (dir)
76 @top Org Mode Manual
78 @insertcopying
79 @end ifnottex
81 @menu
82 * Introduction::                Getting started
83 * Document Structure::          A tree works like your brain
84 * Tables::                      Pure magic for quick formatting
85 * Hyperlinks::                  Notes in context
86 * TODO Items::                  Every tree branch can be a TODO item
87 * Tags::                        Tagging headlines and matching sets of tags
88 * Properties and Columns::      Storing information about an entry
89 * Dates and Times::             Making items useful for planning
90 * Capture::                     Creating tasks and attaching files
91 * Agenda Views::                Collecting information into views
92 * Embedded LaTeX::              LaTeX fragments and formulas
93 * Exporting::                   Sharing and publishing of notes
94 * Publishing::                  Create a web site of linked Org files
95 * Miscellaneous::               All the rest which did not fit elsewhere
96 * Extensions::                  Add-ons for Org mode
97 * Hacking::                     How to hack your way around
98 * History and Acknowledgments::  How Org came into being
99 * Main Index::                  An index of Org's concepts and features
100 * Key Index::                   Key bindings and where they are described
102 @detailmenu
103  --- The Detailed Node Listing ---
105 Introduction
107 * Summary::                     Brief summary of what Org does
108 * Installation::                How to install a downloaded version of Org
109 * Activation::                  How to activate Org for certain buffers
110 * Feedback::                    Bug reports, ideas, patches etc.
111 * Conventions::                 Type-setting conventions in the manual
113 Document Structure
115 * Outlines::                    Org is based on Outline mode
116 * Headlines::                   How to typeset Org tree headlines
117 * Visibility cycling::          Show and hide, much simplified
118 * Motion::                      Jumping to other headlines
119 * Structure editing::           Changing sequence and level of headlines
120 * Archiving::                   Move done task trees to a different place
121 * Sparse trees::                Matches embedded in context
122 * Plain lists::                 Additional structure within an entry
123 * Drawers::                     Tucking stuff away
124 * Footnotes::                   How footnotes are defined in Org's syntax
125 * Orgstruct mode::              Structure editing outside Org
127 Archiving
129 * ARCHIVE tag::                 Marking a tree as inactive
130 * Moving subtrees::             Moving a tree to an archive file
132 Tables
134 * Built-in table editor::       Simple tables
135 * Narrow columns::              Stop wasting space in tables
136 * Column groups::               Grouping to trigger vertical lines
137 * Orgtbl mode::                 The table editor as minor mode
138 * The spreadsheet::             The table editor has spreadsheet capabilities
139 * Org Plot::                    Plotting from org tables
141 The spreadsheet
143 * References::                  How to refer to another field or range
144 * Formula syntax for Calc::     Using Calc to compute stuff
145 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
146 * Field formulas::              Formulas valid for a single field
147 * Column formulas::             Formulas valid for an entire column
148 * Editing and debugging formulas::  Fixing formulas
149 * Updating the table::          Recomputing all dependent fields
150 * Advanced features::           Field names, parameters and automatic recalc
152 Hyperlinks
154 * Link format::                 How links in Org are formatted
155 * Internal links::              Links to other places in the current file
156 * External links::              URL-like links to the world
157 * Handling links::              Creating, inserting and following
158 * Using links outside Org::     Linking from my C source code?
159 * Link abbreviations::          Shortcuts for writing complex links
160 * Search options::              Linking to a specific location
161 * Custom searches::             When the default search is not enough
163 Internal links
165 * Radio targets::               Make targets trigger links in plain text
167 TODO Items
169 * TODO basics::                 Marking and displaying TODO entries
170 * TODO extensions::             Workflow and assignments
171 * Progress logging::            Dates and notes for progress
172 * Priorities::                  Some things are more important than others
173 * Breaking down tasks::         Splitting a task into manageable pieces
174 * Checkboxes::                  Tick-off lists
176 Extended use of TODO keywords
178 * Workflow states::             From TODO to DONE in steps
179 * TODO types::                  I do this, Fred does the rest
180 * Multiple sets in one file::   Mixing it all, and still finding your way
181 * Fast access to TODO states::  Single letter selection of a state
182 * Per-file keywords::           Different files, different requirements
183 * Faces for TODO keywords::     Highlighting states
185 Progress logging
187 * Closing items::               When was this entry marked DONE?
188 * Tracking TODO state changes::  When did the status change?
190 Tags
192 * Tag inheritance::             Tags use the tree structure of the outline
193 * Setting tags::                How to assign tags to a headline
194 * Tag searches::                Searching for combinations of tags
196 Properties and Columns
198 * Property syntax::             How properties are spelled out
199 * Special properties::          Access to other Org mode features
200 * Property searches::           Matching property values
201 * Property inheritance::        Passing values down the tree
202 * Column view::                 Tabular viewing and editing
203 * Property API::                Properties for Lisp programmers
205 Column view
207 * Defining columns::            The COLUMNS format property
208 * Using column view::           How to create and use column view
209 * Capturing column view::       A dynamic block for column view
211 Defining columns
213 * Scope of column definitions::  Where defined, where valid?
214 * Column attributes::           Appearance and content of a column
216 Dates and Times
218 * Timestamps::                  Assigning a time to a tree entry
219 * Creating timestamps::         Commands which insert timestamps
220 * Deadlines and scheduling::    Planning your work
221 * Clocking work time::          Tracking how long you spend on a task
222 * Effort estimates::            Planning work effort in advance
223 * Relative timer::              Notes with a running timer
225 Creating timestamps
227 * The date/time prompt::        How Org mode helps you entering date and time
228 * Custom time format::          Making dates look different
230 Deadlines and scheduling
232 * Inserting deadline/schedule::  Planning items
233 * Repeated tasks::              Items that show up again and again
235 Capture
237 * Remember::                    Capture new tasks/ideas with little interruption
238 * Attachments::                 Add files to tasks.
240 Remember
242 * Setting up Remember::         Some code for .emacs to get things going
243 * Remember templates::          Define the outline of different note types
244 * Storing notes::               Directly get the note to where it belongs
245 * Refiling notes::              Moving a note or task to a project
247 Agenda Views
249 * Agenda files::                Files being searched for agenda information
250 * Agenda dispatcher::           Keyboard access to agenda views
251 * Built-in agenda views::       What is available out of the box?
252 * Presentation and sorting::    How agenda items are prepared for display
253 * Agenda commands::             Remote editing of Org trees
254 * Custom agenda views::         Defining special searches and views
255 * Agenda column view::          Using column view for collected entries
257 The built-in agenda views
259 * Weekly/daily agenda::         The calendar page with current tasks
260 * Global TODO list::            All unfinished action items
261 * Matching tags and properties::  Structured information with fine-tuned search
262 * Timeline::                    Time-sorted view for single file
263 * Keyword search::              Finding entries by keyword
264 * Stuck projects::              Find projects you need to review
266 Presentation and sorting
268 * Categories::                  Not all tasks are equal
269 * Time-of-day specifications::  How the agenda knows the time
270 * Sorting of agenda items::     The order of things
272 Custom agenda views
274 * Storing searches::            Type once, use often
275 * Block agenda::                All the stuff you need in a single buffer
276 * Setting Options::             Changing the rules
277 * Exporting Agenda Views::      Writing agendas to files
278 * Using the agenda elsewhere::  Using agenda information in other programs
280 Embedded LaTeX
282 * Math symbols::                TeX macros for symbols and Greek letters
283 * Subscripts and superscripts::  Simple syntax for raising/lowering text
284 * LaTeX fragments::             Complex formulas made easy
285 * Processing LaTeX fragments::  Previewing LaTeX processing
286 * CDLaTeX mode::                Speed up entering of formulas
288 Exporting
290 * Markup rules::                Which structures are recognized?
291 * Selective export::            Using tags to select and exclude trees
292 * Export options::              Per-file export settings
293 * The export dispatcher::       How to access exporter commands
294 * ASCII export::                Exporting to plain ASCII
295 * HTML export::                 Exporting to HTML
296 * LaTeX and PDF export::        Exporting to LaTeX, and processing to PDF
297 * XOXO export::                 Exporting to XOXO
298 * iCalendar export::            Exporting in iCalendar format
300 Markup rules
302 * Document title::              How the document title is determined
303 * Headings and sections::       The main structure of the exported document
304 * Table of contents::           If, where, how to create a table of contents
305 * Initial text::                Text before the first headline
306 * Lists::                       Plain lists are exported
307 * Paragraphs::                  What determines beginning and ending
308 * Literal examples::            Source code and other examples
309 * Include files::               Include the contents of a file during export
310 * Tables exported::             Tables are exported richly
311 * Inlined images::              How to inline images during export
312 * Footnote markup::             
313 * Emphasis and monospace::      To bold or not to bold
314 * TeX macros and LaTeX fragments::  Create special, rich export.
315 * Horizontal rules::            A line across the page
316 * Comment lines::               Some lines will not be exported
318 HTML export
320 * HTML Export commands::        How to invoke HTML export
321 * Quoting HTML tags::           Using direct HTML in Org mode
322 * Links::                       Transformation of links for HTML
323 * Images in HTML export::       How to insert figures into HTML output
324 * Text areas in HTML export::   An alternative way to show an example
325 * CSS support::                 Changing the appearance of the output
326 * Javascript support::          Info and Folding in a web browser
328 LaTeX and PDF export
330 * LaTeX/PDF export commands::   Which key invokes which commands
331 * Quoting LaTeX code::          Incorporating literal LaTeX code
332 * Sectioning structure::        Changing sectioning in LaTeX output
333 * Tables in LaTeX export::      Options for exporting tables to LaTeX
334 * Images in LaTeX export::      How to insert figures into LaTeX output
336 Publishing
338 * Configuration::               Defining projects
339 * Sample configuration::        Example projects
340 * Triggering publication::      Publication commands
342 Configuration
344 * Project alist::               The central configuration variable
345 * Sources and destinations::    From here to there
346 * Selecting files::             What files are part of the project?
347 * Publishing action::           Setting the function doing the publishing
348 * Publishing options::          Tweaking HTML export
349 * Publishing links::            Which links keep working after publishing?
350 * Project page index::          Publishing a list of project files
352 Sample configuration
354 * Simple example::              One-component publishing
355 * Complex example::             A multi-component publishing example
357 Miscellaneous
359 * Completion::                  M-TAB knows what you need
360 * Customization::               Adapting Org to your taste
361 * In-buffer settings::          Overview of the #+KEYWORDS
362 * The very busy C-c C-c key::   When in doubt, press C-c C-c
363 * Clean view::                  Getting rid of leading stars in the outline
364 * TTY keys::                    Using Org on a tty
365 * Interaction::                 Other Emacs packages
366 * Bugs::                        Things which do not work perfectly
368 Interaction with other packages
370 * Cooperation::                 Packages Org cooperates with
371 * Conflicts::                   Packages that lead to conflicts
373 Extensions
375 * Extensions in the contrib directory::  These come with the Org distro
376 * Other extensions::            These you have to find on the web.
378 Hacking
380 * Adding hyperlink types::      New custom link types
381 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
382 * Dynamic blocks::              Automatically filled blocks
383 * Special agenda views::        Customized views
384 * Using the property API::      Writing programs that use entry properties
385 * Using the mapping API::       Mapping over all or selected entries
387 Tables and lists in arbitrary syntax
389 * Radio tables::                Sending and receiving
390 * A LaTeX example::             Step by step, almost a tutorial
391 * Translator functions::        Copy and modify
392 * Radio lists::                 Doing the same for lists
394 @end detailmenu
395 @end menu
397 @node Introduction, Document Structure, Top, Top
398 @chapter Introduction
399 @cindex introduction
401 @menu
402 * Summary::                     Brief summary of what Org does
403 * Installation::                How to install a downloaded version of Org
404 * Activation::                  How to activate Org for certain buffers
405 * Feedback::                    Bug reports, ideas, patches etc.
406 * Conventions::                 Type-setting conventions in the manual
407 @end menu
409 @node Summary, Installation, Introduction, Introduction
410 @section Summary
411 @cindex summary
413 Org is a mode for keeping notes, maintaining TODO lists, and doing
414 project planning with a fast and effective plain-text system.
416 Org develops organizational tasks around NOTES files that contain
417 lists or information about projects as plain text.  Org is
418 implemented on top of Outline mode, which makes it possible to keep the
419 content of large files well structured.  Visibility cycling and
420 structure editing help to work with the tree.  Tables are easily created
421 with a built-in table editor.  Org supports TODO items, deadlines,
422 time stamps, and scheduling.  It dynamically compiles entries into an
423 agenda that utilizes and smoothly integrates much of the Emacs calendar
424 and diary.  Plain text URL-like links connect to websites, emails,
425 Usenet messages, BBDB entries, and any files related to the projects.
426 For printing and sharing of notes, an Org file can be exported as a
427 structured ASCII file, as HTML, or (TODO and agenda items only) as an
428 iCalendar file.  It can also serve as a publishing tool for a set of
429 linked web pages.
431 An important design aspect that distinguishes Org from for example
432 Planner/Muse is that it encourages to store every piece of information
433 only once.  In Planner, you have project pages, day pages and possibly
434 other files, duplicating some information such as tasks.  In Org,
435 you only have notes files.  In your notes you mark entries as tasks,
436 label them with tags and timestamps.  All necessary lists like a
437 schedule for the day, the agenda for a meeting, tasks lists selected by
438 tags etc are created dynamically when you need them.
440 Org keeps simple things simple.  When first fired up, it should
441 feel like a straightforward, easy to use outliner.  Complexity is not
442 imposed, but a large amount of functionality is available when you need
443 it.  Org is a toolbox and can be used in different ways, for
444 example as:
446 @example
447 @r{@bullet{} outline extension with visibility cycling and structure editing}
448 @r{@bullet{} ASCII system and table editor for taking structured notes}
449 @r{@bullet{} ASCII table editor with spreadsheet-like capabilities}
450 @r{@bullet{} TODO list editor}
451 @r{@bullet{} full agenda and planner with deadlines and work scheduling}
452 @r{@bullet{} environment to implement David Allen's GTD system}
453 @r{@bullet{} a basic database application}
454 @r{@bullet{} simple hypertext system, with HTML and LaTeX export}
455 @r{@bullet{} publishing tool to create a set of interlinked webpages}
456 @end example
458 Org's automatic, context sensitive table editor with spreadsheet
459 capabilities can be integrated into any major mode by activating the
460 minor Orgtbl mode.  Using a translation step, it can be used to maintain
461 tables in arbitrary file types, for example in La@TeX{}.  The structure
462 editing and list creation capabilities can be used outside Org with
463 the minor Orgstruct mode.
465 @cindex FAQ
466 There is a website for Org which provides links to the newest
467 version of Org, as well as additional information, frequently asked
468 questions (FAQ), links to tutorials etc.  This page is located at
469 @uref{http://orgmode.org}.
471 @page
474 @node Installation, Activation, Summary, Introduction
475 @section Installation
476 @cindex installation
477 @cindex XEmacs
479 @b{Important:} @i{If Org is part of the Emacs distribution or an
480 XEmacs package, please skip this section and go directly to
481 @ref{Activation}.}
483 If you have downloaded Org from the Web, either as a distribution @file{.zip}
484 or @file{.tar} file, or as a GIT archive, you must take the following steps
485 to install it: Go into the unpacked Org distribution directory and edit the
486 top section of the file @file{Makefile}.  You must set the name of the Emacs
487 binary (likely either @file{emacs} or @file{xemacs}), and the paths to the
488 directories where local Lisp and Info files are kept.  If you don't have
489 access to the system-wide directories, you can simply run Org directly from
490 the distribution directory by adding the @file{lisp} subdirectory to the
491 Emacs load path.  To do this, add the following line to @file{.emacs}:
493 @example
494 (setq load-path (cons "~/path/to/orgdir/lisp" load-path))
495 @end example
497 @noindent
498 If you plan to use code from the @file{contrib} subdirectory, do a similar
499 step for this directory:
501 @example
502 (setq load-path (cons "~/path/to/orgdir/contrib/lisp" load-path))
503 @end example
505 @b{XEmacs users now need to install the file @file{noutline.el} from
506 the @file{xemacs} sub-directory of the Org distribution.  Use the
507 command:}
509 @example
510 @b{make install-noutline}
511 @end example
513 @noindent Now byte-compile the Lisp files with the shell command:
515 @example
516 make
517 @end example
519 @noindent If you are running Org from the distribution directory, this is
520 all.  If you want to install into the system directories, use
522 @example
523 make install
524 make install-info
525 @end example
527 @noindent Then add to @file{.emacs}:
529 @lisp
530 ;; This line only if Org is not part of the X/Emacs distribution.
531 (require 'org-install)
532 @end lisp
534 Do not forget to activate Org as described in the following section.
536 @node Activation, Feedback, Installation, Introduction
537 @section Activation
538 @cindex activation
539 @cindex autoload
540 @cindex global key bindings
541 @cindex key bindings, global
543 @iftex
544 @b{Important:} @i{If you use copy-and-paste to copy lisp code from the
545 PDF documentation as viewed by some PDF viewers to your .emacs file, the
546 single quote character comes out incorrectly and the code will not work.
547 You need to fix the single quotes by hand, or copy from Info
548 documentation.}
549 @end iftex
551 Add the following lines to your @file{.emacs} file.  The last three lines
552 define @emph{global} keys for the commands @command{org-store-link},
553 @command{org-agenda}, and @command{org-iswitchb} - please choose suitable
554 keys yourself.
556 @lisp
557 ;; The following lines are always needed.  Choose your own keys.
558 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
559 (global-set-key "\C-cl" 'org-store-link)
560 (global-set-key "\C-ca" 'org-agenda)
561 (global-set-key "\C-cb" 'org-iswitchb)
562 @end lisp
564 Furthermore, you must activate @code{font-lock-mode} in Org
565 buffers, because significant functionality depends on font-locking being
566 active.  You can do this with either one of the following two lines
567 (XEmacs user must use the second option):
568 @lisp
569 (global-font-lock-mode 1)                     ; for all buffers
570 (add-hook 'org-mode-hook 'turn-on-font-lock)  ; Org buffers only
571 @end lisp
573 @cindex Org mode, turning on
574 With this setup, all files with extension @samp{.org} will be put
575 into Org mode.  As an alternative, make the first line of a file look
576 like this:
578 @example
579 MY PROJECTS    -*- mode: org; -*-
580 @end example
582 @noindent which will select Org mode for this buffer no matter what
583 the file's name is.  See also the variable
584 @code{org-insert-mode-line-in-empty-file}.
586 Many commands in Org work on the region is the region is active.  To make use
587 of this, you need to have @code{transient-mark-mode} (@code{zmacs-regions} in
588 XEmacs) turned on.  In Emacs 23 this is the default, in Emacs 22 you need to
589 do this yourself with
591 @lisp
592 (transient-mark-mode 1)
593 @end lisp
595 @node Feedback, Conventions, Activation, Introduction
596 @section Feedback
597 @cindex feedback
598 @cindex bug reports
599 @cindex maintainer
600 @cindex author
602 If you find problems with Org, or if you have questions, remarks, or ideas
603 about it, please mail to the Org mailing list @code{emacs-orgmode@@gnu.org}.
604 If you are not a member of the mailing list, your mail will be reviewed by a
605 moderator and then passed through to the list.
607 For bug reports, please provide as much information as possible,
608 including the version information of Emacs (@kbd{C-h v emacs-version
609 @key{RET}}) and Org (@kbd{C-h v org-version @key{RET}}), as well as
610 the Org related setup in @file{.emacs}.  If an error occurs, a
611 backtrace can be very useful (see below on how to create one).  Often a
612 small example file helps, along with clear information about:
614 @enumerate
615 @item What exactly did you do?
616 @item What did you expect to happen?
617 @item What happened instead?
618 @end enumerate
619 @noindent Thank you for helping to improve this mode.
621 @subsubheading How to create a useful backtrace
623 @cindex backtrace of an error
624 If working with Org produces an error with a message you don't
625 understand, you may have hit a bug.  The best way to report this is by
626 providing, in addition to what was mentioned above, a @emph{Backtrace}.
627 This is information from the built-in debugger about where and how the
628 error occurred.  Here is how to produce a useful backtrace:
630 @enumerate
631 @item
632 Start a fresh Emacs or XEmacs, and make sure that it will load the
633 original Lisp code in @file{org.el} instead of the compiled version in
634 @file{org.elc}.  The backtrace contains much more information if it is
635 produced with uncompiled code.  To do this, either rename @file{org.elc}
636 to something else before starting Emacs, or ask Emacs explicitly to load
637 @file{org.el} by using the command line
638 @example
639 emacs -l /path/to/org.el
640 @end example
641 @item
642 Go to the @code{Options} menu and select @code{Enter Debugger on Error}
643 (XEmacs has this option in the @code{Troubleshooting} sub-menu).
644 @item
645 Do whatever you have to do to hit the error.  Don't forget to
646 document the steps you take.
647 @item
648 When you hit the error, a @file{*Backtrace*} buffer will appear on the
649 screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
650 attach it to your bug report.
651 @end enumerate
653 @node Conventions,  , Feedback, Introduction
654 @section Typesetting conventions used in this manual
656 Org uses three types of keywords: TODO keywords, tags, and property
657 names.  In this manual we use the following conventions:
659 @table @code
660 @item TODO
661 @itemx WAITING
662 TODO keywords are written with all capitals, even if they are
663 user-defined.
664 @item boss
665 @itemx ARCHIVE
666 User-defined tags are written in lowercase; built-in tags with special
667 meaning are written with all capitals.
668 @item Release
669 @itemx PRIORITY
670 User-defined properties are capitalized; built-in properties with
671 special meaning are written with all capitals.
672 @end table
674 @node Document Structure, Tables, Introduction, Top
675 @chapter Document Structure
676 @cindex document structure
677 @cindex structure of document
679 Org is based on outline mode and provides flexible commands to
680 edit the structure of the document.
682 @menu
683 * Outlines::                    Org is based on Outline mode
684 * Headlines::                   How to typeset Org tree headlines
685 * Visibility cycling::          Show and hide, much simplified
686 * Motion::                      Jumping to other headlines
687 * Structure editing::           Changing sequence and level of headlines
688 * Archiving::                   Move done task trees to a different place
689 * Sparse trees::                Matches embedded in context
690 * Plain lists::                 Additional structure within an entry
691 * Drawers::                     Tucking stuff away
692 * Footnotes::                   How footnotes are defined in Org's syntax
693 * Orgstruct mode::              Structure editing outside Org
694 @end menu
696 @node Outlines, Headlines, Document Structure, Document Structure
697 @section Outlines
698 @cindex outlines
699 @cindex Outline mode
701 Org is implemented on top of Outline mode.  Outlines allow a
702 document to be organized in a hierarchical structure, which (at least
703 for me) is the best representation of notes and thoughts.  An overview
704 of this structure is achieved by folding (hiding) large parts of the
705 document to show only the general document structure and the parts
706 currently being worked on.  Org greatly simplifies the use of
707 outlines by compressing the entire show/hide functionality into a single
708 command @command{org-cycle}, which is bound to the @key{TAB} key.
710 @node Headlines, Visibility cycling, Outlines, Document Structure
711 @section Headlines
712 @cindex headlines
713 @cindex outline tree
715 Headlines define the structure of an outline tree.  The headlines in
716 Org start with one or more stars, on the left margin@footnote{See
717 the variable @code{org-special-ctrl-a/e} to configure special behavior
718 of @kbd{C-a} and @kbd{C-e} in headlines.}.  For example:
720 @example
721 * Top level headline
722 ** Second level
723 *** 3rd level
724     some text
725 *** 3rd level
726     more text
728 * Another top level headline
729 @end example
731 @noindent Some people find the many stars too noisy and would prefer an
732 outline that has whitespace followed by a single star as headline
733 starters.  @ref{Clean view} describes a setup to realize this.
735 An empty line after the end of a subtree is considered part of it and
736 will be hidden when the subtree is folded.  However, if you leave at
737 least two empty lines, one empty line will remain visible after folding
738 the subtree, in order to structure the collapsed view.  See the
739 variable @code{org-cycle-separator-lines} to modify this behavior.
741 @node Visibility cycling, Motion, Headlines, Document Structure
742 @section Visibility cycling
743 @cindex cycling, visibility
744 @cindex visibility cycling
745 @cindex trees, visibility
746 @cindex show hidden text
747 @cindex hide text
749 Outlines make it possible to hide parts of the text in the buffer.
750 Org uses just two commands, bound to @key{TAB} and
751 @kbd{S-@key{TAB}} to change the visibility in the buffer.
753 @cindex subtree visibility states
754 @cindex subtree cycling
755 @cindex folded, subtree visibility state
756 @cindex children, subtree visibility state
757 @cindex subtree, subtree visibility state
758 @table @kbd
759 @kindex @key{TAB}
760 @item @key{TAB}
761 @emph{Subtree cycling}: Rotate current subtree among the states
763 @example
764 ,-> FOLDED -> CHILDREN -> SUBTREE --.
765 '-----------------------------------'
766 @end example
768 The cursor must be on a headline for this to work@footnote{see, however,
769 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
770 beginning of the buffer and the first line is not a headline, then
771 @key{TAB} actually runs global cycling (see below)@footnote{see the
772 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
773 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
775 @cindex global visibility states
776 @cindex global cycling
777 @cindex overview, global visibility state
778 @cindex contents, global visibility state
779 @cindex show all, global visibility state
780 @kindex S-@key{TAB}
781 @item S-@key{TAB}
782 @itemx C-u @key{TAB}
783 @emph{Global cycling}: Rotate the entire buffer among the states
785 @example
786 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
787 '--------------------------------------'
788 @end example
790 When @kbd{S-@key{TAB}} is called with a numeric prefix argument N, the
791 CONTENTS view up to headlines of level N will be shown.  Note that inside
792 tables, @kbd{S-@key{TAB}} jumps to the previous field.
794 @cindex show all, command
795 @kindex C-u C-u C-u @key{TAB}
796 @item C-u C-u C-u @key{TAB}
797 Show all, including drawers.
798 @kindex C-c C-r
799 @item C-c C-r
800 Reveal context around point, showing the current entry, the following heading
801 and the hierarchy above.  Useful for working near a location that has been
802 exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda command
803 (@pxref{Agenda commands}).  With a prefix argument show, on each
804 level, all sibling headings.
805 @kindex C-c C-x b
806 @item C-c C-x b
807 Show the current subtree in an indirect buffer@footnote{The indirect
808 buffer
809 @ifinfo
810 (@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
811 @end ifinfo
812 @ifnotinfo
813 (see the Emacs manual for more information about indirect buffers)
814 @end ifnotinfo
815 will contain the entire buffer, but will be narrowed to the current
816 tree.  Editing the indirect buffer will also change the original buffer,
817 but without affecting visibility in that buffer.}.  With a numeric
818 prefix argument N, go up to level N and then take that tree.  If N is
819 negative then go up that many levels.  With a @kbd{C-u} prefix, do not remove
820 the previously used indirect buffer.
821 @end table
823 When Emacs first visits an Org file, the global state is set to
824 OVERVIEW, i.e. only the top level headlines are visible.  This can be
825 configured through the variable @code{org-startup-folded}, or on a
826 per-file basis by adding one of the following lines anywhere in the
827 buffer:
829 @example
830 #+STARTUP: overview
831 #+STARTUP: content
832 #+STARTUP: showall
833 @end example
835 @noindent
836 Furthermore, any entries with a @samp{VISIBILITY} property (@pxref{Properties
837 and Columns}) will get their visibility adapted accordingly.  Allowed values
838 for this property are @code{folded}, @code{children}, @code{content}, and
839 @code{all}.
840 @table @kbd
841 @kindex C-u C-u @key{TAB}
842 @item C-u C-u @key{TAB}
843 Switch back to the startup visibility of the buffer, i.e. whatever is
844 requested by startup options and @samp{VISIBILITY} properties in individual
845 entries.
846 @end table
848 @node Motion, Structure editing, Visibility cycling, Document Structure
849 @section Motion
850 @cindex motion, between headlines
851 @cindex jumping, to headlines
852 @cindex headline navigation
853 The following commands jump to other headlines in the buffer.
855 @table @kbd
856 @kindex C-c C-n
857 @item C-c C-n
858 Next heading.
859 @kindex C-c C-p
860 @item C-c C-p
861 Previous heading.
862 @kindex C-c C-f
863 @item C-c C-f
864 Next heading same level.
865 @kindex C-c C-b
866 @item C-c C-b
867 Previous heading same level.
868 @kindex C-c C-u
869 @item C-c C-u
870 Backward to higher level heading.
871 @kindex C-c C-j
872 @item C-c C-j
873 Jump to a different place without changing the current outline
874 visibility.  Shows the document structure in a temporary buffer, where
875 you can use the following keys to find your destination:
876 @example
877 @key{TAB}         @r{Cycle visibility.}
878 @key{down} / @key{up}   @r{Next/previous visible headline.}
879 @key{RET}         @r{Select this location.}
880 @kbd{/}           @r{Do a Sparse-tree search}
881 @r{The following keys work if you turn off @code{org-goto-auto-isearch}}
882 n / p        @r{Next/previous visible headline.}
883 f / b        @r{Next/previous headline same level.}
884 u            @r{One level up.}
885 0-9          @r{Digit argument.}
886 q            @r{Quit}
887 @end example
888 See also the variable@code{org-goto-interface}.
889 @end table
891 @node Structure editing, Archiving, Motion, Document Structure
892 @section Structure editing
893 @cindex structure editing
894 @cindex headline, promotion and demotion
895 @cindex promotion, of subtrees
896 @cindex demotion, of subtrees
897 @cindex subtree, cut and paste
898 @cindex pasting, of subtrees
899 @cindex cutting, of subtrees
900 @cindex copying, of subtrees
901 @cindex subtrees, cut and paste
903 @table @kbd
904 @kindex M-@key{RET}
905 @item M-@key{RET}
906 Insert new heading with same level as current.  If the cursor is in a
907 plain list item, a new item is created (@pxref{Plain lists}).  To force
908 creation of a new headline, use a prefix argument, or first press @key{RET}
909 to get to the beginning of the next line.  When this command is used in
910 the middle of a line, the line is split and the rest of the line becomes
911 the new headline@footnote{If you do not want the line to be split,
912 customize the variable @code{org-M-RET-may-split-line}.}.  If the
913 command is used at the beginning of a headline, the new headline is
914 created before the current line.  If at the beginning of any other line,
915 the content of that line is made the new heading.  If the command is
916 used at the end of a folded subtree (i.e. behind the ellipses at the end
917 of a headline), then a headline like the current one will be inserted
918 after the end of the subtree.
919 @kindex C-@key{RET}
920 @item C-@key{RET}
921 Just like @kbd{M-@key{RET}}, except when adding a new heading below the
922 current heading, the new heading is placed after the body instead of before
923 it.  This command works from anywhere in the entry.
924 @kindex M-S-@key{RET}
925 @item M-S-@key{RET}
926 Insert new TODO entry with same level as current heading.
927 @kindex C-S-@key{RET}
928 @item C-S-@key{RET}
929 Insert new TODO entry with same level as current heading.  Like
930 @kbd{C-@key{RET}}, the new headline will be inserted after the current
931 subtree.
932 @kindex M-@key{left}
933 @item M-@key{left}
934 Promote current heading by one level.
935 @kindex M-@key{right}
936 @item M-@key{right}
937 Demote current heading by one level.
938 @kindex M-S-@key{left}
939 @item M-S-@key{left}
940 Promote the current subtree by one level.
941 @kindex M-S-@key{right}
942 @item M-S-@key{right}
943 Demote the current subtree by one level.
944 @kindex M-S-@key{up}
945 @item M-S-@key{up}
946 Move subtree up (swap with previous subtree of same
947 level).
948 @kindex M-S-@key{down}
949 @item M-S-@key{down}
950 Move subtree down (swap with next subtree of same level).
951 @kindex C-c C-x C-w
952 @item C-c C-x C-w
953 Kill subtree, i.e. remove it from buffer but save in kill ring.
954 With a numeric prefix argument N, kill N sequential subtrees.
955 @kindex C-c C-x M-w
956 @item C-c C-x M-w
957 Copy subtree to kill ring.  With a numeric prefix argument N, copy the N
958 sequential subtrees.
959 @kindex C-c C-x C-y
960 @item C-c C-x C-y
961 Yank subtree from kill ring.  This does modify the level of the subtree to
962 make sure the tree fits in nicely at the yank position.  The yank level can
963 also be specified with a numeric prefix argument, or by yanking after a
964 headline marker like @samp{****}.
965 @kindex C-y
966 @item C-y
967 Depending on the variables @code{org-yank-adjusted-subtrees} and
968 @code{org-yank-folded-subtrees}, Org's internal @code{yank} command will
969 paste subtrees folded and in a clever way, using the same command as @kbd{C-c
970 C-x C-y}.  With the default settings, level adjustment will take place and
971 yanked trees will be folded unless doing so would swallow text previously
972 visible.  Any prefix argument to this command will force a normal @code{yank}
973 to be executed, with the prefix passed along.  A good way to force a normal
974 yank is @kbd{C-u C-y}.  If you use @code{yank-pop} after a yank, it will yank
975 previous kill items plainly, without adjustment and folding.
976 @kindex C-c C-w
977 @item C-c C-w
978 Refile entry or region to a different location.  @xref{Refiling notes}.
979 @kindex C-c ^
980 @item C-c ^
981 Sort same-level entries.  When there is an active region, all entries in the
982 region will be sorted.  Otherwise the children of the current headline are
983 sorted.  The command prompts for the sorting method, which can be
984 alphabetically, numerically, by time (using the first time stamp in each
985 entry), by priority, or by TODO keyword (in the sequence the keywords have
986 been defined in the setup).  Reverse sorting is possible as well.  You can
987 also supply your own function to extract the sorting key.  With a @kbd{C-u}
988 prefix, sorting will be case-sensitive.  With two @kbd{C-u C-u} prefixes,
989 duplicate entries will also be removed.
990 @kindex C-x n s
991 @item C-x n s
992 Narrow buffer to current subtree.
993 @kindex C-x n w
994 @item C-x n w
995 Widen buffer to remove a narrowing.
996 @kindex C-c *
997 @item C-c *
998 Turn a normal line or plain list item into a headline (so that it becomes a
999 subheading at its location).  Also turn a headline into a normal line by
1000 removing the stars.  If there is an active region, turn all lines in the
1001 region into headlines.  If the first line in the region was an item, turn
1002 only the item lines into headlines.  Finally, if the first line is a
1003 headline, remove the stars from all headlines in the region.
1004 @end table
1006 @cindex region, active
1007 @cindex active region
1008 @cindex Transient mark mode
1009 When there is an active region (Transient mark mode), promotion and
1010 demotion work on all headlines in the region.  To select a region of
1011 headlines, it is best to place both point and mark at the beginning of a
1012 line, mark at the beginning of the first headline, and point at the line
1013 just after the last headline to change.  Note that when the cursor is
1014 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
1015 functionality.
1017 @node Archiving, Sparse trees, Structure editing, Document Structure
1018 @section Archiving
1019 @cindex archiving
1021 When a project represented by a (sub)tree is finished, you may want
1022 to move the tree out of the way and to stop it from contributing to the
1023 agenda.  Org mode knows two ways of archiving.  You can mark a tree with
1024 the ARCHIVE tag, or you can move an entire (sub)tree to a different
1025 location.
1027 @menu
1028 * ARCHIVE tag::                 Marking a tree as inactive
1029 * Moving subtrees::             Moving a tree to an archive file
1030 @end menu
1032 @node ARCHIVE tag, Moving subtrees, Archiving, Archiving
1033 @subsection The ARCHIVE tag
1034 @cindex internal archiving
1036 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
1037 its location in the outline tree, but behaves in the following way:
1038 @itemize @minus
1039 @item
1040 It does not open when you attempt to do so with a visibility cycling
1041 command (@pxref{Visibility cycling}).  You can force cycling archived
1042 subtrees with @kbd{C-@key{TAB}}, or by setting the option
1043 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
1044 @code{show-all} will open archived subtrees.
1045 @item
1046 During sparse tree construction (@pxref{Sparse trees}), matches in
1047 archived subtrees are not exposed, unless you configure the option
1048 @code{org-sparse-tree-open-archived-trees}.
1049 @item
1050 During agenda view construction (@pxref{Agenda Views}), the content of
1051 archived trees is ignored unless you configure the option
1052 @code{org-agenda-skip-archived-trees}, in which case these trees will always
1053 be included.  In the agenda you can press the @kbd{v} key to get archives
1054 temporarily included.
1055 @item
1056 Archived trees are not exported (@pxref{Exporting}), only the headline
1057 is.  Configure the details using the variable
1058 @code{org-export-with-archived-trees}.
1059 @end itemize
1061 The following commands help managing the ARCHIVE tag:
1063 @table @kbd
1064 @kindex C-c C-x a
1065 @item C-c C-x a
1066 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
1067 the headline changes to a shadowed face, and the subtree below it is
1068 hidden.
1069 @kindex C-u C-c C-x a
1070 @item C-u C-c C-x a
1071 Check if any direct children of the current headline should be archived.
1072 To do this, each subtree is checked for open TODO entries.  If none are
1073 found, the command offers to set the ARCHIVE tag for the child.  If the
1074 cursor is @emph{not} on a headline when this command is invoked, the
1075 level 1 trees will be checked.
1076 @kindex C-@kbd{TAB}
1077 @item C-@kbd{TAB}
1078 Cycle a tree even if it is tagged with ARCHIVE.
1079 @end table
1081 @node Moving subtrees,  , ARCHIVE tag, Archiving
1082 @subsection Moving subtrees
1083 @cindex external archiving
1085 Once an entire project is finished, you may want to move it to a different
1086 location.  Org can move it to an @emph{Archive Sibling} in the same tree, to a
1087 different tree in the current file, or to a different file, the archive file.
1089 @table @kbd
1090 @kindex C-c C-x A
1091 @item C-c C-x A
1092 Move the current entry to the @emph{Archive Sibling}.  This is a sibling of
1093 the entry with the heading @samp{Archive} and the tag @samp{ARCHIVE}
1094 (@pxref{ARCHIVE tag}).  The entry becomes a child of that sibling and in this
1095 way retains a lot of its original context, including inherited tags and
1096 approximate position in the outline.
1097 @kindex C-c C-x C-s
1098 @item C-c C-x C-s
1099 Archive the subtree starting at the cursor position to the location
1100 given by @code{org-archive-location}.  Context information that could be
1101 lost like the file name, the category, inherited tags, and the TODO
1102 state will be store as properties in the entry.
1103 @kindex C-u C-c C-x C-s
1104 @item C-u C-c C-x C-s
1105 Check if any direct children of the current headline could be moved to
1106 the archive.  To do this, each subtree is checked for open TODO entries.
1107 If none are found, the command offers to move it to the archive
1108 location.  If the cursor is @emph{not} on a headline when this command
1109 is invoked, the level 1 trees will be checked.
1110 @end table
1112 @cindex archive locations
1113 The default archive location is a file in the same directory as the
1114 current file, with the name derived by appending @file{_archive} to the
1115 current file name.  For information and examples on how to change this,
1116 see the documentation string of the variable
1117 @code{org-archive-location}.  There is also an in-buffer option for
1118 setting this variable, for example@footnote{For backward compatibility,
1119 the following also works: If there are several such lines in a file,
1120 each specifies the archive location for the text below it.  The first
1121 such line also applies to any text before its definition.  However,
1122 using this method is @emph{strongly} deprecated as it is incompatible
1123 with the outline structure of the document.  The correct method for
1124 setting multiple archive locations in a buffer is using properties.}:
1126 @example
1127 #+ARCHIVE: %s_done::
1128 @end example
1130 @noindent
1131 If you would like to have a special ARCHIVE location for a single entry
1132 or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
1133 location as the value (@pxref{Properties and Columns}).
1135 When a subtree is moved, it receives a number of special properties that
1136 record context information like the file from where the entry came, it's
1137 outline path the archiving time etc.  Configure the variable
1138 @code{org-archive-save-context-info} to adjust the amount of information
1139 added.
1141 @node Sparse trees, Plain lists, Archiving, Document Structure
1142 @section Sparse trees
1143 @cindex sparse trees
1144 @cindex trees, sparse
1145 @cindex folding, sparse trees
1146 @cindex occur, command
1148 An important feature of Org mode is the ability to construct @emph{sparse
1149 trees} for selected information in an outline tree, so that the entire
1150 document is folded as much as possible, but the selected information is made
1151 visible along with the headline structure above it@footnote{See also the
1152 variables @code{org-show-hierarchy-above}, @code{org-show-following-heading},
1153 @code{org-show-siblings}, and @code{org-show-entry-below} for detailed
1154 control on how much context is shown around each match.}.  Just try it out
1155 and you will see immediately how it works.
1157 Org mode contains several commands creating such trees, all these
1158 commands can be accessed through a dispatcher:
1160 @table @kbd
1161 @kindex C-c /
1162 @item C-c /
1163 This prompts for an extra key to select a sparse-tree creating command.
1164 @kindex C-c / r
1165 @item C-c / r
1166 Occur.  Prompts for a regexp and shows a sparse tree with all matches.  If
1167 the match is in a headline, the headline is made visible.  If the match is in
1168 the body of an entry, headline and body are made visible.  In order to
1169 provide minimal context, also the full hierarchy of headlines above the match
1170 is shown, as well as the headline following the match.  Each match is also
1171 highlighted; the highlights disappear when the buffer is changed by an
1172 editing command@footnote{depending on the option
1173 @code{org-remove-highlights-with-change}}, or by pressing @kbd{C-c C-c}.
1174 When called with a @kbd{C-u} prefix argument, previous highlights are kept,
1175 so several calls to this command can be stacked.
1176 @end table
1178 @noindent
1179 For frequently used sparse trees of specific search strings, you can
1180 use the variable @code{org-agenda-custom-commands} to define fast
1181 keyboard access to specific sparse trees.  These commands will then be
1182 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
1183 For example:
1185 @lisp
1186 (setq org-agenda-custom-commands
1187       '(("f" occur-tree "FIXME")))
1188 @end lisp
1190 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
1191 a sparse tree matching the string @samp{FIXME}.
1193 The other sparse tree commands select headings based on TODO keywords,
1194 tags, or properties and will be discussed later in this manual.
1196 @kindex C-c C-e v
1197 @cindex printing sparse trees
1198 @cindex visible text, printing
1199 To print a sparse tree, you can use the Emacs command
1200 @code{ps-print-buffer-with-faces} which does not print invisible parts
1201 of the document @footnote{This does not work under XEmacs, because
1202 XEmacs uses selective display for outlining, not text properties.}.
1203 Or you can use the command @kbd{C-c C-e v} to export only the visible
1204 part of the document and print the resulting file.
1206 @node Plain lists, Drawers, Sparse trees, Document Structure
1207 @section Plain lists
1208 @cindex plain lists
1209 @cindex lists, plain
1210 @cindex lists, ordered
1211 @cindex ordered lists
1213 Within an entry of the outline tree, hand-formatted lists can provide
1214 additional structure.  They also provide a way to create lists of
1215 checkboxes (@pxref{Checkboxes}).  Org supports editing such lists,
1216 and the HTML exporter (@pxref{Exporting}) parses and formats them.
1218 Org knows ordered lists, unordered lists, and description lists.
1219 @itemize @bullet
1220 @item
1221 @emph{Unordered} list items start with @samp{-}, @samp{+}, or
1222 @samp{*}@footnote{When using @samp{*} as a bullet, lines must be indented or
1223 they will be seen as top-level headlines.  Also, when you are hiding leading
1224 stars to get a clean outline view, plain list items starting with a star are
1225 visually indistinguishable from true headlines.  In short: even though
1226 @samp{*} is supported, it may be better to not use it for plain list items.}
1227 as bullets.
1228 @item
1229 @emph{Ordered} list items start with a numeral followed by either a period or
1230 a right parenthesis, such as @samp{1.} or @samp{1)}.
1231 @item
1232 @emph{Description} list items are like unordered list items, but contain the
1233 separator @samp{ :: } to separate the description @emph{term} from the
1234 description.
1235 @end itemize
1237 Items belonging to the same list must have the same indentation on the first
1238 line.  In particular, if an ordered list reaches number @samp{10.}, then the
1239 2--digit numbers must be written left-aligned with the other numbers in the
1240 list.  Indentation also determines the end of a list item.  It ends before
1241 the next line that is indented like the bullet/number, or less.  Empty lines
1242 are part of the previous item, so you can have several paragraphs in one
1243 item.  If you would like an empty line to terminate all currently open plain
1244 lists, configure the variable @code{org-empty-line-terminates-plain-lists}.
1245 Here is an example:
1247 @example
1248 @group
1249 ** Lord of the Rings
1250    My favorite scenes are (in this order)
1251    1. The attack of the Rohirrim
1252    2. Eowyn's fight with the witch king
1253       + this was already my favorite scene in the book
1254       + I really like Miranda Otto.
1255    3. Peter Jackson being shot by Legolas
1256        - on DVD only
1257       He makes a really funny face when it happens.
1258    But in the end, no individual scenes matter but the film as a whole.
1259    Important actors in this film are:
1260    - @b{Elijah Wood} :: He plays Frodo
1261    - @b{Sean Austin} :: He plays Sam, Frodo's friend.  I still remember
1262      him very well from his role as Mikey Walsh in the Goonies.
1263 @end group
1264 @end example
1266 Org supports these lists by tuning filling and wrapping commands to
1267 deal with them correctly@footnote{Org only changes the filling
1268 settings for Emacs.  For XEmacs, you should use Kyle E. Jones'
1269 @file{filladapt.el}.  To turn this on,  put into @file{.emacs}:
1270 @code{(require 'filladapt)}}, and by exporting them properly
1271 (@pxref{Exporting}).
1273 The following commands act on items when the cursor is in the first line
1274 of an item (the line with the bullet or number).
1276 @table @kbd
1277 @kindex @key{TAB}
1278 @item @key{TAB}
1279 Items can be folded just like headline levels if you set the variable
1280 @code{org-cycle-include-plain-lists}.  The level of an item is then
1281 given by the indentation of the bullet/number.  Items are always
1282 subordinate to real headlines, however; the hierarchies remain
1283 completely separated.
1285 If @code{org-cycle-include-plain-lists} has not been set, @key{TAB}
1286 fixes the indentation of the current line in a heuristic way.
1287 @kindex M-@key{RET}
1288 @item M-@key{RET}
1289 Insert new item at current level.  With a prefix argument, force a new
1290 heading (@pxref{Structure editing}).  If this command is used in the middle
1291 of a line, the line is @emph{split} and the rest of the line becomes the new
1292 item@footnote{If you do not want the line to be split, customize the variable
1293 @code{org-M-RET-may-split-line}.}.  If this command is executed in the
1294 @emph{whitespace before a bullet or number}, the new item is created
1295 @emph{before} the current item.  If the command is executed in the white
1296 space before the text that is part of an item but does not contain the
1297 bullet, a bullet is added to the current line.
1298 @kindex M-S-@key{RET}
1299 @item M-S-@key{RET}
1300 Insert a new item with a checkbox (@pxref{Checkboxes}).
1301 @kindex S-@key{up}
1302 @kindex S-@key{down}
1303 @item S-@key{up}
1304 @itemx S-@key{down}
1305 @cindex shift-selection-mode
1306 Jump to the previous/next item in the current list, but only if
1307 @code{org-support-shift-select} is off.  If not, you can still use paragraph
1308 jumping commands like @kbd{C-@key{up}} and @kbd{C-@key{down}} to quite
1309 similar effect.
1310 @kindex M-S-@key{up}
1311 @kindex M-S-@key{down}
1312 @item M-S-@key{up}
1313 @itemx M-S-@key{down}
1314 Move the item including subitems up/down (swap with previous/next item
1315 of same indentation).  If the list is ordered, renumbering is
1316 automatic.
1317 @kindex M-S-@key{left}
1318 @kindex M-S-@key{right}
1319 @item M-S-@key{left}
1320 @itemx M-S-@key{right}
1321 Decrease/increase the indentation of the item, including subitems.
1322 Initially, the item tree is selected based on current indentation.
1323 When these commands are executed several times in direct succession,
1324 the initially selected region is used, even if the new indentation
1325 would imply a different hierarchy.  To use the new hierarchy, break
1326 the command chain with a cursor motion or so.
1327 @kindex C-c C-c
1328 @item C-c C-c
1329 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1330 state of the checkbox.  If not, this command makes sure that all the
1331 items on this list level use the same bullet.  Furthermore, if this is
1332 an ordered list, make sure the numbering is OK.
1333 @kindex C-c -
1334 @item C-c -
1335 Cycle the entire list level through the different itemize/enumerate bullets
1336 (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}).  With a numeric prefix
1337 argument N, select the Nth bullet from this list.  If there is an active
1338 region when calling this, all lines will be converted to list items.  If the
1339 first line already was a list item, any item markers will be removed from the
1340 list.  Finally, even without an active region, a normal line will be
1341 converted into a list item.
1342 @kindex S-@key{left}
1343 @kindex S-@key{right}
1344 @item S-@key{left}/@key{right}
1345 This command also cycles bullet styles when the cursor in on the bullet or
1346 anywhere in an item line, details depending on
1347 @code{org-support-shift-select}.
1348 @end table
1350 @node Drawers, Footnotes, Plain lists, Document Structure
1351 @section Drawers
1352 @cindex drawers
1353 @cindex visibility cycling, drawers
1355 Sometimes you want to keep information associated with an entry, but you
1356 normally don't want to see it.  For this, Org mode has @emph{drawers}.
1357 Drawers need to be configured with the variable
1358 @code{org-drawers}@footnote{You can define drawers on a per-file basis
1359 with a line like @code{#+DRAWERS: HIDDEN PROPERTIES STATE}}.  Drawers
1360 look like this:
1362 @example
1363 ** This is a headline
1364    Still outside the drawer
1365    :DRAWERNAME:
1366       This is inside the drawer.
1367    :END:
1368    After the drawer.
1369 @end example
1371 Visibility cycling (@pxref{Visibility cycling}) on the headline will
1372 hide and show the entry, but keep the drawer collapsed to a single line.
1373 In order to look inside the drawer, you need to move the cursor to the
1374 drawer line and press @key{TAB} there.  Org mode uses a drawer for
1375 storing properties (@pxref{Properties and Columns}), and another one for
1376 storing clock times (@pxref{Clocking work time}).
1378 @node Footnotes, Orgstruct mode, Drawers, Document Structure
1379 @section Footnotes
1380 @cindex footnotes
1382 Org-mode supports the creation of footnotes.  In contrast to the
1383 @file{footnote.el} package, Org-mode's footnotes are designed for work on a
1384 larger document, not only for one-off documents like emails.  The basic
1385 syntax is similar to the one used by @file{footnote.el}, i.e. a footnote is
1386 defined in a paragraph that is started by a footnote marker in square
1387 brackets in column 0, no indentation allowed.  If you need a paragraph break
1388 inside a footnote, use the LaTeX idiom @samp{\par}.  The footnote reference
1389 is simply the marker in square brackets, inside text.  For example:
1391 @example
1392 The Org homepage[fn:1] now looks a lot better than it used to.
1394 [fn:1] The link is: http://orgmode.org
1395 @end example
1397 Org-mode extends the number-based syntax to @emph{named} footnotes and
1398 optional inline definition.  Using plain numbers as markers (as
1399 @file{footnote.el} does) is supported for backward compatibility, but not
1400 encouraged because of possible conflicts with LaTeX snippets @pxref{Embedded
1401 LaTeX}.  Here are the valid references:
1403 @table @code
1404 @item [1]
1405 A plain numeric footnote marker.
1406 @item [fn:name]
1407 A named footnote reference, where @code{name} is a unique label word, or, for
1408 simplicity of automatic creation, a number.
1409 @item [fn:: This is the inline definition of this footnote]
1410 A LaTeX-like anonymous footnote where the definition is given directly at the
1411 reference point.
1412 @item [fn:name: a definition]
1413 An inline definition of a footnote, which also specifies a name for the note.
1414 Since Org allows multiple references to the same note, you can then use use
1415 @code{[fn:name]} to create additional references.
1416 @end table
1418 Footnote labels can be created automatically, or you create names yourself.
1419 This is handled by the variable @code{org-footnote-auto-label} and its
1420 corresponding @code{#+STARTUP} keywords, see the docstring of that variable
1421 for details.
1423 @noindent The following command handles footnotes:
1425 @table @kbd
1426 @kindex C-c C-x f
1427 @item C-c C-x f
1428 The footnote action command.
1430 When the cursor is on a footnote reference, jump to the definition.  When it
1431 is at a definition, jump to the (first) reference.
1433 Otherwise, create a new footnote.  Depending on the variable
1434 @code{org-footnote-define-inline}@footnote{The corresponding in-buffer
1435 setting is: @code{#+STARTUP: fninline} or @code{#+STARTUP: nofninline}}, the
1436 definition will be placed right into the text as part of the reference, or
1437 separately into the location determined by the variable
1438 @code{org-footnote-section}.
1440 When this command is called with a prefix argument, a menu of additional
1441 options is offered:
1442 @example
1443 s   @r{Sort the footnote definitions by reference sequence.  During editing,}
1444     @r{Org makes no effort to sort footnote definitions into a particular}
1445     @r{sequence.  If you want them sorted, use this command, which will}
1446     @r{also move entries according to @code{org-footnote-section}.}
1447 n   @r{Normalize the footnotes by collecting all definitions (including}
1448     @r{inline definitions) into a special section, and then numbering them}
1449     @r{in sequence.  The references will then also be numbers.  This is}
1450     @r{meant to be the final step before finishing a document (e.g. sending}
1451     @r{off an email).  The exporters do this automatically, and so could}
1452     @r{something like @code{message-send-hook}.}
1453 d   @r{Delete the footnote at point, and all definitions of and references}
1454     @r{to it.}
1455 @end example
1456 @kindex C-c C-c
1457 @item C-c C-c
1458 If the cursor is on a footnote reference, jump to the definition.  If it is a
1459 the definition, jump back to the reference.  When called at a footnote
1460 location with a prefix argument, offer the same menu as @kbd{C-c C-x f}.
1461 @kindex C-c C-o
1462 @kindex mouse-1
1463 @kindex mouse-2
1464 @item C-c C-c  @r{or} mouse-1/2
1465 Footnote labels are also links to the corresponding definition/reference, and
1466 you can use the usual commands to follow these links.
1467 @end table
1469 @node Orgstruct mode,  , Footnotes, Document Structure
1470 @section The Orgstruct minor mode
1471 @cindex Orgstruct mode
1472 @cindex minor mode for structure editing
1474 If you like the intuitive way the Org mode structure editing and list
1475 formatting works, you might want to use these commands in other modes
1476 like Text mode or Mail mode as well.  The minor mode Orgstruct mode
1477 makes this possible.  You can always toggle the mode with @kbd{M-x
1478 orgstruct-mode}.  To turn it on by default, for example in Mail mode,
1481 @lisp
1482 (add-hook 'mail-mode-hook 'turn-on-orgstruct)
1483 @end lisp
1485 When this mode is active and the cursor is on a line that looks to
1486 Org like a headline of the first line of a list item, most
1487 structure editing commands will work, even if the same keys normally
1488 have different functionality in the major mode you are using.  If the
1489 cursor is not in one of those special lines, Orgstruct mode lurks
1490 silently in the shadow.
1492 @node Tables, Hyperlinks, Document Structure, Top
1493 @chapter Tables
1494 @cindex tables
1495 @cindex editing tables
1497 Org comes with a fast and intuitive table editor.  Spreadsheet-like
1498 calculations are supported in connection with the Emacs @file{calc}
1499 package
1500 @ifinfo
1501 (@pxref{Top,Calc,,Calc,Gnu Emacs Calculator Manual}).
1502 @end ifinfo
1503 @ifnotinfo
1504 (see the Emacs Calculator manual for more information about the Emacs
1505 calculator).
1506 @end ifnotinfo
1508 @menu
1509 * Built-in table editor::       Simple tables
1510 * Narrow columns::              Stop wasting space in tables
1511 * Column groups::               Grouping to trigger vertical lines
1512 * Orgtbl mode::                 The table editor as minor mode
1513 * The spreadsheet::             The table editor has spreadsheet capabilities
1514 * Org Plot::                    Plotting from org tables
1515 @end menu
1517 @node Built-in table editor, Narrow columns, Tables, Tables
1518 @section The built-in table editor
1519 @cindex table editor, built-in
1521 Org makes it easy to format tables in plain ASCII.  Any line with
1522 @samp{|} as the first non-whitespace character is considered part of a
1523 table.  @samp{|} is also the column separator.  A table might look like
1524 this:
1526 @example
1527 | Name  | Phone | Age |
1528 |-------+-------+-----|
1529 | Peter |  1234 |  17 |
1530 | Anna  |  4321 |  25 |
1531 @end example
1533 A table is re-aligned automatically each time you press @key{TAB} or
1534 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
1535 the next field (@key{RET} to the next row) and creates new table rows
1536 at the end of the table or before horizontal lines.  The indentation
1537 of the table is set by the first line.  Any line starting with
1538 @samp{|-} is considered as a horizontal separator line and will be
1539 expanded on the next re-align to span the whole table width.  So, to
1540 create the above table, you would only type
1542 @example
1543 |Name|Phone|Age|
1545 @end example
1547 @noindent and then press @key{TAB} to align the table and start filling in
1548 fields.  Even faster would be to type @code{|Name|Phone|Age} followed by
1549 @kbd{C-c @key{RET}}.
1551 When typing text into a field, Org treats @key{DEL},
1552 @key{Backspace}, and all character keys in a special way, so that
1553 inserting and deleting avoids shifting other fields.  Also, when
1554 typing @emph{immediately after the cursor was moved into a new field
1555 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
1556 field is automatically made blank.  If this behavior is too
1557 unpredictable for you, configure the variables
1558 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
1560 @table @kbd
1561 @tsubheading{Creation and conversion}
1562 @kindex C-c |
1563 @item C-c |
1564 Convert the active region to table. If every line contains at least one
1565 TAB character, the function assumes that the material is tab separated.
1566 If every line contains a comma, comma-separated values (CSV) are assumed.
1567 If not, lines are split at whitespace into fields.  You can use a prefix
1568 argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
1569 C-u} forces TAB, and a numeric argument N indicates that at least N
1570 consecutive spaces, or alternatively a TAB will be the separator.
1572 If there is no active region, this command creates an empty Org
1573 table.  But it's easier just to start typing, like
1574 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
1576 @tsubheading{Re-aligning and field motion}
1577 @kindex C-c C-c
1578 @item C-c C-c
1579 Re-align the table without moving the cursor.
1581 @kindex @key{TAB}
1582 @item @key{TAB}
1583 Re-align the table, move to the next field.  Creates a new row if
1584 necessary.
1586 @kindex S-@key{TAB}
1587 @item S-@key{TAB}
1588 Re-align, move to previous field.
1590 @kindex @key{RET}
1591 @item @key{RET}
1592 Re-align the table and move down to next row.  Creates a new row if
1593 necessary.  At the beginning or end of a line, @key{RET} still does
1594 NEWLINE, so it can be used to split a table.
1596 @tsubheading{Column and row editing}
1597 @kindex M-@key{left}
1598 @kindex M-@key{right}
1599 @item M-@key{left}
1600 @itemx M-@key{right}
1601 Move the current column left/right.
1603 @kindex M-S-@key{left}
1604 @item M-S-@key{left}
1605 Kill the current column.
1607 @kindex M-S-@key{right}
1608 @item M-S-@key{right}
1609 Insert a new column to the left of the cursor position.
1611 @kindex M-@key{up}
1612 @kindex M-@key{down}
1613 @item M-@key{up}
1614 @itemx M-@key{down}
1615 Move the current row up/down.
1617 @kindex M-S-@key{up}
1618 @item M-S-@key{up}
1619 Kill the current row or horizontal line.
1621 @kindex M-S-@key{down}
1622 @item M-S-@key{down}
1623 Insert a new row above the current row.  With a prefix argument, the line is
1624 created below the current one.
1626 @kindex C-c -
1627 @item C-c -
1628 Insert a horizontal line below current row.  With a prefix argument, the line
1629 is created above the current line.
1631 @kindex C-c @key{RET}
1632 @item C-c @key{RET}
1633 Insert a horizontal line below current row, and move the cursor into the row
1634 below that line.
1636 @kindex C-c ^
1637 @item C-c ^
1638 Sort the table lines in the region.  The position of point indicates the
1639 column to be used for sorting, and the range of lines is the range
1640 between the nearest horizontal separator lines, or the entire table.  If
1641 point is before the first column, you will be prompted for the sorting
1642 column.  If there is an active region, the mark specifies the first line
1643 and the sorting column, while point should be in the last line to be
1644 included into the sorting.  The command prompts for the sorting type
1645 (alphabetically, numerically, or by time).  When called with a prefix
1646 argument, alphabetic sorting will be case-sensitive.
1648 @tsubheading{Regions}
1649 @kindex C-c C-x M-w
1650 @item C-c C-x M-w
1651 Copy a rectangular region from a table to a special clipboard.  Point
1652 and mark determine edge fields of the rectangle.  The process ignores
1653 horizontal separator lines.
1655 @kindex C-c C-x C-w
1656 @item C-c C-x C-w
1657 Copy a rectangular region from a table to a special clipboard, and
1658 blank all fields in the rectangle.  So this is the ``cut'' operation.
1660 @kindex C-c C-x C-y
1661 @item C-c C-x C-y
1662 Paste a rectangular region into a table.
1663 The upper left corner ends up in the current field.  All involved fields
1664 will be overwritten.  If the rectangle does not fit into the present table,
1665 the table is enlarged as needed.  The process ignores horizontal separator
1666 lines.
1668 @kindex M-@key{RET}
1669 @itemx M-@kbd{RET}
1670 Wrap several fields in a column like a paragraph.  If there is an active
1671 region, and both point and mark are in the same column, the text in the
1672 column is wrapped to minimum width for the given number of lines.  A numeric
1673 prefix argument may be used to change the number of desired lines.  If there
1674 is no region, the current field is split at the cursor position and the text
1675 fragment to the right of the cursor is prepended to the field one line
1676 down. If there is no region, but you specify a prefix argument, the current
1677 field is made blank, and the content is appended to the field above.
1679 @tsubheading{Calculations}
1680 @cindex formula, in tables
1681 @cindex calculations, in tables
1682 @cindex region, active
1683 @cindex active region
1684 @cindex Transient mark mode
1685 @kindex C-c +
1686 @item C-c +
1687 Sum the numbers in the current column, or in the rectangle defined by
1688 the active region.  The result is shown in the echo area and can
1689 be inserted with @kbd{C-y}.
1691 @kindex S-@key{RET}
1692 @item S-@key{RET}
1693 When current field is empty, copy from first non-empty field above.  When not
1694 empty, copy current field down to next row and move cursor along with it.
1695 Depending on the variable @code{org-table-copy-increment}, integer field
1696 values will be incremented during copy.  Integers that are too large will not
1697 be incremented.  Also, a @code{0} prefix argument temporarily disables the
1698 increment.  This key is also used by CUA mode (@pxref{Cooperation}).
1700 @tsubheading{Miscellaneous}
1701 @kindex C-c `
1702 @item C-c `
1703 Edit the current field in a separate window.  This is useful for fields
1704 that are not fully visible (@pxref{Narrow columns}).  When called with a
1705 @kbd{C-u} prefix, just make the full field visible, so that it can be
1706 edited in place.
1708 @item M-x org-table-import
1709 Import a file as a table.  The table should be TAB- or whitespace
1710 separated.  Useful, for example, to import a spreadsheet table or data
1711 from a database, because these programs generally can write
1712 TAB-separated text files.  This command works by inserting the file into
1713 the buffer and then converting the region to a table.  Any prefix
1714 argument is passed on to the converter, which uses it to determine the
1715 separator.
1716 @item C-c |
1717 Tables can also be imported by pasting tabular text into the Org
1718 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
1719 @kbd{C-c |} command (see above under @i{Creation and conversion}).
1721 @item M-x org-table-export
1722 Export the table, by default as a TAB-separated file.  Useful for data
1723 exchange with, for example, spreadsheet or database programs.  The format
1724 used to export the file can be configured in the variable
1725 @code{org-table-export-default-format}.  You may also use properties
1726 @code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
1727 name and the format for table export in a subtree.  Org supports quite
1728 general formats for exported tables.  The exporter format is the same as the
1729 format used by Orgtbl radio tables, see @ref{Translator functions} for a
1730 detailed description.
1731 @end table
1733 If you don't like the automatic table editor because it gets in your
1734 way on lines which you would like to start with @samp{|}, you can turn
1735 it off with
1737 @lisp
1738 (setq org-enable-table-editor nil)
1739 @end lisp
1741 @noindent Then the only table command that still works is
1742 @kbd{C-c C-c} to do a manual re-align.
1744 @node Narrow columns, Column groups, Built-in table editor, Tables
1745 @section Narrow columns
1746 @cindex narrow columns in tables
1748 The width of columns is automatically determined by the table editor.
1749 Sometimes a single field or a few fields need to carry more text,
1750 leading to inconveniently wide columns.  To limit@footnote{This feature
1751 does not work on XEmacs.} the width of a column, one field anywhere in
1752 the column may contain just the string @samp{<N>} where @samp{N} is an
1753 integer specifying the width of the column in characters.  The next
1754 re-align will then set the width of this column to no more than this
1755 value.
1757 @example
1758 @group
1759 |---+------------------------------|               |---+--------|
1760 |   |                              |               |   | <6>    |
1761 | 1 | one                          |               | 1 | one    |
1762 | 2 | two                          |     ----\     | 2 | two    |
1763 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
1764 | 4 | four                         |               | 4 | four   |
1765 |---+------------------------------|               |---+--------|
1766 @end group
1767 @end example
1769 @noindent
1770 Fields that are wider become clipped and end in the string @samp{=>}.
1771 Note that the full text is still in the buffer, it is only invisible.
1772 To see the full text, hold the mouse over the field - a tool-tip window
1773 will show the full content.  To edit such a field, use the command
1774 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
1775 open a new window with the full field.  Edit it and finish with @kbd{C-c
1776 C-c}.
1778 When visiting a file containing a table with narrowed columns, the
1779 necessary character hiding has not yet happened, and the table needs to
1780 be aligned before it looks nice.  Setting the option
1781 @code{org-startup-align-all-tables} will realign all tables in a file
1782 upon visiting, but also slow down startup.  You can also set this option
1783 on a per-file basis with:
1785 @example
1786 #+STARTUP: align
1787 #+STARTUP: noalign
1788 @end example
1790 @node Column groups, Orgtbl mode, Narrow columns, Tables
1791 @section Column groups
1792 @cindex grouping columns in tables
1794 When Org exports tables, it does so by default without vertical
1795 lines because that is visually more satisfying in general.  Occasionally
1796 however, vertical lines can be useful to structure a table into groups
1797 of columns, much like horizontal lines can do for groups of rows.  In
1798 order to specify column groups, you can use a special row where the
1799 first field contains only @samp{/}.  The further fields can either
1800 contain @samp{<} to indicate that this column should start a group,
1801 @samp{>} to indicate the end of a column, or @samp{<>} to make a column
1802 a group of its own.  Boundaries between column groups will upon export be
1803 marked with vertical lines.  Here is an example:
1805 @example
1806 |   |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1807 |---+----+-----+-----+-----+---------+------------|
1808 | / | <> |   < |     |   > |       < |          > |
1809 | # |  1 |   1 |   1 |   1 |       1 |          1 |
1810 | # |  2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
1811 | # |  3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
1812 |---+----+-----+-----+-----+---------+------------|
1813 #+TBLFM: $3=$2^2::$4=$2^3::$5=$2^4::$6=sqrt($2)::$7=sqrt(sqrt(($2)))
1814 @end example
1816 It is also sufficient to just insert the column group starters after
1817 every vertical line you'd like to have:
1819 @example
1820 |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1821 |----+-----+-----+-----+---------+------------|
1822 | /  | <   |     |     | <       |            |
1823 @end example
1825 @node Orgtbl mode, The spreadsheet, Column groups, Tables
1826 @section The Orgtbl minor mode
1827 @cindex Orgtbl mode
1828 @cindex minor mode for tables
1830 If you like the intuitive way the Org table editor works, you
1831 might also want to use it in other modes like Text mode or Mail mode.
1832 The minor mode Orgtbl mode makes this possible.  You can always toggle
1833 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
1834 example in mail mode, use
1836 @lisp
1837 (add-hook 'mail-mode-hook 'turn-on-orgtbl)
1838 @end lisp
1840 Furthermore, with some special setup, it is possible to maintain tables
1841 in arbitrary syntax with Orgtbl mode.  For example, it is possible to
1842 construct La@TeX{} tables with the underlying ease and power of
1843 Orgtbl mode, including spreadsheet capabilities.  For details, see
1844 @ref{Tables in arbitrary syntax}.
1846 @node The spreadsheet, Org Plot, Orgtbl mode, Tables
1847 @section The spreadsheet
1848 @cindex calculations, in tables
1849 @cindex spreadsheet capabilities
1850 @cindex @file{calc} package
1852 The table editor makes use of the Emacs @file{calc} package to implement
1853 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
1854 derive fields from other fields.  While fully featured, Org's
1855 implementation is not identical to other spreadsheets.  For example,
1856 Org knows the concept of a @emph{column formula} that will be
1857 applied to all non-header fields in a column without having to copy the
1858 formula to each relevant field.
1860 @menu
1861 * References::                  How to refer to another field or range
1862 * Formula syntax for Calc::     Using Calc to compute stuff
1863 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
1864 * Field formulas::              Formulas valid for a single field
1865 * Column formulas::             Formulas valid for an entire column
1866 * Editing and debugging formulas::  Fixing formulas
1867 * Updating the table::          Recomputing all dependent fields
1868 * Advanced features::           Field names, parameters and automatic recalc
1869 @end menu
1871 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
1872 @subsection References
1873 @cindex references
1875 To compute fields in the table from other fields, formulas must
1876 reference other fields or ranges.  In Org, fields can be referenced
1877 by name, by absolute coordinates, and by relative coordinates.  To find
1878 out what the coordinates of a field are, press @kbd{C-c ?} in that
1879 field, or press @kbd{C-c @}} to toggle the display of a grid.
1881 @subsubheading Field references
1882 @cindex field references
1883 @cindex references, to fields
1885 Formulas can reference the value of another field in two ways.  Like in
1886 any other spreadsheet, you may reference fields with a letter/number
1887 combination like @code{B3}, meaning the 2nd field in the 3rd row.
1888 @c Such references are always fixed to that field, they don't change
1889 @c when you copy and paste a formula to a different field.  So
1890 @c Org's @code{B3} behaves like @code{$B$3} in other spreadsheets.
1892 @noindent
1893 Org also uses another, more general operator that looks like this:
1894 @example
1895 @@row$column
1896 @end example
1898 @noindent
1899 Column references can be absolute like @samp{1}, @samp{2},...@samp{N},
1900 or relative to the current column like @samp{+1} or @samp{-2}.
1902 The row specification only counts data lines and ignores horizontal
1903 separator lines (hlines).  You can use absolute row numbers
1904 @samp{1}...@samp{N}, and row numbers relative to the current row like
1905 @samp{+3} or @samp{-1}.  Or specify the row relative to one of the
1906 hlines: @samp{I} refers to the first hline@footnote{Note that only
1907 hlines are counted that @emph{separate} table lines.  If the table
1908 starts with a hline above the header, it does not count.}, @samp{II} to
1909 the second etc.  @samp{-I} refers to the first such line above the
1910 current line, @samp{+I} to the first such line below the current line.
1911 You can also write @samp{III+2} which is the second data line after the
1912 third hline in the table.  Relative row numbers like @samp{-3} will not
1913 cross hlines if the current line is too close to the hline.  Instead,
1914 the value directly at the hline is used.
1916 @samp{0} refers to the current row and column.  Also, if you omit
1917 either the column or the row part of the reference, the current
1918 row/column is implied.
1920 Org's references with @emph{unsigned} numbers are fixed references
1921 in the sense that if you use the same reference in the formula for two
1922 different fields, the same field will be referenced each time.
1923 Org's references with @emph{signed} numbers are floating
1924 references because the same reference operator can reference different
1925 fields depending on the field being calculated by the formula.
1927 As a special case references like @samp{$LR5} and @samp{$LR12} can be used to
1928 refer in a stable way to the 5th and 12th field in the last row of the
1929 table.
1931 Here are a few examples:
1933 @example
1934 @@2$3      @r{2nd row, 3rd column}
1935 C2        @r{same as previous}
1936 $5        @r{column 5 in the current row}
1937 E&        @r{same as previous}
1938 @@2        @r{current column, row 2}
1939 @@-1$-3    @r{the field one row up, three columns to the left}
1940 @@-I$2     @r{field just under hline above current row, column 2}
1941 @end example
1943 @subsubheading Range references
1944 @cindex range references
1945 @cindex references, to ranges
1947 You may reference a rectangular range of fields by specifying two field
1948 references connected by two dots @samp{..}.  If both fields are in the
1949 current row, you may simply use @samp{$2..$7}, but if at least one field
1950 is in a different row, you need to use the general @code{@@row$column}
1951 format at least for the first field (i.e the reference must start with
1952 @samp{@@} in order to be interpreted correctly).  Examples:
1954 @example
1955 $1..$3        @r{First three fields in the current row.}
1956 $P..$Q        @r{Range, using column names (see under Advanced)}
1957 @@2$1..@@4$3    @r{6 fields between these two fields.}
1958 A2..C4        @r{Same as above.}
1959 @@-1$-2..@@-1   @r{3 numbers from the column to the left, 2 up to current row}
1960 @end example
1962 @noindent Range references return a vector of values that can be fed
1963 into Calc vector functions.  Empty fields in ranges are normally
1964 suppressed, so that the vector contains only the non-empty fields (but
1965 see the @samp{E} mode switch below).  If there are no non-empty fields,
1966 @samp{[0]} is returned to avoid syntax errors in formulas.
1968 @subsubheading Named references
1969 @cindex named references
1970 @cindex references, named
1971 @cindex name, of column or field
1972 @cindex constants, in calculations
1974 @samp{$name} is interpreted as the name of a column, parameter or
1975 constant.  Constants are defined globally through the variable
1976 @code{org-table-formula-constants}, and locally (for the file) through a
1977 line like
1979 @example
1980 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
1981 @end example
1983 @noindent
1984 Also properties (@pxref{Properties and Columns}) can be used as
1985 constants in table formulas: For a property @samp{:Xyz:} use the name
1986 @samp{$PROP_Xyz}, and the property will be searched in the current
1987 outline entry and in the hierarchy above it.  If you have the
1988 @file{constants.el} package, it will also be used to resolve constants,
1989 including natural constants like @samp{$h} for Planck's constant, and
1990 units like @samp{$km} for kilometers@footnote{@file{Constant.el} can
1991 supply the values of constants in two different unit systems, @code{SI}
1992 and @code{cgs}.  Which one is used depends on the value of the variable
1993 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
1994 @code{constSI} and @code{constcgs} to set this value for the current
1995 buffer.}.  Column names and parameters can be specified in special table
1996 lines.  These are described below, see @ref{Advanced features}.  All
1997 names must start with a letter, and further consist of letters and
1998 numbers.
2000 @subsubheading Remote references
2001 @cindex remote references
2002 @cindex references, remote
2003 @cindex references, to a different table
2004 @cindex name, of column or field
2005 @cindex constants, in calculations
2007 You may also reference constants, fields and ranges from a different table,
2008 either in the current file or even in a different file.  The syntax is
2010 @example
2011 remote(NAME-OR-ID,REF)
2012 @end example
2014 @noindent
2015 where NAME can be the name of a table in the current file as set by a
2016 @code{#+TBLNAME: NAME} line before the table.  It can also be the ID of an
2017 entry, even in a different file, and the reference then refers to the first
2018 table in that entry.  REF is an absolute field or range reference as
2019 described above, valid in the referenced table.
2021 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
2022 @subsection Formula syntax for Calc
2023 @cindex formula syntax, Calc
2024 @cindex syntax, of formulas
2026 A formula can be any algebraic expression understood by the Emacs
2027 @file{Calc} package.  @b{Note that @file{calc} has the
2028 non-standard convention that @samp{/} has lower precedence than
2029 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
2030 evaluation by @code{calc-eval} (@pxref{Calling Calc from
2031 Your Programs,calc-eval,Calling Calc from Your Lisp Programs,Calc,GNU
2032 Emacs Calc Manual}),
2033 @c FIXME:  The link to the Calc manual in HTML does not work.
2034 variable substitution takes place according to the rules described above.
2035 @cindex vectors, in table calculations
2036 The range vectors can be directly fed into the Calc vector functions
2037 like @samp{vmean} and @samp{vsum}.
2039 @cindex format specifier
2040 @cindex mode, for @file{calc}
2041 A formula can contain an optional mode string after a semicolon.  This
2042 string consists of flags to influence Calc and other modes during
2043 execution.  By default, Org uses the standard Calc modes (precision
2044 12, angular units degrees, fraction and symbolic modes off).  The display
2045 format, however, has been changed to @code{(float 5)} to keep tables
2046 compact.  The default settings can be configured using the variable
2047 @code{org-calc-default-modes}.
2049 @example
2050 p20           @r{switch the internal precision to 20 digits}
2051 n3 s3 e2 f4   @r{normal, scientific, engineering, or fixed display format}
2052 D R           @r{angle modes: degrees, radians}
2053 F S           @r{fraction and symbolic modes}
2054 N             @r{interpret all fields as numbers, use 0 for non-numbers}
2055 T             @r{force text interpretation}
2056 E             @r{keep empty fields in ranges}
2057 @end example
2059 @noindent
2060 In addition, you may provide a @code{printf} format specifier to
2061 reformat the final result.  A few examples:
2063 @example
2064 $1+$2                @r{Sum of first and second field}
2065 $1+$2;%.2f           @r{Same, format result to two decimals}
2066 exp($2)+exp($1)      @r{Math functions can be used}
2067 $0;%.1f              @r{Reformat current cell to 1 decimal}
2068 ($3-32)*5/9          @r{Degrees F -> C conversion}
2069 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
2070 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
2071 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
2072 vmean($2..$7)        @r{Compute column range mean, using vector function}
2073 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
2074 taylor($3,x=7,2)     @r{taylor series of $3, at x=7, second degree}
2075 @end example
2077 Calc also contains a complete set of logical operations.  For example
2079 @example
2080 if($1<20,teen,string(""))  @r{``teen'' if age $1 less than 20, else empty}
2081 @end example
2083 @node Formula syntax for Lisp, Field formulas, Formula syntax for Calc, The spreadsheet
2084 @subsection Emacs Lisp forms as formulas
2085 @cindex Lisp forms, as table formulas
2087 It is also possible to write a formula in Emacs Lisp; this can be useful
2088 for string manipulation and control structures, if Calc's
2089 functionality is not enough.  If a formula starts with a single quote
2090 followed by an opening parenthesis, then it is evaluated as a lisp form.
2091 The evaluation should return either a string or a number.  Just as with
2092 @file{calc} formulas, you can specify modes and a printf format after a
2093 semicolon.  With Emacs Lisp forms, you need to be conscious about the way
2094 field references are interpolated into the form.  By default, a
2095 reference will be interpolated as a Lisp string (in double quotes)
2096 containing the field.  If you provide the @samp{N} mode switch, all
2097 referenced elements will be numbers (non-number fields will be zero) and
2098 interpolated as Lisp numbers, without quotes.  If you provide the
2099 @samp{L} flag, all fields will be interpolated literally, without quotes.
2100 I.e., if you want a reference to be interpreted as a string by the Lisp
2101 form, enclose the reference operator itself in double quotes, like
2102 @code{"$3"}.  Ranges are inserted as space-separated fields, so you can
2103 embed them in list or vector syntax.  A few examples, note how the
2104 @samp{N} mode is used when we do computations in lisp.
2106 @example
2107 @r{Swap the first two characters of the content of column 1}
2108   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
2109 @r{Add columns 1 and 2, equivalent to Calc's @code{$1+$2}}
2110   '(+ $1 $2);N
2111 @r{Compute the sum of columns 1-4, like Calc's @code{vsum($1..$4)}}
2112   '(apply '+ '($1..$4));N
2113 @end example
2115 @node Field formulas, Column formulas, Formula syntax for Lisp, The spreadsheet
2116 @subsection Field formulas
2117 @cindex field formula
2118 @cindex formula, for individual table field
2120 To assign a formula to a particular field, type it directly into the
2121 field, preceded by @samp{:=}, for example @samp{:=$1+$2}.  When you
2122 press @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in
2123 the field, the formula will be stored as the formula for this field,
2124 evaluated, and the current field replaced with the result.
2126 Formulas are stored in a special line starting with @samp{#+TBLFM:}
2127 directly below the table.  If you typed the equation in the 4th field of
2128 the 3rd data line in the table, the formula will look like
2129 @samp{@@3$4=$1+$2}.  When inserting/deleting/swapping column and rows
2130 with the appropriate commands, @i{absolute references} (but not relative
2131 ones) in stored formulas are modified in order to still reference the
2132 same field.  Of cause this is not true if you edit the table structure
2133 with normal editing commands - then you must fix the equations yourself.
2134 The left hand side of a formula may also be a named field (@pxref{Advanced
2135 features}), or a last-row reference like @samp{$LR3}.
2137 Instead of typing an equation into the field, you may also use the
2138 following command
2140 @table @kbd
2141 @kindex C-u C-c =
2142 @item C-u C-c =
2143 Install a new formula for the current field.  The command prompts for a
2144 formula, with default taken from the @samp{#+TBLFM:} line, applies
2145 it to the current field and stores it.
2146 @end table
2148 @node Column formulas, Editing and debugging formulas, Field formulas, The spreadsheet
2149 @subsection Column formulas
2150 @cindex column formula
2151 @cindex formula, for table column
2153 Often in a table, the same formula should be used for all fields in a
2154 particular column.  Instead of having to copy the formula to all fields
2155 in that column, Org allows to assign a single formula to an entire
2156 column.  If the table contains horizontal separator hlines, everything
2157 before the first such line is considered part of the table @emph{header}
2158 and will not be modified by column formulas.
2160 To assign a formula to a column, type it directly into any field in the
2161 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
2162 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the
2163 field, the formula will be stored as the formula for the current column,
2164 evaluated and the current field replaced with the result.  If the field
2165 contains only @samp{=}, the previously stored formula for this column is
2166 used.  For each column, Org will only remember the most recently
2167 used formula.  In the @samp{TBLFM:} line, column formulas will look like
2168 @samp{$4=$1+$2}.
2170 Instead of typing an equation into the field, you may also use the
2171 following command:
2173 @table @kbd
2174 @kindex C-c =
2175 @item C-c =
2176 Install a new formula for the current column and replace current field with
2177 the result of the formula.  The command prompts for a formula, with default
2178 taken from the @samp{#+TBLFM} line, applies it to the current field and
2179 stores it.  With a numeric prefix argument(e.g. @kbd{C-5 C-c =}) the command
2180 will apply it to that many consecutive fields in the current column.
2181 @end table
2183 @node Editing and debugging formulas, Updating the table, Column formulas, The spreadsheet
2184 @subsection Editing and debugging formulas
2185 @cindex formula editing
2186 @cindex editing, of table formulas
2188 You can edit individual formulas in the minibuffer or directly in the
2189 field.  Org can also prepare a special buffer with all active
2190 formulas of a table.  When offering a formula for editing, Org
2191 converts references to the standard format (like @code{B3} or @code{D&})
2192 if possible.  If you prefer to only work with the internal format (like
2193 @code{@@3$2} or @code{$4}), configure the variable
2194 @code{org-table-use-standard-references}.
2196 @table @kbd
2197 @kindex C-c =
2198 @kindex C-u C-c =
2199 @item C-c =
2200 @itemx C-u C-c =
2201 Edit the formula associated with the current column/field in the
2202 minibuffer.  See @ref{Column formulas} and @ref{Field formulas}.
2203 @kindex C-u C-u C-c =
2204 @item C-u C-u C-c =
2205 Re-insert the active formula (either a
2206 field formula, or a column formula) into the current field, so that you
2207 can edit it directly in the field.  The advantage over editing in the
2208 minibuffer is that you can use the command @kbd{C-c ?}.
2209 @kindex C-c ?
2210 @item C-c ?
2211 While editing a formula in a table field, highlight the field(s)
2212 referenced by the reference at the cursor position in the formula.
2213 @kindex C-c @}
2214 @item C-c @}
2215 Toggle the display of row and column numbers for a table, using
2216 overlays.  These are updated each time the table is aligned, you can
2217 force it with @kbd{C-c C-c}.
2218 @kindex C-c @{
2219 @item C-c @{
2220 Toggle the formula debugger on and off.  See below.
2221 @kindex C-c '
2222 @item C-c '
2223 Edit all formulas for the current table in a special buffer, where the
2224 formulas will be displayed one per line.  If the current field has an
2225 active formula, the cursor in the formula editor will mark it.
2226 While inside the special buffer, Org will automatically highlight
2227 any field or range reference at the cursor position.  You may edit,
2228 remove and add formulas, and use the following commands:
2229 @table @kbd
2230 @kindex C-c C-c
2231 @kindex C-x C-s
2232 @item C-c C-c
2233 @itemx C-x C-s
2234 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
2235 prefix, also apply the new formulas to the entire table.
2236 @kindex C-c C-q
2237 @item C-c C-q
2238 Exit the formula editor without installing changes.
2239 @kindex C-c C-r
2240 @item C-c C-r
2241 Toggle all references in the formula editor between standard (like
2242 @code{B3}) and internal (like @code{@@3$2}).
2243 @kindex @key{TAB}
2244 @item @key{TAB}
2245 Pretty-print or indent lisp formula at point.  When in a line containing
2246 a lisp formula, format the formula according to Emacs Lisp rules.
2247 Another @key{TAB} collapses the formula back again.  In the open
2248 formula, @key{TAB} re-indents just like in Emacs lisp mode.
2249 @kindex M-@key{TAB}
2250 @item M-@key{TAB}
2251 Complete Lisp symbols, just like in Emacs lisp mode.
2252 @kindex S-@key{up}
2253 @kindex S-@key{down}
2254 @kindex S-@key{left}
2255 @kindex S-@key{right}
2256 @item S-@key{up}/@key{down}/@key{left}/@key{right}
2257 Shift the reference at point.  For example, if the reference is
2258 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
2259 This also works for relative references, and for hline references.
2260 @kindex M-S-@key{up}
2261 @kindex M-S-@key{down}
2262 @item M-S-@key{up}/@key{down}
2263 Move the test line for column formulas in the Org buffer up and
2264 down.
2265 @kindex M-@key{up}
2266 @kindex M-@key{down}
2267 @item M-@key{up}/@key{down}
2268 Scroll the window displaying the table.
2269 @kindex C-c @}
2270 @item C-c @}
2271 Turn the coordinate grid in the table on and off.
2272 @end table
2273 @end table
2275 Making a table field blank does not remove the formula associated with
2276 the field, because that is stored in a different line (the @samp{TBLFM}
2277 line) - during the next recalculation the field will be filled again.
2278 To remove a formula from a field, you have to give an empty reply when
2279 prompted for the formula, or to edit the @samp{#+TBLFM} line.
2281 @kindex C-c C-c
2282 You may edit the @samp{#+TBLFM} directly and re-apply the changed
2283 equations with @kbd{C-c C-c} in that line, or with the normal
2284 recalculation commands in the table.
2286 @subsubheading Debugging formulas
2287 @cindex formula debugging
2288 @cindex debugging, of table formulas
2289 When the evaluation of a formula leads to an error, the field content
2290 becomes the string @samp{#ERROR}.  If you would like see what is going
2291 on during variable substitution and calculation in order to find a bug,
2292 turn on formula debugging in the @code{Tbl} menu and repeat the
2293 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
2294 field.  Detailed information will be displayed.
2296 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
2297 @subsection Updating the table
2298 @cindex recomputing table fields
2299 @cindex updating, table
2301 Recalculation of a table is normally not automatic, but needs to be
2302 triggered by a command.  See @ref{Advanced features} for a way to make
2303 recalculation at least semi-automatically.
2305 In order to recalculate a line of a table or the entire table, use the
2306 following commands:
2308 @table @kbd
2309 @kindex C-c *
2310 @item C-c *
2311 Recalculate the current row by first applying the stored column formulas
2312 from left to right, and all field formulas in the current row.
2314 @kindex C-u C-c *
2315 @item C-u C-c *
2316 @kindex C-u C-c C-c
2317 @itemx C-u C-c C-c
2318 Recompute the entire table, line by line.  Any lines before the first
2319 hline are left alone, assuming that these are part of the table header.
2321 @kindex C-u C-u C-c *
2322 @kindex C-u C-u C-c C-c
2323 @item C-u C-u C-c *
2324 @itemx C-u C-u C-c C-c
2325 Iterate the table by recomputing it until no further changes occur.
2326 This may be necessary if some computed fields use the value of other
2327 fields that are computed @i{later} in the calculation sequence.
2328 @end table
2330 @node Advanced features,  , Updating the table, The spreadsheet
2331 @subsection Advanced features
2333 If you want the recalculation of fields to happen automatically, or if
2334 you want to be able to assign @i{names} to fields and columns, you need
2335 to reserve the first column of the table for special marking characters.
2336 @table @kbd
2337 @kindex C-#
2338 @item C-#
2339 Rotate the calculation mark in first column through the states @samp{},
2340 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  When there is an active region,
2341 change all marks in the region.
2342 @end table
2344 Here is an example of a table that collects exam results of students and
2345 makes use of these features:
2347 @example
2348 @group
2349 |---+---------+--------+--------+--------+-------+------|
2350 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2351 |---+---------+--------+--------+--------+-------+------|
2352 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2353 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2354 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2355 |---+---------+--------+--------+--------+-------+------|
2356 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
2357 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
2358 |---+---------+--------+--------+--------+-------+------|
2359 |   | Average |        |        |        |  29.7 |      |
2360 | ^ |         |        |        |        |    at |      |
2361 | $ | max=50  |        |        |        |       |      |
2362 |---+---------+--------+--------+--------+-------+------|
2363 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
2364 @end group
2365 @end example
2367 @noindent @b{Important}: Please note that for these special tables,
2368 recalculating the table with @kbd{C-u C-c *} will only affect rows that
2369 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
2370 to the field itself.  The column formulas are not applied in rows with
2371 empty first field.
2373 @cindex marking characters, tables
2374 The marking characters have the following meaning:
2375 @table @samp
2376 @item !
2377 The fields in this line define names for the columns, so that you may
2378 refer to a column as @samp{$Tot} instead of @samp{$6}.
2379 @item ^
2380 This row defines names for the fields @emph{above} the row.  With such
2381 a definition, any formula in the table may use @samp{$m1} to refer to
2382 the value @samp{10}.  Also, if you assign a formula to a names field, it
2383 will be stored as @samp{$name=...}.
2384 @item _
2385 Similar to @samp{^}, but defines names for the fields in the row
2386 @emph{below}.
2387 @item $
2388 Fields in this row can define @emph{parameters} for formulas.  For
2389 example, if a field in a @samp{$} row contains @samp{max=50}, then
2390 formulas in this table can refer to the value 50 using @samp{$max}.
2391 Parameters work exactly like constants, only that they can be defined on
2392 a per-table basis.
2393 @item #
2394 Fields in this row are automatically recalculated when pressing
2395 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
2396 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
2397 lines will be left alone by this command.
2398 @item *
2399 Selects this line for global recalculation with @kbd{C-u C-c *}, but
2400 not for automatic recalculation.  Use this when automatic
2401 recalculation slows down editing too much.
2402 @item
2403 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
2404 All lines that should be recalculated should be marked with @samp{#}
2405 or @samp{*}.
2406 @item /
2407 Do not export this line.  Useful for lines that contain the narrowing
2408 @samp{<N>} markers.
2409 @end table
2411 Finally, just to whet your appetite on what can be done with the
2412 fantastic @file{calc} package, here is a table that computes the Taylor
2413 series of degree @code{n} at location @code{x} for a couple of
2414 functions.
2416 @example
2417 @group
2418 |---+-------------+---+-----+--------------------------------------|
2419 |   | Func        | n | x   | Result                               |
2420 |---+-------------+---+-----+--------------------------------------|
2421 | # | exp(x)      | 1 | x   | 1 + x                                |
2422 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
2423 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
2424 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
2425 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
2426 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
2427 |---+-------------+---+-----+--------------------------------------|
2428 #+TBLFM: $5=taylor($2,$4,$3);n3
2429 @end group
2430 @end example
2432 @page
2433 @node Org Plot,  , The spreadsheet, Tables
2434 @section Org Plot
2435 @cindex graph, in tables
2436 @cindex plot tables using gnuplot
2438 Org Plot can produce 2D and 3D graphs of information stored in org tables
2439 using @file{Gnuplot} @uref{http://www.gnuplot.info/} and @file{gnuplot-mode}
2440 @uref{http://cars9.uchicago.edu/~ravel/software/gnuplot-mode.html}.  To see
2441 this in action ensure that you have both Gnuplot and Gnuplot-mode installed
2442 on your system, then call @code{org-plot/gnuplot} on the following table.
2444 @example
2445 @group
2446 #+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
2447 | Sede      | Max cites | H-index |
2448 |-----------+-----------+---------|
2449 | Chile     |    257.72 |   21.39 |
2450 | Leeds     |    165.77 |   19.68 |
2451 | Sao Paolo |     71.00 |   11.50 |
2452 | Stockholm |    134.19 |   14.33 |
2453 | Morelia   |    257.56 |   17.67 |
2454 @end group
2455 @end example
2457 Notice that Org Plot is smart enough to apply the tables headers as labels.
2458 Further control over the labels, type, content, and appearance of plots can
2459 be exercised through the @code{#+Plot:} lines preceding a table.  See below
2460 for a complete list of Org plot options.  For more information and examples
2461 see the org-plot tutorial at
2462 @uref{http://legito.org/worg/org-tutorials/org-plot.php}.
2464 @subsubheading Plot Options
2466 @table @code
2467 @item set
2468 Specify any @file{gnuplot} option to be set when graphing.
2470 @item title
2471 Specify the title of the plot.
2473 @item ind
2474 Specify which column of the table to use as the @code{x} axis.
2476 @item deps
2477 Specify the columns to graph as a lisp style list, surrounded by parenthesis
2478 and separated by spaces for example @code{dep:(3 4)} to graph the third and
2479 fourth columns (defaults to graphing all other columns aside from the ind
2480 column).
2482 @item type
2483 Specify whether the plot will be @code{2d}, @code{3d}, or @code{grid}.
2485 @item with
2486 Specify a @code{with} option to be inserted for every col being plotted
2487 (e.g. @code{lines}, @code{points}, @code{boxes}, @code{impulses}, etc...).
2488 Defaults to 'lines'.
2490 @item file
2491 If you want to plot to a file specify the @code{"path/to/desired/output-file"}.
2493 @item labels
2494 List of labels to be used for the deps (defaults to column headers if they
2495 exist).
2497 @item line
2498 Specify an entire line to be inserted in the gnuplot script.
2500 @item map
2501 When plotting @code{3d} or @code{grid} types, set this to @code{t} to graph a
2502 flat mapping rather than a @code{3d} slope.
2504 @item timefmt
2505 Specify format of org-mode timestamps as they will be parsed by gnuplot.
2506 Defaults to '%Y-%m-%d-%H:%M:%S'.
2508 @item script
2509 If you want total control you can specify a script file (place the file name
2510 between double quotes) which will be used to plot.  Before plotting, every
2511 instance of @code{$datafile} in the specified script will be replaced with
2512 the path to the generated data file.  Note even if you set this option you
2513 may still want to specify the plot type, as that can impact the content of
2514 the data file.
2515 @end table
2517 @node Hyperlinks, TODO Items, Tables, Top
2518 @chapter Hyperlinks
2519 @cindex hyperlinks
2521 Like HTML, Org provides links inside a file, external links to
2522 other files, Usenet articles, emails, and much more.
2524 @menu
2525 * Link format::                 How links in Org are formatted
2526 * Internal links::              Links to other places in the current file
2527 * External links::              URL-like links to the world
2528 * Handling links::              Creating, inserting and following
2529 * Using links outside Org::     Linking from my C source code?
2530 * Link abbreviations::          Shortcuts for writing complex links
2531 * Search options::              Linking to a specific location
2532 * Custom searches::             When the default search is not enough
2533 @end menu
2535 @node Link format, Internal links, Hyperlinks, Hyperlinks
2536 @section Link format
2537 @cindex link format
2538 @cindex format, of links
2540 Org will recognize plain URL-like links and activate them as
2541 clickable links.  The general link format, however, looks like this:
2543 @example
2544 [[link][description]]       @r{or alternatively}           [[link]]
2545 @end example
2547 Once a link in the buffer is complete (all brackets present), Org
2548 will change the display so that @samp{description} is displayed instead
2549 of @samp{[[link][description]]} and @samp{link} is displayed instead of
2550 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
2551 which by default is an underlined face.  You can directly edit the
2552 visible part of a link.  Note that this can be either the @samp{link}
2553 part (if there is no description) or the @samp{description} part.  To
2554 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
2555 cursor on the link.
2557 If you place the cursor at the beginning or just behind the end of the
2558 displayed text and press @key{BACKSPACE}, you will remove the
2559 (invisible) bracket at that location.  This makes the link incomplete
2560 and the internals are again displayed as plain text.  Inserting the
2561 missing bracket hides the link internals again.  To show the
2562 internal structure of all links, use the menu entry
2563 @code{Org->Hyperlinks->Literal links}.
2565 @node Internal links, External links, Link format, Hyperlinks
2566 @section Internal links
2567 @cindex internal links
2568 @cindex links, internal
2569 @cindex targets, for links
2571 If the link does not look like a URL, it is considered to be internal in
2572 the current file.  Links such as @samp{[[My Target]]} or @samp{[[My
2573 Target][Find my target]]} lead to a text search in the current file.
2574 The link can be followed with @kbd{C-c C-o} when the cursor is on the
2575 link, or with a mouse click (@pxref{Handling links}).  The preferred
2576 match for such a link is a dedicated target: the same string in double
2577 angular brackets.  Targets may be located anywhere; sometimes it is
2578 convenient to put them into a comment line. For example
2580 @example
2581 # <<My Target>>
2582 @end example
2584 @noindent In HTML export (@pxref{HTML export}), such targets will become
2585 named anchors for direct access through @samp{http} links@footnote{Note that
2586 text before the first headline is usually not exported, so the first such
2587 target should be after the first headline, or in the line directly before the
2588 first headline.}.
2590 If no dedicated target exists, Org will search for the words in the
2591 link.  In the above example the search would be for @samp{my target}.
2592 Links starting with a star like @samp{*My Target} restrict the search to
2593 headlines.  When searching, Org mode will first try an exact match, but
2594 then move on to more and more lenient searches.  For example, the link
2595 @samp{[[*My Targets]]} will find any of the following:
2597 @example
2598 ** My targets
2599 ** TODO my targets are bright
2600 ** my 20 targets are
2601 @end example
2603 To insert a link targeting a headline, in-buffer completion can be used.
2604 Just type a star followed by a few optional letters into the buffer and
2605 press @kbd{M-@key{TAB}}.  All headlines in the current buffer will be
2606 offered as completions.  @xref{Handling links}, for more commands
2607 creating links.
2609 Following a link pushes a mark onto Org's own mark ring.  You can
2610 return to the previous position with @kbd{C-c &}.  Using this command
2611 several times in direct succession goes back to positions recorded
2612 earlier.
2614 @menu
2615 * Radio targets::               Make targets trigger links in plain text
2616 @end menu
2618 @node Radio targets,  , Internal links, Internal links
2619 @subsection Radio targets
2620 @cindex radio targets
2621 @cindex targets, radio
2622 @cindex links, radio targets
2624 Org can automatically turn any occurrences of certain target names
2625 in normal text into a link.  So without explicitly creating a link, the
2626 text connects to the target radioing its position.  Radio targets are
2627 enclosed by triple angular brackets.  For example, a target @samp{<<<My
2628 Target>>>} causes each occurrence of @samp{my target} in normal text to
2629 become activated as a link.  The Org file is scanned automatically
2630 for radio targets only when the file is first loaded into Emacs.  To
2631 update the target list during editing, press @kbd{C-c C-c} with the
2632 cursor on or at a target.
2634 @node External links, Handling links, Internal links, Hyperlinks
2635 @section External links
2636 @cindex links, external
2637 @cindex external links
2638 @cindex links, external
2639 @cindex Gnus links
2640 @cindex BBDB links
2641 @cindex IRC links
2642 @cindex URL links
2643 @cindex file links
2644 @cindex VM links
2645 @cindex RMAIL links
2646 @cindex WANDERLUST links
2647 @cindex MH-E links
2648 @cindex USENET links
2649 @cindex SHELL links
2650 @cindex Info links
2651 @cindex elisp links
2653 Org supports links to files, websites, Usenet and email messages,
2654 BBDB database entries and links to both IRC conversations and their
2655 logs.  External links are URL-like locators.  They start with a short
2656 identifying string followed by a colon.  There can be no space after
2657 the colon.  The following list shows examples for each link type.
2659 @example
2660 http://www.astro.uva.nl/~dominik          @r{on the web}
2661 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
2662 /home/dominik/images/jupiter.jpg          @r{same as above}
2663 file:papers/last.pdf                      @r{file, relative path}
2664 ./papers/last.pdf                         @r{same as above}
2665 file:projects.org                         @r{another org file}
2666 file:projects.org::some words             @r{text search in org file}
2667 file:projects.org::*task title            @r{heading search in org file}
2668 id:B7423F4D-2E8A-471B-8810-C40F074717E9   @r{Link to heading by ID}
2669 news:comp.emacs                           @r{Usenet link}
2670 mailto:adent@@galaxy.net                   @r{Mail link}
2671 vm:folder                                 @r{VM folder link}
2672 vm:folder#id                              @r{VM message link}
2673 vm://myself@@some.where.org/folder#id      @r{VM on remote machine}
2674 wl:folder                                 @r{WANDERLUST folder link}
2675 wl:folder#id                              @r{WANDERLUST message link}
2676 mhe:folder                                @r{MH-E folder link}
2677 mhe:folder#id                             @r{MH-E message link}
2678 rmail:folder                              @r{RMAIL folder link}
2679 rmail:folder#id                           @r{RMAIL message link}
2680 gnus:group                                @r{Gnus group link}
2681 gnus:group#id                             @r{Gnus article link}
2682 bbdb:R.*Stallman                          @r{BBDB link (with regexp)}
2683 irc:/irc.com/#emacs/bob                   @r{IRC link}
2684 shell:ls *.org                            @r{A shell command}
2685 elisp:org-agenda                          @r{Interactive elisp command}
2686 elisp:(find-file-other-frame "Elisp.org") @r{Elisp form to evaluate}
2687 @end example
2689 A link should be enclosed in double brackets and may contain a
2690 descriptive text to be displayed instead of the URL (@pxref{Link
2691 format}), for example:
2693 @example
2694 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
2695 @end example
2697 @noindent
2698 If the description is a file name or URL that points to an image, HTML
2699 export (@pxref{HTML export}) will inline the image as a clickable
2700 button.  If there is no description at all and the link points to an
2701 image,
2702 that image will be inlined into the exported HTML file.
2704 @cindex angular brackets, around links
2705 @cindex plain text external links
2706 Org also finds external links in the normal text and activates them
2707 as links.  If spaces must be part of the link (for example in
2708 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
2709 about the end of the link, enclose them in angular brackets.
2711 @node Handling links, Using links outside Org, External links, Hyperlinks
2712 @section Handling links
2713 @cindex links, handling
2715 Org provides methods to create a link in the correct syntax, to
2716 insert it into an Org file, and to follow the link.
2718 @table @kbd
2719 @kindex C-c l
2720 @cindex storing links
2721 @item C-c l
2722 Store a link to the current location.  This is a @emph{global} command (you
2723 must create the key binding yourself) which can be used in any buffer to
2724 create a link.  The link will be stored for later insertion into an Org
2725 buffer (see below).
2727 For Org files, if there is a @samp{<<target>>} at the cursor, the link points
2728 to the target.  Otherwise it points to the current headline, either by text
2729 (unsafe), or, if @file{org-id.el} is loaded and @code{org-link-to-org-use-id}
2730 is set, by ID property.
2732 For VM, Rmail, Wanderlust, MH-E, Gnus and BBDB buffers, the link will
2733 indicate the current article/entry.  For W3 and W3M buffers, the link goes to
2734 the current URL.  For IRC links, if you set the variable
2735 @code{org-irc-link-to-logs} to non-nil then @kbd{C-c l} will store a
2736 @samp{file:/} style link to the relevant point in the logs for the current
2737 conversation.  Otherwise an @samp{irc:/} style link to the user/channel/server
2738 under the point will be stored. 
2740 For any other files, the link will point to the file, with a search string
2741 (@pxref{Search options}) pointing to the contents of the current line.  If
2742 there is an active region, the selected words will form the basis of the
2743 search string.  If the automatically created link is not working correctly or
2744 accurately enough, you can write custom functions to select the search string
2745 and to do the search for particular file types - see @ref{Custom searches}.
2746 The key binding @kbd{C-c l} is only a suggestion - see @ref{Installation}.
2748 @kindex C-c C-l
2749 @cindex link completion
2750 @cindex completion, of links
2751 @cindex inserting links
2752 @item C-c C-l
2753 Insert a link.  This prompts for a link to be inserted into the buffer.  You
2754 can just type a link, using text for an internal link, or one of the link
2755 type prefixes mentioned in the examples above.  All links stored during the
2756 current session are part of the history for this prompt, so you can access
2757 them with @key{up} and @key{down} (or @kbd{M-p/n}).  Completion, on the other
2758 hand, will help you to insert valid link prefixes like @samp{http:} or
2759 @samp{ftp:}, including the prefixes defined through link abbreviations
2760 (@pxref{Link abbreviations}).  The link will be inserted into the
2761 buffer@footnote{After insertion of a stored link, the link will be removed
2762 from the list of stored links.  To keep it in the list later use, use a
2763 triple @kbd{C-u} prefix argument to @kbd{C-c C-l}, or configure the option
2764 @code{org-keep-stored-link-after-insertion}.}, along with a descriptive text.
2765 If some text was selected when this command is called, the selected text
2766 becomes the default description.@* Note that you don't have to use this
2767 command to insert a link.  Links in Org are plain text, and you can type
2768 or paste them straight into the buffer.  By using this command, the links are
2769 automatically enclosed in double brackets, and you will be asked for the
2770 optional descriptive text.
2772 @c  If the link is a @samp{file:} link and
2773 @c the linked file is located in the same directory as the current file or
2774 @c a subdirectory of it, the path of the file will be inserted relative to
2775 @c the current directory.
2777 @kindex C-u C-c C-l
2778 @cindex file name completion
2779 @cindex completion, of file names
2780 @item C-u C-c C-l
2781 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
2782 a file will be inserted and you may use file name completion to select
2783 the name of the file.  The path to the file is inserted relative to the
2784 directory of the current org file, if the linked file is in the current
2785 directory or in a sub-directory of it, or if the path is written relative
2786 to the current directory using @samp{../}.  Otherwise an absolute path
2787 is used, if possible with @samp{~/} for your home directory.  You can
2788 force an absolute path with two @kbd{C-u} prefixes.
2790 @item C-c C-l @r{(with cursor on existing link)}
2791 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
2792 link and description parts of the link.
2794 @cindex following links
2795 @kindex C-c C-o
2796 @item C-c C-o
2797 Open link at point.  This will launch a web browser for URLs (using
2798 @command{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB for
2799 the corresponding links, and execute the command in a shell link.  When the
2800 cursor is on an internal link, this commands runs the corresponding search.
2801 When the cursor is on a TAG list in a headline, it creates the corresponding
2802 TAGS view.  If the cursor is on a time stamp, it compiles the agenda for that
2803 date.  Furthermore, it will visit text and remote files in @samp{file:} links
2804 with Emacs and select a suitable application for local non-text files.
2805 Classification of files is based on file extension only.  See option
2806 @code{org-file-apps}.  If you want to override the default application and
2807 visit the file with Emacs, use a @kbd{C-u} prefix.  If you want to avoid
2808 opening in Emacs, use a @kbd{C-u C-u} prefix.
2810 @kindex mouse-2
2811 @kindex mouse-1
2812 @item mouse-2
2813 @itemx mouse-1
2814 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
2815 would.  Under Emacs 22, also @kbd{mouse-1} will follow a link.
2817 @kindex mouse-3
2818 @item mouse-3
2819 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
2820 internal links to be displayed in another window@footnote{See the
2821 variable @code{org-display-internal-link-with-indirect-buffer}}.
2823 @cindex mark ring
2824 @kindex C-c %
2825 @item C-c %
2826 Push the current position onto the mark ring, to be able to return
2827 easily. Commands following an internal link do this automatically.
2829 @cindex links, returning to
2830 @kindex C-c &
2831 @item C-c &
2832 Jump back to a recorded position.  A position is recorded by the
2833 commands following internal links, and by @kbd{C-c %}.  Using this
2834 command several times in direct succession moves through a ring of
2835 previously recorded positions.
2837 @kindex C-c C-x C-n
2838 @kindex C-c C-x C-p
2839 @cindex links, finding next/previous
2840 @item C-c C-x C-n
2841 @itemx C-c C-x C-p
2842 Move forward/backward to the next link in the buffer.  At the limit of
2843 the buffer, the search fails once, and then wraps around.  The key
2844 bindings for this are really too long, you might want to bind this also
2845 to @kbd{C-n} and @kbd{C-p}
2846 @lisp
2847 (add-hook 'org-load-hook
2848   (lambda ()
2849     (define-key 'org-mode-map "\C-n" 'org-next-link)
2850     (define-key 'org-mode-map "\C-p" 'org-previous-link)))
2851 @end lisp
2852 @end table
2854 @node Using links outside Org, Link abbreviations, Handling links, Hyperlinks
2855 @section Using links outside Org
2857 You can insert and follow links that have Org syntax not only in
2858 Org, but in any Emacs buffer.  For this, you should create two
2859 global commands, like this (please select suitable global keys
2860 yourself):
2862 @lisp
2863 (global-set-key "\C-c L" 'org-insert-link-global)
2864 (global-set-key "\C-c o" 'org-open-at-point-global)
2865 @end lisp
2867 @node Link abbreviations, Search options, Using links outside Org, Hyperlinks
2868 @section Link abbreviations
2869 @cindex link abbreviations
2870 @cindex abbreviation, links
2872 Long URLs can be cumbersome to type, and often many similar links are
2873 needed in a document.  For this you can use link abbreviations.  An
2874 abbreviated link looks like this
2876 @example
2877 [[linkword:tag][description]]
2878 @end example
2880 @noindent
2881 where the tag is optional.  Such abbreviations are resolved according to
2882 the information in the variable @code{org-link-abbrev-alist} that
2883 relates the linkwords to replacement text.  Here is an example:
2885 @lisp
2886 @group
2887 (setq org-link-abbrev-alist
2888   '(("bugzilla" . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
2889     ("google"   . "http://www.google.com/search?q=")
2890     ("ads"      . "http://adsabs.harvard.edu/cgi-bin/
2891                    nph-abs_connect?author=%s&db_key=AST")))
2892 @end group
2893 @end lisp
2895 If the replacement text contains the string @samp{%s}, it will be
2896 replaced with the tag.  Otherwise the tag will be appended to the string
2897 in order to create the link.  You may also specify a function that will
2898 be called with the tag as the only argument to create the link.
2900 With the above setting, you could link to a specific bug with
2901 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
2902 @code{[[google:OrgMode]]} and find out what the Org author is
2903 doing besides Emacs hacking with @code{[[ads:Dominik,C]]}.
2905 If you need special abbreviations just for a single Org buffer, you
2906 can define them in the file with
2908 @example
2909 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
2910 #+LINK: google    http://www.google.com/search?q=%s
2911 @end example
2913 @noindent
2914 In-buffer completion @pxref{Completion} can be used after @samp{[} to
2915 complete link abbreviations.
2917 @node Search options, Custom searches, Link abbreviations, Hyperlinks
2918 @section Search options in file links
2919 @cindex search option in file links
2920 @cindex file links, searching
2922 File links can contain additional information to make Emacs jump to a
2923 particular location in the file when following a link.  This can be a
2924 line number or a search option after a double@footnote{For backward
2925 compatibility, line numbers can also follow a single colon.} colon. For
2926 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
2927 links}) to a file, it encodes the words in the current line as a search
2928 string that can be used to find this line back later when following the
2929 link with @kbd{C-c C-o}.
2931 Here is the syntax of the different ways to attach a search to a file
2932 link, together with an explanation:
2934 @example
2935 [[file:~/code/main.c::255]]
2936 [[file:~/xx.org::My Target]]
2937 [[file:~/xx.org::*My Target]]
2938 [[file:~/xx.org::/regexp/]]
2939 @end example
2941 @table @code
2942 @item 255
2943 Jump to line 255.
2944 @item My Target
2945 Search for a link target @samp{<<My Target>>}, or do a text search for
2946 @samp{my target}, similar to the search in internal links, see
2947 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
2948 link will become an HTML reference to the corresponding named anchor in
2949 the linked file.
2950 @item *My Target
2951 In an Org file, restrict search to headlines.
2952 @item /regexp/
2953 Do a regular expression search for @code{regexp}.  This uses the Emacs
2954 command @code{occur} to list all matches in a separate window.  If the
2955 target file is in Org mode, @code{org-occur} is used to create a
2956 sparse tree with the matches.
2957 @c If the target file is a directory,
2958 @c @code{grep} will be used to search all files in the directory.
2959 @end table
2961 As a degenerate case, a file link with an empty file name can be used
2962 to search the current file.  For example, @code{[[file:::find me]]} does
2963 a search for @samp{find me} in the current file, just as
2964 @samp{[[find me]]} would.
2966 @node Custom searches,  , Search options, Hyperlinks
2967 @section Custom Searches
2968 @cindex custom search strings
2969 @cindex search strings, custom
2971 The default mechanism for creating search strings and for doing the
2972 actual search related to a file link may not work correctly in all
2973 cases.  For example, BibTeX database files have many entries like
2974 @samp{year="1993"} which would not result in good search strings,
2975 because the only unique identification for a BibTeX entry is the
2976 citation key.
2978 If you come across such a problem, you can write custom functions to set
2979 the right search string for a particular file type, and to do the search
2980 for the string in the file.  Using @code{add-hook}, these functions need
2981 to be added to the hook variables
2982 @code{org-create-file-search-functions} and
2983 @code{org-execute-file-search-functions}.  See the docstring for these
2984 variables for more information.  Org actually uses this mechanism
2985 for Bib@TeX{} database files, and you can use the corresponding code as
2986 an implementation example.  See the file @file{org-bibtex.el}.
2988 @node TODO Items, Tags, Hyperlinks, Top
2989 @chapter TODO Items
2990 @cindex TODO items
2992 Org mode does not maintain TODO lists as separate documents@footnote{Of
2993 course, you can make a document that contains only long lists of TODO items,
2994 but this is not required.}.  Instead, TODO items are an integral part of the
2995 notes file, because TODO items usually come up while taking notes!  With Org
2996 mode, simply mark any entry in a tree as being a TODO item.  In this way,
2997 information is not duplicated, and the entire context from which the TODO
2998 item emerged is always present.
3000 Of course, this technique for managing TODO items scatters them
3001 throughout your notes file.  Org mode compensates for this by providing
3002 methods to give you an overview of all the things that you have to do.
3004 @menu
3005 * TODO basics::                 Marking and displaying TODO entries
3006 * TODO extensions::             Workflow and assignments
3007 * Progress logging::            Dates and notes for progress
3008 * Priorities::                  Some things are more important than others
3009 * Breaking down tasks::         Splitting a task into manageable pieces
3010 * Checkboxes::                  Tick-off lists
3011 @end menu
3013 @node TODO basics, TODO extensions, TODO Items, TODO Items
3014 @section Basic TODO functionality
3016 Any headline becomes a TODO item when it starts with the word
3017 @samp{TODO}, for example:
3019 @example
3020 *** TODO Write letter to Sam Fortune
3021 @end example
3023 @noindent
3024 The most important commands to work with TODO entries are:
3026 @table @kbd
3027 @kindex C-c C-t
3028 @cindex cycling, of TODO states
3029 @item C-c C-t
3030 Rotate the TODO state of the current item among
3032 @example
3033 ,-> (unmarked) -> TODO -> DONE --.
3034 '--------------------------------'
3035 @end example
3037 The same rotation can also be done ``remotely'' from the timeline and
3038 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
3040 @kindex C-u C-c C-t
3041 @item C-u C-c C-t
3042 Select a specific keyword using completion or (if it has been set up)
3043 the fast selection interface.  For the latter, you need to assign keys
3044 to TODO states, see @ref{Per-file keywords} and @ref{Setting tags} for
3045 more information.
3047 @kindex S-@key{right}
3048 @kindex S-@key{left}
3049 @item S-@key{right}
3050 @itemx S-@key{left}
3051 Select the following/preceding TODO state, similar to cycling.  Useful
3052 mostly if more than two TODO states are possible (@pxref{TODO
3053 extensions}).  See also @ref{Conflicts} for a discussion of the interaction
3054 with @code{shift-selection-mode}.
3055 @kindex C-c C-v
3056 @kindex C-c / t
3057 @cindex sparse tree, for TODO
3058 @item C-c C-v
3059 @itemx C-c / t
3060 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds
3061 the entire buffer, but shows all TODO items and the headings hierarchy
3062 above them.  With a prefix argument, search for a specific TODO.  You will be
3063 prompted for the keyword, and you can also give a list of keywords like
3064 @code{KWD1|KWD2|...}.  With numeric prefix argument N, show the tree for the
3065 Nth keyword in the variable @code{org-todo-keywords}.  With two prefix
3066 arguments, find all TODO and DONE entries.
3067 @kindex C-c a t
3068 @item C-c a t
3069 Show the global TODO list.  Collects the TODO items from all agenda
3070 files (@pxref{Agenda Views}) into a single buffer.  The new buffer will
3071 be in @code{agenda-mode}, which provides commands to examine and
3072 manipulate the TODO entries from the new buffer (@pxref{Agenda
3073 commands}).  @xref{Global TODO list}, for more information.
3074 @kindex S-M-@key{RET}
3075 @item S-M-@key{RET}
3076 Insert a new TODO entry below the current one.
3077 @end table
3079 @noindent
3080 Changing a TODO state can also trigger tag changes.  See the docstring of the
3081 option @code{org-todo-state-tags-triggers} for details.
3083 @node TODO extensions, Progress logging, TODO basics, TODO Items
3084 @section Extended use of TODO keywords
3085 @cindex extended TODO keywords
3087 By default, marked TODO entries have one of only two states: TODO and
3088 DONE.  Org mode allows you to classify TODO items in more complex ways
3089 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With
3090 special setup, the TODO keyword system can work differently in different
3091 files.
3093 Note that @i{tags} are another way to classify headlines in general and
3094 TODO items in particular (@pxref{Tags}).
3096 @menu
3097 * Workflow states::             From TODO to DONE in steps
3098 * TODO types::                  I do this, Fred does the rest
3099 * Multiple sets in one file::   Mixing it all, and still finding your way
3100 * Fast access to TODO states::  Single letter selection of a state
3101 * Per-file keywords::           Different files, different requirements
3102 * Faces for TODO keywords::     Highlighting states
3103 @end menu
3105 @node Workflow states, TODO types, TODO extensions, TODO extensions
3106 @subsection TODO keywords as workflow states
3107 @cindex TODO workflow
3108 @cindex workflow states as TODO keywords
3110 You can use TODO keywords to indicate different @emph{sequential} states
3111 in the process of working on an item, for example@footnote{Changing
3112 this variable only becomes effective after restarting Org mode in a
3113 buffer.}:
3115 @lisp
3116 (setq org-todo-keywords
3117   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
3118 @end lisp
3120 The vertical bar separates the TODO keywords (states that @emph{need
3121 action}) from the DONE states (which need @emph{no further action}).  If
3122 you don't provide the separator bar, the last state is used as the DONE
3123 state.
3124 @cindex completion, of TODO keywords
3125 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
3126 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED.  You may
3127 also use a numeric prefix argument to quickly select a specific state.  For
3128 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY.
3129 Or you can use @kbd{S-left} to go backward through the sequence.  If you
3130 define many keywords, you can use in-buffer completion
3131 (@pxref{Completion}) or even a special one-key selection scheme
3132 (@pxref{Fast access to TODO states}) to insert these words into the
3133 buffer.  Changing a TODO state can be logged with a timestamp, see
3134 @ref{Tracking TODO state changes} for more information.
3136 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
3137 @subsection TODO keywords as types
3138 @cindex TODO types
3139 @cindex names as TODO keywords
3140 @cindex types as TODO keywords
3142 The second possibility is to use TODO keywords to indicate different
3143 @emph{types} of action items.  For example, you might want to indicate
3144 that items are for ``work'' or ``home''.  Or, when you work with several
3145 people on a single project, you might want to assign action items
3146 directly to persons, by using their names as TODO keywords.  This would
3147 be set up like this:
3149 @lisp
3150 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
3151 @end lisp
3153 In this case, different keywords do not indicate a sequence, but rather
3154 different types.  So the normal work flow would be to assign a task to a
3155 person, and later to mark it DONE.  Org mode supports this style by adapting
3156 the workings of the command @kbd{C-c C-t}@footnote{This is also true for the
3157 @kbd{t} command in the timeline and agenda buffers.}.  When used several
3158 times in succession, it will still cycle through all names, in order to first
3159 select the right type for a task.  But when you return to the item after some
3160 time and execute @kbd{C-c C-t} again, it will switch from any name directly
3161 to DONE.  Use prefix arguments or completion to quickly select a specific
3162 name.  You can also review the items of a specific TODO type in a sparse tree
3163 by using a numeric prefix to @kbd{C-c C-v}.  For example, to see all things
3164 Lucy has to do, you would use @kbd{C-3 C-c C-v}.  To collect Lucy's items
3165 from all agenda files into a single buffer, you would use the numeric prefix
3166 argument as well when creating the global TODO list: @kbd{C-3 C-c t}.
3168 @node Multiple sets in one file, Fast access to TODO states, TODO types, TODO extensions
3169 @subsection Multiple keyword sets in one file
3170 @cindex TODO keyword sets
3172 Sometimes you may want to use different sets of TODO keywords in
3173 parallel.  For example, you may want to have the basic
3174 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
3175 separate state indicating that an item has been canceled (so it is not
3176 DONE, but also does not require action).  Your setup would then look
3177 like this:
3179 @lisp
3180 (setq org-todo-keywords
3181       '((sequence "TODO" "|" "DONE")
3182         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
3183         (sequence "|" "CANCELED")))
3184 @end lisp
3186 The keywords should all be different, this helps Org mode to keep track
3187 of which subsequence should be used for a given entry.  In this setup,
3188 @kbd{C-c C-t} only operates within a subsequence, so it switches from
3189 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
3190 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
3191 select the correct sequence.  Besides the obvious ways like typing a
3192 keyword or using completion, you may also apply the following commands:
3194 @table @kbd
3195 @kindex C-S-@key{right}
3196 @kindex C-S-@key{left}
3197 @kindex C-u C-u C-c C-t
3198 @item C-u C-u C-c C-t
3199 @itemx C-S-@key{right}
3200 @itemx C-S-@key{left}
3201 These keys jump from one TODO subset to the next.  In the above example,
3202 @kbd{C-u C-u C-c C-t} or @kbd{C-S-@key{right}} would jump from @code{TODO} or
3203 @code{DONE} to @code{REPORT}, and any of the words in the second row to
3204 @code{CANCELED}.  Note that the @kbd{C-S-} key binding conflict with
3205 @code{shift-selection-mode} (@pxref{Conflicts}).
3206 @kindex S-@key{right}
3207 @kindex S-@key{left}
3208 @item S-@key{right}
3209 @itemx S-@key{left}
3210 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through @emph{all}
3211 keywords from all sets, so for example @kbd{S-@key{<right>}} would switch
3212 from @code{DONE} to @code{REPORT} in the example above.  See also
3213 @ref{Conflicts} for a discussion of the interaction with
3214 @code{shift-selection-mode}.
3215 @end table
3217 @node Fast access to TODO states, Per-file keywords, Multiple sets in one file, TODO extensions
3218 @subsection Fast access to TODO states
3220 If you would like to quickly change an entry to an arbitrary TODO state
3221 instead of cycling through the states, you can set up keys for
3222 single-letter access to the states.  This is done by adding the section
3223 key after each keyword, in parenthesis.  For example:
3225 @lisp
3226 (setq org-todo-keywords
3227       '((sequence "TODO(t)" "|" "DONE(d)")
3228         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
3229         (sequence "|" "CANCELED(c)")))
3230 @end lisp
3232 If you then press @code{C-u C-c C-t} followed by the selection key, the
3233 entry will be switched to this state.  @key{SPC} can be used to remove
3234 any TODO keyword from an entry.  Should you like this way of selecting
3235 TODO states a lot, you might want to set the variable
3236 @code{org-use-fast-todo-selection} to @code{t} and make this behavior
3237 the default.  Check also the variable
3238 @code{org-fast-tag-selection-include-todo}, it allows to change the TODO
3239 state through the tags interface (@pxref{Setting tags}), in case you
3240 like to mingle the two concepts.
3242 @node Per-file keywords, Faces for TODO keywords, Fast access to TODO states, TODO extensions
3243 @subsection Setting up keywords for individual files
3244 @cindex keyword options
3245 @cindex per-file keywords
3247 It can be very useful to use different aspects of the TODO mechanism in
3248 different files.  For file-local settings, you need to add special lines
3249 to the file which set the keywords and interpretation for that file
3250 only.  For example, to set one of the two examples discussed above, you
3251 need one of the following lines, starting in column zero anywhere in the
3252 file:
3254 @example
3255 #+SEQ_TODO: TODO FEEDBACK VERIFY | DONE CANCELED
3256 @end example
3258 @example
3259 #+TYP_TODO: Fred Sara Lucy Mike | DONE
3260 @end example
3262 A setup for using several sets in parallel would be:
3264 @example
3265 #+SEQ_TODO: TODO | DONE
3266 #+SEQ_TODO: REPORT BUG KNOWNCAUSE | FIXED
3267 #+SEQ_TODO: | CANCELED
3268 @end example
3270 @cindex completion, of option keywords
3271 @kindex M-@key{TAB}
3272 @noindent To make sure you are using the correct keyword, type
3273 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
3275 @cindex DONE, final TODO keyword
3276 Remember that the keywords after the vertical bar (or the last keyword
3277 if no bar is there) must always mean that the item is DONE (although you
3278 may use a different word).  After changing one of these lines, use
3279 @kbd{C-c C-c} with the cursor still in the line to make the changes
3280 known to Org mode@footnote{Org mode parses these lines only when
3281 Org mode is activated after visiting a file.  @kbd{C-c C-c} with the
3282 cursor in a line starting with @samp{#+} is simply restarting Org mode
3283 for the current buffer.}.
3285 @node Faces for TODO keywords,  , Per-file keywords, TODO extensions
3286 @subsection Faces for TODO keywords
3287 @cindex faces, for TODO keywords
3289 Org mode highlights TODO keywords with special faces: @code{org-todo}
3290 for keywords indicating that an item still has to be acted upon, and
3291 @code{org-done} for keywords indicating that an item is finished.  If
3292 you are using more than 2 different states, you might want to use
3293 special faces for some of them.  This can be done using the variable
3294 @code{org-todo-keyword-faces}.  For example:
3296 @lisp
3297 @group
3298 (setq org-todo-keyword-faces
3299       '(("TODO"      . org-warning)
3300         ("DEFERRED"  . shadow)
3301         ("CANCELED"  . (:foreground "blue" :weight bold))))
3302 @end group
3303 @end lisp
3305 While using a list with face properties as shown for CANCELED
3306 @emph{should} work, this does not aways seem to be the case.  If
3307 necessary, define a special face and use that.
3309 @page
3310 @node Progress logging, Priorities, TODO extensions, TODO Items
3311 @section Progress logging
3312 @cindex progress logging
3313 @cindex logging, of progress
3315 Org mode can automatically record a time stamp and possibly a note when
3316 you mark a TODO item as DONE, or even each time you change the state of
3317 a TODO item.  This system is highly configurable, settings can be on a
3318 per-keyword basis and can be localized to a file or even a subtree.  For
3319 information on how to clock working time for a task, see @ref{Clocking
3320 work time}.
3322 @menu
3323 * Closing items::               When was this entry marked DONE?
3324 * Tracking TODO state changes::  When did the status change?
3325 @end menu
3327 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
3328 @subsection Closing items
3330 The most basic logging is to keep track of @emph{when} a certain TODO
3331 item was finished.  This is achieved with@footnote{The corresponding
3332 in-buffer setting is: @code{#+STARTUP: logdone}}.
3334 @lisp
3335 (setq org-log-done 'time)
3336 @end lisp
3338 @noindent
3339 Then each time you turn an entry from a TODO (not-done) state into any
3340 of the DONE states, a line @samp{CLOSED: [timestamp]} will be inserted
3341 just after the headline.  If you turn the entry back into a TODO item
3342 through further state cycling, that line will be removed again.  If you
3343 want to record a note along with the timestamp, use@footnote{The
3344 corresponding in-buffer setting is: @code{#+STARTUP: lognotedone}}
3346 @lisp
3347 (setq org-log-done 'note)
3348 @end lisp
3350 @noindent
3351 You will then be prompted for a note, and that note will be stored below
3352 the entry with a @samp{Closing Note} heading.
3354 In the timeline (@pxref{Timeline}) and in the agenda
3355 (@pxref{Weekly/daily agenda}), you can then use the @kbd{l} key to
3356 display the TODO items with a @samp{CLOSED} timestamp on each day,
3357 giving you an overview of what has been done.
3359 @node Tracking TODO state changes,  , Closing items, Progress logging
3360 @subsection Tracking TODO state changes
3362 When TODO keywords are used as workflow states (@pxref{Workflow
3363 states}), you might want to keep track of when a state change occurred
3364 and maybe take a note about this change.  Since it is normally too much
3365 to record a note for every state, Org mode expects configuration on a
3366 per-keyword basis for this.  This is achieved by adding special markers
3367 @samp{!} (for a time stamp) and @samp{@@} (for a note) in parenthesis
3368 after each keyword.  For example, with the setting
3370 @lisp
3371 (setq org-todo-keywords
3372   '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
3373 @end lisp
3375 @noindent
3376 you not only define global TODO keywords and fast access keys, but also
3377 request that a time is recorded when the entry is turned into
3378 DONE@footnote{It is possible that Org mode will record two time stamps
3379 when you are using both @code{org-log-done} and state change logging.
3380 However, it will never prompt for two notes - if you have configured
3381 both, the state change recording note will take precedence and cancel
3382 the @samp{Closing Note}.}, and that a note is recorded when switching to
3383 WAIT or CANCELED.  The setting for WAIT is even more special: The
3384 @samp{!} after the slash means that in addition to the note taken when
3385 entering the state, a time stamp should be recorded when @i{leaving} the
3386 WAIT state, if and only if the @i{target} state does not configure
3387 logging for entering it.  So it has no effect when switching from WAIT
3388 to DONE, because DONE is configured to record a timestamp only.  But
3389 when switching from WAIT back to TODO, the @samp{/!} in the WAIT
3390 setting now triggers a timestamp even though TODO has no logging
3391 configured.
3393 You can use the exact same syntax for setting logging preferences local
3394 to a buffer:
3395 @example
3396 #+SEQ_TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
3397 @end example
3399 In order to define logging settings that are local to a subtree or a
3400 single item, define a LOGGING property in this entry.  Any non-empty
3401 LOGGING property resets all logging settings to nil.  You may then turn
3402 on logging for this specific tree using STARTUP keywords like
3403 @code{lognotedone} or @code{logrepeat}, as well as adding state specific
3404 settings like @code{TODO(!)}.  For example
3406 @example
3407 * TODO Log each state with only a time
3408   :PROPERTIES:
3409   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
3410   :END:
3411 * TODO Only log when switching to WAIT, and when repeating
3412   :PROPERTIES:
3413   :LOGGING: WAIT(@@) logrepeat
3414   :END:
3415 * TODO No logging at all
3416   :PROPERTIES:
3417   :LOGGING: nil
3418   :END:
3419 @end example
3421 @node Priorities, Breaking down tasks, Progress logging, TODO Items
3422 @section Priorities
3423 @cindex priorities
3425 If you use Org mode extensively, you may end up enough TODO items that
3426 it starts to make sense to prioritize them.  Prioritizing can be done by
3427 placing a @emph{priority cookie} into the headline of a TODO item, like
3428 this
3430 @example
3431 *** TODO [#A] Write letter to Sam Fortune
3432 @end example
3434 @noindent
3435 By default, Org mode supports three priorities: @samp{A}, @samp{B}, and
3436 @samp{C}.  @samp{A} is the highest priority.  An entry without a cookie
3437 is treated as priority @samp{B}.  Priorities make a difference only in
3438 the agenda (@pxref{Weekly/daily agenda}); outside the agenda, they have
3439 no inherent meaning to Org mode.
3441 Priorities can be attached to any outline tree entries; they do not need
3442 to be TODO items.
3444 @table @kbd
3445 @kindex @kbd{C-c ,}
3446 @item @kbd{C-c ,}
3447 Set the priority of the current headline.  The command prompts for a
3448 priority character @samp{A}, @samp{B} or @samp{C}.  When you press
3449 @key{SPC} instead, the priority cookie is removed from the headline.
3450 The priorities can also be changed ``remotely'' from the timeline and
3451 agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
3453 @kindex S-@key{up}
3454 @kindex S-@key{down}
3455 @item S-@key{up}
3456 @itemx S-@key{down}
3457 Increase/decrease priority of current headline@footnote{See also the option
3458 @code{org-priority-start-cycle-with-default'}.}.  Note that these keys are
3459 also used to modify time stamps (@pxref{Creating timestamps}).  See also
3460 @ref{Conflicts} for a discussion of the interaction with
3461 @code{shift-selection-mode}.
3462 @end table
3464 You can change the range of allowed priorities by setting the variables
3465 @code{org-highest-priority}, @code{org-lowest-priority}, and
3466 @code{org-default-priority}.  For an individual buffer, you may set
3467 these values (highest, lowest, default) like this (please make sure that
3468 the highest priority is earlier in the alphabet than the lowest
3469 priority):
3471 @example
3472 #+PRIORITIES: A C B
3473 @end example
3475 @node Breaking down tasks, Checkboxes, Priorities, TODO Items
3476 @section Breaking tasks down into subtasks
3477 @cindex tasks, breaking down
3479 It is often advisable to break down large tasks into smaller, manageable
3480 subtasks.  You can do this by creating an outline tree below a TODO item,
3481 with detailed subtasks on the tree@footnote{To keep subtasks out of the
3482 global TODO list, see the @code{org-agenda-todo-list-sublevels}.}.  To keep
3483 the overview over the fraction of subtasks that are already completed, insert
3484 either @samp{[/]} or @samp{[%]} anywhere in the headline.  These cookies will
3485 be updates each time the todo status of a child changes.  For example:
3487 @example
3488 * Organize Party [33%]
3489 ** TODO Call people [1/2]
3490 *** TODO Peter
3491 *** DONE Sarah
3492 ** TODO Buy food
3493 ** DONE Talk to neighbor
3494 @end example
3496 If you would like a TODO entry to automatically change to DONE when all
3497 children are done, you can use the following setup:
3499 @example
3500 (defun org-summary-todo (n-done n-not-done)
3501   "Switch entry to DONE when all subentries are done, to TODO otherwise."
3502   (let (org-log-done org-log-states)   ; turn off logging
3503     (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
3505 (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
3506 @end example
3509 Another possibility is the use of checkboxes to identify (a hierarchy of) a
3510 large number of subtasks (@pxref{Checkboxes}).
3513 @node Checkboxes,  , Breaking down tasks, TODO Items
3514 @section Checkboxes
3515 @cindex checkboxes
3517 Every item in a plain list (@pxref{Plain lists}) can be made into a
3518 checkbox by starting it with the string @samp{[ ]}.  This feature is
3519 similar to TODO items (@pxref{TODO Items}), but is more lightweight.
3520 Checkboxes are not included into the global TODO list, so they are often
3521 great to split a task into a number of simple steps.  Or you can use
3522 them in a shopping list.  To toggle a checkbox, use @kbd{C-c C-c}, or
3523 use the mouse (thanks to Piotr Zielinski's @file{org-mouse.el}).
3525 Here is an example of a checkbox list.
3527 @example
3528 * TODO Organize party [2/4]
3529   - [-] call people [1/3]
3530     - [ ] Peter
3531     - [X] Sarah
3532     - [ ] Sam
3533   - [X] order food
3534   - [ ] think about what music to play
3535   - [X] talk to the neighbors
3536 @end example
3538 Checkboxes work hierarchically, so if a checkbox item has children that
3539 are checkboxes, toggling one of the children checkboxes will make the
3540 parent checkbox reflect if none, some, or all of the children are
3541 checked.
3543 @cindex statistics, for checkboxes
3544 @cindex checkbox statistics
3545 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are
3546 cookies indicating how many checkboxes present in this entry have been
3547 checked off, and the total number of checkboxes are present.  This can
3548 give you an idea on how many checkboxes remain, even without opening a
3549 folded entry.  The cookies can be placed into a headline or into (the
3550 first line of) a plain list item. Each cookie covers all checkboxes
3551 structurally below the headline/item on which the cookie appear.  You
3552 have to insert the cookie yourself by typing either @samp{[/]} or
3553 @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m} result, as in
3554 the examples above.  With @samp{[%]} you get information about the
3555 percentage of checkboxes checked (in the above example, this would be
3556 @samp{[50%]} and @samp{[33%]}, respectively).
3558 @noindent The following commands work with checkboxes:
3560 @table @kbd
3561 @kindex C-c C-c
3562 @item C-c C-c
3563 Toggle checkbox at point.  With a prefix argument, set it to @samp{[-]},
3564 which is considered to be an intermediate state.
3565 @kindex C-c C-x C-b
3566 @item C-c C-x C-b
3567 Toggle checkbox at point.
3568 @itemize @minus
3569 @item
3570 If there is an active region, toggle the first checkbox in the region
3571 and set all remaining boxes to the same status as the first.  If you
3572 want to toggle all boxes in the region independently, use a prefix
3573 argument.
3574 @item
3575 If the cursor is in a headline, toggle checkboxes in the region between
3576 this headline and the next (so @emph{not} the entire subtree).
3577 @item
3578 If there is no active region, just toggle the checkbox at point.
3579 @end itemize
3580 @kindex M-S-@key{RET}
3581 @item M-S-@key{RET}
3582 Insert a new item with a checkbox.
3583 This works only if the cursor is already in a plain list item
3584 (@pxref{Plain lists}).
3585 @kindex C-c #
3586 @item C-c #
3587 Update the checkbox statistics in the current outline entry.  When
3588 called with a @kbd{C-u} prefix, update the entire file.  Checkbox
3589 statistic cookies are updated automatically if you toggle checkboxes
3590 with @kbd{C-c C-c} and make new ones with @kbd{M-S-@key{RET}}.  If you
3591 delete boxes or add/change them by hand, use this command to get things
3592 back into sync.  Or simply toggle any checkbox twice with @kbd{C-c C-c}.
3593 @end table
3595 @node Tags, Properties and Columns, TODO Items, Top
3596 @chapter Tags
3597 @cindex tags
3598 @cindex headline tagging
3599 @cindex matching, tags
3600 @cindex sparse tree, tag based
3602 An excellent way to implement labels and contexts for cross-correlating
3603 information is to assign @i{tags} to headlines.  Org mode has extensive
3604 support for tags.
3606 Every headline can contain a list of tags; they occur at the end of the
3607 headline.  Tags are normal words containing letters, numbers, @samp{_}, and
3608 @samp{@@}.  Tags must be preceded and followed by a single colon, e.g.,
3609 @samp{:work:}.  Several tags can be specified, as in @samp{:work:urgent:}.
3610 Tags will by default get a bold face with the same color as the headline.
3611 You may specify special faces for specific tags using the variable
3612 @code{org-tag-faces}, much in the same way as you can do for TODO keywords
3613 (@pxref{Faces for TODO keywords}).
3615 @menu
3616 * Tag inheritance::             Tags use the tree structure of the outline
3617 * Setting tags::                How to assign tags to a headline
3618 * Tag searches::                Searching for combinations of tags
3619 @end menu
3621 @node Tag inheritance, Setting tags, Tags, Tags
3622 @section Tag inheritance
3623 @cindex tag inheritance
3624 @cindex inheritance, of tags
3625 @cindex sublevels, inclusion into tags match
3627 @i{Tags} make use of the hierarchical structure of outline trees.  If a
3628 heading has a certain tag, all subheadings will inherit the tag as
3629 well.  For example, in the list
3631 @example
3632 * Meeting with the French group      :work:
3633 ** Summary by Frank                  :boss:notes:
3634 *** TODO Prepare slides for him      :action:
3635 @end example
3637 @noindent
3638 the final heading will have the tags @samp{:work:}, @samp{:boss:},
3639 @samp{:notes:}, and @samp{:action:} even though the final heading is not
3640 explicitly marked with those tags.  You can also set tags that all entries in
3641 a file should inherit as if these tags would be defined in a hypothetical
3642 level zero that surrounds the entire file.
3644 @example
3645 #+FILETAGS: :Peter:Boss:Secret:
3646 @end example
3648 @noindent
3649 To limit tag inheritance to specific tags, or to turn it off entirely, use
3650 the variables @code{org-use-tag-inheritance} and
3651 @code{org-tags-exclude-from-inheritance}.
3653 When a headline matches during a tags search while tag inheritance is turned
3654 on, all the sublevels in the same tree will (for a simple match form) match
3655 as well@footnote{This is only true if the search does not involve more
3656 complex tests including properties (@pxref{Property searches}).}.  The list
3657 of matches may then become very long.  If you only want to see the first tags
3658 match in a subtree, configure the variable
3659 @code{org-tags-match-list-sublevels} (not recommended).
3661 @node Setting tags, Tag searches, Tag inheritance, Tags
3662 @section Setting tags
3663 @cindex setting tags
3664 @cindex tags, setting
3666 @kindex M-@key{TAB}
3667 Tags can simply be typed into the buffer at the end of a headline.
3668 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
3669 also a special command for inserting tags:
3671 @table @kbd
3672 @kindex C-c C-q
3673 @item C-c C-q
3674 @cindex completion, of tags
3675 Enter new tags for the current headline.  Org mode will either offer
3676 completion or a special single-key interface for setting tags, see
3677 below.  After pressing @key{RET}, the tags will be inserted and aligned
3678 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
3679 tags in the current buffer will be aligned to that column, just to make
3680 things look nice.  TAGS are automatically realigned after promotion,
3681 demotion, and TODO state changes (@pxref{TODO basics}).
3682 @kindex C-c C-c
3683 @item C-c C-c
3684 When the cursor is in a headline, this does the same as @kbd{C-c C-q}.
3685 @end table
3687 Org will support tag insertion based on a @emph{list of tags}.  By
3688 default this list is constructed dynamically, containing all tags
3689 currently used in the buffer.  You may also globally specify a hard list
3690 of tags with the variable @code{org-tag-alist}.  Finally you can set
3691 the default tags for a given file with lines like
3693 @example
3694 #+TAGS: @@work @@home @@tennisclub
3695 #+TAGS: laptop car pc sailboat
3696 @end example
3698 If you have globally defined your preferred set of tags using the
3699 variable @code{org-tag-alist}, but would like to use a dynamic tag list
3700 in a specific file, add an empty TAGS option line to that file:
3702 @example
3703 #+TAGS:
3704 @end example
3706 By default Org mode uses the standard minibuffer completion facilities for
3707 entering tags.  However, it also implements another, quicker, tag selection
3708 method called @emph{fast tag selection}.  This allows you to select and
3709 deselect tags with just a single key press.  For this to work well you should
3710 assign unique letters to most of your commonly used tags.  You can do this
3711 globally by configuring the variable @code{org-tag-alist} in your
3712 @file{.emacs} file.  For example, you may find the need to tag many items in
3713 different files with @samp{:@@home:}.  In this case you can set something
3714 like:
3716 @lisp
3717 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
3718 @end lisp
3720 @noindent If the tag is only relevant to the file you are working on then you
3721 can, instead, set the TAGS option line as:
3723 @example
3724 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
3725 @end example
3727 @noindent
3728 You can also group together tags that are mutually exclusive.  By using
3729 braces, as in:
3731 @example
3732 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
3733 @end example
3735 @noindent you indicate that at most one of @samp{@@work}, @samp{@@home},
3736 and @samp{@@tennisclub} should be selected.  Multiple such groups are allowed.
3738 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
3739 these lines to activate any changes.
3741 @noindent
3742 To set these mutually exclusive groups in the variable @code{org-mode-alist}
3743 you must use the dummy tags @code{:startgroup} and @code{:endgroup} instead
3744 of the braces.  The previous example would be set globally by the following
3745 configuration:
3747 @lisp
3748 (setq org-tag-alist '((:startgroup . nil)
3749                       ("@@work" . ?w) ("@@home" . ?h)
3750                       ("@@tennisclub" . ?t)
3751                       (:endgroup . nil)
3752                       ("laptop" . ?l) ("pc" . ?p)))
3753 @end lisp
3755 If at least one tag has a selection key then pressing @kbd{C-c C-c} will
3756 automatically present you with a special interface, listing inherited tags,
3757 the tags of the current headline, and a list of all valid tags with
3758 corresponding keys@footnote{Keys will automatically be assigned to tags which
3759 have no configured keys.}.  In this interface, you can use the following
3760 keys:
3762 @table @kbd
3763 @item a-z...
3764 Pressing keys assigned to tags will add or remove them from the list of
3765 tags in the current line.  Selecting a tag in a group of mutually
3766 exclusive tags will turn off any other tags from that group.
3767 @kindex @key{TAB}
3768 @item @key{TAB}
3769 Enter a tag in the minibuffer, even if the tag is not in the predefined
3770 list.  You will be able to complete on all tags present in the buffer.
3771 @kindex @key{SPC}
3772 @item @key{SPC}
3773 Clear all tags for this line.
3774 @kindex @key{RET}
3775 @item @key{RET}
3776 Accept the modified set.
3777 @item C-g
3778 Abort without installing changes.
3779 @item q
3780 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
3781 @item !
3782 Turn off groups of mutually exclusive tags.  Use this to (as an
3783 exception) assign several tags from such a group.
3784 @item C-c
3785 Toggle auto-exit after the next change (see below).
3786 If you are using expert mode, the first @kbd{C-c} will display the
3787 selection window.
3788 @end table
3790 @noindent
3791 This method lets you assign tags to a headline with very few keys.  With
3792 the above setup, you could clear the current tags and set @samp{@@home},
3793 @samp{laptop} and @samp{pc} tags with just the following keys: @kbd{C-c
3794 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to
3795 @samp{@@work} would be done with @kbd{C-c C-c w @key{RET}} or
3796 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
3797 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
3798 @key{RET} @key{RET}}.
3800 If you find that most of the time, you need only a single key press to
3801 modify your list of tags, set the variable
3802 @code{org-fast-tag-selection-single-key}.  Then you no longer have to
3803 press @key{RET} to exit fast tag selection - it will immediately exit
3804 after the first change.  If you then occasionally need more keys, press
3805 @kbd{C-c} to turn off auto-exit for the current tag selection process
3806 (in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
3807 C-c}).  If you set the variable to the value @code{expert}, the special
3808 window is not even shown for single-key tag selection, it comes up only
3809 when you press an extra @kbd{C-c}.
3811 @node Tag searches,  , Setting tags, Tags
3812 @section Tag searches
3813 @cindex tag searches
3814 @cindex searching for tags
3816 Once a system of tags has been set up, it can be used to collect related
3817 information into special lists.
3819 @table @kbd
3820 @kindex C-c \
3821 @kindex C-c / T
3822 @item C-c \
3823 @itemx C-c / T
3824 Create a sparse tree with all headlines matching a tags search.  With a
3825 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
3826 @kindex C-c a m
3827 @item C-c a m
3828 Create a global list of tag matches from all agenda files.
3829 @xref{Matching tags and properties}.
3830 @kindex C-c a M
3831 @item C-c a M
3832 Create a global list of tag matches from all agenda files, but check
3833 only TODO items and force checking subitems (see variable
3834 @code{org-tags-match-list-sublevels}).
3835 @end table
3837 @cindex Boolean logic, for tag searches
3838 A @i{tags} search string can use Boolean operators @samp{&} for AND and
3839 @samp{|} for OR.  @samp{&} binds more strongly than @samp{|}.
3840 Parenthesis are currently not implemented.  A tag may also be preceded
3841 by @samp{-}, to select against it, and @samp{+} is syntactic sugar for
3842 positive selection.  The AND operator @samp{&} is optional when @samp{+}
3843 or @samp{-} is present.  Examples:
3845 @table @samp
3846 @item +work-boss
3847 Select headlines tagged @samp{:work:}, but discard those also tagged
3848 @samp{:boss:}.
3849 @item work|laptop
3850 Selects lines tagged @samp{:work:} or @samp{:laptop:}.
3851 @item work|laptop&night
3852 Like before, but require the @samp{:laptop:} lines to be tagged also
3853 @samp{:night:}.
3854 @end table
3856 @cindex TODO keyword matching, with tags search
3857 You may also test for TODO keywords (@pxref{TODO extensions}) and properties
3858 (@pxref{Properties and Columns}) at the same time as matching tags.  For a
3859 guide on how to match properties, see @ref{Property searches}.  To match a
3860 specific TODO keyword, include an expression like @samp{+TODO="NEXT"} as one
3861 of the terms in a tags search.
3863 There is also the possibility to end the tags part of the match (which may
3864 include several terms connected with @samp{|}) with a @samp{/} and then
3865 specify a Boolean expression just for TODO keywords.  The syntax is then
3866 similar to the tag matches, but should be applied with consideration: For
3867 example, a positive selection on several TODO keywords can not meaningfully
3868 be combined with boolean AND.  However, @emph{negative selection} combined
3869 with AND can be meaningful.  To make sure that only lines are checked that
3870 actually have any TODO keyword (resulting in a speed-up), use @kbd{C-c a M},
3871 or equivalently start the TODO part after the slash with @samp{!}.  Examples:
3873 @table @samp
3874 @item work+TODO="WAITING"
3875 Select @samp{:work:}-tagged TODO lines with the specific TODO
3876 keyword @samp{WAITING}.
3877 @item work+TODO="WAITING"|home+TODO="WAITING"
3878 Waiting tasks both at work and at home.
3879 @item work/WAITING
3880 Same as the first example.
3881 @item work/!-WAITING-NEXT
3882 Select @samp{:work:}-tagged TODO lines that are neither @samp{WAITING}
3883 nor @samp{NEXT}
3884 @item work/!+WAITING|+NEXT
3885 Select @samp{:work:}-tagged TODO lines that are either @samp{WAITING} or
3886 @samp{NEXT}.
3887 @end table
3889 @cindex regular expressions, with tags search
3890 Any element of the tag/todo match can be a regular expression - in this
3891 case it must be enclosed in curly braces.  For example,
3892 @samp{work+@{^boss.*@}} matches headlines that contain the tag
3893 @samp{:work:} and any tag @i{starting} with @samp{boss}.  You may also use a
3894 regular expression in @samp{TODO=@{^W@}} which would match TODO keywords
3895 starting with the letter @samp{W}.
3897 @cindex level, require for tags/property match
3898 @cindex category, require for tags/property match
3899 You can also require a headline to be of a certain level or category, by
3900 writing instead of any TAG an expression like @samp{LEVEL=3} or
3901 @samp{CATEGORY="work"}, respectively.  For example, a search
3902 @samp{+LEVEL=3+boss/-DONE} lists all level three headlines that have the
3903 tag @samp{boss} and are @emph{not} marked with the TODO keyword DONE.
3905 Accessing TODO, LEVEL, and CATEGORY during a search is fast.  Accessing any
3906 other properties will slow down the search.
3908 @node Properties and Columns, Dates and Times, Tags, Top
3909 @chapter Properties and Columns
3910 @cindex properties
3912 Properties are a set of key-value pairs associated with an entry.  There
3913 are two main applications for properties in Org mode.  First, properties
3914 are like tags, but with a value.  Second, you can use properties to
3915 implement (very basic) database capabilities in an Org buffer.  For
3916 an example of the first application, imagine maintaining a file where
3917 you document bugs and plan releases of a piece of software.  Instead of
3918 using tags like @code{:release_1:}, @code{:release_2:}, one can use a
3919 property, say @code{:Release:}, that in different subtrees has different
3920 values, such as @code{1.0} or @code{2.0}.  For an example of the second
3921 application of properties, imagine keeping track of your music CDs,
3922 where properties could be things such as the album artist, date of
3923 release, number of tracks, and so on.
3925 Properties can be conveniently edited and viewed in column view
3926 (@pxref{Column view}).
3928 @menu
3929 * Property syntax::             How properties are spelled out
3930 * Special properties::          Access to other Org mode features
3931 * Property searches::           Matching property values
3932 * Property inheritance::        Passing values down the tree
3933 * Column view::                 Tabular viewing and editing
3934 * Property API::                Properties for Lisp programmers
3935 @end menu
3937 @node Property syntax, Special properties, Properties and Columns, Properties and Columns
3938 @section Property syntax
3939 @cindex property syntax
3940 @cindex drawer, for properties
3942 Properties are key-value pairs.  They need to be inserted into a special
3943 drawer (@pxref{Drawers}) with the name @code{PROPERTIES}.  Each property
3944 is specified on a single line, with the key (surrounded by colons)
3945 first, and the value after it.  Here is an example:
3947 @example
3948 * CD collection
3949 ** Classic
3950 *** Goldberg Variations
3951     :PROPERTIES:
3952     :Title:     Goldberg Variations
3953     :Composer:  J.S. Bach
3954     :Artist:    Glen Gould
3955     :Publisher: Deutsche Grammphon
3956     :NDisks:    1
3957     :END:
3958 @end example
3960 You may define the allowed values for a particular property @samp{:Xyz:}
3961 by setting a property @samp{:Xyz_ALL:}.  This special property is
3962 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
3963 the entire tree.  When allowed values are defined, setting the
3964 corresponding property becomes easier and is less prone to typing
3965 errors.  For the example with the CD collection, we can predefine
3966 publishers and the number of disks in a box like this:
3968 @example
3969 * CD collection
3970   :PROPERTIES:
3971   :NDisks_ALL:  1 2 3 4
3972   :Publisher_ALL: "Deutsche Grammophon" Philips EMI
3973   :END:
3974 @end example
3976 If you want to set properties that can be inherited by any entry in a
3977 file, use a line like
3979 @example
3980 #+PROPERTY: NDisks_ALL 1 2 3 4
3981 @end example
3983 Property values set with the global variable
3984 @code{org-global-properties} can be inherited by all entries in all
3985 Org files.
3987 @noindent
3988 The following commands help to work with properties:
3990 @table @kbd
3991 @kindex M-@key{TAB}
3992 @item M-@key{TAB}
3993 After an initial colon in a line, complete property keys.  All keys used
3994 in the current file will be offered as possible completions.
3995 @kindex C-c C-x p
3996 @item C-c C-x p
3997 Set a property.  This prompts for a property name and a value.  If
3998 necessary, the property drawer is created as well.
3999 @item M-x org-insert-property-drawer
4000 Insert a property drawer into the current entry.  The drawer will be
4001 inserted early in the entry, but after the lines with planning
4002 information like deadlines.
4003 @kindex C-c C-c
4004 @item C-c C-c
4005 With the cursor in a property drawer, this executes property commands.
4006 @item C-c C-c s
4007 Set a property in the current entry.  Both the property and the value
4008 can be inserted using completion.
4009 @kindex S-@key{right}
4010 @kindex S-@key{left}
4011 @item S-@key{left}/@key{right}
4012 Switch property at point to the next/previous allowed value.
4013 @item C-c C-c d
4014 Remove a property from the current entry.
4015 @item C-c C-c D
4016 Globally remove a property, from all entries in the current file.
4017 @item C-c C-c c
4018 Compute the property at point, using the operator and scope from the
4019 nearest column format definition.
4020 @end table
4022 @node Special properties, Property searches, Property syntax, Properties and Columns
4023 @section Special properties
4024 @cindex properties, special
4026 Special properties provide alternative access method to Org mode
4027 features discussed in the previous chapters, like the TODO state or the
4028 priority of an entry.  This interface exists so that you can include
4029 these states into columns view (@pxref{Column view}), or to use them in
4030 queries.  The following property names are special and should not be
4031 used as keys in the properties drawer:
4033 @example
4034 TODO         @r{The TODO keyword of the entry.}
4035 TAGS         @r{The tags defined directly in the headline.}
4036 ALLTAGS      @r{All tags, including inherited ones.}
4037 PRIORITY     @r{The priority of the entry, a string with a single letter.}
4038 DEADLINE     @r{The deadline time string, without the angular brackets.}
4039 SCHEDULED    @r{The scheduling time stamp, without the angular brackets.}
4040 TIMESTAMP    @r{The first keyword-less time stamp in the entry.}
4041 TIMESTAMP_IA @r{The first inactive time stamp in the entry.}
4042 CLOCKSUM     @r{The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}}
4043              @r{must be run first to compute the values.}
4044 @end example
4046 @node Property searches, Property inheritance, Special properties, Properties and Columns
4047 @section Property searches
4048 @cindex properties, searching
4049 @cindex searching, of properties
4051 To create sparse trees and special lists with selection based on properties,
4052 the same commands are used as for tag searches (@pxref{Tag searches}), and
4053 the same logic applies.  For example, here is a search string:
4055 @example
4056 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2         \
4057          +With=@{Sarah\|Denny@}+SCHEDULED>="<2008-10-11>"
4058 @end example
4060 @noindent
4061 The type of comparison will depend on how the comparison value is written:
4062 @itemize @minus
4063 @item
4064 If the comparison value is a plain number, a numerical comparison is done,
4065 and the allowed operators are @samp{<}, @samp{=}, @samp{>}, @samp{<=},
4066 @samp{>=}, and @samp{<>}.
4067 @item
4068 If the comparison value is enclosed in double
4069 quotes, a string comparison is done, and the same operators are allowed.
4070 @item
4071 If the comparison value is enclosed in double quotes @emph{and} angular
4072 brackets (like @samp{DEADLINE<="<2008-12-24 18:30>"}), both values are
4073 assumed to be date/time specifications in the standard Org way, and the
4074 comparison will be done accordingly.  Special values that will be recognized
4075 are @code{"<now>"} for now (including time), and @code{"<today>"}, and
4076 @code{"<tomorrow>"} for these days at 0:00 hours, i.e. without a time
4077 specification.  Also strings like @code{"<+5d>"} or @code{"<-2m>"} with units
4078 @code{d}, @code{w}, @code{m}, and @code{y} for day, week, month, and year,
4079 respectively, can be used.
4080 @item
4081 If the comparison value is enclosed
4082 in curly braces, a regexp match is performed, with @samp{=} meaning that the
4083 regexp matches the property value, and @samp{<>} meaning that it does not
4084 match.
4085 @end itemize
4087 So the search string in the example finds entries tagged @samp{:work:} but
4088 not @samp{:boss:}, which also have a priority value @samp{A}, a
4089 @samp{:Coffee:} property with the value @samp{unlimited}, an @samp{Effort}
4090 property that is numerically smaller than 2, a @samp{:With:} property that is
4091 matched by the regular expression @samp{Sarah\|Denny}, and that are scheduled
4092 on or after October 11, 2008.
4094 You can configure Org mode to use property inheritance during a search, but
4095 beware that this can slow down searches considerably.  See @ref{Property
4096 inheritance} for details.
4098 There is also a special command for creating sparse trees based on a
4099 single property:
4101 @table @kbd
4102 @kindex C-c / p
4103 @item C-c / p
4104 Create a sparse tree based on the value of a property.  This first
4105 prompts for the name of a property, and then for a value.  A sparse tree
4106 is created with all entries that define this property with the given
4107 value.  If you enclose the value into curly braces, it is interpreted as
4108 a regular expression and matched against the property values.
4109 @end table
4111 @node Property inheritance, Column view, Property searches, Properties and Columns
4112 @section Property Inheritance
4113 @cindex properties, inheritance
4114 @cindex inheritance, of properties
4116 The outline structure of Org mode documents lends itself for an
4117 inheritance model of properties: If the parent in a tree has a certain
4118 property, the children can inherit this property.  Org mode does not
4119 turn this on by default, because it can slow down property searches
4120 significantly and is often not needed.  However, if you find inheritance
4121 useful, you can turn it on by setting the variable
4122 @code{org-use-property-inheritance}.  It may be set to @code{t}, to make
4123 all properties inherited from the parent, to a list of properties
4124 that should be inherited, or to a regular expression that matches
4125 inherited properties.
4127 Org mode has a few properties for which inheritance is hard-coded, at
4128 least for the special applications for which they are used:
4130 @table @code
4131 @item COLUMNS
4132 The @code{:COLUMNS:} property defines the format of column view
4133 (@pxref{Column view}).  It is inherited in the sense that the level
4134 where a @code{:COLUMNS:} property is defined is used as the starting
4135 point for a column view table, independently of the location in the
4136 subtree from where columns view is turned on.
4137 @item CATEGORY
4138 For agenda view, a category set through a @code{:CATEGORY:} property
4139 applies to the entire subtree.
4140 @item ARCHIVE
4141 For archiving, the @code{:ARCHIVE:} property may define the archive
4142 location for the entire subtree (@pxref{Moving subtrees}).
4143 @item LOGGING
4144 The LOGGING property may define logging settings for an entry or a
4145 subtree (@pxref{Tracking TODO state changes}).
4146 @end table
4148 @node Column view, Property API, Property inheritance, Properties and Columns
4149 @section Column view
4151 A great way to view and edit properties in an outline tree is
4152 @emph{column view}.  In column view, each outline item is turned into a
4153 table row.  Columns in this table provide access to properties of the
4154 entries.  Org mode implements columns by overlaying a tabular structure
4155 over the headline of each item.  While the headlines have been turned
4156 into a table row, you can still change the visibility of the outline
4157 tree.  For example, you get a compact table by switching to CONTENTS
4158 view (@kbd{S-@key{TAB} S-@key{TAB}}, or simply @kbd{c} while column view
4159 is active), but you can still open, read, and edit the entry below each
4160 headline.  Or, you can switch to column view after executing a sparse
4161 tree command and in this way get a table only for the selected items.
4162 Column view also works in agenda buffers (@pxref{Agenda Views}) where
4163 queries have collected selected items, possibly from a number of files.
4165 @menu
4166 * Defining columns::            The COLUMNS format property
4167 * Using column view::           How to create and use column view
4168 * Capturing column view::       A dynamic block for column view
4169 @end menu
4171 @node Defining columns, Using column view, Column view, Column view
4172 @subsection Defining columns
4173 @cindex column view, for properties
4174 @cindex properties, column view
4176 Setting up a column view first requires defining the columns.  This is
4177 done by defining a column format line.
4179 @menu
4180 * Scope of column definitions::  Where defined, where valid?
4181 * Column attributes::           Appearance and content of a column
4182 @end menu
4184 @node Scope of column definitions, Column attributes, Defining columns, Defining columns
4185 @subsubsection Scope of column definitions
4187 To define a column format for an entire file, use a line like
4189 @example
4190 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
4191 @end example
4193 To specify a format that only applies to a specific tree, add a
4194 @code{:COLUMNS:} property to the top node of that tree, for example:
4196 @example
4197 ** Top node for columns view
4198    :PROPERTIES:
4199    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
4200    :END:
4201 @end example
4203 If a @code{:COLUMNS:} property is present in an entry, it defines columns
4204 for the entry itself, and for the entire subtree below it.  Since the
4205 column definition is part of the hierarchical structure of the document,
4206 you can define columns on level 1 that are general enough for all
4207 sublevels, and more specific columns further down, when you edit a
4208 deeper part of the tree.
4210 @node Column attributes,  , Scope of column definitions, Defining columns
4211 @subsubsection Column attributes
4212 A column definition sets the attributes of a column.  The general
4213 definition looks like this:
4215 @example
4216  %[width]property[(title)][@{summary-type@}]
4217 @end example
4219 @noindent
4220 Except for the percent sign and the property name, all items are
4221 optional.  The individual parts have the following meaning:
4223 @example
4224 width           @r{An integer specifying the width of the column in characters.}
4225                 @r{If omitted, the width will be determined automatically.}
4226 property        @r{The property that should be edited in this column.}
4227 (title)         @r{The header text for the column. If omitted, the}
4228                 @r{property name is used.}
4229 @{summary-type@}  @r{The summary type.  If specified, the column values for}
4230                 @r{parent nodes are computed from the children.}
4231                 @r{Supported summary types are:}
4232                 @{+@}       @r{Sum numbers in this column.}
4233                 @{+;%.1f@}  @r{Like @samp{+}, but format result with @samp{%.1f}.}
4234                 @{$@}       @r{Currency, short for @samp{+;%.2f}.}
4235                 @{:@}       @r{Sum times, HH:MM:SS, plain numbers are hours.}
4236                 @{X@}       @r{Checkbox status, [X] if all children are [X].}
4237                 @{X/@}      @r{Checkbox status, [n/m].}
4238                 @{X%@}      @r{Checkbox status, [n%].}
4239 @end example
4241 @noindent
4242 Here is an example for a complete columns definition, along with allowed
4243 values.
4245 @example
4246 :COLUMNS:  %20ITEM %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.}
4247                    %10Time_Estimate@{:@} %CLOCKSUM
4248 :Owner_ALL:    Tammy Mark Karl Lisa Don
4249 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
4250 :Approved_ALL: "[ ]" "[X]"
4251 @end example
4253 The first column, @samp{%25ITEM}, means the first 25 characters of the
4254 item itself, i.e. of the headline.  You probably always should start the
4255 column definition with the @samp{ITEM} specifier.  The other specifiers
4256 create columns @samp{Owner} with a list of names as allowed values, for
4257 @samp{Status} with four different possible values, and for a checkbox
4258 field @samp{Approved}.  When no width is given after the @samp{%}
4259 character, the column will be exactly as wide as it needs to be in order
4260 to fully display all values.  The @samp{Approved} column does have a
4261 modified title (@samp{Approved?}, with a question mark).  Summaries will
4262 be created for the @samp{Time_Estimate} column by adding time duration
4263 expressions like HH:MM, and for the @samp{Approved} column, by providing
4264 an @samp{[X]} status if all children have been checked.  The
4265 @samp{CLOCKSUM} column is special, it lists the sum of CLOCK intervals
4266 in the subtree.
4268 @node Using column view, Capturing column view, Defining columns, Column view
4269 @subsection Using column view
4271 @table @kbd
4272 @tsubheading{Turning column view on and off}
4273 @kindex C-c C-x C-c
4274 @item C-c C-x C-c
4275 Create the column view for the local environment.  This command searches
4276 the hierarchy, up from point, for a @code{:COLUMNS:} property that defines
4277 a format.  When one is found, the column view table is established for
4278 the entire tree, starting from the entry that contains the @code{:COLUMNS:}
4279 property.  If none is found, the format is taken from the @code{#+COLUMNS}
4280 line or from the variable @code{org-columns-default-format}, and column
4281 view is established for the current entry and its subtree.
4282 @kindex r
4283 @item r
4284 Recreate the column view, to include recent changes made in the buffer.
4285 @kindex g
4286 @item g
4287 Same as @kbd{r}.
4288 @kindex q
4289 @item q
4290 Exit column view.
4291 @tsubheading{Editing values}
4292 @item @key{left} @key{right} @key{up} @key{down}
4293 Move through the column view from field to field.
4294 @kindex S-@key{left}
4295 @kindex S-@key{right}
4296 @item  S-@key{left}/@key{right}
4297 Switch to the next/previous allowed value of the field.  For this, you
4298 have to have specified allowed values for a property.
4299 @item 1..9,0
4300 Directly select the nth allowed value, @kbd{0} selects the 10th value.
4301 @kindex n
4302 @kindex p
4303 @itemx  n / p
4304 Same as @kbd{S-@key{left}/@key{right}}
4305 @kindex e
4306 @item e
4307 Edit the property at point.  For the special properties, this will
4308 invoke the same interface that you normally use to change that
4309 property.  For example, when editing a TAGS property, the tag completion
4310 or fast selection interface will pop up.
4311 @kindex C-c C-c
4312 @item C-c C-c
4313 When there is a checkbox at point, toggle it.
4314 @kindex v
4315 @item v
4316 View the full value of this property.  This is useful if the width of
4317 the column is smaller than that of the value.
4318 @kindex a
4319 @item a
4320 Edit the list of allowed values for this property.  If the list is found
4321 in the hierarchy, the modified values is stored there.  If no list is
4322 found, the new value is stored in the first entry that is part of the
4323 current column view.
4324 @tsubheading{Modifying the table structure}
4325 @kindex <
4326 @kindex >
4327 @item < / >
4328 Make the column narrower/wider by one character.
4329 @kindex S-M-@key{right}
4330 @item S-M-@key{right}
4331 Insert a new column, to the left of the current column.
4332 @kindex S-M-@key{left}
4333 @item S-M-@key{left}
4334 Delete the current column.
4335 @end table
4337 @node Capturing column view,  , Using column view, Column view
4338 @subsection Capturing column view
4340 Since column view is just an overlay over a buffer, it cannot be
4341 exported or printed directly.  If you want to capture a column view, use
4342 this @code{columnview} dynamic block (@pxref{Dynamic blocks}).  The frame
4343 of this block looks like this:
4345 @cindex #+BEGIN: columnview
4346 @example
4347 * The column view
4348 #+BEGIN: columnview :hlines 1 :id "label"
4350 #+END:
4351 @end example
4353 @noindent This dynamic block has the following parameters:
4355 @table @code
4356 @item :id
4357 This is most important parameter.  Column view is a feature that is
4358 often localized to a certain (sub)tree, and the capture block might be
4359 in a different location in the file.  To identify the tree whose view to
4360 capture, you can use 3 values:
4361 @example
4362 local     @r{use the tree in which the capture block is located}
4363 global    @r{make a global view, including all headings in the file}
4364 "file:path-to-file"
4365           @r{run column view at the top of this file}
4366 "ID"      @r{call column view in the tree that has an @code{:ID:}}
4367           @r{property with the value @i{label}.  You can use}
4368           @r{@kbd{M-x org-id-copy} to create a globally unique ID for}
4369           @r{the current entry and copy it to the kill-ring.}
4370 @end example
4371 @item :hlines
4372 When @code{t}, insert a hline after every line.  When a number N, insert
4373 a hline before each headline with level @code{<= N}.
4374 @item :vlines
4375 When set to @code{t}, enforce column groups to get vertical lines.
4376 @item :maxlevel
4377 When set to a number, don't capture entries below this level.
4378 @item :skip-empty-rows
4379 When set to @code{t}, skip row where the only non-empty specifier of the
4380 column view is @code{ITEM}.
4382 @end table
4384 @noindent
4385 The following commands insert or update the dynamic block:
4387 @table @kbd
4388 @kindex C-c C-x i
4389 @item C-c C-x i
4390 Insert a dynamic block capturing a column view.  You will be prompted
4391 for the scope or id of the view.
4392 @kindex C-c C-c
4393 @item C-c C-c
4394 @kindex C-c C-x C-u
4395 @itemx C-c C-x C-u
4396 Update dynamical block at point.  The cursor needs to be in the
4397 @code{#+BEGIN} line of the dynamic block.
4398 @kindex C-u C-c C-x C-u
4399 @item C-u C-c C-x C-u
4400 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
4401 you have several clock table blocks in a buffer.
4402 @end table
4404 You can add formulas to the column view table and you may add plotting
4405 instructions in front of the table - these will survive an update of the
4406 block.  If there is a @code{#+TBLFM:} after the table, the table will
4407 actually be recalculated automatically after an update.
4409 @node Property API,  , Column view, Properties and Columns
4410 @section The Property API
4411 @cindex properties, API
4412 @cindex API, for properties
4414 There is a full API for accessing and changing properties.  This API can
4415 be used by Emacs Lisp programs to work with properties and to implement
4416 features based on them.  For more information see @ref{Using the
4417 property API}.
4419 @node Dates and Times, Capture, Properties and Columns, Top
4420 @chapter Dates and Times
4421 @cindex dates
4422 @cindex times
4423 @cindex time stamps
4424 @cindex date stamps
4426 To assist project planning, TODO items can be labeled with a date and/or
4427 a time.  The specially formatted string carrying the date and time
4428 information is called a @emph{timestamp} in Org mode.  This may be a
4429 little confusing because timestamp is often used as indicating when
4430 something was created or last changed.  However, in Org mode this term
4431 is used in a much wider sense.
4433 @menu
4434 * Timestamps::                  Assigning a time to a tree entry
4435 * Creating timestamps::         Commands which insert timestamps
4436 * Deadlines and scheduling::    Planning your work
4437 * Clocking work time::          Tracking how long you spend on a task
4438 * Effort estimates::            Planning work effort in advance
4439 * Relative timer::              Notes with a running timer
4440 @end menu
4443 @node Timestamps, Creating timestamps, Dates and Times, Dates and Times
4444 @section Timestamps, deadlines and scheduling
4445 @cindex time stamps
4446 @cindex ranges, time
4447 @cindex date stamps
4448 @cindex deadlines
4449 @cindex scheduling
4451 A time stamp is a specification of a date (possibly with time or a range
4452 of times) in a special format, either @samp{<2003-09-16 Tue>} or
4453 @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16 Tue
4454 12:00-12:30>}@footnote{This is the standard ISO date/time format.  To
4455 use an alternative format, see @ref{Custom time format}.}.  A time stamp
4456 can appear anywhere in the headline or body of an Org tree entry.  Its
4457 presence causes entries to be shown on specific dates in the agenda
4458 (@pxref{Weekly/daily agenda}).  We distinguish:
4460 @table @var
4461 @item Plain time stamp; Event; Appointment
4462 @cindex timestamp
4463 A simple time stamp just assigns a date/time to an item.  This is just
4464 like writing down an appointment or event in a paper agenda.  In the
4465 timeline and agenda displays, the headline of an entry associated with a
4466 plain time stamp will be shown exactly on that date.
4468 @example
4469 * Meet Peter at the movies <2006-11-01 Wed 19:15>
4470 * Discussion on climate change <2006-11-02 Thu 20:00-22:00>
4471 @end example
4473 @item Time stamp with repeater interval
4474 @cindex timestamp, with repeater interval
4475 A time stamp may contain a @emph{repeater interval}, indicating that it
4476 applies not only on the given date, but again and again after a certain
4477 interval of N days (d), weeks (w), months(m), or years(y).  The
4478 following will show up in the agenda every Wednesday:
4480 @example
4481 * Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
4482 @end example
4484 @item Diary-style sexp entries
4485 For more complex date specifications, Org mode supports using the
4486 special sexp diary entries implemented in the Emacs calendar/diary
4487 package.  For example
4489 @example
4490 * The nerd meeting on every 2nd Thursday of the month
4491   <%%(diary-float t 4 2)>
4492 @end example
4494 @item Time/Date range
4495 @cindex timerange
4496 @cindex date range
4497 Two time stamps connected by @samp{--} denote a range.  The headline
4498 will be shown on the first and last day of the range, and on any dates
4499 that are displayed and fall in the range.  Here is an example:
4501 @example
4502 ** Meeting in Amsterdam
4503    <2004-08-23 Mon>--<2004-08-26 Thu>
4504 @end example
4506 @item Inactive time stamp
4507 @cindex timestamp, inactive
4508 @cindex inactive timestamp
4509 Just like a plain time stamp, but with square brackets instead of
4510 angular ones.  These time stamps are inactive in the sense that they do
4511 @emph{not} trigger an entry to show up in the agenda.
4513 @example
4514 * Gillian comes late for the fifth time [2006-11-01 Wed]
4515 @end example
4517 @end table
4519 @node Creating timestamps, Deadlines and scheduling, Timestamps, Dates and Times
4520 @section Creating timestamps
4521 @cindex creating timestamps
4522 @cindex timestamps, creating
4524 For Org mode to recognize time stamps, they need to be in the specific
4525 format.  All commands listed below produce time stamps in the correct
4526 format.
4528 @table @kbd
4529 @kindex C-c .
4530 @item C-c .
4531 Prompt for a date and insert a corresponding time stamp.  When the cursor is
4532 at an existing time stamp in the buffer, the command is used to modify this
4533 timestamp instead of inserting a new one.  When this command is used twice in
4534 succession, a time range is inserted.
4536 @kindex C-u C-c .
4537 @item C-u C-c .
4538 Like @kbd{C-c .}, but use the alternative format which contains date
4539 and time.  The default time can be rounded to multiples of 5 minutes,
4540 see the option @code{org-time-stamp-rounding-minutes}.
4542 @kindex C-c !
4543 @item C-c !
4544 Like @kbd{C-c .}, but insert an inactive time stamp that will not cause
4545 an agenda entry.
4547 @kindex C-c <
4548 @item C-c <
4549 Insert a time stamp corresponding to the cursor date in the Calendar.
4551 @kindex C-c >
4552 @item C-c >
4553 Access the Emacs calendar for the current date.  If there is a
4554 timestamp in the current line, go to the corresponding date
4555 instead.
4557 @kindex C-c C-o
4558 @item C-c C-o
4559 Access the agenda for the date given by the time stamp or -range at
4560 point (@pxref{Weekly/daily agenda}).
4562 @kindex S-@key{left}
4563 @kindex S-@key{right}
4564 @item S-@key{left}
4565 @itemx S-@key{right}
4566 Change date at cursor by one day.  These key bindings conflict with
4567 CUA mode (@pxref{Conflicts}).
4569 @kindex S-@key{up}
4570 @kindex S-@key{down}
4571 @item S-@key{up}
4572 @itemx S-@key{down}
4573 Change the item under the cursor in a timestamp.  The cursor can be on a
4574 year, month, day, hour or minute.  Note that if the cursor is in a
4575 headline and not at a time stamp, these same keys modify the priority of
4576 an item.  (@pxref{Priorities}). The key bindings also conflict with
4577 CUA mode (@pxref{Conflicts}).
4579 @kindex C-c C-y
4580 @cindex evaluate time range
4581 @item C-c C-y
4582 Evaluate a time range by computing the difference between start and end.
4583 With a prefix argument, insert result after the time range (in a table: into
4584 the following column).
4585 @end table
4588 @menu
4589 * The date/time prompt::        How Org mode helps you entering date and time
4590 * Custom time format::          Making dates look different
4591 @end menu
4593 @node The date/time prompt, Custom time format, Creating timestamps, Creating timestamps
4594 @subsection The date/time prompt
4595 @cindex date, reading in minibuffer
4596 @cindex time, reading in minibuffer
4598 When Org mode prompts for a date/time, the default is shown as an ISO
4599 date, and the prompt therefore seems to ask for an ISO date.  But it
4600 will in fact accept any string containing some date and/or time
4601 information, and it is really smart about interpreting your input.  You
4602 can, for example, use @kbd{C-y} to paste a (possibly multi-line) string
4603 copied from an email message.  Org mode will find whatever information
4604 is in there and derive anything you have not specified from the
4605 @emph{default date and time}.  The default is usually the current date
4606 and time, but when modifying an existing time stamp, or when entering
4607 the second stamp of a range, it is taken from the stamp in the buffer.
4608 When filling in information, Org mode assumes that most of the time you
4609 will want to enter a date in the future: If you omit the month/year and
4610 the given day/month is @i{before} today, it will assume that you mean a
4611 future date@footnote{See the variable
4612 @code{org-read-date-prefer-future}.}.
4614 For example, let's assume that today is @b{June 13, 2006}.  Here is how
4615 various inputs will be interpreted, the items filled in by Org mode are
4616 in @b{bold}.
4618 @example
4619 3-2-5         --> 2003-02-05
4620 14            --> @b{2006}-@b{06}-14
4621 12            --> @b{2006}-@b{07}-12
4622 Fri           --> nearest Friday (defaultdate or later)
4623 sep 15        --> @b{2006}-09-15
4624 feb 15        --> @b{2007}-02-15
4625 sep 12 9      --> 2009-09-12
4626 12:45         --> @b{2006}-@b{06}-@b{13} 12:45
4627 22 sept 0:34  --> @b{2006}-09-22 0:34
4628 w4            --> ISO week for of the current year @b{2006}
4629 2012 w4 fri   --> Friday of ISO week 4 in 2012
4630 2012-w04-5    --> Same as above
4631 @end example
4633 Furthermore you can specify a relative date by giving, as the
4634 @emph{first} thing in the input: a plus/minus sign, a number and a
4635 letter [dwmy] to indicate change in days weeks, months, years.  With a
4636 single plus or minus, the date is always relative to today.  With a
4637 double plus or minus, it is relative to the default date.  If instead of
4638 a single letter, you use the abbreviation of day name, the date will be
4639 the nth such day.  E.g.
4641 @example
4642 +0            --> today
4643 .             --> today
4644 +4d           --> four days from today
4645 +4            --> same as above
4646 +2w           --> two weeks from today
4647 ++5           --> five days from default date
4648 +2tue         --> second tuesday from now.
4649 @end example
4651 The function understands English month and weekday abbreviations.  If
4652 you want to use unabbreviated names and/or other languages, configure
4653 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
4655 @cindex calendar, for selecting date
4656 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
4657 you don't need/want the calendar, configure the variable
4658 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
4659 prompt, either by clicking on a date in the calendar, or by pressing
4660 @key{RET}, the date selected in the calendar will be combined with the
4661 information entered at the prompt.  You can control the calendar fully
4662 from the minibuffer:
4664 @kindex <
4665 @kindex >
4666 @kindex mouse-1
4667 @kindex S-@key{right}
4668 @kindex S-@key{left}
4669 @kindex S-@key{down}
4670 @kindex S-@key{up}
4671 @kindex M-S-@key{right}
4672 @kindex M-S-@key{left}
4673 @kindex @key{RET}
4674 @example
4675 > / <          @r{Scroll calendar forward/backward by one month.}
4676 mouse-1        @r{Select date by clicking on it.}
4677 S-@key{right}/@key{left}     @r{One day forward/backward.}
4678 S-@key{down}/@key{up}     @r{One week forward/backward.}
4679 M-S-@key{right}/@key{left}   @r{One month forward/backward.}
4680 @key{RET}           @r{Choose date in calendar.}
4681 @end example
4683 The actions of the date/time prompt may seem complex, but I assure you they
4684 will grow on you, and you will start getting annoyed by pretty much any other
4685 way of entering a date/time out there.  To help you understand what is going
4686 on, the current interpretation of your input will be displayed live in the
4687 minibuffer@footnote{If you find this distracting, turn the display of with
4688 @code{org-read-date-display-live}.}.
4690 @node Custom time format,  , The date/time prompt, Creating timestamps
4691 @subsection Custom time format
4692 @cindex custom date/time format
4693 @cindex time format, custom
4694 @cindex date format, custom
4696 Org mode uses the standard ISO notation for dates and times as it is
4697 defined in ISO 8601.  If you cannot get used to this and require another
4698 representation of date and time to keep you happy, you can get it by
4699 customizing the variables @code{org-display-custom-times} and
4700 @code{org-time-stamp-custom-formats}.
4702 @table @kbd
4703 @kindex C-c C-x C-t
4704 @item C-c C-x C-t
4705 Toggle the display of custom formats for dates and times.
4706 @end table
4708 @noindent
4709 Org mode needs the default format for scanning, so the custom date/time
4710 format does not @emph{replace} the default format - instead it is put
4711 @emph{over} the default format using text properties.  This has the
4712 following consequences:
4713 @itemize @bullet
4714 @item
4715 You cannot place the cursor onto a time stamp anymore, only before or
4716 after.
4717 @item
4718 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
4719 each component of a time stamp.  If the cursor is at the beginning of
4720 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
4721 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
4722 time will be changed by one minute.
4723 @item
4724 If the time stamp contains a range of clock times or a repeater, these
4725 will not be overlayed, but remain in the buffer as they were.
4726 @item
4727 When you delete a time stamp character-by-character, it will only
4728 disappear from the buffer after @emph{all} (invisible) characters
4729 belonging to the ISO timestamp have been removed.
4730 @item
4731 If the custom time stamp format is longer than the default and you are
4732 using dates in tables, table alignment will be messed up.  If the custom
4733 format is shorter, things do work as expected.
4734 @end itemize
4737 @node Deadlines and scheduling, Clocking work time, Creating timestamps, Dates and Times
4738 @section Deadlines and scheduling
4740 A time stamp may be preceded by special keywords to facilitate planning:
4742 @table @var
4743 @item DEADLINE
4744 @cindex DEADLINE keyword
4746 Meaning: the task (most likely a TODO item, though not necessarily) is supposed
4747 to be finished on that date.
4749 On the deadline date, the task will be listed in the agenda.  In
4750 addition, the agenda for @emph{today} will carry a warning about the
4751 approaching or missed deadline, starting
4752 @code{org-deadline-warning-days} before the due date, and continuing
4753 until the entry is marked DONE.  An example:
4755 @example
4756 *** TODO write article about the Earth for the Guide
4757     The editor in charge is [[bbdb:Ford Prefect]]
4758     DEADLINE: <2004-02-29 Sun>
4759 @end example
4761 You can specify a different lead time for warnings for a specific
4762 deadlines using the following syntax.  Here is an example with a warning
4763 period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.
4765 @item SCHEDULED
4766 @cindex SCHEDULED keyword
4768 Meaning: you are planning to start working on that task on the given
4769 date.
4771 The headline will be listed under the given date@footnote{It will still
4772 be listed on that date after it has been marked DONE.  If you don't like
4773 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
4774 addition, a reminder that the scheduled date has passed will be present
4775 in the compilation for @emph{today}, until the entry is marked DONE.
4776 I.e., the task will automatically be forwarded until completed.
4778 @example
4779 *** TODO Call Trillian for a date on New Years Eve.
4780     SCHEDULED: <2004-12-25 Sat>
4781 @end example
4783 @noindent
4784 @b{Important:} Scheduling an item in Org mode should @i{not} be
4785 understood in the same way that we understand @i{scheduling a meeting}.
4786 Setting a date for a meeting is just a simple appointment, you should
4787 mark this entry with a simple plain time stamp, to get this item shown
4788 on the date where it applies.  This is a frequent mis-understanding from
4789 Org-users.  In Org mode, @i{scheduling} means setting a date when you
4790 want to start working on an action item.
4791 @end table
4793 You may use time stamps with repeaters in scheduling and deadline
4794 entries.  Org mode will issue early and late warnings based on the
4795 assumption that the time stamp represents the @i{nearest instance} of
4796 the repeater.  However, the use of diary sexp entries like
4798 @code{<%%(diary-float t 42)>}
4800 in scheduling and deadline timestamps is limited.  Org mode does not
4801 know enough about the internals of each sexp function to issue early and
4802 late warnings.  However, it will show the item on each day where the
4803 sexp entry matches.
4805 @menu
4806 * Inserting deadline/schedule::  Planning items
4807 * Repeated tasks::              Items that show up again and again
4808 @end menu
4810 @node Inserting deadline/schedule, Repeated tasks, Deadlines and scheduling, Deadlines and scheduling
4811 @subsection Inserting deadlines or schedules
4813 The following commands allow to quickly insert a deadline or to schedule
4814 an item:
4816 @table @kbd
4818 @kindex C-c C-d
4819 @item C-c C-d
4820 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will
4821 happen in the line directly following the headline.  When called with a
4822 prefix arg, an existing deadline will be removed from the entry.
4823 @c FIXME Any CLOSED timestamp will be removed.????????
4825 @kindex C-c / d
4826 @cindex sparse tree, for deadlines
4827 @item C-c / d
4828 Create a sparse tree with all deadlines that are either past-due, or
4829 which will become due within @code{org-deadline-warning-days}.
4830 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
4831 prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows
4832 all deadlines due tomorrow.
4834 @kindex C-c C-s
4835 @item C-c C-s
4836 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
4837 happen in the line directly following the headline.  Any CLOSED
4838 timestamp will be removed.  When called with a prefix argument, remove
4839 the scheduling date from the entry.
4841 @kindex C-c C-x C-k
4842 @kindex k a
4843 @kindex k s
4844 @item C-c C-x C-k
4845 Mark the current entry for agenda action.  After you have marked the entry
4846 like this, you can open the agenda or the calendar to find an appropriate
4847 date.  With the cursor on the selected date, press @kbd{k s} or @kbd{k d} to
4848 schedule the marked item.
4849 @end table
4851 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
4852 @subsection Repeated tasks
4854 Some tasks need to be repeated again and again.  Org mode helps to
4855 organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
4856 or plain time stamp.  In the following example
4857 @example
4858 ** TODO Pay the rent
4859    DEADLINE: <2005-10-01 Sat +1m>
4860 @end example
4861 the @code{+1m} is a repeater; the intended interpretation is that the
4862 task has a deadline on <2005-10-01> and repeats itself every (one) month
4863 starting from that time.  If you need both a repeater and a special
4864 warning period in a deadline entry, the repeater comes first and the
4865 warning period last: @code{DEADLINE: <2005-10-01 Sat +1m -3d>}.
4867 Deadlines and scheduled items produce entries in the agenda when they
4868 are over-due, so it is important to be able to mark such an entry as
4869 completed once you have done so.  When you mark a DEADLINE or a SCHEDULE
4870 with the TODO keyword DONE, it will no longer produce entries in the
4871 agenda.  The problem with this is, however, that then also the
4872 @emph{next} instance of the repeated entry will not be active.  Org mode
4873 deals with this in the following way: When you try to mark such an entry
4874 DONE (using @kbd{C-c C-t}), it will shift the base date of the repeating
4875 time stamp by the repeater interval, and immediately set the entry state
4876 back to TODO.  In the example above, setting the state to DONE would
4877 actually switch the date like this:
4879 @example
4880 ** TODO Pay the rent
4881    DEADLINE: <2005-11-01 Tue +1m>
4882 @end example
4884 A timestamp@footnote{You can change this using the option
4885 @code{org-log-repeat}, or the @code{#+STARTUP} options @code{logrepeat},
4886 @code{lognoterepeat}, and @code{nologrepeat}.  With @code{lognoterepeat}, you
4887 will also be prompted for a note.} will be added under the deadline, to keep
4888 a record that you actually acted on the previous instance of this deadline.
4890 As a consequence of shifting the base date, this entry will no longer be
4891 visible in the agenda when checking past dates, but all future instances
4892 will be visible.
4894 With the @samp{+1m} cookie, the date shift will always be exactly one
4895 month.  So if you have not payed the rent for three months, marking this
4896 entry DONE will still keep it as an overdue deadline.  Depending on the
4897 task, this may not be the best way to handle it.  For example, if you
4898 forgot to call you father for 3 weeks, it does not make sense to call
4899 him 3 times in a single day to make up for it.  Finally, there are tasks
4900 like changing batteries which should always repeat a certain time
4901 @i{after} the last time you did it.  For these tasks, Org mode has
4902 special repeaters markers with @samp{++} and @samp{.+}.  For example:
4904 @example
4905 ** TODO Call Father
4906    DEADLINE: <2008-02-10 Sun ++1w>
4907    Marking this DONE will shift the date by at least one week,
4908    but also by as many weeks as it takes to get this date into
4909    the future.  However, it stays on a Sunday, even if you called
4910    and marked it done on Saturday.
4911 ** TODO Check the batteries in the smoke detectors
4912    DEADLINE: <2005-11-01 Tue .+1m>
4913    Marking this DONE will shift the date to one month after
4914    today.
4915 @end example
4917 You may have both scheduling and deadline information for a specific
4918 task - just make sure that the repeater intervals on both are the same.
4920 @node Clocking work time, Effort estimates, Deadlines and scheduling, Dates and Times
4921 @section Clocking work time
4923 Org mode allows you to clock the time you spent on specific tasks in a
4924 project.  When you start working on an item, you can start the clock.
4925 When you stop working on that task, or when you mark the task done, the
4926 clock is stopped and the corresponding time interval is recorded.  It
4927 also computes the total time spent on each subtree of a project.
4929 @table @kbd
4930 @kindex C-c C-x C-i
4931 @item C-c C-x C-i
4932 Start the clock on the current item (clock-in).  This inserts the CLOCK
4933 keyword together with a timestamp.  If this is not the first clocking of
4934 this item, the multiple CLOCK lines will be wrapped into a
4935 @code{:CLOCK:} drawer (see also the variable
4936 @code{org-clock-into-drawer}).  When called with a @kbd{C-u} prefix argument,
4937 select the task from a list of recently clocked tasks.  With two @kbd{C-u
4938 C-u} prefixes, clock into the task at point and mark it as the default task.
4939 The default task will always be available when selecting a clocking task,
4940 with letter @kbd{d}.
4941 @kindex C-c C-x C-o
4942 @item C-c C-x C-o
4943 Stop the clock (clock-out).  This inserts another timestamp at the same
4944 location where the clock was last started.  It also directly computes
4945 the resulting time in inserts it after the time range as @samp{=>
4946 HH:MM}.  See the variable @code{org-log-note-clock-out} for the
4947 possibility to record an additional note together with the clock-out
4948 time stamp@footnote{The corresponding in-buffer setting is:
4949 @code{#+STARTUP: lognoteclock-out}}.
4950 @kindex C-c C-y
4951 @item C-c C-y
4952 Recompute the time interval after changing one of the time stamps.  This
4953 is only necessary if you edit the time stamps directly.  If you change
4954 them with @kbd{S-@key{cursor}} keys, the update is automatic.
4955 @kindex C-c C-t
4956 @item C-c C-t
4957 Changing the TODO state of an item to DONE automatically stops the clock
4958 if it is running in this same item.
4959 @kindex C-c C-x C-x
4960 @item C-c C-x C-x
4961 Cancel the current clock.  This is useful if a clock was started by
4962 mistake, or if you ended up working on something else.
4963 @kindex C-c C-x C-j
4964 @item C-c C-x C-j
4965 Jump to the entry that contains the currently running clock.  With a
4966 @kbd{C-u} prefix arg, select the target task from a list of recently clocked
4967 tasks.
4968 @kindex C-c C-x C-d
4969 @item C-c C-x C-d
4970 Display time summaries for each subtree in the current buffer.  This
4971 puts overlays at the end of each headline, showing the total time
4972 recorded under that heading, including the time of any subheadings. You
4973 can use visibility cycling to study the tree, but the overlays disappear
4974 when you change the buffer (see variable
4975 @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
4976 @kindex C-c C-x C-r
4977 @item C-c C-x C-r
4978 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
4979 report as an Org mode table into the current file.  When the cursor is
4980 at an existing clock table, just update it.  When called with a prefix
4981 argument, jump to the first clock report in the current document and
4982 update it.
4983 @cindex #+BEGIN: clocktable
4984 @example
4985 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
4986 #+END: clocktable
4987 @end example
4988 @noindent
4989 If such a block already exists at point, its content is replaced by the
4990 new table.  The @samp{BEGIN} line can specify options:
4991 @example
4992 :maxlevel    @r{Maximum level depth to which times are listed in the table.}
4993 :emphasize   @r{When @code{t}, emphasize level one and level two items}
4994 :scope       @r{The scope to consider.  This can be any of the following:}
4995              nil        @r{the current buffer or narrowed region}
4996              file       @r{the full current buffer}
4997              subtree    @r{the subtree where the clocktable is located}
4998              treeN      @r{the surrounding level N tree, for example @code{tree3}}
4999              tree       @r{the surrounding level 1 tree}
5000              agenda     @r{all agenda files}
5001              ("file"..) @r{scan these files}
5002              file-with-archives    @r{current file and its archives}
5003              agenda-with-archives  @r{all agenda files, including archives}
5004 :block       @r{The time block to consider.  This block is specified either}
5005              @r{absolute, or relative to the current time and may be any of}
5006              @r{these formats:}
5007              2007-12-31    @r{New year eve 2007}
5008              2007-12       @r{December 2007}
5009              2007-W50      @r{ISO-week 50 in 2007}
5010              2007          @r{the year 2007}
5011              today, yesterday, today-N          @r{a relative day}
5012              thisweek, lastweek, thisweek-N     @r{a relative week}
5013              thismonth, lastmonth, thismonth-N  @r{a relative month}
5014              thisyear, lastyear, thisyear-N     @r{a relative year}
5015              @r{Use @kbd{S-@key{left}/@key{right}} keys to shift the time interval.}
5016 :tstart      @r{A time string specifying when to start considering times}
5017 :tend        @r{A time string specifying when to stop considering times}
5018 :step        @r{@code{week} or @code{day}, to split the table into chunks.}
5019              @r{To use this, @code{:block} or @code{:tstart}, @code{:tend} are needed.}
5020 :link        @r{Link the item headlines in the table to their origins}
5021 :formula     @r{Content of a @code{#+TBLFM} line to be added and evaluated.}
5022              @r{As a special case, @samp{:formula %} adds column with % time.}
5023              @r{If you do not specify a formula here, any existing formula}
5024              @r{below the clock table will survive updates and be evaluated.}
5025 @end example
5026 So to get a clock summary of the current level 1 tree, for the current
5027 day, you could write
5028 @example
5029 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
5030 #+END: clocktable
5031 @end example
5032 and to use a specific time range you could write@footnote{Note that all
5033 parameters must be specified in a single line - the line is broken here
5034 only to fit it onto the manual.}
5035 @example
5036 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
5037                     :tend "<2006-08-10 Thu 12:00>"
5038 #+END: clocktable
5039 @end example
5040 A summary of the current subtree with % times would be
5041 @example
5042 #+BEGIN: clocktable :scope subtree :link t :formula %
5043 #+END: clocktable
5044 @end example
5045 @kindex C-c C-c
5046 @item C-c C-c
5047 @kindex C-c C-x C-u
5048 @itemx C-c C-x C-u
5049 Update dynamical block at point.  The cursor needs to be in the
5050 @code{#+BEGIN} line of the dynamic block.
5051 @kindex C-u C-c C-x C-u
5052 @item C-u C-c C-x C-u
5053 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
5054 you have several clock table blocks in a buffer.
5055 @kindex S-@key{left}
5056 @kindex S-@key{right}
5057 @item S-@key{left}
5058 @itemx S-@key{right}
5059 Shift the current @code{:block} interval and update the table.  The cursor
5060 needs to be in the @code{#+BEGIN: clocktable} line for this command.  If
5061 @code{:block} is @code{today}, it will be shifted to @code{today-1} etc.
5062 @end table
5064 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
5065 the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
5066 worked on or closed during a day.
5068 @node Effort estimates, Relative timer, Clocking work time, Dates and Times
5069 @section Effort estimates
5070 @cindex effort estimates
5072 If you want to plan your work in a very detailed way, or if you need to
5073 produce offers with quotations of the estimated work effort, you may want to
5074 assign effort estimates to entries.  If you are also clocking your work, you
5075 may later want to compare the planned effort with the actual working time, a
5076 great way to improve planning estimates.  Effort estimates are stored in a
5077 special property @samp{Effort}@footnote{You may change the property being
5078 used with the variable @code{org-effort-property}.}.  Clearly the best way to
5079 work with effort estimates is through column view (@pxref{Column view}).  You
5080 should start by setting up discrete values for effort estimates, and a
5081 @code{COLUMNS} format that displays these values together with clock sums (if
5082 you want to clock your time).  For a specific buffer you can use
5084 @example
5085 #+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00 8:00
5086 #+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort)@{:@} %CLOCKSUM
5087 @end example
5089 @noindent
5090 or, even better, you can set up these values globally by customizing the
5091 variables @code{org-global-properties} and @code{org-columns-default-format}.
5092 In particular if you want to use this setup also in the agenda, a global
5093 setup may be advised.
5095 The way to assign estimates to individual items is then to switch to column
5096 mode, and to use @kbd{S-@key{right}} and @kbd{S-@key{left}} to change the
5097 value.  The values you enter will immediately be summed up in the hierarchy.
5098 In the column next to it, any clocked time will be displayed.
5100 If you switch to column view in the daily/weekly agenda, the effort column
5101 will summarize the estimated work effort for each day@footnote{Please note
5102 the pitfalls of summing hierarchical data in a flat list (@pxref{Agenda
5103 column view}).}, and you can use this to find space in your schedule.  To get
5104 an overview of the entire part of the day that is committed, you can set the
5105 option @code{org-agenda-columns-add-appointments-to-effort-sum}.  The
5106 appointments on a day that take place over a specified time interval will
5107 then also be added to the load estimate of the day.
5109 Effort estimates can be used in secondary agenda filtering that is triggered
5110 with the @kbd{/} key in the agenda (@pxref{Agenda commands}).  If you have
5111 these estimates defined consistently, two or three key presses will narrow
5112 down the list to stuff that fits into an available time slot.
5114 @node Relative timer,  , Effort estimates, Dates and Times
5115 @section Taking notes with a relative timer
5116 @cindex relative timer
5118 When taking notes during, for example, a meeting or a video viewing, it can
5119 be useful to have access to times relative to a starting time.  Org provides
5120 such a relative timer and make it easy to create timed notes.
5122 @table @kbd
5123 @kindex C-c C-x .
5124 @item C-c C-x .
5125 Insert a relative time into the buffer.  The first time you use this, the
5126 timer will be started.  When called with a prefix argument, the timer is
5127 restarted.
5128 @kindex C-c C-x -
5129 @item C-c C-x -
5130 Insert a description list item with the current relative time.  With a prefix
5131 argument, first reset the timer to 0.
5132 @kindex M-@key{RET}
5133 @item M-@key{RET}
5134 Once the timer list is started, you can also use @kbd{M-@key{RET}} to insert
5135 new timer items.
5136 @kindex C-c C-x ,
5137 @item C-c C-x ,
5138 Pause the timer, or continue it if it is already paused.  With prefix
5139 argument, stop it entirely.
5140 @kindex C-u C-c C-x ,
5141 @item C-u C-c C-x ,
5142 Stop the timer.  After this, you can only start a new timer, not continue the
5143 old one.  This command also removes the timer from the mode line.
5144 @kindex C-c C-x 0
5145 @item C-c C-x 0
5146 Reset the timer without inserting anything into the buffer.  By default, the
5147 timer is reset to 0.  When called with a @kbd{C-u} prefix, reset the timer to
5148 specific starting offset.  The user is prompted for the offset, with a
5149 default taken from a timer string at point, if any, So this can be used to
5150 restart taking notes after a break in the process.  When called with a double
5151 prefix argument @kbd{C-c C-u}, change all timer strings in the active region
5152 by a certain amount.  This can be used to fix timer strings if the timer was
5153 not started at exactly the right moment.
5154 @end table
5156 @node Capture, Agenda Views, Dates and Times, Top
5157 @chapter Capture
5158 @cindex capture
5160 An important part of any organization system is the ability to quickly
5161 capture new ideas and tasks, and to associate reference material with them.
5162 Org uses the @file{remember} package to create tasks, and stores files
5163 related to a task (@i{attachments}) in a special directory.
5165 @menu
5166 * Remember::                    Capture new tasks/ideas with little interruption
5167 * Attachments::                 Add files to tasks.
5168 @end menu
5170 @node Remember, Attachments, Capture, Capture
5171 @section Remember
5172 @cindex @file{remember.el}
5174 The @i{Remember} package by John Wiegley lets you store quick notes with
5175 little interruption of your work flow.  See
5176 @uref{http://www.emacswiki.org/cgi-bin/wiki/RememberMode} for more
5177 information.  It is an excellent way to add new notes and tasks to
5178 Org files.  Org significantly expands the possibilities of
5179 @i{remember}: You may define templates for different note types, and
5180 associate target files and headlines with specific templates.  It also
5181 allows you to select the location where a note should be stored
5182 interactively, on the fly.
5184 @menu
5185 * Setting up Remember::         Some code for .emacs to get things going
5186 * Remember templates::          Define the outline of different note types
5187 * Storing notes::               Directly get the note to where it belongs
5188 * Refiling notes::              Moving a note or task to a project
5189 @end menu
5191 @node Setting up Remember, Remember templates, Remember, Remember
5192 @subsection Setting up Remember
5194 The following customization will tell @i{remember} to use org files as
5195 target, and to create annotations compatible with Org links.
5197 @example
5198 (org-remember-insinuate)
5199 (setq org-directory "~/path/to/my/orgfiles/")
5200 (setq org-default-notes-file (concat org-directory "/notes.org"))
5201 (define-key global-map "\C-cr" 'org-remember)
5202 @end example
5204 The last line binds the command @code{org-remember} to a global
5205 key@footnote{Please select your own key, @kbd{C-c r} is only a
5206 suggestion.}.  @code{org-remember} basically just calls @code{remember},
5207 but it makes a few things easier: If there is an active region, it will
5208 automatically copy the region into the remember buffer.  It also allows
5209 to jump to the buffer and location where remember notes are being
5210 stored: Just call @code{org-remember} with a prefix argument.  If you
5211 use two prefix arguments, Org jumps to the location where the last
5212 remember note was stored.
5214 The remember buffer will actually use @code{org-mode} as its major mode, so
5215 that all editing features of Org-mode are available.  In addition to this, a
5216 minor mode @code{org-remember-mode} is turned on, for the single purpose that
5217 you can use its keymap @code{org-remember-mode-map} to overwrite some of
5218 Org-mode's key bindings.
5220 You can also call @code{org-remember} in a special way from the agenda,
5221 using the @kbd{k r} key combination.  With this access, any time stamps
5222 inserted by the selected remember template (see below) will default to
5223 the cursor date in the agenda, rather than to the current date.
5225 @node Remember templates, Storing notes, Setting up Remember, Remember
5226 @subsection Remember templates
5227 @cindex templates, for remember
5229 In combination with Org, you can use templates to generate
5230 different types of @i{remember} notes.  For example, if you would like
5231 to use one template to create general TODO entries, another one for
5232 journal entries, and a third one for collecting random ideas, you could
5233 use:
5235 @example
5236 (setq org-remember-templates
5237  '(("Todo" ?t "* TODO %?\n  %i\n  %a" "~/org/TODO.org" "Tasks")
5238    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org")
5239    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
5240 @end example
5242 @noindent In these entries, the first string is just a name, and the
5243 character specifies how to select the template.  It is useful if the
5244 character is also the first letter of the name.  The next string specifies
5245 the template.  Two more (optional) strings give the file in which, and the
5246 headline under which the new note should be stored.  The file (if not present
5247 or @code{nil}) defaults to @code{org-default-notes-file}, the heading to
5248 @code{org-remember-default-headline}.  If the file name is not an absolute
5249 path, it will be interpreted relative to @code{org-directory}.  The heading
5250 can also be the symbols @code{top} or @code{bottom} to send note as level 1
5251 entries to the beginning or end of the file, respectively.
5253 An optional sixth element specifies the contexts in which the user can select
5254 the template.  This element can be a list of major modes or a function.
5255 @code{org-remember} will first check whether the function returns @code{t} or
5256 if we are in any of the listed major mode, and exclude templates for which
5257 this condition is not fulfilled.  Templates that do not specify this element
5258 at all, or that use @code{nil} or @code{t} as a value will always be
5259 selectable.
5261 So for example:
5263 @example
5264 (setq org-remember-templates
5265  '(("Bug" ?b "* BUG %?\n  %i\n  %a" "~/org/BUGS.org" "Bugs" (emacs-lisp-mode))
5266    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org" "X" my-check)
5267    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
5268 @end example
5270 The first template will only be available when invoking @code{org-remember}
5271 from an buffer in @code{emacs-lisp-mode}.  The second template will only be
5272 available when the function @code{my-check} returns @code{t}.  The third
5273 template will be proposed in any context.
5275 When you call @kbd{M-x org-remember} (or @kbd{M-x remember}) to remember
5276 something, Org will prompt for a key to select the template (if you have
5277 more than one template) and then prepare the buffer like
5278 @example
5279 * TODO
5280   [[file:link to where you called remember]]
5281 @end example
5283 @noindent
5284 During expansion of the template, special @kbd{%}-escapes allow dynamic
5285 insertion of content:
5286 @example
5287 %^@{prompt@}  @r{prompt the user for a string and replace this sequence with it.}
5288             @r{You may specify a default value and a completion table with}
5289             @r{%^@{prompt|default|completion2|completion3...@}}
5290             @r{The arrow keys access a prompt-specific history.}
5291 %a          @r{annotation, normally the link created with @code{org-store-link}}
5292 %A          @r{like @code{%a}, but prompt for the description part}
5293 %i          @r{initial content, the region when remember is called with C-u.}
5294             @r{The entire text will be indented like @code{%i} itself.}
5295 %t          @r{time stamp, date only}
5296 %T          @r{time stamp with date and time}
5297 %u, %U      @r{like the above, but inactive time stamps}
5298 %^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
5299             @r{You may define a prompt like @code{%^@{Birthday@}t}}
5300 %n          @r{user name (taken from @code{user-full-name})}
5301 %c          @r{Current kill ring head.}
5302 %x          @r{Content of the X clipboard.}
5303 %^C         @r{Interactive selection of which kill or clip to use.}
5304 %^L         @r{Like @code{%^C}, but insert as link.}
5305 %^g         @r{prompt for tags, with completion on tags in target file.}
5306 %k          @r{title of currently clocked task}
5307 %K          @r{link to currently clocked task}
5308 %^G         @r{prompt for tags, with completion all tags in all agenda files.}
5309 %^@{prop@}p   @r{Prompt the user for a value for property @code{prop}}
5310 %:keyword   @r{specific information for certain link types, see below}
5311 %[pathname] @r{insert the contents of the file given by @code{pathname}}
5312 %(sexp)     @r{evaluate elisp @code{(sexp)} and replace with the result}
5313 %!          @r{immediately store note after completing the template}
5314             @r{(skipping the @kbd{C-c C-c} that normally triggers storing)}
5315 %&          @r{jump to target location immediately after storing note}
5316 @end example
5318 @noindent
5319 For specific link types, the following keywords will be
5320 defined@footnote{If you define your own link types (@pxref{Adding
5321 hyperlink types}), any property you store with
5322 @code{org-store-link-props} can be accessed in remember templates in a
5323 similar way.}:
5325 @example
5326 Link type          |  Available keywords
5327 -------------------+----------------------------------------------
5328 bbdb               |  %:name %:company
5329 bbdb               |  %::server %:port %:nick
5330 vm, wl, mh, rmail  |  %:type %:subject %:message-id
5331                    |  %:from %:fromname %:fromaddress
5332                    |  %:to   %:toname   %:toaddress
5333                    |  %: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}.}}
5334 gnus               |  %:group, @r{for messages also all email fields}
5335 w3, w3m            |  %:url
5336 info               |  %:file %:node
5337 calendar           |  %:date"
5338 @end example
5340 @noindent
5341 To place the cursor after template expansion use:
5343 @example
5344 %?          @r{After completing the template, position cursor here.}
5345 @end example
5347 @noindent
5348 If you change your mind about which template to use, call
5349 @code{org-remember} in the remember buffer.  You may then select a new
5350 template that will be filled with the previous context information.
5352 @node Storing notes, Refiling notes, Remember templates, Remember
5353 @subsection Storing notes
5355 When you are finished preparing a note with @i{remember}, you have to press
5356 @kbd{C-c C-c} to file the note away.  If you have started the clock in the
5357 remember buffer, you will first be asked if you want to clock out
5358 now@footnote{To avoid this query, configure the variable
5359 @code{org-remember-clock-out-on-exit}.}.  If you answer @kbd{n}, the clock
5360 will continue to run after the note was filed away.
5362 The handler will then store the note in the file and under the headline
5363 specified in the template, or it will use the default file and headlines.
5364 The window configuration will be restored, sending you back to the working
5365 context before the call to @code{remember}.  To re-use the location found
5366 during the last call to @code{remember}, exit the remember buffer with
5367 @kbd{C-0 C-c C-c}, i.e. specify a zero prefix argument to @kbd{C-c C-c}.
5368 Another special case is @kbd{C-2 C-c C-c} which files the note as a child of
5369 the currently clocked item.
5371 If you want to store the note directly to a different place, use
5372 @kbd{C-1 C-c C-c} instead to exit remember@footnote{Configure the
5373 variable @code{org-remember-store-without-prompt} to make this behavior
5374 the default.}.  The handler will then first prompt for a target file -
5375 if you press @key{RET}, the value specified for the template is used.
5376 Then the command offers the headings tree of the selected file, with the
5377 cursor position at the default headline (if you had specified one in the
5378 template).  You can either immediately press @key{RET} to get the note
5379 placed there.  Or you can use the following keys to find a different
5380 location:
5381 @example
5382 @key{TAB}         @r{Cycle visibility.}
5383 @key{down} / @key{up}   @r{Next/previous visible headline.}
5384 n / p        @r{Next/previous visible headline.}
5385 f / b        @r{Next/previous headline same level.}
5386 u            @r{One level up.}
5387 @c 0-9          @r{Digit argument.}
5388 @end example
5389 @noindent
5390 Pressing @key{RET} or @key{left} or @key{right}
5391 then leads to the following result.
5393 @multitable @columnfractions 0.2 0.15 0.65
5394 @item @b{Cursor position} @tab @b{Key} @tab @b{Note gets inserted}
5395 @item on headline     @tab @key{RET}              @tab as sublevel of the heading at cursor, first or last
5396 @item                 @tab                        @tab depending on @code{org-reverse-note-order}.
5397 @item                 @tab @key{left}/@key{right} @tab as same level, before/after current heading
5398 @item buffer-start    @tab @key{RET} @tab as level 2 heading at end of file or level 1 at beginning
5399 @item                 @tab @tab depending on @code{org-reverse-note-order}.
5400 @item not on headline @tab @key{RET}
5401       @tab at cursor position, level taken from context.
5402 @end multitable
5404 Before inserting the text into a tree, the function ensures that the text has
5405 a headline, i.e. a first line that starts with a @samp{*}.  If not, a
5406 headline is constructed from the current date.  If you have indented the text
5407 of the note below the headline, the indentation will be adapted if inserting
5408 the note into the tree requires demotion from level 1.
5410 @node Refiling notes,  , Storing notes, Remember
5411 @subsection Refiling notes
5412 @cindex refiling notes
5414 Remember is usually used to quickly capture notes and tasks into one or
5415 a few capture lists.  When reviewing the captured data, you may want to
5416 refile some of the entries into a different list, for example into a
5417 project.  Cutting, finding the right location and then pasting the note
5418 is cumbersome.  To simplify this process, you can use the following
5419 special command:
5421 @table @kbd
5422 @kindex C-c C-w
5423 @item C-c C-w
5424 Refile the entry or region at point.  This command offers possible locations
5425 for refiling the entry and lets you select one with completion.  The item (or
5426 all items in the region) is filed below the target heading as a subitem.
5427 Depending on @code{org-reverse-note-order}, it will be either the first or
5428 last subitem.@*
5429 By default, all level 1 headlines in the current buffer are considered to be
5430 targets, but you can have more complex definitions across a number of files.
5431 See the variable @code{org-refile-targets} for details.  If you would like to
5432 select a location via a file-path-like completion along the outline path, see
5433 the variables @code{org-refile-use-outline-path} and
5434 @code{org-outline-path-complete-in-steps}.
5435 @kindex C-u C-c C-w
5436 @item C-u C-c C-w
5437 Use the refile interface to jump to a heading.
5438 @kindex C-u C-u C-c C-w
5439 @item C-u C-u C-c C-w
5440 Jump to the location where @code{org-refile} last moved a tree to.
5441 @end table
5443 @node Attachments,  , Remember, Capture
5444 @section Attachments
5445 @cindex attachments
5447 It is often useful to associate reference material with an outline node/task.
5448 Small chunks of plain text can simply be stored in the subtree of a project.
5449 Hyperlinks (@pxref{Hyperlinks}) can be used to establish associations with
5450 files that live elsewhere on your computer or in the cloud, like emails or
5451 source code files belonging to a project.  Another method is @i{attachments},
5452 which are files located in a directory belonging to an outline node.  Org
5453 uses directories named by the unique ID of each entry.  These directories are
5454 located in the @file{data} directory which lives in the same directory where
5455 your org-file lives@footnote{If you move entries or Org-files from one
5456 directory to the next, you may want to configure @code{org-attach-directory}
5457 to contain an absolute path.}.  If you initialize this directory with
5458 @code{git-init}, Org will automatically commit changes when it sees them.
5459 The attachment system has been contributed to Org by John Wiegley.
5461 In cases where this seems better, you can also attach a directory of your
5462 choice to an entry.  You can also make children inherit the attachment
5463 directory from a parent, so that an entire subtree uses the same attached
5464 directory.
5466 @noindent The following commands deal with attachments.
5468 @table @kbd
5470 @kindex C-c C-a
5471 @item C-c C-a
5472 The dispatcher for commands related to the attachment system.  After these
5473 keys, a list of commands is displayed and you need to press an additional key
5474 to select a command:
5476 @table @kbd
5477 @kindex C-c C-a a
5478 @item a
5479 Select a file and move it into the task's attachment directory.  The file
5480 will be copied, moved, or linked, depending on @code{org-attach-method}.
5481 Note that hard links are not supported on all systems.
5483 @kindex C-c C-a c
5484 @kindex C-c C-a m
5485 @kindex C-c C-a l
5486 @item c/m/l
5487 Attach a file using the copy/move/link method.
5488 Note that hard links are not supported on all systems.
5490 @kindex C-c C-a n
5491 @item n
5492 Create a new attachment as an Emacs buffer.
5494 @kindex C-c C-a z
5495 @item z
5496 Synchronize the current task with its attachment directory, in case you added
5497 attachments yourself.
5499 @kindex C-c C-a o
5500 @item o
5501 Open current task's attachment.  If there are more than one, prompt for a
5502 file name first.  Opening will follow the rules set by @code{org-file-apps}.
5503 For more details, see the information on following hyperlinks
5504 (@pxref{Handling links}).
5506 @kindex C-c C-a O
5507 @item O
5508 Also open the attachment, but force opening the file in Emacs.
5510 @kindex C-c C-a f
5511 @item f
5512 Open the current task's attachment directory.
5514 @kindex C-c C-a F
5515 @item F
5516 Also open the directory, but force using @code{dired} in Emacs.
5518 @kindex C-c C-a d
5519 @item d
5520 Select and delete a single attachment.
5522 @kindex C-c C-a D
5523 @item D
5524 Delete all of a task's attachments.  A safer way is to open the directory in
5525 dired and delete from there.
5527 @kindex C-c C-a s
5528 @item C-c C-a s
5529 Set a specific directory as the entry's attachment directory.  This works by
5530 putting the directory path into the @code{ATTACH_DIR} property.
5532 @kindex C-c C-a i
5533 @item C-c C-a i
5534 Set the @code{ATTACH_DIR_INHERIT} property, so that children will use the
5535 same directory for attachments as the parent.
5536 @end table
5537 @end table
5539 @node Agenda Views, Embedded LaTeX, Capture, Top
5540 @chapter Agenda Views
5541 @cindex agenda views
5543 Due to the way Org works, TODO items, time-stamped items, and
5544 tagged headlines can be scattered throughout a file or even a number of
5545 files.  To get an overview of open action items, or of events that are
5546 important for a particular date, this information must be collected,
5547 sorted and displayed in an organized way.
5549 Org can select items based on various criteria, and display them
5550 in a separate buffer.  Seven different view types are provided:
5552 @itemize @bullet
5553 @item
5554 an @emph{agenda} that is like a calendar and shows information
5555 for specific dates,
5556 @item
5557 a @emph{TODO list} that covers all unfinished
5558 action items,
5559 @item
5560 a @emph{match view}, showings headlines based on the tags, properties and
5561 TODO state associated with them,
5562 @item
5563 a @emph{timeline view} that shows all events in a single Org file,
5564 in time-sorted view,
5565 @item
5566 a @emph{keyword search view} that shows all entries from multiple files
5567 that contain specified keywords.
5568 @item
5569 a @emph{stuck projects view} showing projects that currently don't move
5570 along, and
5571 @item
5572 @emph{custom views} that are special tag/keyword searches and
5573 combinations of different views.
5574 @end itemize
5576 @noindent
5577 The extracted information is displayed in a special @emph{agenda
5578 buffer}.  This buffer is read-only, but provides commands to visit the
5579 corresponding locations in the original Org files, and even to
5580 edit these files remotely.
5582 Two variables control how the agenda buffer is displayed and whether the
5583 window configuration is restored when the agenda exits:
5584 @code{org-agenda-window-setup} and
5585 @code{org-agenda-restore-windows-after-quit}.
5587 @menu
5588 * Agenda files::                Files being searched for agenda information
5589 * Agenda dispatcher::           Keyboard access to agenda views
5590 * Built-in agenda views::       What is available out of the box?
5591 * Presentation and sorting::    How agenda items are prepared for display
5592 * Agenda commands::             Remote editing of Org trees
5593 * Custom agenda views::         Defining special searches and views
5594 * Agenda column view::          Using column view for collected entries
5595 @end menu
5597 @node Agenda files, Agenda dispatcher, Agenda Views, Agenda Views
5598 @section Agenda files
5599 @cindex agenda files
5600 @cindex files for agenda
5602 The information to be shown is normally collected from all @emph{agenda
5603 files}, the files listed in the variable
5604 @code{org-agenda-files}@footnote{If the value of that variable is not a
5605 list, but a single file name, then the list of agenda files will be
5606 maintained in that external file.}. If a directory is part of this list,
5607 all files with the extension @file{.org} in this directory will be part
5608 of the list.
5610 Thus even if you only work with a single Org file, this file should
5611 be put into that list@footnote{When using the dispatcher, pressing
5612 @kbd{<} before selecting a command will actually limit the command to
5613 the current file, and ignore @code{org-agenda-files} until the next
5614 dispatcher command.}.  You can customize @code{org-agenda-files}, but
5615 the easiest way to maintain it is through the following commands
5617 @cindex files, adding to agenda list
5618 @table @kbd
5619 @kindex C-c [
5620 @item C-c [
5621 Add current file to the list of agenda files.  The file is added to
5622 the front of the list.  If it was already in the list, it is moved to
5623 the front.  With a prefix argument, file is added/moved to the end.
5624 @kindex C-c ]
5625 @item C-c ]
5626 Remove current file from the list of agenda files.
5627 @kindex C-,
5628 @kindex C-'
5629 @item C-,
5630 @itemx C-'
5631 Cycle through agenda file list, visiting one file after the other.
5632 @kindex M-x org-iswitchb
5633 @item M-x org-iswitchb
5634 Command to use an @code{iswitchb}-like interface to switch to and between Org
5635 buffers.
5636 @end table
5638 @noindent
5639 The Org menu contains the current list of files and can be used
5640 to visit any of them.
5642 If you would like to focus the agenda temporarily onto a file not in
5643 this list, or onto just one file in the list or even only a subtree in a
5644 file, this can be done in different ways.  For a single agenda command,
5645 you may press @kbd{<} once or several times in the dispatcher
5646 (@pxref{Agenda dispatcher}).  To restrict the agenda scope for an
5647 extended period, use the following commands:
5649 @table @kbd
5650 @kindex C-c C-x <
5651 @item C-c C-x <
5652 Permanently restrict the agenda to the current subtree.  When with a
5653 prefix argument, or with the cursor before the first headline in a file,
5654 the agenda scope is set to the entire file.  This restriction remains in
5655 effect until removed with @kbd{C-c C-x >}, or by typing either @kbd{<}
5656 or @kbd{>} in the agenda dispatcher.  If there is a window displaying an
5657 agenda view, the new restriction takes effect immediately.
5658 @kindex C-c C-x >
5659 @item C-c C-x >
5660 Remove the permanent restriction created by @kbd{C-c C-x <}.
5661 @end table
5663 @noindent
5664 When working with @file{Speedbar}, you can use the following commands in
5665 the Speedbar frame:
5666 @table @kbd
5667 @kindex <
5668 @item < @r{in the speedbar frame}
5669 Permanently restrict the agenda to the item at the cursor in the
5670 Speedbar frame, either an Org file or a subtree in such a file.
5671 If there is a window displaying an agenda view, the new restriction takes
5672 effect immediately.
5673 @kindex >
5674 @item > @r{in the speedbar frame}
5675 Lift the restriction again.
5676 @end table
5678 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda Views
5679 @section The agenda dispatcher
5680 @cindex agenda dispatcher
5681 @cindex dispatching agenda commands
5682 The views are created through a dispatcher that should be bound to a
5683 global key, for example @kbd{C-c a} (@pxref{Installation}).  In the
5684 following we will assume that @kbd{C-c a} is indeed how the dispatcher
5685 is accessed and list keyboard access to commands accordingly.  After
5686 pressing @kbd{C-c a}, an additional letter is required to execute a
5687 command.  The dispatcher offers the following default commands:
5688 @table @kbd
5689 @item a
5690 Create the calendar-like agenda (@pxref{Weekly/daily agenda}).
5691 @item t @r{/} T
5692 Create a list of all TODO items (@pxref{Global TODO list}).
5693 @item m @r{/} M
5694 Create a list of headlines matching a TAGS expression (@pxref{Matching
5695 tags and properties}).
5696 @item L
5697 Create the timeline view for the current buffer (@pxref{Timeline}).
5698 @item s
5699 Create a list of entries selected by a boolean expression of keywords
5700 and/or regular expressions that must or must not occur in the entry.
5701 @item /
5702 Search for a regular expression in all agenda files and additionally in
5703 the files listed in @code{org-agenda-multi-occur-extra-files}.  This
5704 uses the Emacs command @code{multi-occur}.  A prefix argument can be
5705 used to specify the number of context lines for each match, default is
5707 @item # @r{/} !
5708 Create a list of stuck projects (@pxref{Stuck projects}).
5709 @item <
5710 Restrict an agenda command to the current buffer@footnote{For backward
5711 compatibility, you can also press @kbd{1} to restrict to the current
5712 buffer.}.  After pressing @kbd{<}, you still need to press the character
5713 selecting the command.
5714 @item < <
5715 If there is an active region, restrict the following agenda command to
5716 the region.  Otherwise, restrict it to the current subtree@footnote{For
5717 backward compatibility, you can also press @kbd{0} to restrict to the
5718 current buffer.}.  After pressing @kbd{< <}, you still need to press the
5719 character selecting the command.
5720 @end table
5722 You can also define custom commands that will be accessible through the
5723 dispatcher, just like the default commands.  This includes the
5724 possibility to create extended agenda buffers that contain several
5725 blocks together, for example the weekly agenda, the global TODO list and
5726 a number of special tags matches.  @xref{Custom agenda views}.
5728 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda Views
5729 @section The built-in agenda views
5731 In this section we describe the built-in views.
5733 @menu
5734 * Weekly/daily agenda::         The calendar page with current tasks
5735 * Global TODO list::            All unfinished action items
5736 * Matching tags and properties::  Structured information with fine-tuned search
5737 * Timeline::                    Time-sorted view for single file
5738 * Keyword search::              Finding entries by keyword
5739 * Stuck projects::              Find projects you need to review
5740 @end menu
5742 @node Weekly/daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
5743 @subsection The weekly/daily agenda
5744 @cindex agenda
5745 @cindex weekly agenda
5746 @cindex daily agenda
5748 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
5749 paper agenda, showing all the tasks for the current week or day.
5751 @table @kbd
5752 @cindex org-agenda, command
5753 @kindex C-c a a
5754 @item C-c a a
5755 Compile an agenda for the current week from a list of org files.  The agenda
5756 shows the entries for each day.  With a numeric prefix@footnote{For backward
5757 compatibility, the universal prefix @kbd{C-u} causes all TODO entries to be
5758 listed before the agenda.  This feature is deprecated, use the dedicated TODO
5759 list, or a block agenda instead (@pxref{Block agenda}).}  (like @kbd{C-u 2 1
5760 C-c a a}) you may set the number of days to be displayed (see also the
5761 variable @code{org-agenda-ndays})
5762 @end table
5764 Remote editing from the agenda buffer means, for example, that you can
5765 change the dates of deadlines and appointments from the agenda buffer.
5766 The commands available in the Agenda buffer are listed in @ref{Agenda
5767 commands}.
5769 @subsubheading Calendar/Diary integration
5770 @cindex calendar integration
5771 @cindex diary integration
5773 Emacs contains the calendar and diary by Edward M. Reingold.  The
5774 calendar displays a three-month calendar with holidays from different
5775 countries and cultures.  The diary allows you to keep track of
5776 anniversaries, lunar phases, sunrise/set, recurrent appointments
5777 (weekly, monthly) and more.  In this way, it is quite complementary to
5778 Org.  It can be very useful to combine output from Org with
5779 the diary.
5781 In order to include entries from the Emacs diary into Org mode's
5782 agenda, you only need to customize the variable
5784 @lisp
5785 (setq org-agenda-include-diary t)
5786 @end lisp
5788 @noindent After that, everything will happen automatically.  All diary
5789 entries including holidays, anniversaries etc will be included in the
5790 agenda buffer created by Org mode.  @key{SPC}, @key{TAB}, and
5791 @key{RET} can be used from the agenda buffer to jump to the diary
5792 file in order to edit existing diary entries.  The @kbd{i} command to
5793 insert new entries for the current date works in the agenda buffer, as
5794 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
5795 Sunrise/Sunset times, show lunar phases and to convert to other
5796 calendars, respectively.  @kbd{c} can be used to switch back and forth
5797 between calendar and agenda.
5799 If you are using the diary only for sexp entries and holidays, it is
5800 faster to not use the above setting, but instead to copy or even move
5801 the entries into an Org file. Org mode evaluates diary-style sexp
5802 entries, and does it faster because there is no overhead for first
5803 creating the diary display.  Note that the sexp entries must start at
5804 the left margin, no white space is allowed before them.  For example,
5805 the following segment of an Org file will be processed and entries
5806 will be made in the agenda:
5808 @example
5809 * Birthdays and similar stuff
5810 #+CATEGORY: Holiday
5811 %%(org-calendar-holiday)   ; special function for holiday names
5812 #+CATEGORY: Ann
5813 %%(diary-anniversary 14  5 1956) Arthur Dent is %d years old
5814 %%(diary-anniversary  2 10 1869) Mahatma Gandhi would be %d years old
5815 @end example
5817 @subsubheading Appointment reminders
5818 @cindex @file{appt.el}
5819 @cindex appointment reminders
5821 Org can interact with Emacs appointments notification facility.
5823 To add all the appointments of your agenda files, use the command
5824 @code{org-agenda-to-appt}.  This commands also lets you filter through
5825 the list of your appointments and add only those belonging to a specific
5826 category or matching a regular expression. See the docstring for
5827 details.
5829 @node Global TODO list, Matching tags and properties, Weekly/daily agenda, Built-in agenda views
5830 @subsection The global TODO list
5831 @cindex global TODO list
5832 @cindex TODO list, global
5834 The global TODO list contains all unfinished TODO items, formatted and
5835 collected into a single place.
5837 @table @kbd
5838 @kindex C-c a t
5839 @item C-c a t
5840 Show the global TODO list.  This collects the TODO items from all
5841 agenda files (@pxref{Agenda Views}) into a single buffer.  The buffer is in
5842 @code{agenda-mode}, so there are commands to examine and manipulate
5843 the TODO entries directly from that buffer (@pxref{Agenda commands}).
5844 @kindex C-c a T
5845 @item C-c a T
5846 @cindex TODO keyword matching
5847 Like the above, but allows selection of a specific TODO keyword.  You
5848 can also do this by specifying a prefix argument to @kbd{C-c a t}.  With
5849 a @kbd{C-u} prefix you are prompted for a keyword, and you may also
5850 specify several keywords by separating them with @samp{|} as boolean OR
5851 operator.  With a numeric prefix, the Nth keyword in
5852 @code{org-todo-keywords} is selected.
5853 @kindex r
5854 The @kbd{r} key in the agenda buffer regenerates it, and you can give
5855 a prefix argument to this command to change the selected TODO keyword,
5856 for example @kbd{3 r}.  If you often need a search for a specific
5857 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
5858 Matching specific TODO keywords can also be done as part of a tags
5859 search (@pxref{Tag searches}).
5860 @end table
5862 Remote editing of TODO items means that you can change the state of a
5863 TODO entry with a single key press.  The commands available in the
5864 TODO list are described in @ref{Agenda commands}.
5866 @cindex sublevels, inclusion into TODO list
5867 Normally the global TODO list simply shows all headlines with TODO
5868 keywords.  This list can become very long.  There are two ways to keep
5869 it more compact:
5870 @itemize @minus
5871 @item
5872 Some people view a TODO item that has been @emph{scheduled} for
5873 execution (@pxref{Timestamps}) as no longer @emph{open}.  Configure the
5874 variable @code{org-agenda-todo-ignore-scheduled} to exclude scheduled
5875 items from the global TODO list.
5876 @item
5877 TODO items may have sublevels to break up the task into subtasks.  In
5878 such cases it may be enough to list only the highest level TODO headline
5879 and omit the sublevels from the global list.  Configure the variable
5880 @code{org-agenda-todo-list-sublevels} to get this behavior.
5881 @end itemize
5883 @node Matching tags and properties, Timeline, Global TODO list, Built-in agenda views
5884 @subsection Matching tags and properties
5885 @cindex matching, of tags
5886 @cindex matching, of properties
5887 @cindex tags view
5888 @cindex match view
5890 If headlines in the agenda files are marked with @emph{tags}
5891 (@pxref{Tags}), you can select headlines based on the tags that apply
5892 to them and collect them into an agenda buffer.
5894 @table @kbd
5895 @kindex C-c a m
5896 @item C-c a m
5897 Produce a list of all headlines that match a given set of tags.  The
5898 command prompts for a selection criterion, which is a boolean logic
5899 expression with tags, like @samp{+work+urgent-withboss} or
5900 @samp{work|home} (@pxref{Tags}).  If you often need a specific search,
5901 define a custom command for it (@pxref{Agenda dispatcher}).
5902 @kindex C-c a M
5903 @item C-c a M
5904 Like @kbd{C-c a m}, but only select headlines that are also TODO items
5905 and force checking subitems (see variable
5906 @code{org-tags-match-list-sublevels}).  Matching specific TODO keywords
5907 together with a tags match is also possible, see @ref{Tag searches}.
5908 @end table
5910 The commands available in the tags list are described in @ref{Agenda
5911 commands}.
5913 @node Timeline, Keyword search, Matching tags and properties, Built-in agenda views
5914 @subsection Timeline for a single file
5915 @cindex timeline, single file
5916 @cindex time-sorted view
5918 The timeline summarizes all time-stamped items from a single Org mode
5919 file in a @emph{time-sorted view}.  The main purpose of this command is
5920 to give an overview over events in a project.
5922 @table @kbd
5923 @kindex C-c a L
5924 @item C-c a L
5925 Show a time-sorted view of the org file, with all time-stamped items.
5926 When called with a @kbd{C-u} prefix, all unfinished TODO entries
5927 (scheduled or not) are also listed under the current date.
5928 @end table
5930 @noindent
5931 The commands available in the timeline buffer are listed in
5932 @ref{Agenda commands}.
5934 @node Keyword search, Stuck projects, Timeline, Built-in agenda views
5935 @subsection Keyword search
5936 @cindex keyword search
5937 @cindex searching, for keywords
5939 This agenda view is a general text search facility for Org mode entries.
5940 It is particularly useful to find notes.
5942 @table @kbd
5943 @kindex C-c a s
5944 @item C-c a s
5945 This is a special search that lets you select entries by keywords or
5946 regular expression, using a boolean logic.  For example, the search
5947 string
5949 @example
5950 +computer +wifi -ethernet -@{8\.11[bg]@}
5951 @end example
5953 @noindent
5954 will search for note entries that contain the keywords @code{computer}
5955 and @code{wifi}, but not the keyword @code{ethernet}, and which are also
5956 not matched by the regular expression @code{8\.11[bg]}, meaning to
5957 exclude both 8.11b and 8.11g.
5959 Note that in addition to the agenda files, this command will also search
5960 the files listed in @code{org-agenda-text-search-extra-files}.
5961 @end table
5963 @node Stuck projects,  , Keyword search, Built-in agenda views
5964 @subsection Stuck projects
5966 If you are following a system like David Allen's GTD to organize your
5967 work, one of the ``duties'' you have is a regular review to make sure
5968 that all projects move along.  A @emph{stuck} project is a project that
5969 has no defined next actions, so it will never show up in the TODO lists
5970 Org mode produces.  During the review, you need to identify such
5971 projects and define next actions for them.
5973 @table @kbd
5974 @kindex C-c a #
5975 @item C-c a #
5976 List projects that are stuck.
5977 @kindex C-c a !
5978 @item C-c a !
5979 Customize the variable @code{org-stuck-projects} to define what a stuck
5980 project is and how to find it.
5981 @end table
5983 You almost certainly will have to configure this view before it will
5984 work for you.  The built-in default assumes that all your projects are
5985 level-2 headlines, and that a project is not stuck if it has at least
5986 one entry marked with a TODO keyword TODO or NEXT or NEXTACTION.
5988 Let's assume that you, in your own way of using Org mode, identify
5989 projects with a tag PROJECT, and that you use a TODO keyword MAYBE to
5990 indicate a project that should not be considered yet.  Let's further
5991 assume that the TODO keyword DONE marks finished projects, and that NEXT
5992 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
5993 is a next action even without the NEXT tag.  Finally, if the project
5994 contains the special word IGNORE anywhere, it should not be listed
5995 either.  In this case you would start by identifying eligible projects
5996 with a tags/todo match @samp{+PROJECT/-MAYBE-DONE}, and then check for
5997 TODO, NEXT, @@SHOP, and IGNORE in the subtree to identify projects that
5998 are not stuck.  The correct customization for this is
6000 @lisp
6001 (setq org-stuck-projects
6002       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
6003                                "\\<IGNORE\\>"))
6004 @end lisp
6007 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda Views
6008 @section Presentation and sorting
6009 @cindex presentation, of agenda items
6011 Before displaying items in an agenda view, Org mode visually prepares
6012 the items and sorts them.  Each item occupies a single line.  The line
6013 starts with a @emph{prefix} that contains the @emph{category}
6014 (@pxref{Categories}) of the item and other important information.  You can
6015 customize the prefix using the option @code{org-agenda-prefix-format}.
6016 The prefix is followed by a cleaned-up version of the outline headline
6017 associated with the item.
6019 @menu
6020 * Categories::                  Not all tasks are equal
6021 * Time-of-day specifications::  How the agenda knows the time
6022 * Sorting of agenda items::     The order of things
6023 @end menu
6025 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
6026 @subsection Categories
6028 @cindex category
6029 The category is a broad label assigned to each agenda item.  By default,
6030 the category is simply derived from the file name, but you can also
6031 specify it with a special line in the buffer, like this@footnote{For
6032 backward compatibility, the following also works: If there are several
6033 such lines in a file, each specifies the category for the text below it.
6034 The first category also applies to any text before the first CATEGORY
6035 line.  However, using this method is @emph{strongly} deprecated as it is
6036 incompatible with the outline structure of the document.  The correct
6037 method for setting multiple categories in a buffer is using a
6038 property.}:
6040 @example
6041 #+CATEGORY: Thesis
6042 @end example
6044 @noindent
6045 If you would like to have a special CATEGORY for a single entry or a
6046 (sub)tree, give the entry a @code{:CATEGORY:} property with the
6047 special category you want to apply as the value.
6049 @noindent
6050 The display in the agenda buffer looks best if the category is not
6051 longer than 10 characters.
6053 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
6054 @subsection Time-of-day specifications
6055 @cindex time-of-day specification
6057 Org mode checks each agenda item for a time-of-day specification.  The
6058 time can be part of the time stamp that triggered inclusion into the
6059 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
6060 ranges can be specified with two time stamps, like
6062 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
6064 In the headline of the entry itself, a time(range) may also appear as
6065 plain text (like @samp{12:45} or a @samp{8:30-1pm}).  If the agenda
6066 integrates the Emacs diary (@pxref{Weekly/daily agenda}), time
6067 specifications in diary entries are recognized as well.
6069 For agenda display, Org mode extracts the time and displays it in a
6070 standard 24 hour format as part of the prefix.  The example times in
6071 the previous paragraphs would end up in the agenda like this:
6073 @example
6074     8:30-13:00 Arthur Dent lies in front of the bulldozer
6075    12:45...... Ford Prefect arrives and takes Arthur to the pub
6076    19:00...... The Vogon reads his poem
6077    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
6078 @end example
6080 @cindex time grid
6081 If the agenda is in single-day mode, or for the display of today, the
6082 timed entries are embedded in a time grid, like
6084 @example
6085     8:00...... ------------------
6086     8:30-13:00 Arthur Dent lies in front of the bulldozer
6087    10:00...... ------------------
6088    12:00...... ------------------
6089    12:45...... Ford Prefect arrives and takes Arthur to the pub
6090    14:00...... ------------------
6091    16:00...... ------------------
6092    18:00...... ------------------
6093    19:00...... The Vogon reads his poem
6094    20:00...... ------------------
6095    20:30-22:15 Marvin escorts the Hitchhikers to the bridge
6096 @end example
6098 The time grid can be turned on and off with the variable
6099 @code{org-agenda-use-time-grid}, and can be configured with
6100 @code{org-agenda-time-grid}.
6102 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
6103 @subsection Sorting of agenda items
6104 @cindex sorting, of agenda items
6105 @cindex priorities, of agenda items
6106 Before being inserted into a view, the items are sorted.  How this is
6107 done depends on the type of view.
6108 @itemize @bullet
6109 @item
6110 For the daily/weekly agenda, the items for each day are sorted.  The
6111 default order is to first collect all items containing an explicit
6112 time-of-day specification.  These entries will be shown at the beginning
6113 of the list, as a @emph{schedule} for the day.  After that, items remain
6114 grouped in categories, in the sequence given by @code{org-agenda-files}.
6115 Within each category, items are sorted by priority (@pxref{Priorities}),
6116 which is composed of the base priority (2000 for priority @samp{A}, 1000
6117 for @samp{B}, and 0 for @samp{C}), plus additional increments for
6118 overdue scheduled or deadline items.
6119 @item
6120 For the TODO list, items remain in the order of categories, but within
6121 each category, sorting takes place according to priority
6122 (@pxref{Priorities}).
6123 @item
6124 For tags matches, items are not sorted at all, but just appear in the
6125 sequence in which they are found in the agenda files.
6126 @end itemize
6128 Sorting can be customized using the variable
6129 @code{org-agenda-sorting-strategy}, and may also include criteria based on
6130 the estimated effort of an entry (@pxref{Effort estimates}).
6132 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda Views
6133 @section Commands in the agenda buffer
6134 @cindex commands, in agenda buffer
6136 Entries in the agenda buffer are linked back to the org file or diary
6137 file where they originate.  You are not allowed to edit the agenda
6138 buffer itself, but commands are provided to show and jump to the
6139 original entry location, and to edit the org-files ``remotely'' from
6140 the agenda buffer.  In this way, all information is stored only once,
6141 removing the risk that your agenda and note files may diverge.
6143 Some commands can be executed with mouse clicks on agenda lines.  For
6144 the other commands, the cursor needs to be in the desired line.
6146 @table @kbd
6147 @tsubheading{Motion}
6148 @cindex motion commands in agenda
6149 @kindex n
6150 @item n
6151 Next line (same as @key{up} and @kbd{C-p}).
6152 @kindex p
6153 @item p
6154 Previous line (same as @key{down} and @kbd{C-n}).
6155 @tsubheading{View/Go to org file}
6156 @kindex mouse-3
6157 @kindex @key{SPC}
6158 @item mouse-3
6159 @itemx @key{SPC}
6160 Display the original location of the item in another window.
6161 With prefix arg, make sure that the entire entry is made visible in the
6162 outline, not only the heading.
6164 @kindex L
6165 @item L
6166 Display original location and recenter that window.
6168 @kindex mouse-2
6169 @kindex mouse-1
6170 @kindex @key{TAB}
6171 @item mouse-2
6172 @itemx mouse-1
6173 @itemx @key{TAB}
6174 Go to the original location of the item in another window.  Under Emacs
6175 22, @kbd{mouse-1} will also works for this.
6177 @kindex @key{RET}
6178 @itemx @key{RET}
6179 Go to the original location of the item and delete other windows.
6181 @kindex f
6182 @item f
6183 Toggle Follow mode.  In Follow mode, as you move the cursor through
6184 the agenda buffer, the other window always shows the corresponding
6185 location in the org file.  The initial setting for this mode in new
6186 agenda buffers can be set with the variable
6187 @code{org-agenda-start-with-follow-mode}.
6189 @kindex b
6190 @item b
6191 Display the entire subtree of the current item in an indirect buffer.  With a
6192 numeric prefix argument N, go up to level N and then take that tree.  If N is
6193 negative, go up that many levels.  With a @kbd{C-u} prefix, do not remove the
6194 previously used indirect buffer.
6196 @kindex l
6197 @item l
6198 Toggle Logbook mode.  In Logbook mode, entries that were marked DONE while
6199 logging was on (variable @code{org-log-done}) are shown in the agenda, as are
6200 entries that have been clocked on that day.  You can configure the entry
6201 types that should be included in log mode using the variable
6202 @code{org-agenda-log-mode-items}.  When called with a @kbd{C-u} prefix, show
6203 all possible logbook entries, including state changes.  When called with two
6204 prefix args @kbd{C-u C-u}, show only logging information, nothing else.
6206 @kindex v
6207 @item v
6208 Toggle Archives mode.  In archives mode, trees that are marked
6209 @code{ARCHIVED} are also scanned when producing the agenda.  When you call
6210 this command with a @kbd{C-u} prefix argument, even all archive files are
6211 included.  To exit archives mode, press @kbd{v} again.
6213 @kindex R
6214 @item R
6215 Toggle Clockreport mode.  In clockreport mode, the daily/weekly agenda will
6216 always show a table with the clocked times for the timespan and file scope
6217 covered by the current agenda view.  The initial setting for this mode in new
6218 agenda buffers can be set with the variable
6219 @code{org-agenda-start-with-clockreport-mode}.
6221 @tsubheading{Change display}
6222 @cindex display changing, in agenda
6223 @kindex o
6224 @item o
6225 Delete other windows.
6227 @kindex d
6228 @kindex w
6229 @kindex m
6230 @kindex y
6231 @item d w m y
6232 Switch to day/week/month/year view.  When switching to day or week view,
6233 this setting becomes the default for subsequent agenda commands.  Since
6234 month and year views are slow to create, they do not become the default.
6235 A numeric prefix argument may be used to jump directly to a specific day
6236 of the year, ISO week, month, or year, respectively.  For example,
6237 @kbd{32 d} jumps to February 1st, @kbd{9 w} to ISO week number 9.  When
6238 setting day, week, or month view, a year may be encoded in the prefix
6239 argument as well.  For example, @kbd{200712 w} will jump to week 12 in
6240 2007.  If such a year specification has only one or two digits, it will
6241 be mapped to the interval 1938-2037.
6243 @kindex D
6244 @item D
6245 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
6247 @kindex G
6248 @item G
6249 Toggle the time grid on and off.  See also the variables
6250 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
6252 @kindex r
6253 @item r
6254 Recreate the agenda buffer, for example to reflect the changes
6255 after modification of the time stamps of items with S-@key{left} and
6256 S-@key{right}.  When the buffer is the global TODO list, a prefix
6257 argument is interpreted to create a selective list for a specific TODO
6258 keyword.
6259 @kindex g
6260 @item g
6261 Same as @kbd{r}.
6263 @kindex s
6264 @kindex C-x C-s
6265 @item s
6266 @itemx C-x C-s
6267 Save all Org buffers in the current Emacs session.
6269 @kindex @key{right}
6270 @item @key{right}
6271 Display the following @code{org-agenda-ndays} days.  For example, if
6272 the display covers a week, switch to the following week.  With prefix
6273 arg, go forward that many times @code{org-agenda-ndays} days.
6275 @kindex @key{left}
6276 @item @key{left}
6277 Display the previous dates.
6279 @kindex .
6280 @item .
6281 Go to today.
6283 @kindex C-c C-x C-c
6284 @item C-c C-x C-c
6285 Invoke column view (@pxref{Column view}) in the agenda buffer.  The column
6286 view format is taken from the entry at point, or (if there is no entry at
6287 point), from the first entry in the agenda view.  So whatever the format for
6288 that entry would be in the original buffer (taken from a property, from a
6289 @code{#+COLUMNS} line, or from the default variable
6290 @code{org-columns-default-format}), will be used in the agenda.
6292 @tsubheading{Secondary filtering and query editing}
6293 @cindex filtering, by tag and effort, in agenda
6294 @cindex tag filtering, in agenda
6295 @cindex effort filtering, in agenda
6296 @cindex query editing, in agenda
6298 @kindex /
6299 @item /
6300 Filter the current agenda view with respect to a tag and/or effort estimates.
6301 The difference between this and a custom agenda commands is that filtering is
6302 very fast, so that you can switch quickly between different filters without
6303 having to recreate the agenda.
6305 You will be prompted for a tag selection letter.  Pressing @key{TAB} at that
6306 prompt will offer use completion to select a tag (including any tags that do
6307 not have a selection character).  The command then hides all entries that do
6308 not contain or inherit this tag.  When called with prefix arg, remove the
6309 entries that @emph{do} have the tag.  A second @kbd{/} at the prompt will
6310 turn off the filter and unhide any hidden entries.  If the first key you
6311 press is either @kbd{+} or @kbd{-}, the previous filter will be narrowed by
6312 requiring or forbidding the selected additional tag.  Instead of pressing
6313 @kbd{+} or @kbd{-} after @kbd{/}, you can also immediately use the @kbd{\}
6314 command.
6316 In order to filter for effort estimates, you should set-up allowed
6317 efforts globally, for example
6318 @lisp
6319 (setq org-global-properties
6320     '(("Effort_ALL". "0 0:10 0:30 1:00 2:00 3:00 4:00")))
6321 @end lisp
6322 You can then filter for an effort by first typing an operator, one of @kbd{<},
6323 @kbd{>}, and @kbd{=}, and then the one-digit index of an effort estimate in
6324 your array of allowed values, where @kbd{0} means the 10th value.  The filter
6325 will then restrict to entries with effort smaller-or-equal, equal, or
6326 larger-or-equal than the selected value.  If the digits 0-9 are not used as
6327 fast access keys to tags, you can also simply press the index digit directly
6328 without an operator.  In this case, @kbd{<} will be assumed.
6330 @kindex \
6331 @item \
6332 Narrow the current agenda filter by an additional condition.  When called with
6333 prefix arg, remove the entries that @emph{do} have the tag, or that do match
6334 the effort criterion.  You can achieve the same effect by pressing @kbd{+} or
6335 @kbd{-} as the first key after the @kbd{/} command.
6337 @kindex [
6338 @kindex ]
6339 @kindex @{
6340 @kindex @}
6341 @item [ ] @{ @}
6342 In the @i{search view} (@pxref{Keyword search}), these keys add new search
6343 words (@kbd{[} and @kbd{]}) or new regular expressions (@kbd{@{} and
6344 @kbd{@}}) to the query string.  The opening bracket/brace will add a positive
6345 search term prefixed by @samp{+}, indicating that this search term @i{must}
6346 occur/match in the entry.  The closing bracket/brace will add a negative
6347 search term which @i{must not} occur/match in the entry for it to be
6348 selected.
6351 @tsubheading{Remote editing}
6352 @cindex remote editing, from agenda
6354 @item 0-9
6355 Digit argument.
6357 @cindex undoing remote-editing events
6358 @cindex remote editing, undo
6359 @kindex C-_
6360 @item C-_
6361 Undo a change due to a remote editing command.  The change is undone
6362 both in the agenda buffer and in the remote buffer.
6364 @kindex t
6365 @item t
6366 Change the TODO state of the item, both in the agenda and in the
6367 original org file.
6369 @kindex C-k
6370 @item C-k
6371 Delete the current agenda item along with the entire subtree belonging
6372 to it in the original Org file.  If the text to be deleted remotely
6373 is longer than one line, the kill needs to be confirmed by the user.  See
6374 variable @code{org-agenda-confirm-kill}.
6376 @kindex a
6377 @item a
6378 Toggle the ARCHIVE tag for the current headline.
6380 @kindex A
6381 @item A
6382 Move the subtree corresponding to the current entry to its @emph{Archive
6383 Sibling}.
6385 @kindex $
6386 @item $
6387 Archive the subtree corresponding to the current headline.  This means the
6388 entry will be moved to the configured archive location, most likely a
6389 different file.
6391 @kindex T
6392 @item T
6393 Show all tags associated with the current item.  This is useful if you have
6394 turned off @code{org-agenda-show-inherited-tags}, but still want to see all
6395 tags of a headline occasionally.
6397 @kindex :
6398 @item :
6399 Set tags for the current headline.  If there is an active region in the
6400 agenda, change a tag for all headings in the region.
6402 @kindex ,
6403 @item ,
6404 Set the priority for the current item.  Org mode prompts for the
6405 priority character. If you reply with @key{SPC}, the priority cookie
6406 is removed from the entry.
6408 @kindex P
6409 @item P
6410 Display weighted priority of current item.
6412 @kindex +
6413 @kindex S-@key{up}
6414 @item +
6415 @itemx S-@key{up}
6416 Increase the priority of the current item.  The priority is changed in
6417 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
6418 key for this.
6420 @kindex -
6421 @kindex S-@key{down}
6422 @item -
6423 @itemx S-@key{down}
6424 Decrease the priority of the current item.
6426 @kindex C-c C-a
6427 @item C-c C-a
6428 Dispatcher for all command related to attachments.
6430 @kindex C-c C-s
6431 @item C-c C-s
6432 Schedule this item
6434 @kindex C-c C-d
6435 @item C-c C-d
6436 Set a deadline for this item.
6438 @kindex k
6439 @item k
6440 Agenda actions, to set dates for selected items to the cursor date.
6441 This command also works in the calendar!  The command prompts for an
6442 additional key:
6443 @example
6444 m   @r{Mark the entry at point for action.  You can also make entries}
6445     @r{in Org files with @kbd{C-c C-x C-k}.}
6446 d   @r{Set the deadline of the marked entry to the date at point.}
6447 s   @r{Schedule the marked entry at the date at point.}
6448 r   @r{Call @code{org-remember} with the cursor date as default date.}
6449 @end example
6450 Press @kbd{r} afterward to refresh the agenda and see the effect of the
6451 command.
6453 @kindex S-@key{right}
6454 @item S-@key{right}
6455 Change the time stamp associated with the current line by one day into the
6456 future.  With a numeric prefix argument, change it by that many days.  For
6457 example, @kbd{3 6 5 S-@key{right}} will change it by a year.  The stamp is
6458 changed in the original org file, but the change is not directly reflected in
6459 the agenda buffer.  Use the @kbd{r} key to update the buffer.
6461 @kindex S-@key{left}
6462 @item S-@key{left}
6463 Change the time stamp associated with the current line by one day
6464 into the past.
6466 @kindex >
6467 @item >
6468 Change the time stamp associated with the current line to today.
6469 The key @kbd{>} has been chosen, because it is the same as @kbd{S-.}
6470 on my keyboard.
6472 @kindex I
6473 @item I
6474 Start the clock on the current item.  If a clock is running already, it
6475 is stopped first.
6477 @kindex O
6478 @item O
6479 Stop the previously started clock.
6481 @kindex X
6482 @item X
6483 Cancel the currently running clock.
6485 @kindex J
6486 @item J
6487 Jump to the running clock in another window.
6489 @tsubheading{Calendar commands}
6490 @cindex calendar commands, from agenda
6491 @kindex c
6492 @item c
6493 Open the Emacs calendar and move to the date at the agenda cursor.
6495 @item c
6496 When in the calendar, compute and show the Org mode agenda for the
6497 date at the cursor.
6499 @cindex diary entries, creating from agenda
6500 @kindex i
6501 @item i
6502 Insert a new entry into the diary.  Prompts for the type of entry
6503 (day, weekly, monthly, yearly, anniversary, cyclic) and creates a new
6504 entry in the diary, just as @kbd{i d} etc. would do in the calendar.
6505 The date is taken from the cursor position.
6507 @kindex M
6508 @item M
6509 Show the phases of the moon for the three months around current date.
6511 @kindex S
6512 @item S
6513 Show sunrise and sunset times.  The geographical location must be set
6514 with calendar variables, see documentation of the Emacs calendar.
6516 @kindex C
6517 @item C
6518 Convert the date at cursor into many other cultural and historic
6519 calendars.
6521 @kindex H
6522 @item H
6523 Show holidays for three month around the cursor date.
6525 @item M-x org-export-icalendar-combine-agenda-files
6526 Export a single iCalendar file containing entries from all agenda files.
6527 This is a globally available command, and also available in the agenda menu.
6529 @tsubheading{Exporting to a file}
6530 @kindex C-x C-w
6531 @item C-x C-w
6532 @cindex exporting agenda views
6533 @cindex agenda views, exporting
6534 Write the agenda view to a file.  Depending on the extension of the
6535 selected file name, the view will be exported as HTML (extension
6536 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}), or
6537 plain text (any other extension).  Use the variable
6538 @code{org-agenda-exporter-settings} to set options for @file{ps-print}
6539 and for @file{htmlize} to be used during export.
6541 @tsubheading{Quit and Exit}
6542 @kindex q
6543 @item q
6544 Quit agenda, remove the agenda buffer.
6546 @kindex x
6547 @cindex agenda files, removing buffers
6548 @item x
6549 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
6550 for the compilation of the agenda.  Buffers created by the user to
6551 visit org files will not be removed.
6552 @end table
6555 @node Custom agenda views, Agenda column view, Agenda commands, Agenda Views
6556 @section Custom agenda views
6557 @cindex custom agenda views
6558 @cindex agenda views, custom
6560 Custom agenda commands serve two purposes: to store and quickly access
6561 frequently used TODO and tags searches, and to create special composite
6562 agenda buffers.  Custom agenda commands will be accessible through the
6563 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
6565 @menu
6566 * Storing searches::            Type once, use often
6567 * Block agenda::                All the stuff you need in a single buffer
6568 * Setting Options::             Changing the rules
6569 * Exporting Agenda Views::      Writing agendas to files
6570 * Using the agenda elsewhere::  Using agenda information in other programs
6571 @end menu
6573 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
6574 @subsection Storing searches
6576 The first application of custom searches is the definition of keyboard
6577 shortcuts for frequently used searches, either creating an agenda
6578 buffer, or a sparse tree (the latter covering of course only the current
6579 buffer).
6580 @kindex C-c a C
6581 Custom commands are configured in the variable
6582 @code{org-agenda-custom-commands}.  You can customize this variable, for
6583 example by pressing @kbd{C-c a C}.  You can also directly set it with
6584 Emacs Lisp in @file{.emacs}.  The following example contains all valid
6585 search types:
6587 @lisp
6588 @group
6589 (setq org-agenda-custom-commands
6590       '(("w" todo "WAITING")
6591         ("W" todo-tree "WAITING")
6592         ("u" tags "+boss-urgent")
6593         ("v" tags-todo "+boss-urgent")
6594         ("U" tags-tree "+boss-urgent")
6595         ("f" occur-tree "\\<FIXME\\>")
6596         ("h" . "HOME+Name tags searches") ; description for "h" prefix
6597         ("hl" tags "+home+Lisa")
6598         ("hp" tags "+home+Peter")
6599         ("hk" tags "+home+Kim")))
6600 @end group
6601 @end lisp
6603 @noindent
6604 The initial string in each entry defines the keys you have to press
6605 after the dispatcher command @kbd{C-c a} in order to access the command.
6606 Usually this will be just a single character, but if you have many
6607 similar commands, you can also define two-letter combinations where the
6608 first character is the same in several combinations and serves as a
6609 prefix key@footnote{You can provide a description for a prefix key by
6610 inserting a cons cell with the prefix and the description.}.  The second
6611 parameter is the search type, followed by the string or regular
6612 expression to be used for the matching.  The example above will
6613 therefore define:
6615 @table @kbd
6616 @item C-c a w
6617 as a global search for TODO entries with @samp{WAITING} as the TODO
6618 keyword
6619 @item C-c a W
6620 as the same search, but only in the current buffer and displaying the
6621 results as a sparse tree
6622 @item C-c a u
6623 as a global tags search for headlines marked @samp{:boss:} but not
6624 @samp{:urgent:}
6625 @item C-c a v
6626 as the same search as @kbd{C-c a u}, but limiting the search to
6627 headlines that are also TODO items
6628 @item C-c a U
6629 as the same search as @kbd{C-c a u}, but only in the current buffer and
6630 displaying the result as a sparse tree
6631 @item C-c a f
6632 to create a sparse tree (again: current buffer only) with all entries
6633 containing the word @samp{FIXME}
6634 @item C-c a h
6635 as a prefix command for a HOME tags search where you have to press an
6636 additional key (@kbd{l}, @kbd{p} or @kbd{k}) to select a name (Lisa,
6637 Peter, or Kim) as additional tag to match.
6638 @end table
6640 @node Block agenda, Setting Options, Storing searches, Custom agenda views
6641 @subsection Block agenda
6642 @cindex block agenda
6643 @cindex agenda, with block views
6645 Another possibility is the construction of agenda views that comprise
6646 the results of @emph{several} commands, each of which creates a block in
6647 the agenda buffer.  The available commands include @code{agenda} for the
6648 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
6649 for the global TODO list (as constructed with @kbd{C-c a t}), and the
6650 matching commands discussed above: @code{todo}, @code{tags}, and
6651 @code{tags-todo}.  Here are two examples:
6653 @lisp
6654 @group
6655 (setq org-agenda-custom-commands
6656       '(("h" "Agenda and Home-related tasks"
6657          ((agenda "")
6658           (tags-todo "home")
6659           (tags "garden")))
6660         ("o" "Agenda and Office-related tasks"
6661          ((agenda "")
6662           (tags-todo "work")
6663           (tags "office")))))
6664 @end group
6665 @end lisp
6667 @noindent
6668 This will define @kbd{C-c a h} to create a multi-block view for stuff
6669 you need to attend to at home.  The resulting agenda buffer will contain
6670 your agenda for the current week, all TODO items that carry the tag
6671 @samp{home}, and also all lines tagged with @samp{garden}.  Finally the
6672 command @kbd{C-c a o} provides a similar view for office tasks.
6674 @node Setting Options, Exporting Agenda Views, Block agenda, Custom agenda views
6675 @subsection Setting options for custom commands
6676 @cindex options, for custom agenda views
6678 Org mode contains a number of variables regulating agenda construction
6679 and display.  The global variables define the behavior for all agenda
6680 commands, including the custom commands.  However, if you want to change
6681 some settings just for a single custom view, you can do so.  Setting
6682 options requires inserting a list of variable names and values at the
6683 right spot in @code{org-agenda-custom-commands}.  For example:
6685 @lisp
6686 @group
6687 (setq org-agenda-custom-commands
6688       '(("w" todo "WAITING"
6689          ((org-agenda-sorting-strategy '(priority-down))
6690           (org-agenda-prefix-format "  Mixed: ")))
6691         ("U" tags-tree "+boss-urgent"
6692          ((org-show-following-heading nil)
6693           (org-show-hierarchy-above nil)))
6694         ("N" search ""
6695          ((org-agenda-files '("~org/notes.org"))
6696           (org-agenda-text-search-extra-files nil)))))
6697 @end group
6698 @end lisp
6700 @noindent
6701 Now the @kbd{C-c a w} command will sort the collected entries only by
6702 priority, and the prefix format is modified to just say @samp{  Mixed: }
6703 instead of giving the category of the entry.  The sparse tags tree of
6704 @kbd{C-c a U} will now turn out ultra-compact, because neither the
6705 headline hierarchy above the match, nor the headline following the match
6706 will be shown.  The command @kbd{C-c a N} will do a text search limited
6707 to only a single file.
6709 For command sets creating a block agenda,
6710 @code{org-agenda-custom-commands} has two separate spots for setting
6711 options.  You can add options that should be valid for just a single
6712 command in the set, and options that should be valid for all commands in
6713 the set.  The former are just added to the command entry, the latter
6714 must come after the list of command entries.  Going back to the block
6715 agenda example (@pxref{Block agenda}), let's change the sorting strategy
6716 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
6717 the results for GARDEN tags query in the opposite order,
6718 @code{priority-up}.  This would look like this:
6720 @lisp
6721 @group
6722 (setq org-agenda-custom-commands
6723       '(("h" "Agenda and Home-related tasks"
6724          ((agenda)
6725           (tags-todo "home")
6726           (tags "garden"
6727                 ((org-agenda-sorting-strategy '(priority-up)))))
6728          ((org-agenda-sorting-strategy '(priority-down))))
6729         ("o" "Agenda and Office-related tasks"
6730          ((agenda)
6731           (tags-todo "work")
6732           (tags "office")))))
6733 @end group
6734 @end lisp
6736 As you see, the values and parenthesis setting is a little complex.
6737 When in doubt, use the customize interface to set this variable - it
6738 fully supports its structure.  Just one caveat: When setting options in
6739 this interface, the @emph{values} are just lisp expressions.  So if the
6740 value is a string, you need to add the double quotes around the value
6741 yourself.
6744 @node Exporting Agenda Views, Using the agenda elsewhere, Setting Options, Custom agenda views
6745 @subsection Exporting Agenda Views
6746 @cindex agenda views, exporting
6748 If you are away from your computer, it can be very useful to have a printed
6749 version of some agenda views to carry around.  Org mode can export custom
6750 agenda views as plain text, HTML@footnote{You need to install Hrvoje Niksic's
6751 @file{htmlize.el}.}, Postscript, and iCalendar files.  If you want to do this
6752 only occasionally, use the command
6754 @table @kbd
6755 @kindex C-x C-w
6756 @item C-x C-w
6757 @cindex exporting agenda views
6758 @cindex agenda views, exporting
6759 Write the agenda view to a file.  Depending on the extension of the
6760 selected file name, the view will be exported as HTML (extension
6761 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}),
6762 iCalendar (extension @file{.ics}), or plain text (any other extension).
6763 Use the variable @code{org-agenda-exporter-settings} to
6764 set options for @file{ps-print} and for @file{htmlize} to be used during
6765 export, for example
6767 @lisp
6768 (setq org-agenda-exporter-settings
6769       '((ps-number-of-columns 2)
6770         (ps-landscape-mode t)
6771         (htmlize-output-type 'css)))
6772 @end lisp
6773 @end table
6775 If you need to export certain agenda views frequently, you can associate
6776 any custom agenda command with a list of output file names
6777 @footnote{If you want to store standard views like the weekly agenda
6778 or the global TODO list as well, you need to define custom commands for
6779 them in order to be able to specify file names.}.  Here is an example
6780 that first does define custom commands for the agenda and the global
6781 todo list, together with a number of files to which to export them.
6782 Then we define two block agenda commands and specify file names for them
6783 as well.  File names can be relative to the current working directory,
6784 or absolute.
6786 @lisp
6787 @group
6788 (setq org-agenda-custom-commands
6789       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
6790         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
6791         ("h" "Agenda and Home-related tasks"
6792          ((agenda "")
6793           (tags-todo "home")
6794           (tags "garden"))
6795          nil
6796          ("~/views/home.html"))
6797         ("o" "Agenda and Office-related tasks"
6798          ((agenda)
6799           (tags-todo "work")
6800           (tags "office"))
6801          nil
6802          ("~/views/office.ps" "~/calendars/office.ics"))))
6803 @end group
6804 @end lisp
6806 The extension of the file name determines the type of export.  If it is
6807 @file{.html}, Org mode will use the @file{htmlize.el} package to convert
6808 the buffer to HTML and save it to this file name.  If the extension is
6809 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
6810 postscript output.  If the extension is @file{.ics}, iCalendar export is
6811 run export over all files that were used to construct the agenda, and
6812 limit the export to entries listed in the agenda now.  Any other
6813 extension produces a plain ASCII file.
6815 The export files are @emph{not} created when you use one of those
6816 commands interactively because this might use too much overhead.
6817 Instead, there is a special command to produce @emph{all} specified
6818 files in one step:
6820 @table @kbd
6821 @kindex C-c a e
6822 @item C-c a e
6823 Export all agenda views that have export file names associated with
6824 them.
6825 @end table
6827 You can use the options section of the custom agenda commands to also
6828 set options for the export commands.  For example:
6830 @lisp
6831 (setq org-agenda-custom-commands
6832       '(("X" agenda ""
6833          ((ps-number-of-columns 2)
6834           (ps-landscape-mode t)
6835           (org-agenda-prefix-format " [ ] ")
6836           (org-agenda-with-colors nil)
6837           (org-agenda-remove-tags t))
6838          ("theagenda.ps"))))
6839 @end lisp
6841 @noindent
6842 This command sets two options for the postscript exporter, to make it
6843 print in two columns in landscape format - the resulting page can be cut
6844 in two and then used in a paper agenda.  The remaining settings modify
6845 the agenda prefix to omit category and scheduling information, and
6846 instead include a checkbox to check off items.  We also remove the tags
6847 to make the lines compact, and we don't want to use colors for the
6848 black-and-white printer.  Settings specified in
6849 @code{org-agenda-exporter-settings} will also apply, but the settings
6850 in @code{org-agenda-custom-commands} take precedence.
6852 @noindent
6853 From the command line you may also use
6854 @example
6855 emacs -f org-batch-store-agenda-views -kill
6856 @end example
6857 @noindent
6858 or, if you need to modify some parameters@footnote{Quoting may depend on the
6859 system you use, please check th FAQ for examples.}
6860 @example
6861 emacs -eval '(org-batch-store-agenda-views                      \
6862               org-agenda-ndays 30                               \
6863               org-agenda-start-day "2007-11-01"                 \
6864               org-agenda-include-diary nil                      \
6865               org-agenda-files (quote ("~/org/project.org")))'  \
6866       -kill
6867 @end example
6868 @noindent
6869 which will create the agenda views restricted to the file
6870 @file{~/org/project.org}, without diary entries and with 30 days
6871 extent.
6873 @node Using the agenda elsewhere,  , Exporting Agenda Views, Custom agenda views
6874 @subsection Using agenda information outside of Org
6875 @cindex agenda, pipe
6876 @cindex Scripts, for agenda processing
6878 Org provides commands to access agenda information for the command
6879 line in emacs batch mode.  This extracted information can be sent
6880 directly to a printer, or it can be read by a program that does further
6881 processing of the data.  The first of these commands is the function
6882 @code{org-batch-agenda}, that produces an agenda view and sends it as
6883 ASCII text to STDOUT.  The command takes a single string as parameter.
6884 If the string has length 1, it is used as a key to one of the commands
6885 you have configured in @code{org-agenda-custom-commands}, basically any
6886 key you can use after @kbd{C-c a}.  For example, to directly print the
6887 current TODO list, you could use
6889 @example
6890 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
6891 @end example
6893 If the parameter is a string with 2 or more characters, it is used as a
6894 tags/todo match string.  For example, to print your local shopping list
6895 (all items with the tag @samp{shop}, but excluding the tag
6896 @samp{NewYork}), you could use
6898 @example
6899 emacs -batch -l ~/.emacs                                      \
6900       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
6901 @end example
6903 @noindent
6904 You may also modify parameters on the fly like this:
6906 @example
6907 emacs -batch -l ~/.emacs                                      \
6908    -eval '(org-batch-agenda "a"                               \
6909             org-agenda-ndays 30                               \
6910             org-agenda-include-diary nil                      \
6911             org-agenda-files (quote ("~/org/project.org")))'  \
6912    | lpr
6913 @end example
6915 @noindent
6916 which will produce a 30 day agenda, fully restricted to the Org file
6917 @file{~/org/projects.org}, not even including the diary.
6919 If you want to process the agenda data in more sophisticated ways, you
6920 can use the command @code{org-batch-agenda-csv} to get a comma-separated
6921 list of values for each agenda item.  Each line in the output will
6922 contain a number of fields separated by commas.  The fields in a line
6923 are:
6925 @example
6926 category     @r{The category of the item}
6927 head         @r{The headline, without TODO kwd, TAGS and PRIORITY}
6928 type         @r{The type of the agenda entry, can be}
6929                 todo               @r{selected in TODO match}
6930                 tagsmatch          @r{selected in tags match}
6931                 diary              @r{imported from diary}
6932                 deadline           @r{a deadline}
6933                 scheduled          @r{scheduled}
6934                 timestamp          @r{appointment, selected by timestamp}
6935                 closed             @r{entry was closed on date}
6936                 upcoming-deadline  @r{warning about nearing deadline}
6937                 past-scheduled     @r{forwarded scheduled item}
6938                 block              @r{entry has date block including date}
6939 todo         @r{The TODO keyword, if any}
6940 tags         @r{All tags including inherited ones, separated by colons}
6941 date         @r{The relevant date, like 2007-2-14}
6942 time         @r{The time, like 15:00-16:50}
6943 extra        @r{String with extra planning info}
6944 priority-l   @r{The priority letter if any was given}
6945 priority-n   @r{The computed numerical priority}
6946 @end example
6948 @noindent
6949 Time and date will only be given if a timestamp (or deadline/scheduled)
6950 lead to the selection of the item.
6952 A CSV list like this is very easy to use in a post processing script.
6953 For example, here is a Perl program that gets the TODO list from
6954 Emacs/Org and prints all the items, preceded by a checkbox:
6956 @example
6957 @group
6958 #!/usr/bin/perl
6960 # define the Emacs command to run
6961 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
6963 # run it and capture the output
6964 $agenda = qx@{$cmd 2>/dev/null@};
6966 # loop over all lines
6967 foreach $line (split(/\n/,$agenda)) @{
6969   # get the individual values
6970   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
6971    $priority_l,$priority_n) = split(/,/,$line);
6973   # process and print
6974   print "[ ] $head\n";
6976 @end group
6977 @end example
6979 @node Agenda column view,  , Custom agenda views, Agenda Views
6980 @section Using column view in the agenda
6981 @cindex column view, in agenda
6982 @cindex agenda, column view
6984 Column view (@pxref{Column view}) is normally used to view and edit
6985 properties embedded in the hierarchical structure of an Org file.  It can be
6986 quite useful to use column view also from the agenda, where entries are
6987 collected by certain criteria.
6989 @table @kbd
6990 @kindex C-c C-x C-c
6991 @item C-c C-x C-c
6992 Turn on column view in the agenda.
6993 @end table
6995 To understand how to use this properly, it is important to realize that the
6996 entries in the agenda are no longer in their proper outline environment.
6997 This causes the following issues:
6999 @enumerate
7000 @item
7001 Org needs to make a decision which @code{COLUMNS} format to use.  Since the
7002 entries in the agenda are collected from different files, and different files
7003 may have different @code{COLUMNS} formats, this is a non-trivial problem.
7004 Org first checks if the variable @code{org-overriding-columns-format} is
7005 currently set, and if yes takes the format from there.  Otherwise it takes
7006 the format associated with the first item in the agenda, or, if that item
7007 does not have a specific format (defined in a property, or in it's file), it
7008 uses @code{org-columns-default-format}.
7009 @item
7010 If any of the columns has a summary type defined (@pxref{Column attributes}),
7011 turning on column view in the agenda will visit all relevant agenda files and
7012 make sure that the computations of this property are up to date.  This is
7013 also true for the special @code{CLOCKSUM} property.  Org will then sum the
7014 values displayed in the agenda.  In the daily/weekly agenda, the sums will
7015 cover a single day, in all other views they cover the entire block.  It is
7016 vital to realize that the agenda may show the same entry @emph{twice} (for
7017 example as scheduled and as a deadline), and it may show two entries from the
7018 same hierarchy (for example a @emph{parent} and it's @emph{child}).  In these
7019 cases, the summation in the agenda will lead to incorrect results because
7020 some values will count double.
7021 @item
7022 When the column view in the agenda shows the @code{CLOCKSUM}, that is always
7023 the entire clocked time for this item.  So even in the daily/weekly agenda,
7024 the clocksum listed in column view may originate from times outside the
7025 current view.  This has the advantage that you can compare these values with
7026 a column listing the planned total effort for a task - one of the major
7027 applications for column view in the agenda.  If you want information about
7028 clocked time in the displayed period use clock table mode (press @kbd{R} in
7029 the agenda).
7030 @end enumerate
7033 @node Embedded LaTeX, Exporting, Agenda Views, Top
7034 @chapter Embedded LaTeX
7035 @cindex @TeX{} interpretation
7036 @cindex La@TeX{} interpretation
7038 Plain ASCII is normally sufficient for almost all note taking.  One
7039 exception, however, are scientific notes which need to be able to contain
7040 mathematical symbols and the occasional formula.  La@TeX{}@footnote{La@TeX{}
7041 is a macro system based on Donald E. Knuth's @TeX{} system.  Many of the
7042 features described here as ``La@TeX{}'' are really from @TeX{}, but for
7043 simplicity I am blurring this distinction.}  is widely used to typeset
7044 scientific documents. Org mode supports embedding La@TeX{} code into its
7045 files, because many academics are used to reading La@TeX{} source code, and
7046 because it can be readily processed into images for HTML production.
7048 It is not necessary to mark La@TeX{} macros and code in any special way.
7049 If you observe a few conventions, Org mode knows how to find it and what
7050 to do with it.
7052 @menu
7053 * Math symbols::                TeX macros for symbols and Greek letters
7054 * Subscripts and superscripts::  Simple syntax for raising/lowering text
7055 * LaTeX fragments::             Complex formulas made easy
7056 * Processing LaTeX fragments::  Previewing LaTeX processing
7057 * CDLaTeX mode::                Speed up entering of formulas
7058 @end menu
7060 @node Math symbols, Subscripts and superscripts, Embedded LaTeX, Embedded LaTeX
7061 @section Math symbols
7062 @cindex math symbols
7063 @cindex TeX macros
7065 You can use La@TeX{} macros to insert special symbols like @samp{\alpha} to
7066 indicate the Greek letter, or @samp{\to} to indicate an arrow.  Completion
7067 for these macros is available, just type @samp{\} and maybe a few letters,
7068 and press @kbd{M-@key{TAB}} to see possible completions.  Unlike La@TeX{}
7069 code, Org mode allows these macros to be present without surrounding math
7070 delimiters, for example:
7072 @example
7073 Angles are written as Greek letters \alpha, \beta and \gamma.
7074 @end example
7076 During HTML export (@pxref{HTML export}), these symbols are translated
7077 into the proper syntax for HTML, for the above examples this is
7078 @samp{&alpha;} and @samp{&rarr;}, respectively.  If you need such a symbol
7079 inside a word, terminate it like this: @samp{\Aacute@{@}stor}.
7081 @node Subscripts and superscripts, LaTeX fragments, Math symbols, Embedded LaTeX
7082 @section Subscripts and superscripts
7083 @cindex subscript
7084 @cindex superscript
7086 Just like in La@TeX{}, @samp{^} and @samp{_} are used to indicate super-
7087 and subscripts.  Again, these can be used without embedding them in
7088 math-mode delimiters.  To increase the readability of ASCII text, it is
7089 not necessary (but OK) to surround multi-character sub- and superscripts
7090 with curly braces.  For example
7092 @example
7093 The mass if the sun is M_sun = 1.989 x 10^30 kg.  The radius of
7094 the sun is R_@{sun@} = 6.96 x 10^8 m.
7095 @end example
7097 To avoid interpretation as raised or lowered text, you can quote
7098 @samp{^} and @samp{_} with a backslash: @samp{\_} and @samp{\^}.
7100 During HTML export (@pxref{HTML export}), subscript and superscripts
7101 are surrounded with @code{<sub>} and @code{<sup>} tags, respectively.
7103 @node LaTeX fragments, Processing LaTeX fragments, Subscripts and superscripts, Embedded LaTeX
7104 @section LaTeX fragments
7105 @cindex LaTeX fragments
7107 With symbols, sub- and superscripts, HTML is pretty much at its end when
7108 it comes to representing mathematical formulas@footnote{Yes, there is
7109 MathML, but that is not yet fully supported by many browsers, and there
7110 is no decent converter for turning La@TeX{} or ASCII representations of
7111 formulas into MathML. So for the time being, converting formulas into
7112 images seems the way to go.}. More complex expressions need a dedicated
7113 formula processor. To this end, Org mode can contain arbitrary La@TeX{}
7114 fragments. It provides commands to preview the typeset result of these
7115 fragments, and upon export to HTML, all fragments will be converted to
7116 images and inlined into the HTML document@footnote{The La@TeX{} export
7117 will not use images for displaying La@TeX{} fragments but include these
7118 fragments directly into the La@TeX{} code.}. For this to work you
7119 need to be on a system with a working La@TeX{} installation. You also
7120 need the @file{dvipng} program, available at
7121 @url{http://sourceforge.net/projects/dvipng/}. The La@TeX{} header that
7122 will be used when processing a fragment can be configured with the
7123 variable @code{org-format-latex-header}.
7125 La@TeX{} fragments don't need any special marking at all.  The following
7126 snippets will be identified as La@TeX{} source code:
7127 @itemize @bullet
7128 @item
7129 Environments of any kind.  The only requirement is that the
7130 @code{\begin} statement appears on a new line, preceded by only
7131 whitespace.
7132 @item
7133 Text within the usual La@TeX{} math delimiters.  To avoid conflicts with
7134 currency specifications, single @samp{$} characters are only recognized as
7135 math delimiters if the enclosed text contains at most two line breaks, is
7136 directly attached to the @samp{$} characters with no whitespace in between,
7137 and if the closing @samp{$} is followed by whitespace, punctuation or a dash.
7138 For the other delimiters, there is no such restriction, so when in doubt, use
7139 @samp{\(...\)} as inline math delimiters.
7140 @end itemize
7142 @noindent For example:
7144 @example
7145 \begin@{equation@}                          % arbitrary environments,
7146 x=\sqrt@{b@}                                % even tables, figures
7147 \end@{equation@}                            % etc
7149 If $a^2=b$ and \( b=2 \), then the solution must be
7150 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
7151 @end example
7153 @noindent
7154 If you need any of the delimiter ASCII sequences for other purposes, you
7155 can configure the option @code{org-format-latex-options} to deselect the
7156 ones you do not wish to have interpreted by the La@TeX{} converter.
7158 @node Processing LaTeX fragments, CDLaTeX mode, LaTeX fragments, Embedded LaTeX
7159 @section Processing LaTeX fragments
7160 @cindex LaTeX fragments, preview
7162 La@TeX{} fragments can be processed to produce a preview images of the
7163 typeset expressions:
7165 @table @kbd
7166 @kindex C-c C-x C-l
7167 @item C-c C-x C-l
7168 Produce a preview image of the La@TeX{} fragment at point and overlay it
7169 over the source code.  If there is no fragment at point, process all
7170 fragments in the current entry (between two headlines).  When called
7171 with a prefix argument, process the entire subtree.  When called with
7172 two prefix arguments, or when the cursor is before the first headline,
7173 process the entire buffer.
7174 @kindex C-c C-c
7175 @item C-c C-c
7176 Remove the overlay preview images.
7177 @end table
7179 During HTML export (@pxref{HTML export}), all La@TeX{} fragments are
7180 converted into images and inlined into the document if the following
7181 setting is active:
7183 @lisp
7184 (setq org-export-with-LaTeX-fragments t)
7185 @end lisp
7187 @node CDLaTeX mode,  , Processing LaTeX fragments, Embedded LaTeX
7188 @section Using CDLaTeX to enter math
7189 @cindex CDLaTeX
7191 CDLaTeX mode is a minor mode that is normally used in combination with a
7192 major La@TeX{} mode like AUCTeX in order to speed-up insertion of
7193 environments and math templates.  Inside Org mode, you can make use of
7194 some of the features of CDLaTeX mode.  You need to install
7195 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
7196 AUCTeX) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
7197 Don't use CDLaTeX mode itself under Org mode, but use the light
7198 version @code{org-cdlatex-mode} that comes as part of Org mode.  Turn it
7199 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
7200 Org files with
7202 @lisp
7203 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
7204 @end lisp
7206 When this mode is enabled, the following features are present (for more
7207 details see the documentation of CDLaTeX mode):
7208 @itemize @bullet
7209 @kindex C-c @{
7210 @item
7211 Environment templates can be inserted with @kbd{C-c @{}.
7212 @item
7213 @kindex @key{TAB}
7214 The @key{TAB} key will do template expansion if the cursor is inside a
7215 La@TeX{} fragment@footnote{Org mode has a method to test if the cursor is
7216 inside such a fragment, see the documentation of the function
7217 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
7218 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
7219 correctly inside the first brace.  Another @key{TAB} will get you into
7220 the second brace.  Even outside fragments, @key{TAB} will expand
7221 environment abbreviations at the beginning of a line.  For example, if
7222 you write @samp{equ} at the beginning of a line and press @key{TAB},
7223 this abbreviation will be expanded to an @code{equation} environment.
7224 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
7225 @item
7226 @kindex _
7227 @kindex ^
7228 Pressing @kbd{_} and @kbd{^} inside a La@TeX{} fragment will insert these
7229 characters together with a pair of braces.  If you use @key{TAB} to move
7230 out of the braces, and if the braces surround only a single character or
7231 macro, they are removed again (depending on the variable
7232 @code{cdlatex-simplify-sub-super-scripts}).
7233 @item
7234 @kindex `
7235 Pressing the backquote @kbd{`} followed by a character inserts math
7236 macros, also outside La@TeX{} fragments.  If you wait more than 1.5 seconds
7237 after the backquote, a help window will pop up.
7238 @item
7239 @kindex '
7240 Pressing the normal quote @kbd{'} followed by another character modifies
7241 the symbol before point with an accent or a font.  If you wait more than
7242 1.5 seconds after the backquote, a help window will pop up.  Character
7243 modification will work only inside La@TeX{} fragments, outside the quote
7244 is normal.
7245 @end itemize
7247 @node Exporting, Publishing, Embedded LaTeX, Top
7248 @chapter Exporting
7249 @cindex exporting
7251 Org mode documents can be exported into a variety of other formats.  For
7252 printing and sharing of notes, ASCII export produces a readable and
7253 simple version of an Org file.  HTML export allows you to publish a
7254 notes file on the web, while the XOXO format provides a solid base for
7255 exchange with a broad range of other applications. La@TeX{} export lets
7256 you use Org mode and its structured editing functions to easily create
7257 La@TeX{} files.  To incorporate entries with associated times like
7258 deadlines or appointments into a desktop calendar program like iCal,
7259 Org mode can also produce extracts in the iCalendar format.  Currently
7260 Org mode only supports export, not import of these different formats.
7262 Org supports export of selected regions when @code{transient-mark-mode} is
7263 enabled (default in Emacs 23).
7265 @menu
7266 * Markup rules::                Which structures are recognized?
7267 * Selective export::            Using tags to select and exclude trees
7268 * Export options::              Per-file export settings
7269 * The export dispatcher::       How to access exporter commands
7270 * ASCII export::                Exporting to plain ASCII
7271 * HTML export::                 Exporting to HTML
7272 * LaTeX and PDF export::        Exporting to LaTeX, and processing to PDF
7273 * XOXO export::                 Exporting to XOXO
7274 * iCalendar export::            Exporting in iCalendar format
7275 @end menu
7277 @node Markup rules, Selective export, Exporting, Exporting
7278 @section Markup rules
7280 When exporting Org mode documents,  the exporter tries to reflect the
7281 structure of the document as accurately as possible in the back-end.  Since
7282 export targets like HTML or La@TeX{} allow much richer formatting, Org mode
7283 has rules how to prepare text for rich export.  This section summarizes the
7284 markup rule used in an Org mode buffer.
7286 @menu
7287 * Document title::              How the document title is determined
7288 * Headings and sections::       The main structure of the exported document
7289 * Table of contents::           If, where, how to create a table of contents
7290 * Initial text::                Text before the first headline
7291 * Lists::                       Plain lists are exported
7292 * Paragraphs::                  What determines beginning and ending
7293 * Literal examples::            Source code and other examples
7294 * Include files::               Include the contents of a file during export
7295 * Tables exported::             Tables are exported richly
7296 * Inlined images::              How to inline images during export
7297 * Footnote markup::             
7298 * Emphasis and monospace::      To bold or not to bold
7299 * TeX macros and LaTeX fragments::  Create special, rich export.
7300 * Horizontal rules::            A line across the page
7301 * Comment lines::               Some lines will not be exported
7302 @end menu
7304 @node Document title, Headings and sections, Markup rules, Markup rules
7305 @subheading Document title
7306 @cindex document title, markup rules
7308 @noindent
7309 The title of the exported document is taken from the special line
7311 @example
7312 #+TITLE: This is the title of the document
7313 @end example
7315 @noindent
7316 If this line does not exist, the title is derived from the first non-empty,
7317 non-comment line in the buffer.  If no such line exists, or if you have
7318 turned off exporting of the text before the first headline (see below), the
7319 title will be the file name without extension.
7321 If you are exporting only a subtree by marking is as the region, the heading
7322 of the subtree will become the title of the document.  If the subtree has a
7323 property @code{EXPORT_TITLE}, that will take precedence.
7325 @node Headings and sections, Table of contents, Document title, Markup rules
7326 @subheading Headings and sections
7327 @cindex headings and sections, markup rules
7329 The outline structure of the document as described in @ref{Document
7330 Structure} forms the basis for defining sections of the exported document.
7331 However, since the outline structure is also used for (for example) lists of
7332 tasks, only the first three outline levels will be used as headings.  Deeper
7333 levels will become itemized lists.  You can change the location of this
7334 switch, globally by setting the variable @code{org-headline-levels}, or on a
7335 per file basis with a line
7337 @example
7338 #+OPTIONS: H:4
7339 @end example
7341 @node Table of contents, Initial text, Headings and sections, Markup rules
7342 @subheading Table of contents
7343 @cindex table of contents, markup rules
7345 The table of contents is normally inserted directly before the first headline
7346 of the file.  If you would like to get it to a different location, insert the
7347 string @code{[TABLE-OF-CONTENTS]} on a line by itself at the desired
7348 location.  The depth of the table of contents is by default the same as the
7349 number of headline levels, but you can choose a smaller number or turn off
7350 the table of contents entirely by configuring the variable
7351 @code{org-export-with-toc}, or on a per-file basis with a line like
7353 @example
7354 #+OPTIONS: toc:2          (only to two levels in TOC)
7355 #+OPTIONS: toc:nil        (no TOC at all)
7356 @end example
7358 @node Initial text, Lists, Table of contents, Markup rules
7359 @subheading Text before the first headline
7360 @cindex text before first headline, markup rules
7361 @cindex #+TEXT
7363 Org mode normally exports the text before the first headline, and even uses
7364 the first line as the document title.  The text will be fully marked up.  If
7365 you need to include literal HTML or La@TeX{} code, use the special constructs
7366 described below in the sections for the individual exporters.
7368 Some people like to use the space before the first headline for setup and
7369 internal links and therefore would like to control the exported text before
7370 the first headline in a different way.  You can do so by setting the variable
7371 @code{org-export-skip-text-before-1st-heading} to @code{t}.  On a per-file
7372 basis, you can get the same effect with @samp{#+OPTIONS: skip:t}.
7374 @noindent
7375 If you still want to have some text before the first headline, use the
7376 @code{#+TEXT} construct:
7378 @example
7379 #+OPTIONS: skip:t
7380 #+TEXT: This text will go before the *first* headline.
7381 #+TEXT: [TABLE-OF-CONTENTS]
7382 #+TEXT: This goes between the table of contents and the first headline
7383 @end example
7385 @node Lists, Paragraphs, Initial text, Markup rules
7386 @subheading Lists
7387 @cindex lists, markup rules
7389 Plain lists as described in @ref{Plain lists} are translated to the back-ends
7390 syntax for such lists.  Most back-ends support unordered, ordered, and
7391 description lists.
7393 @node Paragraphs, Literal examples, Lists, Markup rules
7394 @subheading Paragraphs, line breaks, and quoting
7395 @cindex paragraphs, markup rules
7397 Paragraphs are separated by at least one empty line.  If you need to enforce
7398 a line break within a paragraph, use @samp{\\} at the end of a line.
7400 To keep the line breaks in a region, but otherwise use normal formatting, you
7401 can use this construct, which can also be used to format poetry.
7403 @example
7404 #+BEGIN_VERSE
7405  Great clouds overhead
7406  Tiny black birds rise and fall
7407  Snow covers Emacs
7409      -- AlexSchroeder
7410 #+END_VERSE
7411 @end example
7413 When quoting a passage from another document, it is customary to format this
7414 as a paragraph that is indented on both the left and the right margin.  You
7415 can include quotations in Org mode documents like this:
7417 @example
7418 #+BEGIN_QUOTE
7419 Everything should be made as simple as possible,
7420 but not any simpler -- Albert Einstein
7421 #+END_QUOTE
7422 @end example
7425 @node Literal examples, Include files, Paragraphs, Markup rules
7426 @subheading Literal examples
7427 @cindex literal examples, markup rules
7428 @cindex code line refenences, markup rules
7430 You can include literal examples that should not be subjected to
7431 markup.  Such examples will be typeset in monospace, so this is well suited
7432 for source code and similar examples.
7433 @cindex #+BEGIN_EXAMPLE
7435 @example
7436 #+BEGIN_EXAMPLE
7437 Some example from a text file.
7438 #+END_EXAMPLE
7439 @end example
7441 For simplicity when using small examples, you can also start the example
7442 lines with a colon followed by a space.  There may also be additional
7443 whitespace before the colon:
7445 @example
7446 Here is an example
7447    : Some example from a text file.
7448 @end example
7450 @cindex formatting source code, markup rules
7451 If the example is source code from a programming language, or any other text
7452 that can be marked up by font-lock in Emacs, you can ask for the example to
7453 look like the fontified Emacs buffer@footnote{Currently this works only for
7454 the HTML back-end, and requires the @file{htmlize.el} package version 1.34 or
7455 later.}.  This is done with the @samp{src} block, where you also need to
7456 specify the name of the major mode that should be used to fontify the
7457 example:
7458 @cindex #+BEGIN_SRC
7460 @example
7461 #+BEGIN_SRC emacs-lisp
7462 (defun org-xor (a b)
7463    "Exclusive or."
7464    (if a (not b) b))
7465 #+END_SRC
7466 @end example
7468 Both in @code{example} and in @code{src} snippets, you can add a @code{-n}
7469 switch to the end of the @code{BEGIN} line, to get the lines of the example
7470 numbered.  If you use a @code{+n} switch, the numbering from the previous
7471 numbered snippet will be continued in the current one.  In literal examples,
7472 Org will interpret strings like @samp{(ref:name)} as labels, and use them as
7473 targets for special hyperlinks like @code{[[(name)]]} (i.e. the reference
7474 name enclosed in single parenthesis).  In HTML, hovering the mouse over such
7475 a link will remote-highlight the corresponding code line, which is kind of
7476 cool.  If the example/src snippet is numbered, you can also add a @code{-r}
7477 switch.  Then labels will be @i{removed} from the source code and the links
7478 will be @i{replaced}@footnote{If you want to explain the use of such labels
7479 themelves in org-mode example code, you can use the @code{-k} switch to make
7480 sure they are not touched.} with line numbers from the code listing.  Here is
7481 an example:
7483 @example
7484 #+BEGIN_SRC emacs-lisp -n -r
7485 (save-excursion                  (ref:sc)
7486    (goto-char (point-min))       (ref:jump)
7487 #+END SRC
7488 In line [[(sc)]] we remember the current positon.  [[(jump)][Line (jump)]]
7489 jumps to point-min.
7490 @end example
7492 If the syntax for the label format conflicts with the language syntax, use a
7493 @code{-l} switch to change the format, for example @samp{#+BEGIN_SRC pascal
7494 -n -r -l "((%s))"}.  See also the variable @code{org-coderef-label-format}.
7496 HTML export also allows examples to be published as text areas, @pxref{Text
7497 areas in HTML export}.
7499 @table @kbd
7500 @kindex C-c '
7501 @item C-c '
7502 Edit the source code example at point in its native mode.  This works by
7503 switching to an indirect buffer, narrowing the buffer and switching to the
7504 other mode.  You need to exit by pressing @kbd{C-c '} again@footnote{Upon
7505 exit, lines starting with @samp{*} or @samp{#} will get a comma prepended, to
7506 keep them from being interpreted by Org as outline nodes or special
7507 comments.  These commas will be striped for editing with @kbd{C-c '}, and
7508 also for export.}.  Fixed-width
7509 regions (where each line starts with a colon followed by a space) will be
7510 edited using @code{artist-mode}@footnote{You may select a different-mode with
7511 the variable @code{org-edit-fixed-width-region-mode}.} to allow creating
7512 ASCII drawings easily.  Using this command in an empty line will create a new
7513 fixed-width region.
7514 @kindex C-c l
7515 @item C-c l
7516 Calling @code{org-store-link} while editing a source code example in a
7517 temporary buffer created with @kbd{C-c '} will prompt for a label, make sure
7518 that it is unique in the current buffer, and insert it with the proper
7519 formatting like @samp{(ref:label)} at the end of the current line.  Then the
7520 label is stored as a link @samp{(label)}, for retrieval with @kbd{C-c C-l}.
7521 @end table
7524 @node Include files, Tables exported, Literal examples, Markup rules
7525 @subheading Include files
7526 @cindex include files, markup rules
7528 During export, you can include the content of another file.  For example, to
7529 include your .emacs file, you could use:
7530 @cindex #+INCLUDE
7532 @example
7533 #+INCLUDE: "~/.emacs" src emacs-lisp
7534 @end example
7536 The optional second and third parameter are the markup (@samp{quote},
7537 @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
7538 language for formatting the contents.  The markup is optional, if it is not
7539 given, the text will be assumed to be in Org mode format and will be
7540 processed normally.  The include line will also allow additional keyword
7541 parameters @code{:prefix1} and @code{:prefix} to specify prefixes for the
7542 first line and for each following line, as well as any options accepted by
7543 the selected markup.  For example, to include a file as an item, use
7545 @example
7546 #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
7547 @end example
7549 @table @kbd
7550 @kindex C-c '
7551 @item C-c '
7552 Visit the include file at point.
7553 @end table
7555 @node Tables exported, Inlined images, Include files, Markup rules
7556 @subheading Tables
7557 @cindex tables, markup rules
7559 Both the native Org mode tables (@pxref{Tables}) and tables formatted with
7560 the @file{table.el} package will be exported properly.  For Org mode tables,
7561 the lines before the first horizontal separator line will become table header
7562 lines.  You can use the following lines somewhere before the table to assign
7563 a caption and a label for cross references:
7565 @example
7566 #+CAPTION: This is the caption for the next table (or link)
7567 #+LABEL:   tbl:basic-data
7568 @end example
7570 @node Inlined images, Footnote markup, Tables exported, Markup rules
7571 @subheading Inlined Images
7572 @cindex inlined images, markup rules
7574 Some backends (HTML and LaTeX) allow to directly include images into the
7575 exported document.  Org does this, if a link to an image files does not have
7576 a description part, for example @code{[[./img/a.jpg]]}.  If you wish to
7577 define a caption for the image and maybe a label for internal cross
7578 references, you can use (before, but close to the link)
7580 @example
7581 #+CAPTION: This is the caption for the next figure link (or table)
7582 #+LABEL:   fig:SED-HR4049
7583 @end example
7585 You may also define additional attributes for the figure.  As this is
7586 backend-specific, see the sections about the individual backends for more
7587 information.
7589 @node Footnote markup, Emphasis and monospace, Inlined images, Markup rules
7590 @subheading Footnote markup
7591 @cindex footnotes, markup rules
7592 @cindex @file{footnote.el}
7594 Footnotes defined in the way descriped in @ref{Footnotes} will be exported by
7595 all backends.  Org does allow multiple references to the same note, and
7596 different backends support this to varying degree.
7598 @node Emphasis and monospace, TeX macros and LaTeX fragments, Footnote markup, Markup rules
7599 @subheading Emphasis and monospace
7601 @cindex underlined text, markup rules
7602 @cindex bold text, markup rules
7603 @cindex italic text, markup rules
7604 @cindex verbatim text, markup rules
7605 @cindex code text, markup rules
7606 @cindex strike-through text, markup rules
7607 You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
7608 and @code{~verbatim~}, and, if you must, @samp{+strike-through+}.  Text
7609 in the code and verbatim string is not processed for Org mode specific
7610 syntax, it is exported verbatim.
7612 @node TeX macros and LaTeX fragments, Horizontal rules, Emphasis and monospace, Markup rules
7613 @subheading @TeX{} macros and La@TeX{} fragments
7614 @cindex LaTeX fragments, markup rules
7615 @cindex TeX macros, markup rules
7616 @cindex HTML entities
7617 @cindex LaTeX entities
7619 A @TeX{}-like syntax is used to specify special characters.  Where possible,
7620 these will be transformed into the native format of the exporter back-end.
7621 Strings like @code{\alpha} will be exported as @code{&alpha;} in the HTML
7622 output, and as @code{$\alpha$} in the La@TeX{} output.  Similarly,
7623 @code{\nbsp} will become @code{&nbsp;} in HTML and @code{~} in La@TeX{}.
7624 This applies for a large number of entities, with names taken from both HTML
7625 and La@TeX{}, see the variable @code{org-html-entities} for the complete
7626 list.  If you are unsure about a name, use @kbd{M-@key{TAB}} for completion
7627 after having typed the backslash and maybe a few characters
7628 (@pxref{Completion}).
7630 La@TeX{} fragments are converted into images for HTML export, and they are
7631 written literally into the La@TeX{} export.  See also @ref{Embedded LaTeX}.
7633 Finally, @samp{\-} is treated as a shy hyphen, and @samp{--}, @samp{---}, and
7634 @samp{...} are all converted into special commands creating hyphens of
7635 different lengths or a compact set of dots.
7637 @node Horizontal rules, Comment lines, TeX macros and LaTeX fragments, Markup rules
7638 @subheading  Horizontal rules
7639 @cindex horizontal rules, markup rules
7640 A line consisting of only dashes, and at least 5 of them, will be
7641 exported as a horizontal line (@samp{<hr/>} in HTML).
7643 @node Comment lines,  , Horizontal rules, Markup rules
7644 @subheading Comment lines
7645 @cindex comment lines
7646 @cindex exporting, not
7648 Lines starting with @samp{#} in column zero are treated as comments and will
7649 never be exported.  Also entire subtrees starting with the word
7650 @samp{COMMENT} will never be exported.  Finally, regions surrounded by
7651 @samp{#+BEGIN_COMMENT} ... @samp{#+END_COMMENT} will not be exported.
7653 @table @kbd
7654 @kindex C-c ;
7655 @item C-c ;
7656 Toggle the COMMENT keyword at the beginning of an entry.
7657 @end table
7659 @node Selective export, Export options, Markup rules, Exporting
7660 @section Selective export
7661 @cindex export, selective by tags
7663 You may use tags to select the parts of a document that should be exported,
7664 or to exclude parts from export.  This behavior is governed by two variables:
7665 @code{org-export-select-tags} and @code{org-export-exclude-tags}.
7667 Org first checks if any of the @emph{select} tags is present in the buffer.
7668 If yes, all trees that do not carry one of these tags will be excluded.  If a
7669 selected tree is a subtree, the heading hierarchy above it will also be
7670 selected for export, but not the text below those headings.
7672 @noindent
7673 If none of the select tags is found, the whole buffer will be selected for
7674 export.
7676 @noindent
7677 Finally, all subtrees that are marked by any of the @emph{exclude} tags will
7678 be removed from the export buffer.
7680 @node Export options, The export dispatcher, Selective export, Exporting
7681 @section Export options
7682 @cindex options, for export
7684 @cindex completion, of option keywords
7685 The exporter recognizes special lines in the buffer which provide
7686 additional information.  These lines may be put anywhere in the file.
7687 The whole set of lines can be inserted into the buffer with @kbd{C-c
7688 C-e t}.  For individual lines, a good way to make sure the keyword is
7689 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
7690 (@pxref{Completion}).
7692 @table @kbd
7693 @kindex C-c C-e t
7694 @item C-c C-e t
7695 Insert template with export options, see example below.
7696 @end table
7698 @cindex #+TITLE:
7699 @cindex #+AUTHOR:
7700 @cindex #+DATE:
7701 @cindex #+EMAIL:
7702 @cindex #+LANGUAGE:
7703 @cindex #+TEXT:
7704 @cindex #+OPTIONS:
7705 @cindex #+LINK_UP:
7706 @cindex #+LINK_HOME:
7707 @cindex #+EXPORT_SELECT_TAGS:
7708 @cindex #+EXPORT_EXCLUDE_TAGS:
7709 @example
7710 #+TITLE:     the title to be shown (default is the buffer name)
7711 #+AUTHOR:    the author (default taken from @code{user-full-name})
7712 #+DATE:      A date, fixed, of a format string for @code{format-time-string}
7713 #+EMAIL:     his/her email address (default from @code{user-mail-address})
7714 #+LANGUAGE:  language for HTML, e.g. @samp{en} (@code{org-export-default-language})
7715 #+TEXT:      Some descriptive text to be inserted at the beginning.
7716 #+TEXT:      Several lines may be given.
7717 #+OPTIONS:   H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
7718 #+LINK_UP:   the ``up'' link of an exported page
7719 #+LINK_HOME: the ``home'' link of an exported page
7720 #+EXPORT_SELECT_TAGS:   Tags that select a tree for export
7721 #+EXPORT_EXCLUDE_TAGS:  Tags that exclude a tree from export
7722 @end example
7724 @noindent
7725 The OPTIONS line is a compact@footnote{If you want to configure many options
7726 this way, you can use several OPTIONS lines.} form to specify export settings.  Here
7727 you can:
7728 @cindex headline levels
7729 @cindex section-numbers
7730 @cindex table of contents
7731 @cindex line-break preservation
7732 @cindex quoted HTML tags
7733 @cindex fixed-width sections
7734 @cindex tables
7735 @cindex @TeX{}-like syntax for sub- and superscripts
7736 @cindex footnotes
7737 @cindex special strings
7738 @cindex emphasized text
7739 @cindex @TeX{} macros
7740 @cindex La@TeX{} fragments
7741 @cindex author info, in export
7742 @cindex time info, in export
7743 @example
7744 H:         @r{set the number of headline levels for export}
7745 num:       @r{turn on/off section-numbers}
7746 toc:       @r{turn on/off table of contents, or set level limit (integer)}
7747 \n:        @r{turn on/off line-break-preservation}
7748 @@:         @r{turn on/off quoted HTML tags}
7749 ::         @r{turn on/off fixed-width sections}
7750 |:         @r{turn on/off tables}
7751 ^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
7752            @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
7753            @r{the simple @code{a_b} will be left as it is.}
7754 -:         @r{turn on/off conversion of special strings.}
7755 f:         @r{turn on/off footnotes like this[1].}
7756 todo:      @r{turn on/off inclusion of TODO keywords into exported text}
7757 pri:       @r{turn on/off priority cookies}
7758 tags:      @r{turn on/off inclusion of tags, may also be @code{not-in-toc}}
7759 <:         @r{turn on/off inclusion of any time/date stamps like DEADLINES}
7760 *:         @r{turn on/off emphasized text (bold, italic, underlined)}
7761 TeX:       @r{turn on/off simple @TeX{} macros in plain text}
7762 LaTeX:     @r{turn on/off La@TeX{} fragments}
7763 skip:      @r{turn on/off skipping the text before the first heading}
7764 author:    @r{turn on/off inclusion of author name/email into exported file}
7765 creator:   @r{turn on/off inclusion of creator info into exported file}
7766 timestamp: @r{turn on/off inclusion creation time into exported file}
7767 d:         @r{turn on/off inclusion of drawers}
7768 @end example
7770 These options take effect in both the HTML and La@TeX{} export, except
7771 for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
7772 @code{nil} for the La@TeX{} export.
7774 When exporting only a single subtree by selecting it with @kbd{C-c @@} before
7775 calling an export command, the subtree can overrule some of the file's export
7776 settings with properties @code{EXPORT_FILE_NAME}, @code{EXPORT_TITLE},
7777 @code{EXPORT_TEXT}, and @code{EXPORT_OPTIONS}.
7779 @node The export dispatcher, ASCII export, Export options, Exporting
7780 @section The export dispatcher
7781 @cindex dispatcher, for export commands
7783 All export commands can be reached using the export dispatcher, which is a
7784 prefix key that prompts for an additional key specifying the command.
7785 Normally the entire file is exported, but if there is an active region that
7786 contains one outline tree, the first heading is used as document title and
7787 the subtrees are exported.
7789 @table @kbd
7790 @kindex C-c C-e
7791 @item C-c C-e
7792 Dispatcher for export and publishing commands.  Displays a help-window
7793 listing the additional key(s) needed to launch an export or publishing
7794 command.  The prefix arg is passed through to the exporter.  A double prefix
7795 @kbd{C-u C-u} causes most commands to be executed in the background, in a
7796 separate emacs process@footnote{To make this behavior the default, customize
7797 the variable @code{org-export-run-in-background}.}.
7798 @kindex C-c C-e v
7799 @item C-c C-e v
7800 Like @kbd{C-c C-e}, but only export the text that is currently visible
7801 (i.e. not hidden by outline visibility).
7802 @kindex C-u C-u C-c C-e
7803 @item C-u C-u C-c C-e
7804 Call an the exporter, but reverse the setting of
7805 @code{org-export-run-in-background}, i.e. request background processing if
7806 not set, or force processing in the current Emacs process if st.
7807 @end table
7809 @node ASCII export, HTML export, The export dispatcher, Exporting
7810 @section ASCII export
7811 @cindex ASCII export
7813 ASCII export produces a simple and very readable version of an Org mode
7814 file.
7816 @cindex region, active
7817 @cindex active region
7818 @cindex transient-mark-mode
7819 @table @kbd
7820 @kindex C-c C-e a
7821 @item C-c C-e a
7822 Export as ASCII file.  For an org file @file{myfile.org}, the ASCII file
7823 will be @file{myfile.txt}.  The file will be overwritten without
7824 warning.  If there is an active region@footnote{this requires
7825 @code{transient-mark-mode} to be turned on}, only the region will be
7826 exported. If the selected region is a single tree@footnote{To select the
7827 current subtree, use @kbd{C-c @@}.}, the tree head will
7828 become the document title.  If the tree head entry has or inherits an
7829 @code{EXPORT_FILE_NAME} property, that name will be used for the
7830 export.
7831 @kindex C-c C-e v a
7832 @item C-c C-e v a
7833 Export only the visible part of the document.
7834 @end table
7836 @cindex headline levels, for exporting
7837 In the exported version, the first 3 outline levels will become
7838 headlines, defining a general document structure.  Additional levels
7839 will be exported as itemized lists.  If you want that transition to occur
7840 at a different level, specify it with a prefix argument.  For example,
7842 @example
7843 @kbd{C-1 C-c C-e a}
7844 @end example
7846 @noindent
7847 creates only top level headlines and does the rest as items.  When
7848 headlines are converted to items, the indentation of the text following
7849 the headline is changed to fit nicely under the item.  This is done with
7850 the assumption that the first body line indicates the base indentation of
7851 the body text.  Any indentation larger than this is adjusted to preserve
7852 the layout relative to the first line.  Should there be lines with less
7853 indentation than the first, these are left alone.
7855 @node HTML export, LaTeX and PDF export, ASCII export, Exporting
7856 @section HTML export
7857 @cindex HTML export
7859 Org mode contains an HTML (XHTML 1.0 strict) exporter with extensive
7860 HTML formatting, in ways similar to John Gruber's @emph{markdown}
7861 language, but with additional support for tables.
7863 @menu
7864 * HTML Export commands::        How to invoke HTML export
7865 * Quoting HTML tags::           Using direct HTML in Org mode
7866 * Links::                       Transformation of links for HTML
7867 * Images in HTML export::       How to insert figures into HTML output
7868 * Text areas in HTML export::   An alternative way to show an example
7869 * CSS support::                 Changing the appearance of the output
7870 * Javascript support::          Info and Folding in a web browser
7871 @end menu
7873 @node HTML Export commands, Quoting HTML tags, HTML export, HTML export
7874 @subsection HTML export commands
7876 @cindex region, active
7877 @cindex active region
7878 @cindex transient-mark-mode
7879 @table @kbd
7880 @kindex C-c C-e h
7881 @item C-c C-e h
7882 Export as HTML file @file{myfile.html}.  For an org file @file{myfile.org},
7883 the ASCII file will be @file{myfile.html}.  The file will be overwritten
7884 without warning.  If there is an active region@footnote{this requires
7885 @code{transient-mark-mode} to be turned on}, only the region will be
7886 exported. If the selected region is a single tree@footnote{To select the
7887 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
7888 title.  If the tree head entry has, or inherits, an @code{EXPORT_FILE_NAME}
7889 property, that name will be used for the export.
7890 @kindex C-c C-e b
7891 @item C-c C-e b
7892 Export as HTML file and immediately open it with a browser.
7893 @kindex C-c C-e H
7894 @item C-c C-e H
7895 Export to a temporary buffer, do not create a file.
7896 @kindex C-c C-e R
7897 @item C-c C-e R
7898 Export the active region to a temporary buffer.  With a prefix argument, do
7899 not produce the file header and footer, but just the plain HTML section for
7900 the region.  This is good for cut-and-paste operations.
7901 @kindex C-c C-e v h
7902 @kindex C-c C-e v b
7903 @kindex C-c C-e v H
7904 @kindex C-c C-e v R
7905 @item C-c C-e v h
7906 @item C-c C-e v b
7907 @item C-c C-e v H
7908 @item C-c C-e v R
7909 Export only the visible part of the document.
7910 @item M-x org-export-region-as-html
7911 Convert the region to HTML under the assumption that it was Org mode
7912 syntax before.  This is a global command that can be invoked in any
7913 buffer.
7914 @item M-x org-replace-region-by-HTML
7915 Replace the active region (assumed to be in Org mode syntax) by HTML
7916 code.
7917 @end table
7919 @cindex headline levels, for exporting
7920 In the exported version, the first 3 outline levels will become headlines,
7921 defining a general document structure.  Additional levels will be exported as
7922 itemized lists.  If you want that transition to occur at a different level,
7923 specify it with a numeric prefix argument.  For example,
7925 @example
7926 @kbd{C-2 C-c C-e b}
7927 @end example
7929 @noindent
7930 creates two levels of headings and does the rest as items.
7932 @node Quoting HTML tags, Links, HTML Export commands, HTML export
7933 @subsection Quoting HTML tags
7935 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
7936 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
7937 which should be interpreted as such, mark them with @samp{@@} as in
7938 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
7939 simple tags.  For more extensive HTML that should be copied verbatim to
7940 the exported file use either
7942 @example
7943 #+HTML: Literal HTML code for export
7944 @end example
7946 @noindent or
7947 @cindex #+BEGIN_HTML
7949 @example
7950 #+BEGIN_HTML
7951 All lines between these markers are exported literally
7952 #+END_HTML
7953 @end example
7956 @node Links, Images in HTML export, Quoting HTML tags, HTML export
7957 @subsection Links
7959 @cindex links, in HTML export
7960 @cindex internal links, in HTML export
7961 @cindex external links, in HTML export
7962 Internal links (@pxref{Internal links}) will continue to work in HTML.  This
7963 does include automatic links created by radio targets (@pxref{Radio
7964 targets}).  Links to external files will still work if the target file is on
7965 the same @i{relative} path as the published Org file.  Links to other
7966 @file{.org} files will be translated into HTML links under the assumption
7967 that an HTML version also exists of the linked file, at the same relative
7968 path.  @samp{id:} links can then be used to jump to specific entries across
7969 files.  For information related to linking files while publishing them to a
7970 publishing directory see @ref{Publishing links}.
7972 If you want to specify attributes for links, you can do so using a special
7973 @code{#+ATTR_HTML} line to define attributes that will be added to the
7974 @code{<a>} or @code{<img>} tags.  Here is an example that sets @code{alt} and
7975 @code{title} attributes for an inlined image:
7977 @example
7978 #+ATTR_HTML: alt="This is image A" title="Image with no action"
7979 [[./img/a.jpg]]
7980 @end example
7982 @node Images in HTML export, Text areas in HTML export, Links, HTML export
7983 @subsection Images
7985 @cindex images, inline in HTML
7986 @cindex inlining images in HTML
7987 HTML export can inline images given as links in the Org file, and
7988 it can make an image the clickable part of a link.  By
7989 default@footnote{but see the variable
7990 @code{org-export-html-inline-images}}, images are inlined if a link does
7991 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
7992 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
7993 @samp{the image} that points to the image.  If the description part
7994 itself is a @code{file:} link or a @code{http:} URL pointing to an
7995 image, this image will be inlined and activated so that clicking on the
7996 image will activate the link.  For example, to include a thumbnail that
7997 will link to a high resolution version of the image, you could use:
7999 @example
8000 [[file:highres.jpg][file:thumb.jpg]]
8001 @end example
8003 @noindent
8004 and you could use @code{http} addresses just as well.
8006 @node Text areas in HTML export, CSS support, Images in HTML export, HTML export
8007 @subsection Text areas
8009 @cindex text areas, in HTML
8010 An alternative way to publish literal code examples in HTML is to use text
8011 areas, where the example can even be edited before pasting it into an
8012 application.  It is triggered by a @code{-t} switch at an @code{example} or
8013 @code{src} block.  Using this switch disables any options for syntax and
8014 label highlighting, and line numbering, which may be present.  You may also
8015 use @code{-h} and @code{-w} switches to specify the height and width of the
8016 text area, which default to the number of lines in the example, and 80,
8017 respectively.  For example
8019 @example
8020 #+BEGIN_EXAMPLE -t -w 40
8021 (defun org-xor (a b)
8022    "Exclusive or."
8023    (if a (not b) b))
8024 #+END_EXAMPLE
8025 @end example
8028 @node CSS support, Javascript support, Text areas in HTML export, HTML export
8029 @subsection CSS support
8030 @cindex CSS, for HTML export
8031 @cindex HTML export, CSS
8033 You can also give style information for the exported file.  The HTML exporter
8034 assigns the following special CSS classes to appropriate parts of the
8035 document - your style specifications may change these, in addition to any of
8036 the standard classes like for headlines, tables etc.
8037 @example
8038 .todo              @r{TODO keywords}
8039 .done              @r{the DONE keyword}
8040 .timestamp         @r{time stamp}
8041 .timestamp-kwd     @r{keyword associated with a time stamp, like SCHEDULED}
8042 .tag               @r{tag in a headline}
8043 .target            @r{target for links}
8044 div.figure         @r{how to format an inlined image}
8045 .linenr            @r{the line number in a code example}
8046 .code-highlighted  @r{for highlighting referenced code lines}
8047 @end example
8049 Each exported files contains a compact default style that defines these
8050 classes in a basic way@footnote{This style is defined in the constant
8051 @code{org-export-html-style-default}, which you should not modify.  To turn
8052 inclusion of these defaults off, customize
8053 @code{org-export-html-style-include-default}}.  You may overwrite these
8054 settings, or add to them by using the variables @code{org-export-html-style}
8055 (for Org-wide settings) and @code{org-export-html-style-extra} (for more
8056 granular settings, like file-local settings).  To set the latter variable
8057 individually for each file, you can use
8059 @example
8060 #+STYLE: <link rel="stylesheet" type="text/css" href="stylesheet.css" />
8061 @end example
8063 @noindent
8064 For longer style definitions, you can use several such lines.  You could also
8065 directly write a @code{<style>} @code{</style>} section in this way, without
8066 referring to an external file.
8068 @c FIXME: More about header and footer styles
8069 @c FIXME: Talk about links and targets.
8071 @node Javascript support,  , CSS support, HTML export
8072 @subsection Javascript supported display of web pages
8074 @emph{Sebastian Rose} has written a JavaScript program especially designed to
8075 enhance the web viewing experience of HTML files created with Org.  This
8076 program allows you to view large files in two different ways.  The first one
8077 is an @emph{Info}-like mode where each section is displayed separately and
8078 navigation can be done with the @kbd{n} and @kbd{p} keys (and some other keys
8079 as well, press @kbd{?} for an overview of the available keys).  The second
8080 view type is a @emph{folding} view much like Org provides inside Emacs.  The
8081 script is available at @url{http://orgmode.org/org-info.js} and you can find
8082 the documentation for it at @url{http://orgmode.org/worg/code/org-info-js/}.
8083 We are serving the script from our site, but if you use it a lot, you might
8084 not want to be dependent on @url{orgmode.org} and prefer to install a local
8085 copy on your own web server.
8087 To use the script, you need to make sure that the @file{org-jsinfo.el} module
8088 gets loaded.  It should be loaded by default, but you can try @kbd{M-x
8089 customize-variable @key{RET} org-modules @key{RET}} to convince yourself that
8090 this is indeed the case.  All it then takes to make use of the program is
8091 adding a single line to the Org file:
8093 @example
8094 #+INFOJS_OPT: view:info toc:nil
8095 @end example
8097 @noindent
8098 If this line is found, the HTML header will automatically contain the code
8099 needed to invoke the script.  Using the line above, you can set the following
8100 viewing options:
8102 @example
8103 path:    @r{The path to the script.  The default is to grab the script from}
8104          @r{@url{http://orgmode.org/org-info.js}, but you might want to have}
8105          @r{a local copy and use a path like @samp{../scripts/org-info.js}.}
8106 view:    @r{Initial view when website is first shown.  Possible values are:}
8107          info      @r{Info-like interface with one section per page.}
8108          overview  @r{Folding interface, initially showing only top-level.}
8109          content   @r{Folding interface, starting with all headlines visible.}
8110          showall   @r{Folding interface, all headlines and text visible.}
8111 sdepth:  @r{Maximum headline level that will still become an independent}
8112          @r{section for info and folding modes.  The default is taken from}
8113          @r{@code{org-headline-levels} (= the @code{H} switch in @code{#+OPTIONS}).}
8114          @r{If this is smaller than in @code{org-headline-levels}, each}
8115          @r{info/folding section can still contain children headlines.}
8116 toc:     @r{Should the table of content @emph{initially} be visible?}
8117          @r{Even when @code{nil}, you can always get to the toc with @kbd{i}.}
8118 tdepth:  @r{The depth of the table of contents.  The defaults are taken from}
8119          @r{the variables @code{org-headline-levels} and @code{org-export-with-toc}.}
8120 ftoc:    @r{Does the css of the page specify a fixed position for the toc?}
8121          @r{If yes, the toc will never be displayed as a section.}
8122 ltoc:    @r{Should there be short contents (children) in each section?}
8123 mouse:   @r{Headings are highlighted when the mouse is over them.  Should be}
8124          @r{@samp{underline} (default) or a background color like @samp{#cccccc}.}
8125 buttons: @r{Should view-toggle buttons be everywhere?  When @code{nil} (the}
8126          @r{default), only one such button will be present.}
8127 @end example
8129 You can choose default values for these options by customizing the variable
8130 @code{org-infojs-options}.  If you always want to apply the script to your
8131 pages, configure the variable @code{org-export-html-use-infojs}.
8133 @node LaTeX and PDF export, XOXO export, HTML export, Exporting
8134 @section LaTeX and PDF export
8135 @cindex LaTeX export
8136 @cindex PDF export
8138 Org mode contains a La@TeX{} exporter written by Bastien Guerry.  With
8139 further processing, this backend is also used to produce PDF output.  Since
8140 the LaTeX output uses @file{hyperref} to implement links and cross
8141 references, the PDF output file will be fully linked.
8143 @menu
8144 * LaTeX/PDF export commands::   Which key invokes which commands
8145 * Quoting LaTeX code::          Incorporating literal LaTeX code
8146 * Sectioning structure::        Changing sectioning in LaTeX output
8147 * Tables in LaTeX export::      Options for exporting tables to LaTeX
8148 * Images in LaTeX export::      How to insert figures into LaTeX output
8149 @end menu
8151 @node LaTeX/PDF export commands, Quoting LaTeX code, LaTeX and PDF export, LaTeX and PDF export
8152 @subsection LaTeX export commands
8154 @cindex region, active
8155 @cindex active region
8156 @cindex transient-mark-mode
8157 @table @kbd
8158 @kindex C-c C-e l
8159 @item C-c C-e l
8160 Export as La@TeX{} file @file{myfile.tex}.  For an org file
8161 @file{myfile.org}, the ASCII file will be @file{myfile.tex}.  The file will
8162 be overwritten without warning.  If there is an active region@footnote{this
8163 requires @code{transient-mark-mode} to be turned on}, only the region will be
8164 exported. If the selected region is a single tree@footnote{To select the
8165 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
8166 title.  If the tree head entry has or inherits an @code{EXPORT_FILE_NAME}
8167 property, that name will be used for the export.
8168 @kindex C-c C-e L
8169 @item C-c C-e L
8170 Export to a temporary buffer, do not create a file.
8171 @kindex C-c C-e v l
8172 @kindex C-c C-e v L
8173 @item C-c C-e v l
8174 @item C-c C-e v L
8175 Export only the visible part of the document.
8176 @item M-x org-export-region-as-latex
8177 Convert the region to La@TeX{} under the assumption that it was Org mode
8178 syntax before.  This is a global command that can be invoked in any
8179 buffer.
8180 @item M-x org-replace-region-by-latex
8181 Replace the active region (assumed to be in Org mode syntax) by La@TeX{}
8182 code.
8183 @kindex C-c C-e p
8184 @item C-c C-e p
8185 Export as LaTeX and then process to PDF.
8186 @kindex C-c C-e d
8187 @item C-c C-e d
8188 Export as LaTeX and then process to PDF, then open the resulting PDF file.
8189 @end table
8191 @cindex headline levels, for exporting
8192 In the exported version, the first 3 outline levels will become
8193 headlines, defining a general document structure.  Additional levels
8194 will be exported as description lists.  The exporter can ignore them or
8195 convert them to a custom string depending on
8196 @code{org-latex-low-levels}.
8198 If you want that transition to occur at a different level, specify it
8199 with a numeric prefix argument. For example,
8201 @example
8202 @kbd{C-2 C-c C-e l}
8203 @end example
8205 @noindent
8206 creates two levels of headings and does the rest as items.
8208 @node Quoting LaTeX code, Sectioning structure, LaTeX/PDF export commands, LaTeX and PDF export
8209 @subsection Quoting LaTeX code
8211 Embedded La@TeX{} as described in @ref{Embedded LaTeX} will be correctly
8212 inserted into the La@TeX{} file.  This includes simple macros like
8213 @samp{\ref@{LABEL@}} to create a cross reference to a figure.  Furthermore,
8214 you can add special code that should only be present in La@TeX{} export with
8215 the following constructs:
8217 @example
8218 #+LaTeX: Literal LaTeX code for export
8219 @end example
8221 @noindent or
8222 @cindex #+BEGIN_LaTeX
8224 @example
8225 #+BEGIN_LaTeX
8226 All lines between these markers are exported literally
8227 #+END_LaTeX
8228 @end example
8230 @node  Sectioning structure, Tables in LaTeX export, Quoting LaTeX code, LaTeX and PDF export
8231 @subsection Sectioning structure
8232 @cindex LaTeX class
8233 @cindex LaTeX sectioning structure
8235 By default, the La@TeX{} output uses the class @code{article}.
8237 You can change this globally by setting a different value for
8238 @code{org-export-latex-default-class} or locally by adding an option like
8239 @code{#+LaTeX_CLASS: myclass} in your file, or with a @code{:LaTeX_CLASS:}
8240 property that applies when exporting a region containing only this (sub)tree.
8241 The class should be listed in @code{org-export-latex-classes}, where you can
8242 also define the sectioning structure for each class, as well as defining
8243 additional classes.
8245 @node Tables in LaTeX export, Images in LaTeX export, Sectioning structure, LaTeX and PDF export
8246 @subsection Tables in LaTeX export
8247 @cindex tables, in LaTeX export
8249 For LaTeX export of a table, you can specify a label and a caption
8250 (@pxref{Markup rules}).  You can also use the @code{ATTR_LaTeX} line to
8251 request a longtable environment for the table, so that it may span several
8252 pages:
8254 @example
8255 #+CAPTION: A long table
8256 #+LABEL: tbl:long
8257 #+ATTR_LaTeX: longtable
8258 | ..... | ..... |
8259 | ..... | ..... |
8260 @end example
8263 @node Images in LaTeX export,  , Tables in LaTeX export, LaTeX and PDF export
8264 @subsection Images in LaTeX export
8265 @cindex images, inline in LaTeX
8266 @cindex inlining images in LaTeX
8268 Images that are linked to without a description part in the link, like
8269 @samp{[[file:img.jpg]]} or @samp{[[./img.jpg]]} will be inserted into the PDF
8270 output files resulting from LaTeX output.  Org will use an
8271 @code{\includegraphics} macro to insert the image.  If you have specified a
8272 caption and/or a label as described in @ref{Markup rules}, the figure will
8273 be wrapped into a @code{figure} environment and thus become a floating
8274 element.  Finally, you can use an @code{#+ATTR_LaTeX:} line to specify the
8275 options that can be used in the optional argument of the
8276 @code{\includegraphics} macro.
8278 @example
8279 #+CAPTION:    The black-body emission of the disk around HR 4049
8280 #+LABEL:      fig:SED-HR4049
8281 #+ATTR_LaTeX: width=5cm,angle=90
8282 [[./img/sed-hr4049.pdf]]
8283 @end example
8285 If you need references to a label created in this way, write
8286 @samp{\ref@{fig:SED-HR4049@}} just like in LaTeX.  The default settings will
8287 recognize files types that can be included as images during processing by
8288 pdflatex (@file{png}, @file{jpg}, and @file{pdf} files).  If you process your
8289 files in a different way, you may need to customize the variable
8290 @code{org-export-latex-inline-image-extensions}.
8292 @node XOXO export, iCalendar export, LaTeX and PDF export, Exporting
8293 @section XOXO export
8294 @cindex XOXO export
8296 Org mode contains an exporter that produces XOXO-style output.
8297 Currently, this exporter only handles the general outline structure and
8298 does not interpret any additional Org mode features.
8300 @table @kbd
8301 @kindex C-c C-e x
8302 @item C-c C-e x
8303 Export as XOXO file @file{myfile.html}.
8304 @kindex C-c C-e v
8305 @item C-c C-e v x
8306 Export only the visible part of the document.
8307 @end table
8309 @node iCalendar export,  , XOXO export, Exporting
8310 @section iCalendar export
8311 @cindex iCalendar export
8313 Some people like to use Org mode for keeping track of projects, but still
8314 prefer a standard calendar application for anniversaries and appointments.
8315 In this case it can be useful to have deadlines and other time-stamped items
8316 in Org files show up in the calendar application.  Org mode can export
8317 calendar information in the standard iCalendar format.  If you also want to
8318 have TODO entries included in the export, configure the variable
8319 @code{org-icalendar-include-todo}.  iCalendar export will export plain time
8320 stamps as VEVENT, and TODO items as VTODO.  It will also create events from
8321 deadlines that are in non-TODO items.  Deadlines and scheduling dates in TODO
8322 items will be used to set the start and due dates for the todo
8323 entry@footnote{See the variables @code{org-icalendar-use-deadline} and
8324 @code{org-icalendar-use-scheduled}.}.  As categories, it will use the tags
8325 locally defined in the heading, and the file/tree category@footnote{To add
8326 inherited tags or the TODO state, configure the variable
8327 @code{org-icalendar-categories}.}.
8329 The iCalendar standard requires each entry to have a globally unique
8330 identifier (UID).  Org creates these identifiers during export.  If you set
8331 the variable @code{org-icalendar-store-UID}, the UID will be stored in the
8332 @code{:ID:} property of the entry and re-used next time you report this
8333 entry.  Since a single entry can give rise to multiple iCalendar entries (as
8334 a timestamp, a deadline, a scheduled item, and as a TODO item), Org adds
8335 prefixes to the UID, depending on what triggered the inclusion of the entry.
8336 In this way the UID remains unique, but a synchronization program can still
8337 figure out from which entry all the different instances originate.
8339 @table @kbd
8340 @kindex C-c C-e i
8341 @item C-c C-e i
8342 Create iCalendar entries for the current file and store them in the same
8343 directory, using a file extension @file{.ics}.
8344 @kindex C-c C-e I
8345 @item C-c C-e I
8346 Like @kbd{C-c C-e i}, but do this for all files in
8347 @code{org-agenda-files}.  For each of these files, a separate iCalendar
8348 file will be written.
8349 @kindex C-c C-e c
8350 @item C-c C-e c
8351 Create a single large iCalendar file from all files in
8352 @code{org-agenda-files} and write it to the file given by
8353 @code{org-combined-agenda-icalendar-file}.
8354 @end table
8356 The export will honor SUMMARY, DESCRIPTION and LOCATION@footnote{The LOCATION
8357 property can be inherited from higher in the hierarchy if you configure
8358 @code{org-use-property-inheritance} accordingly.} properties if the selected
8359 entries have them.  If not, the summary will be derived from the headline,
8360 and the description from the body (limited to
8361 @code{org-icalendar-include-body} characters).
8363 How this calendar is best read and updated, that depends on the application
8364 you are using.  The FAQ covers this issue.
8366 @node Publishing, Miscellaneous, Exporting, Top
8367 @chapter Publishing
8368 @cindex publishing
8370 Org includes@footnote{@file{org-publish.el} is not distributed with
8371 Emacs 21, if you are still using Emacs 21, you need you need to download
8372 this file separately.} a publishing management system that allows you to
8373 configure automatic HTML conversion of @emph{projects} composed of
8374 interlinked org files.  This system is called @emph{org-publish}.  You can
8375 also configure org-publish to automatically upload your exported HTML
8376 pages and related attachments, such as images and source code files, to
8377 a web server. Org-publish turns Org into a web-site authoring tool.
8379 You can also use Org-publish to convert files into La@TeX{}, or even
8380 combine HTML and La@TeX{} conversion so that files are available in both
8381 formats on the server@footnote{Since La@TeX{} files on a server are not
8382 that helpful, you surely want to perform further conversion on them --
8383 e.g. convert them to @code{PDF} format.}.
8385 Org-publish has been contributed to Org by David O'Toole.
8387 @menu
8388 * Configuration::               Defining projects
8389 * Sample configuration::        Example projects
8390 * Triggering publication::      Publication commands
8391 @end menu
8393 @node Configuration, Sample configuration, Publishing, Publishing
8394 @section Configuration
8396 Publishing needs significant configuration to specify files, destination
8397 and many other properties of a project.
8399 @menu
8400 * Project alist::               The central configuration variable
8401 * Sources and destinations::    From here to there
8402 * Selecting files::             What files are part of the project?
8403 * Publishing action::           Setting the function doing the publishing
8404 * Publishing options::          Tweaking HTML export
8405 * Publishing links::            Which links keep working after publishing?
8406 * Project page index::          Publishing a list of project files
8407 @end menu
8409 @node Project alist, Sources and destinations, Configuration, Configuration
8410 @subsection The variable @code{org-publish-project-alist}
8411 @cindex org-publish-project-alist
8412 @cindex projects, for publishing
8414 Org-publish is configured almost entirely through setting the value of
8415 one variable, called @code{org-publish-project-alist}.
8416 Each element of the list configures one project, and may be in one of
8417 the two following forms:
8419 @lisp
8420 ("project-name" :property value :property value ...)
8422 @r{or}
8424 ("project-name" :components ("project-name" "project-name" ...))
8426 @end lisp
8428 In both cases, projects are configured by specifying property values.
8429 A project defines the set of files that will be published, as well as
8430 the publishing configuration to use when publishing those files.  When
8431 a project takes the second form listed above, the individual members
8432 of the ``components'' property are taken to be components of the
8433 project, which group together files requiring different publishing
8434 options. When you publish such a ``meta-project'' all the components
8435 will also publish.  The @code{:components} are published in the sequence
8436 provided.
8438 @node Sources and destinations, Selecting files, Project alist, Configuration
8439 @subsection Sources and destinations for files
8440 @cindex directories, for publishing
8442 Most properties are optional, but some should always be set. In
8443 particular, org-publish needs to know where to look for source files,
8444 and where to put published files.
8446 @multitable @columnfractions 0.3 0.7
8447 @item @code{:base-directory}
8448 @tab Directory containing publishing source files
8449 @item @code{:publishing-directory}
8450 @tab Directory (possibly remote) where output files will be published.
8451 @item @code{:preparation-function}
8452 @tab Function called before starting the publishing process, for example to
8453 run @code{make} for updating files to be published.
8454 @item @code{:completion-function}
8455 @tab Function called after finishing the publishing process, for example to
8456 change permissions of the resulting files.
8457 @end multitable
8458 @noindent
8460 @node Selecting files, Publishing action, Sources and destinations, Configuration
8461 @subsection Selecting files
8462 @cindex files, selecting for publishing
8464 By default, all files with extension @file{.org} in the base directory
8465 are considered part of the project.  This can be modified by setting the
8466 properties
8467 @multitable @columnfractions 0.25 0.75
8468 @item @code{:base-extension}
8469 @tab Extension (without the dot!) of source files.  This actually is a
8470 regular expression.
8472 @item @code{:exclude}
8473 @tab Regular expression to match file names that should not be
8474 published, even though they have been selected on the basis of their
8475 extension.
8477 @item @code{:include}
8478 @tab List of files to be included regardless of @code{:base-extension}
8479 and @code{:exclude}.
8480 @end multitable
8482 @node Publishing action, Publishing options, Selecting files, Configuration
8483 @subsection Publishing action
8484 @cindex action, for publishing
8486 Publishing means that a file is copied to the destination directory and
8487 possibly transformed in the process.  The default transformation is to export
8488 Org files as HTML files, and this is done by the function
8489 @code{org-publish-org-to-html} which calls the HTML exporter (@pxref{HTML
8490 export}). But you also can publish your files in La@TeX{} by using the
8491 function @code{org-publish-org-to-latex} instead, or as PDF files using
8492 @code{org-publish-org-to-pdf}.  Other files like images only need to be
8493 copied to the publishing destination. For non-Org files, you need to provide
8494 your own publishing function:
8496 @multitable @columnfractions 0.3 0.7
8497 @item @code{:publishing-function}
8498 @tab Function executing the publication of a file.  This may also be a
8499 list of functions, which will all be called in turn.
8500 @end multitable
8502 The function must accept two arguments: a property list containing at
8503 least a @code{:publishing-directory} property, and the name of the file
8504 to be published.  It should take the specified file, make the necessary
8505 transformation (if any) and place the result into the destination folder.
8506 You can write your own publishing function, but @code{org-publish}
8507 provides one for attachments (files that only need to be copied):
8508 @code{org-publish-attachment}.
8510 @node Publishing options, Publishing links, Publishing action, Configuration
8511 @subsection Options for the HTML/LaTeX exporters
8512 @cindex options, for publishing
8514 The property list can be used to set many export options for the HTML
8515 and La@TeX{} exporters.  In most cases, these properties correspond to user
8516 variables in Org.  The table below lists these properties along
8517 with the variable they belong to.  See the documentation string for the
8518 respective variable for details.
8520 @multitable @columnfractions 0.32 0.68
8521 @item @code{:link-up}               @tab @code{org-export-html-link-up}
8522 @item @code{:link-home}             @tab @code{org-export-html-link-home}
8523 @item @code{:language}              @tab @code{org-export-default-language}
8524 @item @code{:customtime}            @tab @code{org-display-custom-times}
8525 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
8526 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
8527 @item @code{:section-number-format} @tab @code{org-export-section-number-format}
8528 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
8529 @item @code{:preserve-breaks}       @tab @code{org-export-preserve-breaks}
8530 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
8531 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
8532 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
8533 @item @code{:special-strings}       @tab @code{org-export-with-special-strings}
8534 @item @code{:footnotes}             @tab @code{org-export-with-footnotes}
8535 @item @code{:drawers}               @tab @code{org-export-with-drawers}
8536 @item @code{:tags}                  @tab @code{org-export-with-tags}
8537 @item @code{:todo-keywords}         @tab @code{org-export-with-todo-keywords}
8538 @item @code{:priority}              @tab @code{org-export-with-priority}
8539 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
8540 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
8541 @item @code{:skip-before-1st-heading} @tab @code{org-export-skip-text-before-1st-heading}
8542 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
8543 @item @code{:timestamps}            @tab @code{org-export-with-timestamps}
8544 @item @code{:author-info}           @tab @code{org-export-author-info}
8545 @item @code{:creator-info}          @tab @code{org-export-creator-info}
8546 @item @code{:tables}                @tab @code{org-export-with-tables}
8547 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
8548 @item @code{:style-include-default} @tab @code{org-export-html-style-include-default}
8549 @item @code{:style}                 @tab @code{org-export-html-style}
8550 @item @code{:style-extra}           @tab @code{org-export-html-style-extra}
8551 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
8552 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
8553 @item @code{:html-extension}        @tab @code{org-export-html-extension}
8554 @item @code{:html-table-tag}        @tab @code{org-export-html-table-tag}
8555 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
8556 @item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
8557 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
8558 @item @code{:preamble}              @tab @code{org-export-html-preamble}
8559 @item @code{:postamble}             @tab @code{org-export-html-postamble}
8560 @item @code{:auto-preamble}         @tab @code{org-export-html-auto-preamble}
8561 @item @code{:auto-postamble}        @tab @code{org-export-html-auto-postamble}
8562 @item @code{:author}                @tab @code{user-full-name}
8563 @item @code{:email}                 @tab @code{user-mail-address}
8564 @item @code{:select-tags}           @tab @code{org-export-select-tags}
8565 @item @code{:exclude-tags}          @tab @code{org-export-exclude-tags}
8566 @end multitable
8568 If you use several email addresses, separate them by a semi-column.
8570 Most of the @code{org-export-with-*} variables have the same effect in
8571 both HTML and La@TeX{} exporters, except for @code{:TeX-macros} and
8572 @code{:LaTeX-fragments}, respectively @code{nil} and @code{t} in the
8573 La@TeX{} export.
8575 When a property is given a value in @code{org-publish-project-alist},
8576 its setting overrides the value of the corresponding user variable (if
8577 any) during publishing.  Options set within a file (@pxref{Export
8578 options}), however, override everything.
8580 @node Publishing links, Project page index, Publishing options, Configuration
8581 @subsection Links between published files
8582 @cindex links, publishing
8584 To create a link from one Org file to another, you would use
8585 something like @samp{[[file:foo.org][The foo]]} or simply
8586 @samp{file:foo.org.} (@pxref{Hyperlinks}).  Upon publishing this link
8587 becomes a link to @file{foo.html}.  In this way, you can interlink the
8588 pages of your "org web" project and the links will work as expected when
8589 you publish them to HTML.
8591 You may also link to related files, such as images. Provided you are
8592 careful with relative pathnames, and provided you have also configured
8593 @code{org-publish} to upload the related files, these links will work
8594 too. See @ref{Complex example} for an example of this usage.
8596 Sometime an Org file to be published may contain links that are
8597 only valid in your production environment, but not in the publishing
8598 location.  In this case, use the property
8600 @multitable @columnfractions 0.4 0.6
8601 @item @code{:link-validation-function}
8602 @tab Function to validate links
8603 @end multitable
8605 @noindent
8606 to define a function for checking link validity.  This function must
8607 accept two arguments, the file name and a directory relative to which
8608 the file name is interpreted in the production environment.  If this
8609 function returns @code{nil}, then the HTML generator will only insert a
8610 description into the HTML file, but no link.  One option for this
8611 function is @code{org-publish-validate-link} which checks if the given
8612 file is part of any project in @code{org-publish-project-alist}.
8614 @node Project page index,  , Publishing links, Configuration
8615 @subsection Project page index
8616 @cindex index, of published pages
8618 The following properties may be used to control publishing of an
8619 index of files or summary page for a given project.
8621 @multitable @columnfractions 0.25 0.75
8622 @item @code{:auto-index}
8623 @tab When non-nil, publish an index during org-publish-current-project or
8624 org-publish-all.
8626 @item @code{:index-filename}
8627 @tab Filename for output of index. Defaults to @file{index.org} (which
8628 becomes @file{index.html}).
8630 @item @code{:index-title}
8631 @tab Title of index page. Defaults to name of file.
8633 @item @code{:index-function}
8634 @tab Plug-in function to use for generation of index.
8635 Defaults to @code{org-publish-org-index}, which generates a plain list
8636 of links to all files in the project.
8637 @end multitable
8639 @node Sample configuration, Triggering publication, Configuration, Publishing
8640 @section Sample configuration
8642 Below we provide two example configurations.  The first one is a simple
8643 project publishing only a set of Org files.  The second example is
8644 more complex, with a multi-component project.
8646 @menu
8647 * Simple example::              One-component publishing
8648 * Complex example::             A multi-component publishing example
8649 @end menu
8651 @node Simple example, Complex example, Sample configuration, Sample configuration
8652 @subsection Example: simple publishing configuration
8654 This example publishes a set of Org files to the @file{public_html}
8655 directory on the local machine.
8657 @lisp
8658 (setq org-publish-project-alist
8659       '(("org"
8660          :base-directory "~/org/"
8661          :publishing-directory "~/public_html"
8662          :section-numbers nil
8663          :table-of-contents nil
8664          :style "<link rel=\"stylesheet\"
8665                 href=\"../other/mystyle.css\"
8666                 type=\"text/css\">")))
8667 @end lisp
8669 @node Complex example,  , Simple example, Sample configuration
8670 @subsection Example: complex publishing configuration
8672 This more complicated example publishes an entire website, including
8673 org files converted to HTML, image files, emacs lisp source code, and
8674 style sheets. The publishing-directory is remote and private files are
8675 excluded.
8677 To ensure that links are preserved, care should be taken to replicate
8678 your directory structure on the web server, and to use relative file
8679 paths. For example, if your org files are kept in @file{~/org} and your
8680 publishable images in @file{~/images}, you'd link to an image with
8682 @example
8683 file:../images/myimage.png
8684 @end example
8686 On the web server, the relative path to the image should be the
8687 same. You can accomplish this by setting up an "images" folder in the
8688 right place on the web server, and publishing images to it.
8690 @lisp
8691 (setq org-publish-project-alist
8692       '(("orgfiles"
8693           :base-directory "~/org/"
8694           :base-extension "org"
8695           :publishing-directory "/ssh:user@@host:~/html/notebook/"
8696           :publishing-function org-publish-org-to-html
8697           :exclude "PrivatePage.org"   ;; regexp
8698           :headline-levels 3
8699           :section-numbers nil
8700           :table-of-contents nil
8701           :style "<link rel=\"stylesheet\"
8702                   href=\"../other/mystyle.css\" type=\"text/css\">"
8703           :auto-preamble t
8704           :auto-postamble nil)
8706          ("images"
8707           :base-directory "~/images/"
8708           :base-extension "jpg\\|gif\\|png"
8709           :publishing-directory "/ssh:user@@host:~/html/images/"
8710           :publishing-function org-publish-attachment)
8712          ("other"
8713           :base-directory "~/other/"
8714           :base-extension "css\\|el"
8715           :publishing-directory "/ssh:user@@host:~/html/other/"
8716           :publishing-function org-publish-attachment)
8717          ("website" :components ("orgfiles" "images" "other"))))
8718 @end lisp
8720 @node Triggering publication,  , Sample configuration, Publishing
8721 @section Triggering publication
8723 Once org-publish is properly configured, you can publish with the
8724 following functions:
8726 @table @kbd
8727 @item C-c C-e C
8728 Prompt for a specific project and publish all files that belong to it.
8729 @item C-c C-e P
8730 Publish the project containing the current file.
8731 @item C-c C-e F
8732 Publish only the current file.
8733 @item C-c C-e A
8734 Publish all projects.
8735 @end table
8737 Org uses timestamps to track when a file has changed. The above
8738 functions normally only publish changed files. You can override this and
8739 force publishing of all files by giving a prefix argument.
8741 @node Miscellaneous, Extensions, Publishing, Top
8742 @chapter Miscellaneous
8744 @menu
8745 * Completion::                  M-TAB knows what you need
8746 * Customization::               Adapting Org to your taste
8747 * In-buffer settings::          Overview of the #+KEYWORDS
8748 * The very busy C-c C-c key::   When in doubt, press C-c C-c
8749 * Clean view::                  Getting rid of leading stars in the outline
8750 * TTY keys::                    Using Org on a tty
8751 * Interaction::                 Other Emacs packages
8752 * Bugs::                        Things which do not work perfectly
8753 @end menu
8755 @node Completion, Customization, Miscellaneous, Miscellaneous
8756 @section Completion
8757 @cindex completion, of @TeX{} symbols
8758 @cindex completion, of TODO keywords
8759 @cindex completion, of dictionary words
8760 @cindex completion, of option keywords
8761 @cindex completion, of tags
8762 @cindex completion, of property keys
8763 @cindex completion, of link abbreviations
8764 @cindex @TeX{} symbol completion
8765 @cindex TODO keywords completion
8766 @cindex dictionary word completion
8767 @cindex option keyword completion
8768 @cindex tag completion
8769 @cindex link abbreviations, completion of
8771 Org supports in-buffer completion.  This type of completion does
8772 not make use of the minibuffer.  You simply type a few letters into
8773 the buffer and use the key to complete text right there.
8775 @table @kbd
8776 @kindex M-@key{TAB}
8777 @item M-@key{TAB}
8778 Complete word at point
8779 @itemize @bullet
8780 @item
8781 At the beginning of a headline, complete TODO keywords.
8782 @item
8783 After @samp{\}, complete @TeX{} symbols supported by the exporter.
8784 @item
8785 After @samp{*}, complete headlines in the current buffer so that they
8786 can be used in search links like @samp{[[*find this headline]]}.
8787 @item
8788 After @samp{:} in a headline, complete tags.  The list of tags is taken
8789 from the variable @code{org-tag-alist} (possibly set through the
8790 @samp{#+TAGS} in-buffer option, @pxref{Setting tags}), or it is created
8791 dynamically from all tags used in the current buffer.
8792 @item
8793 After @samp{:} and not in a headline, complete property keys.  The list
8794 of keys is constructed dynamically from all keys used in the current
8795 buffer.
8796 @item
8797 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
8798 @item
8799 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
8800 @samp{OPTIONS} which set file-specific options for Org mode.  When the
8801 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
8802 will insert example settings for this keyword.
8803 @item
8804 In the line after @samp{#+STARTUP: }, complete startup keywords,
8805 i.e. valid keys for this line.
8806 @item
8807 Elsewhere, complete dictionary words using Ispell.
8808 @end itemize
8809 @end table
8811 @node Customization, In-buffer settings, Completion, Miscellaneous
8812 @section Customization
8813 @cindex customization
8814 @cindex options, for customization
8815 @cindex variables, for customization
8817 There are more than 180 variables that can be used to customize
8818 Org.  For the sake of compactness of the manual, I am not
8819 describing the variables here.  A structured overview of customization
8820 variables is available with @kbd{M-x org-customize}.  Or select
8821 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
8822 settings can also be activated on a per-file basis, by putting special
8823 lines into the buffer (@pxref{In-buffer settings}).
8825 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
8826 @section Summary of in-buffer settings
8827 @cindex in-buffer settings
8828 @cindex special keywords
8830 Org mode uses special lines in the buffer to define settings on a
8831 per-file basis.  These lines start with a @samp{#+} followed by a
8832 keyword, a colon, and then individual words defining a setting.  Several
8833 setting words can be in the same line, but you can also have multiple
8834 lines for the keyword.  While these settings are described throughout
8835 the manual, here is a summary.  After changing any of those lines in the
8836 buffer, press @kbd{C-c C-c} with the cursor still in the line to
8837 activate the changes immediately.  Otherwise they become effective only
8838 when the file is visited again in a new Emacs session.
8840 @table @kbd
8841 @item #+ARCHIVE: %s_done::
8842 This line sets the archive location for the agenda file.  It applies for
8843 all subsequent lines until the next @samp{#+ARCHIVE} line, or the end
8844 of the file.  The first such line also applies to any entries before it.
8845 The corresponding variable is @code{org-archive-location}.
8846 @item #+CATEGORY:
8847 This line sets the category for the agenda file.  The category applies
8848 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
8849 end of the file.  The first such line also applies to any entries before it.
8850 @item #+COLUMNS: %25ITEM .....
8851 Set the default format for columns view.  This format applies when
8852 columns view is invoked in location where no @code{COLUMNS} property
8853 applies.
8854 @item #+CONSTANTS: name1=value1 ...
8855 Set file-local values for constants to be used in table formulas.  This
8856 line set the local variable @code{org-table-formula-constants-local}.
8857 The global version of this variable is
8858 @code{org-table-formula-constants}.
8859 @item #+FILETAGS: :tag1:tag2:tag3:
8860 Set tags that can be inherited by any entry in the file, including the
8861 top-level entries.
8862 @item #+DRAWERS: NAME1 .....
8863 Set the file-local set of drawers.  The corresponding global variable is
8864 @code{org-drawers}.
8865 @item #+LINK:  linkword replace
8866 These lines (several are allowed) specify link abbreviations.
8867 @xref{Link abbreviations}.  The corresponding variable is
8868 @code{org-link-abbrev-alist}.
8869 @item #+PRIORITIES: highest lowest default
8870 This line sets the limits and the default for the priorities.  All three
8871 must be either letters A-Z or numbers 0-9.  The highest priority must
8872 have a lower ASCII number that the lowest priority.
8873 @item #+PROPERTY: Property_Name Value
8874 This line sets a default inheritance value for entries in the current
8875 buffer, most useful for specifying the allowed values of a property.
8876 @item #+SETUPFILE: file
8877 This line defines a file that holds more in-buffer setup.  Normally this is
8878 entirely ignored.  Only when the buffer is parsed for option-setting lines
8879 (i.e. when starting Org mode for a file, when pressing @kbd{C-c C-c} in a
8880 settings line, or when exporting), then the contents of this file are parsed
8881 as if they had been included in the buffer.  In particular, the file can be
8882 any other Org mode file with internal setup.  You can visit the file the
8883 cursor is in the line with @kbd{C-c '}.
8884 @item #+STARTUP:
8885 This line sets options to be used at startup of Org mode, when an
8886 Org file is being visited.  The first set of options deals with the
8887 initial visibility of the outline tree.  The corresponding variable for
8888 global default settings is @code{org-startup-folded}, with a default
8889 value @code{t}, which means @code{overview}.
8890 @cindex @code{overview}, STARTUP keyword
8891 @cindex @code{content}, STARTUP keyword
8892 @cindex @code{showall}, STARTUP keyword
8893 @example
8894 overview   @r{top-level headlines only}
8895 content    @r{all headlines}
8896 showall    @r{no folding at all, show everything}
8897 @end example
8898 Then there are options for aligning tables upon visiting a file.  This
8899 is useful in files containing narrowed table columns.  The corresponding
8900 variable is @code{org-startup-align-all-tables}, with a default value
8901 @code{nil}.
8902 @cindex @code{align}, STARTUP keyword
8903 @cindex @code{noalign}, STARTUP keyword
8904 @example
8905 align      @r{align all tables}
8906 noalign    @r{don't align tables on startup}
8907 @end example
8908 Logging closing and reinstating TODO items, and clock intervals
8909 (variables @code{org-log-done}, @code{org-log-note-clock-out}, and
8910 @code{org-log-repeat}) can be configured using these options.
8911 @cindex @code{logdone}, STARTUP keyword
8912 @cindex @code{lognotedone}, STARTUP keyword
8913 @cindex @code{nologdone}, STARTUP keyword
8914 @cindex @code{lognoteclock-out}, STARTUP keyword
8915 @cindex @code{nolognoteclock-out}, STARTUP keyword
8916 @cindex @code{logrepeat}, STARTUP keyword
8917 @cindex @code{lognoterepeat}, STARTUP keyword
8918 @cindex @code{nologrepeat}, STARTUP keyword
8919 @example
8920 logdone            @r{record a timestamp when an item is marked DONE}
8921 lognotedone        @r{record timestamp and a note when DONE}
8922 nologdone          @r{don't record when items are marked DONE}
8923 logrepeat          @r{record a time when reinstating a repeating item}
8924 lognoterepeat      @r{record a note when reinstating a repeating item}
8925 nologrepeat        @r{do not record when reinstating repeating item}
8926 lognoteclock-out   @r{record a note when clocking out}
8927 nolognoteclock-out @r{don't record a note when clocking out}
8928 @end example
8929 Here are the options for hiding leading stars in outline headings, and for
8930 indenting outlines.  The corresponding variables are
8931 @code{org-hide-leading-stars} and @code{org-odd-levels-only}, both with a
8932 default setting @code{nil} (meaning @code{showstars} and @code{oddeven}).
8933 @cindex @code{hidestars}, STARTUP keyword
8934 @cindex @code{showstars}, STARTUP keyword
8935 @cindex @code{odd}, STARTUP keyword
8936 @cindex @code{even}, STARTUP keyword
8937 @example
8938 hidestars  @r{make all but one of the stars starting a headline invisible.}
8939 showstars  @r{show all stars starting a headline}
8940 indent     @r{virtual indentation according to outline level}
8941 noindent   @r{no virtual indentation according to outline level}
8942 odd        @r{allow only odd outline levels (1,3,...)}
8943 oddeven    @r{allow all outline levels}
8944 @end example
8945 To turn on custom format overlays over time stamps (variables
8946 @code{org-put-time-stamp-overlays} and
8947 @code{org-time-stamp-overlay-formats}), use
8948 @cindex @code{customtime}, STARTUP keyword
8949 @example
8950 customtime @r{overlay custom time format}
8951 @end example
8952 The following options influence the table spreadsheet (variable
8953 @code{constants-unit-system}).
8954 @cindex @code{constcgs}, STARTUP keyword
8955 @cindex @code{constSI}, STARTUP keyword
8956 @example
8957 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
8958 constSI    @r{@file{constants.el} should use the SI unit system}
8959 @end example
8960 To influence footnote settings, use the following keywords.  The
8961 corresponding variables are @code{org-footnote-define-inline} and
8962 @code{org-footnote-auto-label}.
8963 @cindex @code{fninline}, STARTUP keyword
8964 @cindex @code{fnnoinline}, STARTUP keyword
8965 @cindex @code{fnlocal}, STARTUP keyword
8966 @cindex @code{fnprompt}, STARTUP keyword
8967 @cindex @code{fnauto}, STARTUP keyword
8968 @cindex @code{fnconfirm}, STARTUP keyword
8969 @cindex @code{fnplain}, STARTUP keyword
8970 @example
8971 fninline    @r{define footnotes inline}
8972 fnnoinline  @r{define footnotes in separate section}
8973 fnlocal     @r{define footnotes near first reference, but not inline}
8974 fnprompt    @r{prompt for footnote labels}
8975 fnauto      @r{create [fn:1]-like labels automatically (default)}
8976 fnconfirm   @r{offer automatic label for editing or confirmation}
8977 fnplain     @r{create [1]-like labels automatically}
8978 @end example
8979 @item #+TAGS:  TAG1(c1) TAG2(c2)
8980 These lines (several such lines are allowed) specify the valid tags in
8981 this file, and (potentially) the corresponding @emph{fast tag selection}
8982 keys.  The corresponding variable is @code{org-tag-alist}.
8983 @item #+TBLFM:
8984 This line contains the formulas for the table directly above the line.
8985 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+OPTIONS, #+DATE:
8986 These lines provide settings for exporting files.  For more details see
8987 @ref{Export options}.
8988 @item #+SEQ_TODO:   #+TYP_TODO:
8989 These lines set the TODO keywords and their interpretation in the
8990 current file.  The corresponding variables are @code{org-todo-keywords}
8991 and @code{org-todo-interpretation}.
8992 @end table
8994 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
8995 @section The very busy C-c C-c key
8996 @kindex C-c C-c
8997 @cindex C-c C-c, overview
8999 The key @kbd{C-c C-c} has many purposes in Org, which are all
9000 mentioned scattered throughout this manual.  One specific function of
9001 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
9002 other circumstances it means something like @emph{Hey Org, look
9003 here and update according to what you see here}.  Here is a summary of
9004 what this means in different contexts.
9006 @itemize @minus
9007 @item
9008 If there are highlights in the buffer from the creation of a sparse
9009 tree, or from clock display, remove these highlights.
9010 @item
9011 If the cursor is in one of the special @code{#+KEYWORD} lines, this
9012 triggers scanning the buffer for these lines and updating the
9013 information.
9014 @item
9015 If the cursor is inside a table, realign the table.  This command
9016 works even if the automatic table editor has been turned off.
9017 @item
9018 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
9019 the entire table.
9020 @item
9021 If the cursor is inside a table created by the @file{table.el} package,
9022 activate that table.
9023 @item
9024 If the current buffer is a remember buffer, close the note and file it.
9025 With a prefix argument, file it, without further interaction, to the
9026 default location.
9027 @item
9028 If the cursor is on a @code{<<<target>>>}, update radio targets and
9029 corresponding links in this buffer.
9030 @item
9031 If the cursor is in a property line or at the start or end of a property
9032 drawer, offer property commands.
9033 @item
9034 If the cursor is at a footnote reference, go to the corresponding
9035 definition, and vice versa.
9036 @item
9037 If the cursor is in a plain list item with a checkbox, toggle the status
9038 of the checkbox.
9039 @item
9040 If the cursor is on a numbered item in a plain list, renumber the
9041 ordered list.
9042 @item
9043 If the cursor is on the @code{#+BEGIN} line of a dynamical block, the
9044 block is updated.
9045 @end itemize
9047 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
9048 @section A cleaner outline view
9049 @cindex hiding leading stars
9050 @cindex dynamic indentation
9051 @cindex odd-levels-only outlines
9052 @cindex clean outline view
9054 Some people find it noisy and distracting that the Org headlines are starting
9055 with a potentially large number of stars, and that text below the headlines
9056 is not indented.  This is not really a problem when you are writing a book
9057 where the outline headings are really section headlines.  However, in a more
9058 list-oriented outline, it is clear that an indented structure is a lot
9059 cleaner, as can be seen by comparing the two columns in the following
9060 example:
9062 @example
9063 @group
9064 * Top level headline             |    * Top level headline
9065 ** Second level                  |      * Second level
9066 *** 3rd level                    |        * 3rd level
9067 some text                        |          some text
9068 *** 3rd level                    |        * 3rd level
9069 more text                        |          more text
9070 * Another top level headline     |    * Another top level headline
9071 @end group
9072 @end example
9074 @noindent
9075 It is non-trivial to make such a look work in Emacs, but Org contains three
9076 separate features that, combined, achieve just that.
9078 @enumerate
9079 @item
9080 @emph{Indentation of text below headlines}@*
9081 You may indent text below each headline to make the left boundary line up
9082 with the headline, like
9084 @example
9085 *** 3rd level
9086     more text, now indented
9087 @end example
9089 A good way to get this indentation is by hand, and Org supports this with
9090 paragraph filling, line wrapping, and structure editing@footnote{See also the
9091 variable @code{org-adapt-indentation}.} preserving or adapting the
9092 indentation appropriate.  A different approach would be to have a way to
9093 automatically indent lines according to outline structure by adding overlays
9094 or text properties.  But I have not yet found a robust and efficient way to
9095 do this in large files.
9097 @item
9098 @emph{Hiding leading stars}@* You can modify the display in such a way that
9099 all leading stars become invisible.  To do this in a global way, configure
9100 the variable @code{org-hide-leading-stars} or change this on a per-file basis
9101 with
9103 @example
9104 #+STARTUP: hidestars
9105 @end example
9107 @noindent
9108 Note that the opposite behavior is selected with @code{showstars}.
9110 With hidden stars, the tree becomes:
9112 @example
9113 @group
9114 * Top level headline
9115  * Second level
9116   * 3rd level
9117   ...
9118 @end group
9119 @end example
9121 @noindent
9122 Note that the leading stars are not truly replaced by whitespace, they
9123 are only fontified with the face @code{org-hide} that uses the
9124 background color as font color.  If you are not using either white or
9125 black background, you may have to customize this face to get the wanted
9126 effect.  Another possibility is to set this font such that the extra
9127 stars are @i{almost} invisible, for example using the color
9128 @code{grey90} on a white background.
9130 @item
9131 Things become cleaner still if you skip all the even levels and use only odd
9132 levels 1, 3, 5..., effectively adding two stars to go from one outline level
9133 to the next.  In this way we get the outline view shown at the beginning of
9134 this section.  In order to make the structure editing and export commands
9135 handle this convention correctly, configure the variable
9136 @code{org-odd-levels-only}, or set this on a per-file basis with one of the
9137 following lines:
9139 @example
9140 #+STARTUP: odd
9141 #+STARTUP: oddeven
9142 @end example
9144 You can convert an Org file from single-star-per-level to the
9145 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
9146 RET} in that file.  The reverse operation is @kbd{M-x
9147 org-convert-to-oddeven-levels}.
9148 @end enumerate
9150 @node TTY keys, Interaction, Clean view, Miscellaneous
9151 @section Using Org on a tty
9152 @cindex tty key bindings
9154 Because Org contains a large number of commands, by default much of
9155 Org's core commands are bound to keys that are generally not
9156 accessible on a tty, such as the cursor keys (@key{left}, @key{right},
9157 @key{up}, @key{down}), @key{TAB} and @key{RET}, in particular when used
9158 together with modifiers like @key{Meta} and/or @key{Shift}.  To access
9159 these commands on a tty when special keys are unavailable, the following
9160 alternative bindings can be used.  The tty bindings below will likely be
9161 more cumbersome; you may find for some of the bindings below that a
9162 customized work-around suits you better.  For example, changing a time
9163 stamp is really only fun with @kbd{S-@key{cursor}} keys, whereas on a
9164 tty you would rather use @kbd{C-c .} to re-insert the timestamp.
9166 @multitable @columnfractions 0.15 0.2 0.2
9167 @item @b{Default} @tab @b{Alternative 1} @tab @b{Alternative 2}
9168 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab
9169 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{@key{Esc} @key{left}}
9170 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab
9171 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x i}           @tab @kbd{@key{Esc} @key{right}}
9172 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab
9173 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{@key{Esc} @key{up}}
9174 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab
9175 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{@key{Esc} @key{down}}
9176 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab
9177 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab
9178 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{@key{Esc} @key{RET}}
9179 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab
9180 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab
9181 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab
9182 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab
9183 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab
9184 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab
9185 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab
9186 @end multitable
9188 @node Interaction, Bugs, TTY keys, Miscellaneous
9189 @section Interaction with other packages
9190 @cindex packages, interaction with other
9191 Org lives in the world of GNU Emacs and interacts in various ways
9192 with other code out there.
9194 @menu
9195 * Cooperation::                 Packages Org cooperates with
9196 * Conflicts::                   Packages that lead to conflicts
9197 @end menu
9199 @node Cooperation, Conflicts, Interaction, Interaction
9200 @subsection Packages that Org cooperates with
9202 @table @asis
9203 @cindex @file{calc.el}
9204 @item @file{calc.el} by Dave Gillespie
9205 Org uses the Calc package for implementing spreadsheet
9206 functionality in its tables (@pxref{The spreadsheet}).  Org
9207 checks for the availability of Calc by looking for the function
9208 @code{calc-eval} which should be autoloaded in your setup if Calc has
9209 been installed properly.  As of Emacs 22, Calc is part of the Emacs
9210 distribution.  Another possibility for interaction between the two
9211 packages is using Calc for embedded calculations. @xref{Embedded Mode,
9212 , Embedded Mode, Calc, GNU Emacs Calc Manual}.
9213 @cindex @file{constants.el}
9214 @item @file{constants.el} by Carsten Dominik
9215 In a table formula (@pxref{The spreadsheet}), it is possible to use
9216 names for natural constants or units.  Instead of defining your own
9217 constants in the variable @code{org-table-formula-constants}, install
9218 the @file{constants} package which defines a large number of constants
9219 and units, and lets you use unit prefixes like @samp{M} for
9220 @samp{Mega} etc.  You will need version 2.0 of this package, available
9221 at @url{http://www.astro.uva.nl/~dominik/Tools}. Org checks for
9222 the function @code{constants-get}, which has to be autoloaded in your
9223 setup.  See the installation instructions in the file
9224 @file{constants.el}.
9225 @item @file{cdlatex.el} by Carsten Dominik
9226 @cindex @file{cdlatex.el}
9227 Org mode can make use of the CDLaTeX package to efficiently enter
9228 La@TeX{} fragments into Org files. See @ref{CDLaTeX mode}.
9229 @item @file{imenu.el} by Ake Stenhoff and Lars Lindberg
9230 @cindex @file{imenu.el}
9231 Imenu allows menu access to an index of items in a file.  Org mode
9232 supports Imenu - all you need to do to get the index is the following:
9233 @lisp
9234 (add-hook 'org-mode-hook
9235           (lambda () (imenu-add-to-menubar "Imenu")))
9236 @end lisp
9237 By default the index is two levels deep - you can modify the depth using
9238 the option @code{org-imenu-depth}.
9239 @item @file{remember.el} by John Wiegley
9240 @cindex @file{remember.el}
9241 Org cooperates with remember, see @ref{Remember}.
9242 @file{Remember.el} is not part of Emacs, find it on the web.
9243 @item @file{speedbar.el} by Eric M. Ludlam
9244 @cindex @file{speedbar.el}
9245 Speedbar is a package that creates a special frame displaying files and
9246 index items in files.  Org mode supports Speedbar and allows you to
9247 drill into Org files directly from the Speedbar.  It also allows to
9248 restrict the scope of agenda commands to a file or a subtree by using
9249 the command @kbd{<} in the Speedbar frame.
9250 @cindex @file{table.el}
9251 @item @file{table.el} by Takaaki Ota
9252 @kindex C-c C-c
9253 @cindex table editor, @file{table.el}
9254 @cindex @file{table.el}
9256 Complex ASCII tables with automatic line wrapping, column- and
9257 row-spanning, and alignment can be created using the Emacs table
9258 package by Takaaki Ota (@uref{http://sourceforge.net/projects/table},
9259 and also part of Emacs 22).
9260 When @key{TAB} or @kbd{C-c C-c} is pressed in such a table, Org mode
9261 will call @command{table-recognize-table} and move the cursor into the
9262 table.  Inside a table, the keymap of Org mode is inactive.  In order
9263 to execute Org mode-related commands, leave the table.
9265 @table @kbd
9266 @kindex C-c C-c
9267 @item C-c C-c
9268 Recognize @file{table.el} table.  Works when the cursor is in a
9269 table.el table.
9271 @kindex C-c ~
9272 @item C-c ~
9273 Insert a table.el table.  If there is already a table at point, this
9274 command converts it between the table.el format and the Org mode
9275 format.  See the documentation string of the command
9276 @code{org-convert-table} for the restrictions under which this is
9277 possible.
9278 @end table
9279 @file{table.el} is part of Emacs 22.
9280 @cindex @file{footnote.el}
9281 @item @file{footnote.el} by Steven L. Baur
9282 Org mode recognizes numerical footnotes as provided by this package.
9283 However, Org-mode also has its own footnote support (@pxref{Footnotes}),
9284 which makes using @file{footnote.el} unnecessary.
9285 @end table
9287 @node Conflicts,  , Cooperation, Interaction
9288 @subsection Packages that lead to conflicts with Org mode
9290 @table @asis
9292 @cindex @code{shift-selection-mode}
9293 In Emacs 23, @code{shift-selection-mode} is on by default, meaning that
9294 cursor motions combined with the shift key should start or enlarge regions.
9295 This conflicts with the use of @kbd{S-@key{cursor}} commands in Org to change
9296 timestamps, TODO keywords, priorities, and item bullet types if the cursor is
9297 at such a location.  By default, @kbd{S-@key{cursor}} commands outside
9298 special contexts don't do anything, but you can customize the variable
9299 @code{org-support-shift-select}.  Org-mode then tries to accommodate shift
9300 selection by (i) using it outside of the special contexts where special
9301 commands apply, and by (ii) extending an existing active region even if the
9302 cursor moves across a special context.
9304 @cindex @file{CUA.el}
9305 @item @file{CUA.el} by Kim. F. Storm
9306 Key bindings in Org conflict with the @kbd{S-<cursor>} keys used by CUA mode
9307 (as well as pc-select-mode and s-region-mode) to select and extend the
9308 region.  In fact, Emacs 23 has this built-in in the form of
9309 @code{shift-selection-mode}, see previous paragraph.  If you are using Emacs
9310 23 you probably don't want to use another package for this purpose.  However,
9311 if you prefer to leave these keys to a different package while working in
9312 Org-mode, configure the variable @code{org-replace-disputed-keys}.  When set,
9313 Org will move the following key bindings in Org files, and in the agenda
9314 buffer (but not during date selection).
9316 @example
9317 S-UP      ->  M-p             S-DOWN     ->  M-n
9318 S-LEFT    ->  M--             S-RIGHT    ->  M-+
9319 C-S-LEFT  ->  M-S--           C-S-RIGHT  ->  M-S-+
9320 @end example
9322 Yes, these are unfortunately more difficult to remember.  If you want
9323 to have other replacement keys, look at the variable
9324 @code{org-disputed-keys}.
9326 @item @file{windmove.el} by Hovav Shacham
9327 @cindex @file{windmove.el}
9328 Also this package uses the @kbd{S-<cursor>} keys, so everything written
9329 in the paragraph above about CUA mode also applies here.
9331 @end table
9334 @node Bugs,  , Interaction, Miscellaneous
9335 @section Bugs
9336 @cindex bugs
9338 Here is a list of things that should work differently, but which I
9339 have found too hard to fix.
9341 @itemize @bullet
9342 @item
9343 If a table field starts with a link, and if the corresponding table
9344 column is narrowed (@pxref{Narrow columns}) to a width too small to
9345 display the link, the field would look entirely empty even though it is
9346 not.  To prevent this, Org throws an error.  The work-around is to
9347 make the column wide enough to fit the link, or to add some text (at
9348 least 2 characters) before the link in the same field.
9349 @item
9350 Narrowing table columns does not work on XEmacs, because the
9351 @code{format} function does not transport text properties.
9352 @item
9353 Text in an entry protected with the @samp{QUOTE} keyword should not
9354 autowrap.
9355 @item
9356 When the application called by @kbd{C-c C-o} to open a file link fails
9357 (for example because the application does not exist or refuses to open
9358 the file), it does so silently.  No error message is displayed.
9359 @item
9360 Recalculating a table line applies the formulas from left to right.
9361 If a formula uses @emph{calculated} fields further down the row,
9362 multiple recalculation may be needed to get all fields consistent.  You
9363 may use the command @code{org-table-iterate} (@kbd{C-u C-c *}) to
9364 recalculate until convergence.
9365 @item
9366 The exporters work well, but could be made more efficient.
9367 @end itemize
9370 @node Extensions, Hacking, Miscellaneous, Top
9371 @appendix Extensions
9373 This appendix lists the extension modules that have been written for Org.
9374 Many of these extensions live in the @file{contrib} directory of the Org
9375 distribution, others are available somewhere on the web.
9377 @menu
9378 * Extensions in the contrib directory::  These come with the Org distro
9379 * Other extensions::            These you have to find on the web.
9380 @end menu
9382 @node Extensions in the contrib directory, Other extensions, Extensions, Extensions
9383 @section Extensions in the @file{contrib} directory
9385 A number of extension are distributed with Org when you download it from its
9386 homepage.  Please note that these extensions are @emph{not} distributed as
9387 part of Emacs, so if you use Org as delivered with Emacs, you still need to
9388 go to @url{http://orgmode.org} to get access to these modules.
9390 @table @asis
9391 @item @file{org-annotate-file.el} by @i{Philip Jackson}
9392 Annotate a file with org syntax, in a separate file, with links back to the
9393 annotated file.
9395 @item @file{org-annotation-helper.el} by @i{Bastien Guerry and Daniel E. German}
9396 Call @i{remember} directly from Firefox/Opera, or from Adobe Reader.  When
9397 activating a special link or bookmark, Emacs receives a trigger to create a
9398 note with a link back to the website.  Requires some setup, a detailed
9399 description is in @file{contrib/packages/org-annotation-helper}.
9401 @item @file{org-bookmark.el} by @i{Tokuya Kameshima}
9402 Support for links to Emacs bookmarks.
9404 @item @file{org-depend.el} by @i{Carsten Dominik}
9405 TODO dependencies for Org-mode.  Make TODO state changes in one entry trigger
9406 changes in another, or be blocked by the state of another entry.  Also,
9407 easily create chains of TODO items with exactly one active item at any time.
9409 @item @file{org-elisp-symbol.el} by @i{Bastien Guerry}
9410 Org links to emacs-lisp symbols.  This can create annotated links that
9411 exactly point to the definition location of a variable of function.
9413 @item @file{org-eval.el} by @i{Carsten Dominik}
9414 The @code{<lisp>} tag, adapted from Emacs Wiki and Emacs Muse, allows text to
9415 be included in a document that is the result of evaluating some code.  Other
9416 scripting languages like @code{perl} can be supported with this package as
9417 well.
9419 @item @file{org-eval-light.el} by @i{Eric Schulte}
9420 User-controlled evaluation of code in an Org buffer.
9422 @item @file{org-exp-blocks.el} by @i{Eric Schulte}
9423 Preprocess user-defined blocks for export.
9425 @item @file{org-expiry.el} by @i{Bastien Guerry}
9426 Expiry mechanism for Org entries.
9428 @item @file{org-indent.el} by @i{Carsten Dominik}
9429 Dynamic indentation of Org outlines.  The plan is to indent an outline
9430 according to level, but so far this is too hard for a proper and stable
9431 implementation.  Still, it works somewhat.
9433 @item @file{org-interactive-query.el} by @i{Christopher League}
9434 Interactive modification of tags queries.  After running a general query in
9435 Org, this package allows you to narrow down the results by adding more tags
9436 or keywords.
9438 @item @file{org-mairix.el} by @i{Georg C. F. Greve}
9439 Hook mairix search into Org for different MUAs.
9441 @item @file{org-man.el} by @i{Carsten Dominik}
9442 Support for links to manpages in Org-mode.
9444 @item @file{org-mtags.el} by @i{Carsten Dominik}
9445 Support for some Muse-like tags in Org-mode.  This package allows you to
9446 write @code{<example>} and @code{<src>} and other syntax copied from Emacs
9447 Muse, right inside an Org file.  The goal here is to make it easy to publish
9448 the same file using either org-publish or Muse.
9450 @item @file{org-panel.el} by @i{Lennart Borgman}
9451 Simplified and display-aided access to some Org commands.
9453 @item @file{org-registry.el} by @i{Bastien Guerry}
9454 A registry for Org links, to find out from where links point to a given file
9455 or location.
9457 @item @file{org2rem.el} by @i{Bastien Guerry}
9458 Convert org appointments into reminders for the @file{remind} program.
9460 @item @file{org-screen.el} by @i{Andrew Hyatt}
9461 Visit screen sessions through Org-mode links.
9463 @item @file{org-toc.el} by @i{Bastien Guerry}
9464 Table of contents in a separate buffer, with fast access to sections and easy
9465 visibility cycling.
9467 @item @file{orgtbl-sqlinsert.el} by @i{Jason Riedy}
9468 Convert Org-mode tables to SQL insertions.  Documentation for this can be
9469 found on the Worg pages.
9471 @end table
9473 @node Other extensions,  , Extensions in the contrib directory, Extensions
9474 @section Other extensions
9476 @i{TO BE DONE}
9478 @node Hacking, History and Acknowledgments, Extensions, Top
9479 @appendix Hacking
9481 This appendix covers some aspects where users can extend the functionality of
9482 Org.
9484 @menu
9485 * Adding hyperlink types::      New custom link types
9486 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
9487 * Dynamic blocks::              Automatically filled blocks
9488 * Special agenda views::        Customized views
9489 * Using the property API::      Writing programs that use entry properties
9490 * Using the mapping API::       Mapping over all or selected entries
9491 @end menu
9493 @node Adding hyperlink types, Tables in arbitrary syntax, Hacking, Hacking
9494 @section Adding hyperlink types
9495 @cindex hyperlinks, adding new types
9497 Org has a large number of hyperlink types built-in
9498 (@pxref{Hyperlinks}).  If you would like to add new link types, it
9499 provides an interface for doing so.  Let's look at an example file
9500 @file{org-man.el} that will add support for creating links like
9501 @samp{[[man:printf][The printf manpage]]} to show Unix manual pages inside
9502 emacs:
9504 @lisp
9505 ;;; org-man.el - Support for links to manpages in Org
9507 (require 'org)
9509 (org-add-link-type "man" 'org-man-open)
9510 (add-hook 'org-store-link-functions 'org-man-store-link)
9512 (defcustom org-man-command 'man
9513   "The Emacs command to be used to display a man page."
9514   :group 'org-link
9515   :type '(choice (const man) (const woman)))
9517 (defun org-man-open (path)
9518   "Visit the manpage on PATH.
9519 PATH should be a topic that can be thrown at the man command."
9520   (funcall org-man-command path))
9522 (defun org-man-store-link ()
9523   "Store a link to a manpage."
9524   (when (memq major-mode '(Man-mode woman-mode))
9525     ;; This is a man page, we do make this link
9526     (let* ((page (org-man-get-page-name))
9527            (link (concat "man:" page))
9528            (description (format "Manpage for %s" page)))
9529       (org-store-link-props
9530        :type "man"
9531        :link link
9532        :description description))))
9534 (defun org-man-get-page-name ()
9535   "Extract the page name from the buffer name."
9536   ;; This works for both `Man-mode' and `woman-mode'.
9537   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
9538       (match-string 1 (buffer-name))
9539     (error "Cannot create link to this man page")))
9541 (provide 'org-man)
9543 ;;; org-man.el ends here
9544 @end lisp
9546 @noindent
9547 You would activate this new link type in @file{.emacs} with
9549 @lisp
9550 (require 'org-man)
9551 @end lisp
9553 @noindent
9554 Let's go through the file and see what it does.
9555 @enumerate
9556 @item
9557 It does @code{(require 'org)} to make sure that @file{org.el} has been
9558 loaded.
9559 @item
9560 The next line calls @code{org-add-link-type} to define a new link type
9561 with prefix @samp{man}.  The call also contains the name of a function
9562 that will be called to follow such a link.
9563 @item
9564 The next line adds a function to @code{org-store-link-functions}, in
9565 order to allow the command @kbd{C-c l} to record a useful link in a
9566 buffer displaying a man page.
9567 @end enumerate
9569 The rest of the file defines the necessary variables and functions.
9570 First there is a customization variable that determines which emacs
9571 command should be used to display man pages.  There are two options,
9572 @code{man} and @code{woman}.  Then the function to follow a link is
9573 defined.  It gets the link path as an argument - in this case the link
9574 path is just a topic for the manual command.  The function calls the
9575 value of @code{org-man-command} to display the man page.
9577 Finally the function @code{org-man-store-link} is defined.  When you try
9578 to store a link with @kbd{C-c l}, also this function will be called to
9579 try to make a link.  The function must first decide if it is supposed to
9580 create the link for this buffer type, we do this by checking the value
9581 of the variable @code{major-mode}.  If not, the function must exit and
9582 return the value @code{nil}.  If yes, the link is created by getting the
9583 manual topic from the buffer name and prefixing it with the string
9584 @samp{man:}.  Then it must call the command @code{org-store-link-props}
9585 and set the @code{:type} and @code{:link} properties.  Optionally you
9586 can also set the @code{:description} property to provide a default for
9587 the link description when the link is later inserted into an Org
9588 buffer with @kbd{C-c C-l}.
9590 @node Tables in arbitrary syntax, Dynamic blocks, Adding hyperlink types, Hacking
9591 @section Tables and lists in arbitrary syntax
9592 @cindex tables, in other modes
9593 @cindex lists, in other modes
9594 @cindex Orgtbl mode
9596 Since Orgtbl mode can be used as a minor mode in arbitrary buffers, a
9597 frequent feature request has been to make it work with native tables in
9598 specific languages, for example La@TeX{}.  However, this is extremely
9599 hard to do in a general way, would lead to a customization nightmare,
9600 and would take away much of the simplicity of the Orgtbl mode table
9601 editor.
9604 This appendix describes a different approach.  We keep the Orgtbl mode
9605 table in its native format (the @i{source table}), and use a custom
9606 function to @i{translate} the table to the correct syntax, and to
9607 @i{install} it in the right location (the @i{target table}).  This puts
9608 the burden of writing conversion functions on the user, but it allows
9609 for a very flexible system.
9611 Bastien added the ability to do the same with lists.  You can use Org's
9612 facilities to edit and structure lists by turning @code{orgstruct-mode}
9613 on, then locally exporting such lists in another format (HTML, La@TeX{}
9614 or Texinfo.)
9617 @menu
9618 * Radio tables::                Sending and receiving
9619 * A LaTeX example::             Step by step, almost a tutorial
9620 * Translator functions::        Copy and modify
9621 * Radio lists::                 Doing the same for lists
9622 @end menu
9624 @node Radio tables, A LaTeX example, Tables in arbitrary syntax, Tables in arbitrary syntax
9625 @subsection Radio tables
9626 @cindex radio tables
9628 To define the location of the target table, you first need to create two
9629 lines that are comments in the current mode, but contain magic words for
9630 Orgtbl mode to find.  Orgtbl mode will insert the translated table
9631 between these lines, replacing whatever was there before.  For example:
9633 @example
9634 /* BEGIN RECEIVE ORGTBL table_name */
9635 /* END RECEIVE ORGTBL table_name */
9636 @end example
9638 @noindent
9639 Just above the source table, we put a special line that tells
9640 Orgtbl mode how to translate this table and where to install it.  For
9641 example:
9642 @example
9643 #+ORGTBL: SEND table_name translation_function arguments....
9644 @end example
9646 @noindent
9647 @code{table_name} is the reference name for the table that is also used
9648 in the receiver lines. @code{translation_function} is the Lisp function
9649 that does the translation.  Furthermore, the line can contain a list of
9650 arguments (alternating key and value) at the end.  The arguments will be
9651 passed as a property list to the translation function for
9652 interpretation.  A few standard parameters are already recognized and
9653 acted upon before the translation function is called:
9655 @table @code
9656 @item :skip N
9657 Skip the first N lines of the table.  Hlines do count as separate lines for
9658 this parameter!
9660 @item :skipcols (n1 n2 ...)
9661 List of columns that should be skipped.  If the table has a column with
9662 calculation marks, that column is automatically discarded as well.
9663 Please note that the translator function sees the table @emph{after} the
9664 removal of these columns, the function never knows that there have been
9665 additional columns.
9666 @end table
9668 @noindent
9669 The one problem remaining is how to keep the source table in the buffer
9670 without disturbing the normal workings of the file, for example during
9671 compilation of a C file or processing of a La@TeX{} file.  There are a
9672 number of different solutions:
9674 @itemize @bullet
9675 @item
9676 The table could be placed in a block comment if that is supported by the
9677 language.  For example, in C mode you could wrap the table between
9678 @samp{/*} and @samp{*/} lines.
9679 @item
9680 Sometimes it is possible to put the table after some kind of @i{END}
9681 statement, for example @samp{\bye} in TeX and @samp{\end@{document@}}
9682 in La@TeX{}.
9683 @item
9684 You can just comment the table line by line whenever you want to process
9685 the file, and uncomment it whenever you need to edit the table.  This
9686 only sounds tedious - the command @kbd{M-x orgtbl-toggle-comment} does
9687 make this comment-toggling very easy, in particular if you bind it to a
9688 key.
9689 @end itemize
9691 @node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
9692 @subsection A LaTeX example of radio tables
9693 @cindex LaTeX, and Orgtbl mode
9695 The best way to wrap the source table in La@TeX{} is to use the
9696 @code{comment} environment provided by @file{comment.sty}.  It has to be
9697 activated by placing @code{\usepackage@{comment@}} into the document
9698 header.  Orgtbl mode can insert a radio table skeleton@footnote{By
9699 default this works only for La@TeX{}, HTML, and Texinfo.  Configure the
9700 variable @code{orgtbl-radio-tables} to install templates for other
9701 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
9702 be prompted for a table name, let's say we use @samp{salesfigures}.  You
9703 will then get the following template:
9705 @cindex #+ORGTBL: SEND
9706 @example
9707 % BEGIN RECEIVE ORGTBL salesfigures
9708 % END RECEIVE ORGTBL salesfigures
9709 \begin@{comment@}
9710 #+ORGTBL: SEND salesfigures orgtbl-to-latex
9711 | | |
9712 \end@{comment@}
9713 @end example
9715 @noindent
9716 The @code{#+ORGTBL: SEND} line tells Orgtbl mode to use the function
9717 @code{orgtbl-to-latex} to convert the table into La@TeX{} and to put it
9718 into the receiver location with name @code{salesfigures}.  You may now
9719 fill in the table, feel free to use the spreadsheet features@footnote{If
9720 the @samp{#+TBLFM} line contains an odd number of dollar characters,
9721 this may cause problems with font-lock in LaTeX mode.  As shown in the
9722 example you can fix this by adding an extra line inside the
9723 @code{comment} environment that is used to balance the dollar
9724 expressions.  If you are using AUCTeX with the font-latex library, a
9725 much better solution is to add the @code{comment} environment to the
9726 variable @code{LaTeX-verbatim-environments}.}:
9728 @example
9729 % BEGIN RECEIVE ORGTBL salesfigures
9730 % END RECEIVE ORGTBL salesfigures
9731 \begin@{comment@}
9732 #+ORGTBL: SEND salesfigures orgtbl-to-latex
9733 | Month | Days | Nr sold | per day |
9734 |-------+------+---------+---------|
9735 | Jan   |   23 |      55 |     2.4 |
9736 | Feb   |   21 |      16 |     0.8 |
9737 | March |   22 |     278 |    12.6 |
9738 #+TBLFM: $4=$3/$2;%.1f
9739 % $ (optional extra dollar to keep font-lock happy, see footnote)
9740 \end@{comment@}
9741 @end example
9743 @noindent
9744 When you are done, press @kbd{C-c C-c} in the table to get the converted
9745 table inserted between the two marker lines.
9747 Now let's assume you want to make the table header by hand, because you
9748 want to control how columns are aligned etc.  In this case we make sure
9749 that the table translator does skip the first 2 lines of the source
9750 table, and tell the command to work as a @i{splice}, i.e. to not produce
9751 header and footer commands of the target table:
9753 @example
9754 \begin@{tabular@}@{lrrr@}
9755 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
9756 % BEGIN RECEIVE ORGTBL salesfigures
9757 % END RECEIVE ORGTBL salesfigures
9758 \end@{tabular@}
9760 \begin@{comment@}
9761 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
9762 | Month | Days | Nr sold | per day |
9763 |-------+------+---------+---------|
9764 | Jan   |   23 |      55 |     2.4 |
9765 | Feb   |   21 |      16 |     0.8 |
9766 | March |   22 |     278 |    12.6 |
9767 #+TBLFM: $4=$3/$2;%.1f
9768 \end@{comment@}
9769 @end example
9771 The La@TeX{} translator function @code{orgtbl-to-latex} is already part of
9772 Orgtbl mode.  It uses a @code{tabular} environment to typeset the table
9773 and marks horizontal lines with @code{\hline}.  Furthermore, it
9774 interprets the following parameters (see also @ref{Translator functions}):
9776 @table @code
9777 @item :splice nil/t
9778 When set to t, return only table body lines, don't wrap them into a
9779 tabular environment.  Default is nil.
9781 @item :fmt fmt
9782 A format to be used to wrap each field, should contain @code{%s} for the
9783 original field value.  For example, to wrap each field value in dollars,
9784 you could use @code{:fmt "$%s$"}.  This may also be a property list with
9785 column numbers and formats. for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
9786 A function of one argument can be used in place of the strings; the
9787 function must return a formatted string.
9789 @item :efmt efmt
9790 Use this format to print numbers with exponentials.  The format should
9791 have @code{%s} twice for inserting mantissa and exponent, for example
9792 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
9793 may also be a property list with column numbers and formats, for example
9794 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
9795 @code{efmt} has been applied to a value, @code{fmt} will also be
9796 applied.  Similar to @code{fmt}, functions of two arguments can be
9797 supplied instead of strings.
9798 @end table
9800 @node Translator functions, Radio lists, A LaTeX example, Tables in arbitrary syntax
9801 @subsection Translator functions
9802 @cindex HTML, and Orgtbl mode
9803 @cindex translator function
9805 Orgtbl mode has several translator functions built-in: @code{orgtbl-to-csv}
9806 (comma-separated values), @code{orgtbl-to-tsv} (TAB-separated values)
9807 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and @code{orgtbl-to-texinfo}.
9808 Except for @code{orgtbl-to-html}@footnote{The HTML translator uses the same
9809 code that produces tables during HTML export.}, these all use a generic
9810 translator, @code{orgtbl-to-generic}.  For example, @code{orgtbl-to-latex}
9811 itself is a very short function that computes the column definitions for the
9812 @code{tabular} environment, defines a few field and line separators and then
9813 hands over to the generic translator.  Here is the entire code:
9815 @lisp
9816 @group
9817 (defun orgtbl-to-latex (table params)
9818   "Convert the Orgtbl mode TABLE to LaTeX."
9819   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
9820                                org-table-last-alignment ""))
9821          (params2
9822           (list
9823            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
9824            :tend "\\end@{tabular@}"
9825            :lstart "" :lend " \\\\" :sep " & "
9826            :efmt "%s\\,(%s)" :hline "\\hline")))
9827     (orgtbl-to-generic table (org-combine-plists params2 params))))
9828 @end group
9829 @end lisp
9831 As you can see, the properties passed into the function (variable
9832 @var{PARAMS}) are combined with the ones newly defined in the function
9833 (variable @var{PARAMS2}).  The ones passed into the function (i.e. the
9834 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
9835 would like to use the La@TeX{} translator, but wanted the line endings to
9836 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
9837 overrule the default with
9839 @example
9840 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
9841 @end example
9843 For a new language, you can either write your own converter function in
9844 analogy with the La@TeX{} translator, or you can use the generic function
9845 directly.  For example, if you have a language where a table is started
9846 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
9847 started with @samp{!BL!}, ended with @samp{!EL!} and where the field
9848 separator is a TAB, you could call the generic translator like this (on
9849 a single line!):
9851 @example
9852 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
9853                               :lstart "!BL! " :lend " !EL!" :sep "\t"
9854 @end example
9856 @noindent
9857 Please check the documentation string of the function
9858 @code{orgtbl-to-generic} for a full list of parameters understood by
9859 that function and remember that you can pass each of them into
9860 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
9861 using the generic function.
9863 Of course you can also write a completely new function doing complicated
9864 things the generic translator cannot do.  A translator function takes
9865 two arguments.  The first argument is the table, a list of lines, each
9866 line either the symbol @code{hline} or a list of fields.  The second
9867 argument is the property list containing all parameters specified in the
9868 @samp{#+ORGTBL: SEND} line.  The function must return a single string
9869 containing the formatted table.  If you write a generally useful
9870 translator, please post it on @code{emacs-orgmode@@gnu.org} so that
9871 others can benefit from your work.
9873 @node  Radio lists,  , Translator functions, Tables in arbitrary syntax
9874 @subsection Radio lists
9875 @cindex radio lists
9876 @cindex org-list-insert-radio-list
9878 Sending and receiving radio lists works exactly the same way than
9879 sending and receiving radio tables (@pxref{Radio tables}) @footnote{You
9880 need to load the @code{org-export-latex.el} package to use radio lists
9881 since the relevant code is there for now.}.  As for radio tables, you
9882 can insert radio lists templates in HTML, La@TeX{} and Texinfo modes by
9883 calling @code{org-list-insert-radio-list}.
9885 Here are the differences with radio tables:
9887 @itemize @minus
9888 @item
9889 Use @code{ORGLST} instead of @code{ORGTBL}.
9890 @item
9891 The available translation functions for radio lists don't take
9892 parameters.
9893 @item
9894 `C-c C-c' will work when pressed on the first item of the list.
9895 @end itemize
9897 Here is a La@TeX{} example.  Let's say that you have this in your
9898 La@TeX{} file:
9900 @example
9901 % BEGIN RECEIVE ORGLST to-buy
9902 % END RECEIVE ORGLST to-buy
9903 \begin@{comment@}
9904 #+ORGLIST: SEND to-buy orgtbl-to-latex
9905 - a new house
9906 - a new computer
9907   + a new keyboard
9908   + a new mouse
9909 - a new life
9910 \end@{comment@}
9911 @end example
9913 Pressing `C-c C-c' on @code{a new house} and will insert the converted
9914 La@TeX{} list between the two marker lines.
9916 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Hacking
9917 @section Dynamic blocks
9918 @cindex dynamic blocks
9920 Org documents can contain @emph{dynamic blocks}.  These are
9921 specially marked regions that are updated by some user-written function.
9922 A good example for such a block is the clock table inserted by the
9923 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
9925 Dynamic block are enclosed by a BEGIN-END structure that assigns a name
9926 to the block and can also specify parameters for the function producing
9927 the content of the block.
9929 #+BEGIN:dynamic block
9930 @example
9931 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
9933 #+END:
9934 @end example
9936 Dynamic blocks are updated with the following commands
9938 @table @kbd
9939 @kindex C-c C-x C-u
9940 @item C-c C-x C-u
9941 Update dynamic block at point.
9942 @kindex C-u C-c C-x C-u
9943 @item C-u C-c C-x C-u
9944 Update all dynamic blocks in the current file.
9945 @end table
9947 Updating a dynamic block means to remove all the text between BEGIN and
9948 END, parse the BEGIN line for parameters and then call the specific
9949 writer function for this block to insert the new content.  If you want
9950 to use the original content in the writer function, you can use the
9951 extra parameter @code{:content}.
9953 For a block with name @code{myblock}, the writer function is
9954 @code{org-dblock-write:myblock} with as only parameter a property list
9955 with the parameters given in the begin line.  Here is a trivial example
9956 of a block that keeps track of when the block update function was last
9957 run:
9959 @example
9960 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
9962 #+END:
9963 @end example
9965 @noindent
9966 The corresponding block writer function could look like this:
9968 @lisp
9969 (defun org-dblock-write:block-update-time (params)
9970    (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
9971      (insert "Last block update at: "
9972              (format-time-string fmt (current-time)))))
9973 @end lisp
9975 If you want to make sure that all dynamic blocks are always up-to-date,
9976 you could add the function @code{org-update-all-dblocks} to a hook, for
9977 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
9978 written in a way that is does nothing in buffers that are not in
9979 @code{org-mode}.
9981 @node Special agenda views, Using the property API, Dynamic blocks, Hacking
9982 @section Special agenda views
9983 @cindex agenda views, user-defined
9985 Org provides a special hook that can be used to narrow down the
9986 selection made by any of the agenda views.  You may specify a function
9987 that is used at each match to verify if the match should indeed be part
9988 of the agenda view, and if not, how much should be skipped.
9990 Let's say you want to produce a list of projects that contain a WAITING
9991 tag anywhere in the project tree.  Let's further assume that you have
9992 marked all tree headings that define a project with the TODO keyword
9993 PROJECT.  In this case you would run a TODO search for the keyword
9994 PROJECT, but skip the match unless there is a WAITING tag anywhere in
9995 the subtree belonging to the project line.
9997 To achieve this, you must write a function that searches the subtree for
9998 the tag.  If the tag is found, the function must return @code{nil} to
9999 indicate that this match should not be skipped.  If there is no such
10000 tag, return the location of the end of the subtree, to indicate that
10001 search should continue from there.
10003 @lisp
10004 (defun my-skip-unless-waiting ()
10005   "Skip trees that are not waiting"
10006   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
10007     (if (re-search-forward ":waiting:" subtree-end t)
10008         nil          ; tag found, do not skip
10009       subtree-end))) ; tag not found, continue after end of subtree
10010 @end lisp
10012 Now you may use this function in an agenda custom command, for example
10013 like this:
10015 @lisp
10016 (org-add-agenda-custom-command
10017  '("b" todo "PROJECT"
10018    ((org-agenda-skip-function 'my-skip-unless-waiting)
10019     (org-agenda-overriding-header "Projects waiting for something: "))))
10020 @end lisp
10022 Note that this also binds @code{org-agenda-overriding-header} to get a
10023 meaningful header in the agenda view.
10025 A general way to create custom searches is to base them on a search for
10026 entries with a certain level limit.  If you want to study all entries with
10027 your custom search function, simply do a search for @samp{LEVEL>0}, and then
10028 use @code{org-agenda-skip-function} to select the entries you really want to
10029 have.
10031 You may also put a Lisp form into @code{org-agenda-skip-function}.  In
10032 particular, you may use the functions @code{org-agenda-skip-entry-if}
10033 and @code{org-agenda-skip-subtree-if} in this form, for example:
10035 @table @code
10036 @item '(org-agenda-skip-entry-if 'scheduled)
10037 Skip current entry if it has been scheduled.
10038 @item '(org-agenda-skip-entry-if 'notscheduled)
10039 Skip current entry if it has not been scheduled.
10040 @item '(org-agenda-skip-entry-if 'deadline)
10041 Skip current entry if it has a deadline.
10042 @item '(org-agenda-skip-entry-if 'scheduled 'deadline)
10043 Skip current entry if it has a deadline, or if it is scheduled.
10044 @item '(org-agenda-skip-entry 'regexp "regular expression")
10045 Skip current entry if the regular expression matches in the entry.
10046 @item '(org-agenda-skip-entry 'notregexp "regular expression")
10047 Skip current entry unless the regular expression matches.
10048 @item '(org-agenda-skip-subtree-if 'regexp "regular expression")
10049 Same as above, but check and skip the entire subtree.
10050 @end table
10052 Therefore we could also have written the search for WAITING projects
10053 like this, even without defining a special function:
10055 @lisp
10056 (org-add-agenda-custom-command
10057  '("b" todo "PROJECT"
10058    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
10059                                 'regexp ":waiting:"))
10060     (org-agenda-overriding-header "Projects waiting for something: "))))
10061 @end lisp
10063 @node Using the property API, Using the mapping API, Special agenda views, Hacking
10064 @section Using the property API
10065 @cindex API, for properties
10066 @cindex properties, API
10068 Here is a description of the functions that can be used to work with
10069 properties.
10071 @defun org-entry-properties &optional pom which
10072 Get all properties of the entry at point-or-marker POM.
10073 This includes the TODO keyword, the tags, time strings for deadline,
10074 scheduled, and clocking, and any additional properties defined in the
10075 entry.  The return value is an alist, keys may occur multiple times
10076 if the property key was used several times.
10077 POM may also be nil, in which case the current entry is used.
10078 If WHICH is nil or `all', get all properties.  If WHICH is
10079 `special' or `standard', only get that subclass.
10080 @end defun
10081 @defun org-entry-get pom property &optional inherit
10082 Get value of PROPERTY for entry at point-or-marker POM.  By default,
10083 this only looks at properties defined locally in the entry.  If INHERIT
10084 is non-nil and the entry does not have the property, then also check
10085 higher levels of the hierarchy.  If INHERIT is the symbol
10086 @code{selective}, use inheritance if and only if the setting of
10087 @code{org-use-property-inheritance} selects PROPERTY for inheritance.
10088 @end defun
10090 @defun org-entry-delete pom property
10091 Delete the property PROPERTY from entry at point-or-marker POM.
10092 @end defun
10094 @defun org-entry-put pom property value
10095 Set PROPERTY to VALUE for entry at point-or-marker POM.
10096 @end defun
10098 @defun org-buffer-property-keys &optional include-specials
10099 Get all property keys in the current buffer.
10100 @end defun
10102 @defun org-insert-property-drawer
10103 Insert a property drawer at point.
10104 @end defun
10106 @defun org-entry-put-multivalued-property pom property &rest values
10107 Set PROPERTY at point-or-marker POM to VALUES.  VALUES should be a list of
10108 strings.  They will be concatenated, with spaces as separators.
10109 @end defun
10111 @defun org-entry-get-multivalued-property pom property
10112 Treat the value of the property PROPERTY as a whitespace-separated list of
10113 values and return the values as a list of strings.
10114 @end defun
10116 @defun org-entry-add-to-multivalued-property pom property value
10117 Treat the value of the property PROPERTY as a whitespace-separated list of
10118 values and make sure that VALUE is in this list.
10119 @end defun
10121 @defun org-entry-remove-from-multivalued-property pom property value
10122 Treat the value of the property PROPERTY as a whitespace-separated list of
10123 values and make sure that VALUE is @emph{not} in this list.
10124 @end defun
10126 @defun org-entry-member-in-multivalued-property pom property value
10127 Treat the value of the property PROPERTY as a whitespace-separated list of
10128 values and check if VALUE is in this list.
10129 @end defun
10131 @node Using the mapping API,  , Using the property API, Hacking
10132 @section Using the mapping API
10133 @cindex API, for mapping
10134 @cindex mapping entries, API
10136 Org has sophisticated mapping capabilities to find all entries satisfying
10137 certain criteria.  Internally, this functionality is used to produce agenda
10138 views, but there is also an API that can be used to execute arbitrary
10139 functions for each or selected entries.  The main entry point for this API
10142 @defun org-map-entries func &optional match scope &rest skip
10143 Call FUNC at each headline selected by MATCH in SCOPE.
10145 FUNC is a function or a lisp form.  The function will be called without
10146 arguments, with the cursor positioned at the beginning of the headline.
10147 The return values of all calls to the function will be collected and
10148 returned as a list.
10150 MATCH is a tags/property/todo match as it is used in the agenda match view.
10151 Only headlines that are matched by this query will be considered during
10152 the iteration.  When MATCH is nil or t, all headlines will be
10153 visited by the iteration.
10155 SCOPE determines the scope of this command.  It can be any of:
10157 @example
10158 nil     @r{the current buffer, respecting the restriction if any}
10159 tree    @r{the subtree started with the entry at point}
10160 file    @r{the current buffer, without restriction}
10161 file-with-archives
10162         @r{the current buffer, and any archives associated with it}
10163 agenda  @r{all agenda files}
10164 agenda-with-archives
10165         @r{all agenda files with any archive files associated with them}
10166 (file1 file2 ...)
10167         @r{if this is a list, all files in the list will be scanned}
10168 @end example
10170 The remaining args are treated as settings for the skipping facilities of
10171 the scanner.  The following items can be given here:
10173 @example
10174 archive   @r{skip trees with the archive tag}
10175 comment   @r{skip trees with the COMMENT keyword}
10176 function or Lisp form
10177           @r{will be used as value for @code{org-agenda-skip-function},}
10178           @r{so whenever the the function returns t, FUNC}
10179           @r{will not be called for that entry and search will}
10180           @r{continue from the point where the function leaves it}
10181 @end example
10182 @end defun
10184 The function given to that mapping routine can really do anything you like.
10185 It can use the property API (@pxref{Using the property API}) to gather more
10186 information about the entry, or in order to change metadata in the entry.
10187 Here are a couple of functions that might be handy:
10189 @defun org-todo &optional arg
10190 Change the TODO state of the entry, see the docstring of the functions for
10191 the many possible values for the argument ARG.
10192 @end defun
10194 @defun org-priority &optional action
10195 Change the priority of the entry, see the docstring of this function for the
10196 possible values for ACTION.
10197 @end defun
10199 @defun org-toggle-tag tag &optional onoff
10200 Toggle the tag TAG in the current entry.  Setting ONOFF to either @code{on}
10201 or @code{off} will not toggle tag, but ensure that it is either on or off.
10202 @end defun
10204 @defun org-promote
10205 Promote the current entry.
10206 @end defun
10208 @defun org-demote
10209 Demote the current entry.
10210 @end defun
10212 Here is a simple example that will turn all entries in the current file with
10213 a tag @code{TOMORROW} into TODO entries with the keyword @code{UPCOMING}.
10214 Entries in comment trees and in archive trees will be ignored.
10216 @lisp
10217 (org-map-entries
10218    '(org-todo "UPCOMING")
10219    "+TOMORROW" 'file 'archive 'comment)
10220 @end lisp
10222 The following example counts the number of entries with TODO keyword
10223 @code{WAITING}, in all agenda files.
10225 @lisp
10226 (length (org-map-entries t "/+WAITING" 'agenda))
10227 @end lisp
10229 @node History and Acknowledgments, Main Index, Hacking, Top
10230 @appendix History and Acknowledgments
10231 @cindex acknowledgments
10232 @cindex history
10233 @cindex thanks
10235 Org was borne in 2003, out of frustration over the user interface
10236 of the Emacs Outline mode.  I was trying to organize my notes and
10237 projects, and using Emacs seemed to be the natural way to go.  However,
10238 having to remember eleven different commands with two or three keys per
10239 command, only to hide and show parts of the outline tree, that seemed
10240 entirely unacceptable to me.  Also, when using outlines to take notes, I
10241 constantly want to restructure the tree, organizing it parallel to my
10242 thoughts and plans.  @emph{Visibility cycling} and @emph{structure
10243 editing} were originally implemented in the package
10244 @file{outline-magic.el}, but quickly moved to the more general
10245 @file{org.el}.  As this environment became comfortable for project
10246 planning, the next step was adding @emph{TODO entries}, basic @emph{time
10247 stamps}, and @emph{table support}.  These areas highlight the two main
10248 goals that Org still has today: To create a new, outline-based,
10249 plain text mode with innovative and intuitive editing features, and to
10250 incorporate project planning functionality directly into a notes file.
10252 A special thanks goes to @i{Bastien Guerry} who has not only written a large
10253 number of extensions to Org (most of them integrated into the core by now),
10254 but has also helped the development and maintenance of Org so much that he
10255 should be considered co-author of this package.
10257 Since the first release, literally thousands of emails to me or on
10258 @code{emacs-orgmode@@gnu.org} have provided a constant stream of bug
10259 reports, feedback, new ideas, and sometimes patches and add-on code.
10260 Many thanks to everyone who has helped to improve this package.  I am
10261 trying to keep here a list of the people who had significant influence
10262 in shaping one or more aspects of Org.  The list may not be
10263 complete, if I have forgotten someone, please accept my apologies and
10264 let me know.
10266 @itemize @bullet
10268 @item
10269 @i{Russel Adams} came up with the idea for drawers.
10270 @item
10271 @i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}.
10272 @item
10273 @i{Christophe Bataillon} created the great unicorn logo that we use on the
10274 Org-mode website.
10275 @item
10276 @i{Alex Bochannek} provided a patch for rounding time stamps.
10277 @item
10278 @i{Charles Cave}'s suggestion sparked the implementation of templates
10279 for Remember.
10280 @item
10281 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
10282 specified time.
10283 @item
10284 @i{Gregory Chernov} patched support for lisp forms into table
10285 calculations and improved XEmacs compatibility, in particular by porting
10286 @file{nouline.el} to XEmacs.
10287 @item
10288 @i{Sacha Chua} suggested to copy some linking code from Planner.
10289 @item
10290 @i{Eddward DeVilla} proposed and tested checkbox statistics.  He also
10291 came up with the idea of properties, and that there should be an API for
10292 them.
10293 @item
10294 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
10295 inspired some of the early development, including HTML export.  He also
10296 asked for a way to narrow wide table columns.
10297 @item
10298 @i{Christian Egli} converted the documentation into Texinfo format,
10299 patched CSS formatting into the HTML exporter, and inspired the agenda.
10300 @item
10301 @i{David Emery} provided a patch for custom CSS support in exported
10302 HTML agendas.
10303 @item
10304 @i{Nic Ferrier} contributed mailcap and XOXO support.
10305 @item
10306 @i{Miguel A. Figueroa-Villanueva} implemented hierarchical checkboxes.
10307 @item
10308 @i{John Foerch} figured out how to make incremental search show context
10309 around a match in a hidden outline tree.
10310 @item
10311 @i{Niels Giesen} had the idea to automatically archive DONE trees.
10312 @item
10313 @i{Bastien Guerry} wrote the La@TeX{} exporter and @file{org-bibtex.el}, and
10314 has been prolific with patches, ideas, and bug reports.
10315 @item
10316 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
10317 @item
10318 @i{Bernt Hansen} has driven much of the support for auto-repeating tasks,
10319 task state change logging, and the clocktable.  His clear explanations have
10320 been critical when we started to adopt the GIT version control system.
10321 @item
10322 @i{Manuel Hermenegildo} has contributed various ideas, small fixed and
10323 patches.
10324 @item
10325 @i{Phil Jackson} wrote @file{org-irc.el}.
10326 @item
10327 @i{Scott Jaderholm} proposed footnotes, control over whitespace between
10328 folded entries, and column view for properties.
10329 @item
10330 @i{Tokuya Kameshima} wrote @file{org-wl.el} and @file{org-mew.el}.
10331 @item
10332 @i{Shidai Liu} ("Leo") asked for embedded La@TeX{} and tested it.  He also
10333 provided frequent feedback and some patches.
10334 @item
10335 @i{Matt Lundin} has proposed last-row references for table formulas and named
10336 invisible anchors.  He has also worked a lot on the FAQ.
10337 @item
10338 @i{Jason F. McBrayer} suggested agenda export to CSV format.
10339 @item
10340 @i{Max Mikhanosha} came up with the idea of refiling.
10341 @item
10342 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
10343 basis.
10344 @item
10345 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
10346 happy.
10347 @item
10348 @i{Rick Moynihan} proposed to allow multiple TODO sequences in a file
10349 and to be able to quickly restrict the agenda to a subtree.
10350 @item
10351 @i{Todd Neal} provided patches for links to Info files and elisp forms.
10352 @item
10353 @i{Tim O'Callaghan} suggested in-file links, search options for general
10354 file links, and TAGS.
10355 @item
10356 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
10357 into Japanese.
10358 @item
10359 @i{Oliver Oppitz} suggested multi-state TODO items.
10360 @item
10361 @i{Scott Otterson} sparked the introduction of descriptive text for
10362 links, among other things.
10363 @item
10364 @i{Pete Phillips} helped during the development of the TAGS feature, and
10365 provided frequent feedback.
10366 @item
10367 @i{T.V. Raman} reported bugs and suggested improvements.
10368 @item
10369 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
10370 control.
10371 @item
10372 @i{Paul Rivier} provided the basic implementation of named footnotes.
10373 @item
10374 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
10375 @item
10376 @i{Sebastian Rose} wrote @file{org-info.js}, a Java script for displaying
10377 webpages derived from Org using an Info-like, or a folding interface with
10378 single key navigation.
10379 @item
10380 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
10381 conflict with @file{allout.el}.
10382 @item
10383 @i{Jason Riedy} generalized the send-receive mechanism for orgtbl tables with
10384 extensive patches.
10385 @item
10386 @i{Philip Rooke} created the Org reference card, provided lots
10387 of feedback, developed and applied standards to the Org documentation.
10388 @item
10389 @i{Christian Schlauer} proposed angular brackets around links, among
10390 other things.
10391 @item
10392 @i{Eric Schulte} wrote @file{org-plot.el}.
10393 @item
10394 Linking to VM/BBDB/Gnus was first inspired by @i{Tom Shannon}'s
10395 @file{organizer-mode.el}.
10396 @item
10397 @i{Ilya Shlyakhter} proposed the Archive Sibling, line numbering in literal
10398 examples, and remote highlighting for referenced code lines.
10399 @item
10400 @i{Stathis Sideris} wrote the @file{ditaa.jar} ASCII to PNG converter that is
10401 now packaged into Org's @file{contrib} directory.
10402 @item
10403 @i{Daniel Sinder} came up with the idea of internal archiving by locking
10404 subtrees.
10405 @item
10406 @i{Dale Smith} proposed link abbreviations.
10407 @item
10408 @i{James TD Smith} has contributed a large number of patches for useful
10409 tweaks and features.
10410 @item
10411 @i{Adam Spiers} asked for global linking commands, inspired the link
10412 extension system, added support for mairix, and proposed the mapping API.
10413 @item
10414 @i{Andy Stewart} contributed code to @file{org-w3m.el}, to copy HTML content
10415 with links transformation to Org syntax.
10416 @item
10417 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
10418 chapter about publishing.
10419 @item
10420 @i{J@"urgen Vollmer} contributed code generating the table of contents
10421 in HTML output.
10422 @item
10423 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
10424 keyword.
10425 @item
10426 @i{David Wainberg} suggested archiving, and improvements to the linking
10427 system.
10428 @item
10429 @i{John Wiegley} wrote @file{emacs-wiki.el}, @file{planner.el}, and
10430 @file{muse.el}, which have similar goals as Org.  Initially the
10431 development of Org was fully independent because I was not aware of the
10432 existence of these packages.  But with time I have occasionally looked
10433 at John's code and learned a lot from it.  John has also contributed a
10434 number of great ideas and patches directly to Org, including the attachment
10435 system (@file{org-attach.el}) and integration with Apple Mail
10436 (@file{org-mac-message.el}).
10437 @item
10438 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
10439 linking to Gnus.
10440 @item
10441 @i{Roland Winkler} requested additional key bindings to make Org
10442 work on a tty.
10443 @item
10444 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
10445 and contributed various ideas and code snippets.
10446 @end itemize
10449 @node Main Index, Key Index, History and Acknowledgments, Top
10450 @unnumbered The Main Index
10452 @printindex cp
10454 @node Key Index,  , Main Index, Top
10455 @unnumbered Key Index
10457 @printindex ky
10459 @bye
10461 @ignore
10462         arch-tag: 7893d1Fe-cc57-4d13-b5e5-f494a1CBC7ac
10463 @end ignore
10465 @c Local variables:
10466 @c ispell-local-dictionary: "en_US-w_accents"
10467 @c ispell-local-pdict: "./.aspell.org.pws"
10468 @c fill-column: 77
10469 @c End: