Minor fixes.
[org-mode.git] / doc / org.texi
blob10fb22ddf4f8d729eccec8c271cf7eed4f26ddc8
1 925\input texinfo
2 @c %**start of header
3 @setfilename ../../info/org
4 @settitle The Org Manual
6 @set VERSION 6.08-pre01
7 @set DATE September 2008
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 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.2 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 * Remember::                    Quickly adding nodes to the outline tree
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 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 * Orgstruct mode::              Structure editing outside Org
126 Archiving
128 * ARCHIVE tag::                 Marking a tree as inactive
129 * Moving subtrees::             Moving a tree to an archive file
131 Tables
133 * Built-in table editor::       Simple tables
134 * Narrow columns::              Stop wasting space in tables
135 * Column groups::               Grouping to trigger vertical lines
136 * Orgtbl mode::                 The table editor as minor mode
137 * The spreadsheet::             The table editor has spreadsheet capabilities
139 The spreadsheet
141 * References::                  How to refer to another field or range
142 * Formula syntax for Calc::     Using Calc to compute stuff
143 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
144 * Field formulas::              Formulas valid for a single field
145 * Column formulas::             Formulas valid for an entire column
146 * Editing and debugging formulas::  Fixing formulas
147 * Updating the table::          Recomputing all dependent fields
148 * Advanced features::           Field names, parameters and automatic recalc
150 Hyperlinks
152 * Link format::                 How links in Org are formatted
153 * Internal links::              Links to other places in the current file
154 * External links::              URL-like links to the world
155 * Handling links::              Creating, inserting and following
156 * Using links outside Org::     Linking from my C source code?
157 * Link abbreviations::          Shortcuts for writing complex links
158 * Search options::              Linking to a specific location
159 * Custom searches::             When the default search is not enough
161 Internal links
163 * Radio targets::               Make targets trigger links in plain text
165 TODO Items
167 * TODO basics::                 Marking and displaying TODO entries
168 * TODO extensions::             Workflow and assignments
169 * Progress logging::            Dates and notes for progress
170 * Priorities::                  Some things are more important than others
171 * Breaking down tasks::         Splitting a task into manageable pieces
172 * Checkboxes::                  Tick-off lists
174 Extended use of TODO keywords
176 * Workflow states::             From TODO to DONE in steps
177 * TODO types::                  I do this, Fred does the rest
178 * Multiple sets in one file::   Mixing it all, and still finding your way
179 * Fast access to TODO states::  Single letter selection of a state
180 * Per-file keywords::           Different files, different requirements
181 * Faces for TODO keywords::     Highlighting states
183 Progress logging
185 * Closing items::               When was this entry marked DONE?
186 * Tracking TODO state changes::  When did the status change?
188 Tags
190 * Tag inheritance::             Tags use the tree structure of the outline
191 * Setting tags::                How to assign tags to a headline
192 * Tag searches::                Searching for combinations of tags
194 Properties and Columns
196 * Property syntax::             How properties are spelled out
197 * Special properties::          Access to other Org mode features
198 * Property searches::           Matching property values
199 * Property inheritance::        Passing values down the tree
200 * Column view::                 Tabular viewing and editing
201 * Property API::                Properties for Lisp programmers
203 Column view
205 * Defining columns::            The COLUMNS format property
206 * Using column view::           How to create and use column view
207 * Capturing column view::       A dynamic block for column view
209 Defining columns
211 * Scope of column definitions::  Where defined, where valid?
212 * Column attributes::           Appearance and content of a column
214 Dates and Times
216 * Timestamps::                  Assigning a time to a tree entry
217 * Creating timestamps::         Commands which insert timestamps
218 * Deadlines and scheduling::    Planning your work
219 * Clocking work time::          Tracking how long you spend on a task
220 * Effort estimates::            Planning work effort in advance
222 Creating timestamps
224 * The date/time prompt::        How Org mode helps you entering date and time
225 * Custom time format::          Making dates look different
227 Deadlines and scheduling
229 * Inserting deadline/schedule::  Planning items
230 * Repeated tasks::              Items that show up again and again
232 Remember
234 * Setting up Remember::         Some code for .emacs to get things going
235 * Remember templates::          Define the outline of different note types
236 * Storing notes::               Directly get the note to where it belongs
237 * Refiling notes::              Moving a note or task to a project
239 Agenda Views
241 * Agenda files::                Files being searched for agenda information
242 * Agenda dispatcher::           Keyboard access to agenda views
243 * Built-in agenda views::       What is available out of the box?
244 * Presentation and sorting::    How agenda items are prepared for display
245 * Agenda commands::             Remote editing of Org trees
246 * Custom agenda views::         Defining special searches and views
247 * Agenda column view::          Using column view for collected entries
249 The built-in agenda views
251 * Weekly/daily agenda::         The calendar page with current tasks
252 * Global TODO list::            All unfinished action items
253 * Matching tags and properties::  Structured information with fine-tuned search
254 * Timeline::                    Time-sorted view for single file
255 * Keyword search::              Finding entries by keyword
256 * Stuck projects::              Find projects you need to review
258 Presentation and sorting
260 * Categories::                  Not all tasks are equal
261 * Time-of-day specifications::  How the agenda knows the time
262 * Sorting of agenda items::     The order of things
264 Custom agenda views
266 * Storing searches::            Type once, use often
267 * Block agenda::                All the stuff you need in a single buffer
268 * Setting Options::             Changing the rules
269 * Exporting Agenda Views::      Writing agendas to files
270 * Using the agenda elsewhere::  Using agenda information in other programs
272 Embedded LaTeX
274 * Math symbols::                TeX macros for symbols and Greek letters
275 * Subscripts and superscripts::  Simple syntax for raising/lowering text
276 * LaTeX fragments::             Complex formulas made easy
277 * Processing LaTeX fragments::  Previewing LaTeX processing
278 * CDLaTeX mode::                Speed up entering of formulas
280 Exporting
282 * Markup rules::                Which structures are recognized?
283 * Selective export::            Using tags to select and exclude trees
284 * Export options::              Per-file export settings
285 * The export dispatcher::       How to access exporter commands
286 * ASCII export::                Exporting to plain ASCII
287 * HTML export::                 Exporting to HTML
288 * LaTeX export::                Exporting to LaTeX
289 * XOXO export::                 Exporting to XOXO
290 * iCalendar export::            Exporting in iCalendar format
292 Markup rules
294 * Document title::              How the document title is determined
295 * Headings and sections::       The main structure of the exported document
296 * Table of contents::           If, where, how to create a table of contents
297 * Initial text::                Text before the first headline
298 * Lists::                       Plain lists are exported
299 * Paragraphs::                  What determines beginning and ending
300 * Literal examples::            Source code and other examples
301 * Include files::               Include the contents of a file during export
302 * Tables exported::             Tables are exported richly
303 * Footnotes::                   Numbers like [1]
304 * Emphasis and monospace::      To bold or not to bold
305 * TeX macros and LaTeX fragments::  Create special, rich export.
306 * Horizontal rules::            A line across the page
307 * Comment lines::               Some lines will not be exported
309 HTML export
311 * HTML Export commands::        How to invoke HTML export
312 * Quoting HTML tags::           Using direct HTML in Org mode
313 * Links::                       Transformation of links for HTML
314 * Images::                      How to include images
315 * CSS support::                 Changing the appearance of the output
316 * Javascript support::          Info and Folding in a web browser
318 LaTeX export
320 * LaTeX export commands::       How to invoke LaTeX export
321 * Quoting LaTeX code::          Incorporating literal LaTeX code
322 * Sectioning structure::        Changing sectioning in LaTeX output
324 Publishing
326 * Configuration::               Defining projects
327 * Sample configuration::        Example projects
328 * Triggering publication::      Publication commands
330 Configuration
332 * Project alist::               The central configuration variable
333 * Sources and destinations::    From here to there
334 * Selecting files::             What files are part of the project?
335 * Publishing action::           Setting the function doing the publishing
336 * Publishing options::          Tweaking HTML export
337 * Publishing links::            Which links keep working after publishing?
338 * Project page index::          Publishing a list of project files
340 Sample configuration
342 * Simple example::              One-component publishing
343 * Complex example::             A multi-component publishing example
345 Miscellaneous
347 * Completion::                  M-TAB knows what you need
348 * Customization::               Adapting Org to your taste
349 * In-buffer settings::          Overview of the #+KEYWORDS
350 * The very busy C-c C-c key::   When in doubt, press C-c C-c
351 * Clean view::                  Getting rid of leading stars in the outline
352 * TTY keys::                    Using Org on a tty
353 * Interaction::                 Other Emacs packages
354 * Bugs::                        Things which do not work perfectly
356 Interaction with other packages
358 * Cooperation::                 Packages Org cooperates with
359 * Conflicts::                   Packages that lead to conflicts
361 Extensions
363 * Extensions in the contrib directory::  These come with the Org distro
364 * Other extensions::            These you have to find on the web.
366 Hacking
368 * Adding hyperlink types::      New custom link types
369 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
370 * Dynamic blocks::              Automatically filled blocks
371 * Special agenda views::        Customized views
372 * Using the property API::      Writing programs that use entry properties
373 * Using the mapping API::       Mapping over all or selected entries
375 Tables and lists in arbitrary syntax
377 * Radio tables::                Sending and receiving
378 * A LaTeX example::             Step by step, almost a tutorial
379 * Translator functions::        Copy and modify
380 * Radio lists::                 Doing the same for lists
382 @end detailmenu
383 @end menu
385 @node Introduction, Document Structure, Top, Top
386 @chapter Introduction
387 @cindex introduction
389 @menu
390 * Summary::                     Brief summary of what Org does
391 * Installation::                How to install a downloaded version of Org
392 * Activation::                  How to activate Org for certain buffers
393 * Feedback::                    Bug reports, ideas, patches etc.
394 * Conventions::                 Type-setting conventions in the manual
395 @end menu
397 @node Summary, Installation, Introduction, Introduction
398 @section Summary
399 @cindex summary
401 Org is a mode for keeping notes, maintaining TODO lists, and doing
402 project planning with a fast and effective plain-text system.
404 Org develops organizational tasks around NOTES files that contain
405 lists or information about projects as plain text.  Org is
406 implemented on top of Outline mode, which makes it possible to keep the
407 content of large files well structured.  Visibility cycling and
408 structure editing help to work with the tree.  Tables are easily created
409 with a built-in table editor.  Org supports TODO items, deadlines,
410 time stamps, and scheduling.  It dynamically compiles entries into an
411 agenda that utilizes and smoothly integrates much of the Emacs calendar
412 and diary.  Plain text URL-like links connect to websites, emails,
413 Usenet messages, BBDB entries, and any files related to the projects.
414 For printing and sharing of notes, an Org file can be exported as a
415 structured ASCII file, as HTML, or (TODO and agenda items only) as an
416 iCalendar file.  It can also serve as a publishing tool for a set of
417 linked web pages.
419 An important design aspect that distinguishes Org from for example
420 Planner/Muse is that it encourages to store every piece of information
421 only once.  In Planner, you have project pages, day pages and possibly
422 other files, duplicating some information such as tasks.  In Org,
423 you only have notes files.  In your notes you mark entries as tasks,
424 label them with tags and timestamps.  All necessary lists like a
425 schedule for the day, the agenda for a meeting, tasks lists selected by
426 tags etc are created dynamically when you need them.
428 Org keeps simple things simple.  When first fired up, it should
429 feel like a straightforward, easy to use outliner.  Complexity is not
430 imposed, but a large amount of functionality is available when you need
431 it.  Org is a toolbox and can be used in different ways, for
432 example as:
434 @example
435 @r{@bullet{} outline extension with visibility cycling and structure editing}
436 @r{@bullet{} ASCII system and table editor for taking structured notes}
437 @r{@bullet{} ASCII table editor with spreadsheet-like capabilities}
438 @r{@bullet{} TODO list editor}
439 @r{@bullet{} full agenda and planner with deadlines and work scheduling}
440 @r{@bullet{} environment to implement David Allen's GTD system}
441 @r{@bullet{} a basic database application}
442 @r{@bullet{} simple hypertext system, with HTML and LaTeX export}
443 @r{@bullet{} publishing tool to create a set of interlinked webpages}
444 @end example
446 Org's automatic, context sensitive table editor with spreadsheet
447 capabilities can be integrated into any major mode by activating the
448 minor Orgtbl mode.  Using a translation step, it can be used to maintain
449 tables in arbitrary file types, for example in La@TeX{}.  The structure
450 editing and list creation capabilities can be used outside Org with
451 the minor Orgstruct mode.
453 @cindex FAQ
454 There is a website for Org which provides links to the newest
455 version of Org, as well as additional information, frequently asked
456 questions (FAQ), links to tutorials etc.  This page is located at
457 @uref{http://orgmode.org}.
459 @page
462 @node Installation, Activation, Summary, Introduction
463 @section Installation
464 @cindex installation
465 @cindex XEmacs
467 @b{Important:} @i{If Org is part of the Emacs distribution or an
468 XEmacs package, please skip this section and go directly to
469 @ref{Activation}.}
471 If you have downloaded Org from the Web, either as a distribution @file{.zip}
472 or @file{.tar} file, or as a GIT archive, you must take the following steps
473 to install it: Go into the unpacked Org distribution directory and edit the
474 top section of the file @file{Makefile}.  You must set the name of the Emacs
475 binary (likely either @file{emacs} or @file{xemacs}), and the paths to the
476 directories where local Lisp and Info files are kept.  If you don't have
477 access to the system-wide directories, you can simply run Org directly from
478 the distribution directory by adding the @file{lisp} subdirectory to the
479 Emacs load path.  To do this, add the following line to @file{.emacs}:
481 @example
482 (setq load-path (cons "~/path/to/orgdir/lisp" load-path))
483 @end example
485 @noindent
486 If you plan to use code from the @file{contrib} subdirectory, do a similar
487 step for this directory:
489 @example
490 (setq load-path (cons "~/path/to/orgdir/contrib/lisp" load-path))
491 @end example
493 @b{XEmacs users now need to install the file @file{noutline.el} from
494 the @file{xemacs} sub-directory of the Org distribution.  Use the
495 command:}
497 @example
498 @b{make install-noutline}
499 @end example
501 @noindent Now byte-compile the Lisp files with the shell command:
503 @example
504 make
505 @end example
507 @noindent If you are running Org from the distribution directory, this is
508 all.  If you want to install into the system directories, use
510 @example
511 make install
512 make install-info
513 @end example
515 @noindent Then add to @file{.emacs}:
517 @lisp
518 ;; This line only if Org is not part of the X/Emacs distribution.
519 (require 'org-install)
520 @end lisp
523 @node Activation, Feedback, Installation, Introduction
524 @section Activation
525 @cindex activation
526 @cindex autoload
527 @cindex global key bindings
528 @cindex key bindings, global
530 @iftex
531 @b{Important:} @i{If you use copy-and-paste to copy lisp code from the
532 PDF documentation as viewed by some PDF viewers to your .emacs file, the
533 single quote character comes out incorrectly and the code will not work.
534 You need to fix the single quotes by hand, or copy from Info
535 documentation.}
536 @end iftex
538 Add the following lines to your @file{.emacs} file.  The last two lines
539 define @emph{global} keys for the commands @command{org-store-link},
540 @command{org-agenda}, and @command{org-iswitchb} - please choose suitable
541 keys yourself.
543 @lisp
544 ;; The following lines are always needed.  Choose your own keys.
545 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
546 (global-set-key "\C-cl" 'org-store-link)
547 (global-set-key "\C-ca" 'org-agenda)
548 (global-set-key "\C-cb" 'org-iswitchb)
549 @end lisp
551 Furthermore, you must activate @code{font-lock-mode} in Org
552 buffers, because significant functionality depends on font-locking being
553 active.  You can do this with either one of the following two lines
554 (XEmacs user must use the second option):
555 @lisp
556 (global-font-lock-mode 1)                     ; for all buffers
557 (add-hook 'org-mode-hook 'turn-on-font-lock)  ; Org buffers only
558 @end lisp
560 @cindex Org mode, turning on
561 With this setup, all files with extension @samp{.org} will be put
562 into Org mode.  As an alternative, make the first line of a file look
563 like this:
565 @example
566 MY PROJECTS    -*- mode: org; -*-
567 @end example
569 @noindent which will select Org mode for this buffer no matter what
570 the file's name is.  See also the variable
571 @code{org-insert-mode-line-in-empty-file}.
573 @node Feedback, Conventions, Activation, Introduction
574 @section Feedback
575 @cindex feedback
576 @cindex bug reports
577 @cindex maintainer
578 @cindex author
580 If you find problems with Org, or if you have questions, remarks, or ideas
581 about it, please mail to the Org mailing list @code{emacs-orgmode@@gnu.org}.
582 If you are not a member of the mailing list, your mail will be reviewed by a
583 moderator and then passed through to the list.
585 For bug reports, please provide as much information as possible,
586 including the version information of Emacs (@kbd{C-h v emacs-version
587 @key{RET}}) and Org (@kbd{C-h v org-version @key{RET}}), as well as
588 the Org related setup in @file{.emacs}.  If an error occurs, a
589 backtrace can be very useful (see below on how to create one).  Often a
590 small example file helps, along with clear information about:
592 @enumerate
593 @item What exactly did you do?
594 @item What did you expect to happen?
595 @item What happened instead?
596 @end enumerate
597 @noindent Thank you for helping to improve this mode.
599 @subsubheading How to create a useful backtrace
601 @cindex backtrace of an error
602 If working with Org produces an error with a message you don't
603 understand, you may have hit a bug.  The best way to report this is by
604 providing, in addition to what was mentioned above, a @emph{Backtrace}.
605 This is information from the built-in debugger about where and how the
606 error occurred.  Here is how to produce a useful backtrace:
608 @enumerate
609 @item
610 Start a fresh Emacs or XEmacs, and make sure that it will load the
611 original Lisp code in @file{org.el} instead of the compiled version in
612 @file{org.elc}.  The backtrace contains much more information if it is
613 produced with uncompiled code.  To do this, either rename @file{org.elc}
614 to something else before starting Emacs, or ask Emacs explicitly to load
615 @file{org.el} by using the command line
616 @example
617 emacs -l /path/to/org.el
618 @end example
619 @item
620 Go to the @code{Options} menu and select @code{Enter Debugger on Error}
621 (XEmacs has this option in the @code{Troubleshooting} sub-menu).
622 @item
623 Do whatever you have to do to hit the error.  Don't forget to
624 document the steps you take.
625 @item
626 When you hit the error, a @file{*Backtrace*} buffer will appear on the
627 screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
628 attach it to your bug report.
629 @end enumerate
631 @node Conventions,  , Feedback, Introduction
632 @section Typesetting conventions used in this manual
634 Org uses three types of keywords: TODO keywords, tags, and property
635 names.  In this manual we use the following conventions:
637 @table @code
638 @item TODO
639 @itemx WAITING
640 TODO keywords are written with all capitals, even if they are
641 user-defined.
642 @item boss
643 @itemx ARCHIVE
644 User-defined tags are written in lowercase; built-in tags with special
645 meaning are written with all capitals.
646 @item Release
647 @itemx PRIORITY
648 User-defined properties are capitalized; built-in properties with
649 special meaning are written with all capitals.
650 @end table
652 @node Document Structure, Tables, Introduction, Top
653 @chapter Document Structure
654 @cindex document structure
655 @cindex structure of document
657 Org is based on outline mode and provides flexible commands to
658 edit the structure of the document.
660 @menu
661 * Outlines::                    Org is based on Outline mode
662 * Headlines::                   How to typeset Org tree headlines
663 * Visibility cycling::          Show and hide, much simplified
664 * Motion::                      Jumping to other headlines
665 * Structure editing::           Changing sequence and level of headlines
666 * Archiving::                   Move done task trees to a different place
667 * Sparse trees::                Matches embedded in context
668 * Plain lists::                 Additional structure within an entry
669 * Drawers::                     Tucking stuff away
670 * Orgstruct mode::              Structure editing outside Org
671 @end menu
673 @node Outlines, Headlines, Document Structure, Document Structure
674 @section Outlines
675 @cindex outlines
676 @cindex Outline mode
678 Org is implemented on top of Outline mode.  Outlines allow a
679 document to be organized in a hierarchical structure, which (at least
680 for me) is the best representation of notes and thoughts.  An overview
681 of this structure is achieved by folding (hiding) large parts of the
682 document to show only the general document structure and the parts
683 currently being worked on.  Org greatly simplifies the use of
684 outlines by compressing the entire show/hide functionality into a single
685 command @command{org-cycle}, which is bound to the @key{TAB} key.
687 @node Headlines, Visibility cycling, Outlines, Document Structure
688 @section Headlines
689 @cindex headlines
690 @cindex outline tree
692 Headlines define the structure of an outline tree.  The headlines in
693 Org start with one or more stars, on the left margin@footnote{See
694 the variable @code{org-special-ctrl-a/e} to configure special behavior
695 of @kbd{C-a} and @kbd{C-e} in headlines.}.  For example:
697 @example
698 * Top level headline
699 ** Second level
700 *** 3rd level
701     some text
702 *** 3rd level
703     more text
705 * Another top level headline
706 @end example
708 @noindent Some people find the many stars too noisy and would prefer an
709 outline that has whitespace followed by a single star as headline
710 starters.  @ref{Clean view} describes a setup to realize this.
712 An empty line after the end of a subtree is considered part of it and
713 will be hidden when the subtree is folded.  However, if you leave at
714 least two empty lines, one empty line will remain visible after folding
715 the subtree, in order to structure the collapsed view.  See the
716 variable @code{org-cycle-separator-lines} to modify this behavior.
718 @node Visibility cycling, Motion, Headlines, Document Structure
719 @section Visibility cycling
720 @cindex cycling, visibility
721 @cindex visibility cycling
722 @cindex trees, visibility
723 @cindex show hidden text
724 @cindex hide text
726 Outlines make it possible to hide parts of the text in the buffer.
727 Org uses just two commands, bound to @key{TAB} and
728 @kbd{S-@key{TAB}} to change the visibility in the buffer.
730 @cindex subtree visibility states
731 @cindex subtree cycling
732 @cindex folded, subtree visibility state
733 @cindex children, subtree visibility state
734 @cindex subtree, subtree visibility state
735 @table @kbd
736 @kindex @key{TAB}
737 @item @key{TAB}
738 @emph{Subtree cycling}: Rotate current subtree among the states
740 @example
741 ,-> FOLDED -> CHILDREN -> SUBTREE --.
742 '-----------------------------------'
743 @end example
745 The cursor must be on a headline for this to work@footnote{see, however,
746 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
747 beginning of the buffer and the first line is not a headline, then
748 @key{TAB} actually runs global cycling (see below)@footnote{see the
749 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
750 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
752 @cindex global visibility states
753 @cindex global cycling
754 @cindex overview, global visibility state
755 @cindex contents, global visibility state
756 @cindex show all, global visibility state
757 @kindex S-@key{TAB}
758 @item S-@key{TAB}
759 @itemx C-u @key{TAB}
760 @emph{Global cycling}: Rotate the entire buffer among the states
762 @example
763 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
764 '--------------------------------------'
765 @end example
767 When @kbd{S-@key{TAB}} is called with a numeric prefix argument N, the
768 CONTENTS view up to headlines of level N will be shown.  Note that inside
769 tables, @kbd{S-@key{TAB}} jumps to the previous field.
771 @cindex show all, command
772 @kindex C-c C-a
773 @item C-c C-a
774 Show all.
775 @kindex C-c C-r
776 @item C-c C-r
777 Reveal context around point, showing the current entry, the following heading
778 and the hierarchy above.  Useful for working near a location that has been
779 exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda command
780 (@pxref{Agenda commands}).  With a prefix argument show, on each
781 level, all sibling headings.
782 @kindex C-c C-x b
783 @item C-c C-x b
784 Show the current subtree in an indirect buffer@footnote{The indirect
785 buffer
786 @ifinfo
787 (@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
788 @end ifinfo
789 @ifnotinfo
790 (see the Emacs manual for more information about indirect buffers)
791 @end ifnotinfo
792 will contain the entire buffer, but will be narrowed to the current
793 tree.  Editing the indirect buffer will also change the original buffer,
794 but without affecting visibility in that buffer.}.  With a numeric
795 prefix argument N, go up to level N and then take that tree.  If N is
796 negative then go up that many levels.  With a @kbd{C-u} prefix, do not remove
797 the previously used indirect buffer.
798 @end table
800 When Emacs first visits an Org file, the global state is set to
801 OVERVIEW, i.e. only the top level headlines are visible.  This can be
802 configured through the variable @code{org-startup-folded}, or on a
803 per-file basis by adding one of the following lines anywhere in the
804 buffer:
806 @example
807 #+STARTUP: overview
808 #+STARTUP: content
809 #+STARTUP: showall
810 @end example
812 @noindent
813 Forthermore, any entries with a @samp{VISIBILITY} property (@pxref{Properties
814 and Columns}) will get their visibility adapted accordingly.  Allowed values
815 for this property are @code{folded}, @code{children}, @code{content}, and
816 @code{all}.
817 @table @kbd
818 @kindex C-u C-u @key{TAB}
819 @item C-u C-u @key{TAB}
820 Switch back to the startup visibility of the buffer, i.e. whatever is
821 requested by startup options and @samp{VISIBILITY} properties in individual
822 entries.
823 @end table
825 @node Motion, Structure editing, Visibility cycling, Document Structure
826 @section Motion
827 @cindex motion, between headlines
828 @cindex jumping, to headlines
829 @cindex headline navigation
830 The following commands jump to other headlines in the buffer.
832 @table @kbd
833 @kindex C-c C-n
834 @item C-c C-n
835 Next heading.
836 @kindex C-c C-p
837 @item C-c C-p
838 Previous heading.
839 @kindex C-c C-f
840 @item C-c C-f
841 Next heading same level.
842 @kindex C-c C-b
843 @item C-c C-b
844 Previous heading same level.
845 @kindex C-c C-u
846 @item C-c C-u
847 Backward to higher level heading.
848 @kindex C-c C-j
849 @item C-c C-j
850 Jump to a different place without changing the current outline
851 visibility.  Shows the document structure in a temporary buffer, where
852 you can use the following keys to find your destination:
853 @example
854 @key{TAB}         @r{Cycle visibility.}
855 @key{down} / @key{up}   @r{Next/previous visible headline.}
856 n / p        @r{Next/previous visible headline.}
857 f / b        @r{Next/previous headline same level.}
858 u            @r{One level up.}
859 0-9          @r{Digit argument.}
860 @key{RET}         @r{Select this location.}
861 @end example
862 @end table
864 @node Structure editing, Archiving, Motion, Document Structure
865 @section Structure editing
866 @cindex structure editing
867 @cindex headline, promotion and demotion
868 @cindex promotion, of subtrees
869 @cindex demotion, of subtrees
870 @cindex subtree, cut and paste
871 @cindex pasting, of subtrees
872 @cindex cutting, of subtrees
873 @cindex copying, of subtrees
874 @cindex subtrees, cut and paste
876 @table @kbd
877 @kindex M-@key{RET}
878 @item M-@key{RET}
879 Insert new heading with same level as current.  If the cursor is in a
880 plain list item, a new item is created (@pxref{Plain lists}).  To force
881 creation of a new headline, use a prefix argument, or first press @key{RET}
882 to get to the beginning of the next line.  When this command is used in
883 the middle of a line, the line is split and the rest of the line becomes
884 the new headline@footnote{If you do not want the line to be split,
885 customize the variable @code{org-M-RET-may-split-line}.}.  If the
886 command is used at the beginning of a headline, the new headline is
887 created before the current line.  If at the beginning of any other line,
888 the content of that line is made the new heading.  If the command is
889 used at the end of a folded subtree (i.e. behind the ellipses at the end
890 of a headline), then a headline like the current one will be inserted
891 after the end of the subtree.
892 @kindex C-@key{RET}
893 @item C-@key{RET}
894 Just like @kbd{M-@key{RET}}, but if the heading is inserted after the current,
895 insert it actually after the entire subtree.
896 @kindex M-S-@key{RET}
897 @item M-S-@key{RET}
898 Insert new TODO entry with same level as current heading.
899 @kindex C-S-@key{RET}
900 @item C-S-@key{RET}
901 Insert new TODO entry with same level as current heading.  Like
902 @kbd{C-@key{RET}}, the new headline will be inserted after the current
903 subtree.
904 @kindex M-@key{left}
905 @item M-@key{left}
906 Promote current heading by one level.
907 @kindex M-@key{right}
908 @item M-@key{right}
909 Demote current heading by one level.
910 @kindex M-S-@key{left}
911 @item M-S-@key{left}
912 Promote the current subtree by one level.
913 @kindex M-S-@key{right}
914 @item M-S-@key{right}
915 Demote the current subtree by one level.
916 @kindex M-S-@key{up}
917 @item M-S-@key{up}
918 Move subtree up (swap with previous subtree of same
919 level).
920 @kindex M-S-@key{down}
921 @item M-S-@key{down}
922 Move subtree down (swap with next subtree of same level).
923 @kindex C-c C-x C-w
924 @kindex C-c C-x C-k
925 @item C-c C-x C-w
926 @itemx C-c C-x C-k
927 Kill subtree, i.e. remove it from buffer but save in kill ring.
928 With a numeric prefix argument N, kill N sequential subtrees.
929 @kindex C-c C-x M-w
930 @item C-c C-x M-w
931 Copy subtree to kill ring.  With a numeric prefix argument N, copy the N
932 sequential subtrees.
933 @kindex C-c C-x C-y
934 @item C-c C-x C-y
935 Yank subtree from kill ring.  This does modify the level of the subtree to
936 make sure the tree fits in nicely at the yank position.  The yank level can
937 also be specified with a numeric prefix argument, or by yanking after a
938 headline marker like @samp{****}.
939 @kindex C-c C-w
940 @item C-c C-w
941 Refile entry to a different location.  @xref{Refiling notes}.
942 @kindex C-c ^
943 @item C-c ^
944 Sort same-level entries.  When there is an active region, all entries in the
945 region will be sorted.  Otherwise the children of the current headline are
946 sorted.  The command prompts for the sorting method, which can be
947 alphabetically, numerically, by time (using the first time stamp in each
948 entry), by priority, or by TODO keyword (in the sequence the keywords have
949 been defined in the setup).  Reverse sorting is possible as well.  You can
950 also supply your own function to extract the sorting key.  With a @kbd{C-u}
951 prefix, sorting will be case-sensitive.  With two @kbd{C-u C-u} prefixes,
952 duplicate entries will also be removed.
953 @kindex C-x n s
954 @item C-x n s
955 Narrow buffer to current subtree.
956 @kindex C-x n w
957 @item C-x n w
958 Widen buffer to remove a narrowing.
959 @kindex C-c *
960 @item C-c *
961 Turn a normal line or plain list item into a headline (so that it
962 becomes a subheading at its location).  Also turn a headline into a
963 normal line by removing the stars.  If there is an active region, turn
964 all lines in the region into headlines.  Or, if the first line is a
965 headline, remove the stars from all headlines in the region.
966 @end table
968 @cindex region, active
969 @cindex active region
970 @cindex Transient mark mode
971 When there is an active region (Transient mark mode), promotion and
972 demotion work on all headlines in the region.  To select a region of
973 headlines, it is best to place both point and mark at the beginning of a
974 line, mark at the beginning of the first headline, and point at the line
975 just after the last headline to change.  Note that when the cursor is
976 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
977 functionality.
979 @node Archiving, Sparse trees, Structure editing, Document Structure
980 @section Archiving
981 @cindex archiving
983 When a project represented by a (sub)tree is finished, you may want
984 to move the tree out of the way and to stop it from contributing to the
985 agenda.  Org mode knows two ways of archiving.  You can mark a tree with
986 the ARCHIVE tag, or you can move an entire (sub)tree to a different
987 location.
989 @menu
990 * ARCHIVE tag::                 Marking a tree as inactive
991 * Moving subtrees::             Moving a tree to an archive file
992 @end menu
994 @node ARCHIVE tag, Moving subtrees, Archiving, Archiving
995 @subsection The ARCHIVE tag
996 @cindex internal archiving
998 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
999 its location in the outline tree, but behaves in the following way:
1000 @itemize @minus
1001 @item
1002 It does not open when you attempt to do so with a visibility cycling
1003 command (@pxref{Visibility cycling}).  You can force cycling archived
1004 subtrees with @kbd{C-@key{TAB}}, or by setting the option
1005 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
1006 @code{show-all} will open archived subtrees.
1007 @item
1008 During sparse tree construction (@pxref{Sparse trees}), matches in
1009 archived subtrees are not exposed, unless you configure the option
1010 @code{org-sparse-tree-open-archived-trees}.
1011 @item
1012 During agenda view construction (@pxref{Agenda Views}), the content of
1013 archived trees is ignored unless you configure the option
1014 @code{org-agenda-skip-archived-trees}, in which case these trees will always
1015 be included.  In the agenda you can press the @kbd{v} key to get archives
1016 temporarily included.
1017 @item
1018 Archived trees are not exported (@pxref{Exporting}), only the headline
1019 is.  Configure the details using the variable
1020 @code{org-export-with-archived-trees}.
1021 @end itemize
1023 The following commands help managing the ARCHIVE tag:
1025 @table @kbd
1026 @kindex C-c C-x a
1027 @item C-c C-x a
1028 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
1029 the headline changes to a shadowed face, and the subtree below it is
1030 hidden.
1031 @kindex C-u C-c C-x a
1032 @item C-u C-c C-x a
1033 Check if any direct children of the current headline should be archived.
1034 To do this, each subtree is checked for open TODO entries.  If none are
1035 found, the command offers to set the ARCHIVE tag for the child.  If the
1036 cursor is @emph{not} on a headline when this command is invoked, the
1037 level 1 trees will be checked.
1038 @kindex C-@kbd{TAB}
1039 @item C-@kbd{TAB}
1040 Cycle a tree even if it is tagged with ARCHIVE.
1041 @end table
1043 @node Moving subtrees,  , ARCHIVE tag, Archiving
1044 @subsection Moving subtrees
1045 @cindex external archiving
1047 Once an entire project is finished, you may want to move it to a different
1048 location.  Org can move it to an @emph{Archive Sibling} in the same tree, to a
1049 different tree in the current file, or to a different file, the archive file.
1051 @table @kbd
1052 @kindex C-c C-x A
1053 @item C-c C-x A
1054 Move the current entry to the @emph{Archive Sibling}.  This is a sibling of
1055 the entry with the heading @samp{Archive} and the tag @samp{ARCHIVE}
1056 (@pxref{ARCHIVE tag}).  The entry becomes a child of that sibling and in this
1057 way retains a lot of its original context, including inherited tags and
1058 approximate position in the outline.
1059 @kindex C-c C-x C-s
1060 @item C-c C-x C-s
1061 Archive the subtree starting at the cursor position to the location
1062 given by @code{org-archive-location}.  Context information that could be
1063 lost like the file name, the category, inherited tags, and the TODO
1064 state will be store as properties in the entry.
1065 @kindex C-u C-c C-x C-s
1066 @item C-u C-c C-x C-s
1067 Check if any direct children of the current headline could be moved to
1068 the archive.  To do this, each subtree is checked for open TODO entries.
1069 If none are found, the command offers to move it to the archive
1070 location.  If the cursor is @emph{not} on a headline when this command
1071 is invoked, the level 1 trees will be checked.
1072 @end table
1074 @cindex archive locations
1075 The default archive location is a file in the same directory as the
1076 current file, with the name derived by appending @file{_archive} to the
1077 current file name.  For information and examples on how to change this,
1078 see the documentation string of the variable
1079 @code{org-archive-location}.  There is also an in-buffer option for
1080 setting this variable, for example@footnote{For backward compatibility,
1081 the following also works: If there are several such lines in a file,
1082 each specifies the archive location for the text below it.  The first
1083 such line also applies to any text before its definition.  However,
1084 using this method is @emph{strongly} deprecated as it is incompatible
1085 with the outline structure of the document.  The correct method for
1086 setting multiple archive locations in a buffer is using a property.}:
1088 @example
1089 #+ARCHIVE: %s_done::
1090 @end example
1092 @noindent
1093 If you would like to have a special ARCHIVE location for a single entry
1094 or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
1095 location as the value (@pxref{Properties and Columns}).
1097 When a subtree is moved, it receives a number of special properties that
1098 record context information like the file from where the entry came, it's
1099 outline path the archiving time etc.  Configure the variable
1100 @code{org-archive-save-context-info} to adjust the amount of information
1101 added.
1103 @node Sparse trees, Plain lists, Archiving, Document Structure
1104 @section Sparse trees
1105 @cindex sparse trees
1106 @cindex trees, sparse
1107 @cindex folding, sparse trees
1108 @cindex occur, command
1110 An important feature of Org mode is the ability to construct @emph{sparse
1111 trees} for selected information in an outline tree, so that the entire
1112 document is folded as much as possible, but the selected information is made
1113 visible along with the headline structure above it@footnote{See also the
1114 variables @code{org-show-hierarchy-above}, @code{org-show-following-heading},
1115 @code{org-show-siblings}, and @code{org-show-entry-below} for detailed
1116 control on how much context is shown around each match.}.  Just try it out
1117 and you will see immediately how it works.
1119 Org mode contains several commands creating such trees, all these
1120 commands can be accessed through a dispatcher:
1122 @table @kbd
1123 @kindex C-c /
1124 @item C-c /
1125 This prompts for an extra key to select a sparse-tree creating command.
1126 @kindex C-c / r
1127 @item C-c / r
1128 Occur.  Prompts for a regexp and shows a sparse tree with all matches.  If
1129 the match is in a headline, the headline is made visible.  If the match is in
1130 the body of an entry, headline and body are made visible.  In order to
1131 provide minimal context, also the full hierarchy of headlines above the match
1132 is shown, as well as the headline following the match.  Each match is also
1133 highlighted; the highlights disappear when the buffer is changed by an
1134 editing command@footnote{depending on the option
1135 @code{org-remove-highlights-with-change}}, or by pressing @kbd{C-c C-c}.
1136 When called with a @kbd{C-u} prefix argument, previous highlights are kept,
1137 so several calls to this command can be stacked.
1138 @end table
1140 @noindent
1141 For frequently used sparse trees of specific search strings, you can
1142 use the variable @code{org-agenda-custom-commands} to define fast
1143 keyboard access to specific sparse trees.  These commands will then be
1144 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
1145 For example:
1147 @lisp
1148 (setq org-agenda-custom-commands
1149       '(("f" occur-tree "FIXME")))
1150 @end lisp
1152 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
1153 a sparse tree matching the string @samp{FIXME}.
1155 The other sparse tree commands select headings based on TODO keywords,
1156 tags, or properties and will be discussed later in this manual.
1158 @kindex C-c C-e v
1159 @cindex printing sparse trees
1160 @cindex visible text, printing
1161 To print a sparse tree, you can use the Emacs command
1162 @code{ps-print-buffer-with-faces} which does not print invisible parts
1163 of the document @footnote{This does not work under XEmacs, because
1164 XEmacs uses selective display for outlining, not text properties.}.
1165 Or you can use the command @kbd{C-c C-e v} to export only the visible
1166 part of the document and print the resulting file.
1168 @node Plain lists, Drawers, Sparse trees, Document Structure
1169 @section Plain lists
1170 @cindex plain lists
1171 @cindex lists, plain
1172 @cindex lists, ordered
1173 @cindex ordered lists
1175 Within an entry of the outline tree, hand-formatted lists can provide
1176 additional structure.  They also provide a way to create lists of
1177 checkboxes (@pxref{Checkboxes}).  Org supports editing such lists,
1178 and the HTML exporter (@pxref{Exporting}) parses and formats them.
1180 Org knows ordered lists, unordered lists, and description lists.
1181 @itemize @bullet
1182 @item
1183 @emph{Unordered} list items start with @samp{-}, @samp{+}, or
1184 @samp{*}@footnote{When using @samp{*} as a bullet, lines must be indented or
1185 they will be seen as top-level headlines.  Also, when you are hiding leading
1186 stars to get a clean outline view, plain list items starting with a star are
1187 visually indistinguishable from true headlines.  In short: even though
1188 @samp{*} is supported, it may be better to not use it for plain list items.}
1189 as bullets.
1190 @item
1191 @emph{Ordered} list items start with a numeral followed by either a period or
1192 a right parenthesis, such as @samp{1.} or @samp{1)}.
1193 @item
1194 @emph{Description} list items are like unordered list items, but contain the
1195 separator @samp{ :: } to separate the description @emph{term} from the
1196 desciption.
1197 @end itemize
1199 Items belonging to the same list must have the same indentation on the first
1200 line.  In particular, if an ordered list reaches number @samp{10.}, then the
1201 2--digit numbers must be written left-aligned with the other numbers in the
1202 list.  Indentation also determines the end of a list item.  It ends before
1203 the next line that is indented like the bullet/number, or less.  Empty lines
1204 are part of the previous item, so you can have several paragraphs in one
1205 item.  If you would like an empty line to terminate all currently open plain
1206 lists, configure the variable @code{org-empty-line-terminates-plain-lists}.
1207 Here is an example:
1209 @example
1210 @group
1211 ** Lord of the Rings
1212    My favorite scenes are (in this order)
1213    1. The attack of the Rohirrim
1214    2. Eowyns fight with the witch king
1215       + this was already my favorite scene in the book
1216       + I really like Miranda Otto.
1217    3. Peter Jackson being shot by Legolas
1218        - on DVD only
1219       He makes a really funny face when it happens.
1220    But in the end, not individual scenes matter but the film as a whole.
1221    Important actors in this film are:
1222    - @b{Elijah Wood} :: He plays the Frodo
1223    - @b{Sean Austin} :: He plays the Sam, Frodos friend.  I still remember
1224      him very well from his role as Mikey Walsh a in the Goonies.
1225 @end group
1226 @end example
1228 Org supports these lists by tuning filling and wrapping commands to
1229 deal with them correctly@footnote{Org only changes the filling
1230 settings for Emacs.  For XEmacs, you should use Kyle E. Jones'
1231 @file{filladapt.el}.  To turn this on,  put into @file{.emacs}:
1232 @code{(require 'filladapt)}}, and by exporting them properly
1233 (@pxref{Exporting}).
1235 The following commands act on items when the cursor is in the first line
1236 of an item (the line with the bullet or number).
1238 @table @kbd
1239 @kindex @key{TAB}
1240 @item @key{TAB}
1241 Items can be folded just like headline levels if you set the variable
1242 @code{org-cycle-include-plain-lists}.  The level of an item is then
1243 given by the indentation of the bullet/number.  Items are always
1244 subordinate to real headlines, however; the hierarchies remain
1245 completely separated.
1247 If @code{org-cycle-include-plain-lists} has not been set, @key{TAB}
1248 fixes the indentation of the current line in a heuristic way.
1249 @kindex M-@key{RET}
1250 @item M-@key{RET}
1251 Insert new item at current level.  With a prefix argument, force a new
1252 heading (@pxref{Structure editing}).  If this command is used in the middle
1253 of a line, the line is @emph{split} and the rest of the line becomes the new
1254 item@footnote{If you do not want the line to be split, customize the variable
1255 @code{org-M-RET-may-split-line}.}.  If this command is executed in the
1256 @emph{whitespace before a bullet or number}, the new item is created
1257 @emph{before} the current item.  If the command is executed in the white
1258 space before the text that is part of an item but does not contain the
1259 bullet, a bullet is added to the current line.
1260 @kindex M-S-@key{RET}
1261 @item M-S-@key{RET}
1262 Insert a new item with a checkbox (@pxref{Checkboxes}).
1263 @kindex S-@key{up}
1264 @kindex S-@key{down}
1265 @item S-@key{up}
1266 @itemx S-@key{down}
1267 Jump to the previous/next item in the current list.
1268 @kindex M-S-@key{up}
1269 @kindex M-S-@key{down}
1270 @item M-S-@key{up}
1271 @itemx M-S-@key{down}
1272 Move the item including subitems up/down (swap with previous/next item
1273 of same indentation).  If the list is ordered, renumbering is
1274 automatic.
1275 @kindex M-S-@key{left}
1276 @kindex M-S-@key{right}
1277 @item M-S-@key{left}
1278 @itemx M-S-@key{right}
1279 Decrease/increase the indentation of the item, including subitems.
1280 Initially, the item tree is selected based on current indentation.
1281 When these commands are executed several times in direct succession,
1282 the initially selected region is used, even if the new indentation
1283 would imply a different hierarchy.  To use the new hierarchy, break
1284 the command chain with a cursor motion or so.
1285 @kindex C-c C-c
1286 @item C-c C-c
1287 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1288 state of the checkbox.  If not, this command makes sure that all the
1289 items on this list level use the same bullet.  Furthermore, if this is
1290 an ordered list, make sure the numbering is OK.
1291 @kindex C-c -
1292 @item C-c -
1293 Cycle the entire list level through the different itemize/enumerate bullets
1294 (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}).  With a numeric prefix
1295 argument N, select the Nth bullet from this list.  If there is an active
1296 region when calling this, all lines will be converted to list items.  If the
1297 first line already was a list item, any item markers will be removed from the
1298 list.  Finally, even without an active region, a normal line will be
1299 converted into a list item.
1300 @end table
1302 @node Drawers, Orgstruct mode, Plain lists, Document Structure
1303 @section Drawers
1304 @cindex drawers
1305 @cindex visibility cycling, drawers
1307 Sometimes you want to keep information associated with an entry, but you
1308 normally don't want to see it.  For this, Org mode has @emph{drawers}.
1309 Drawers need to be configured with the variable
1310 @code{org-drawers}@footnote{You can define drawers on a per-file basis
1311 with a line like @code{#+DRAWERS: HIDDEN PROPERTIES STATE}}.  Drawers
1312 look like this:
1314 @example
1315 ** This is a headline
1316    Still outside the drawer
1317    :DRAWERNAME:
1318       This is inside the drawer.
1319    :END:
1320    After the drawer.
1321 @end example
1323 Visibility cycling (@pxref{Visibility cycling}) on the headline will
1324 hide and show the entry, but keep the drawer collapsed to a single line.
1325 In order to look inside the drawer, you need to move the cursor to the
1326 drawer line and press @key{TAB} there.  Org mode uses a drawer for
1327 storing properties (@pxref{Properties and Columns}), and another one for
1328 storing clock times (@pxref{Clocking work time}).
1330 @node Orgstruct mode,  , Drawers, Document Structure
1331 @section The Orgstruct minor mode
1332 @cindex Orgstruct mode
1333 @cindex minor mode for structure editing
1335 If you like the intuitive way the Org mode structure editing and list
1336 formatting works, you might want to use these commands in other modes
1337 like Text mode or Mail mode as well.  The minor mode Orgstruct mode
1338 makes this possible.  You can always toggle the mode with @kbd{M-x
1339 orgstruct-mode}.  To turn it on by default, for example in Mail mode,
1342 @lisp
1343 (add-hook 'mail-mode-hook 'turn-on-orgstruct)
1344 @end lisp
1346 When this mode is active and the cursor is on a line that looks to
1347 Org like a headline of the first line of a list item, most
1348 structure editing commands will work, even if the same keys normally
1349 have different functionality in the major mode you are using.  If the
1350 cursor is not in one of those special lines, Orgstruct mode lurks
1351 silently in the shadow.
1353 @node Tables, Hyperlinks, Document Structure, Top
1354 @chapter Tables
1355 @cindex tables
1356 @cindex editing tables
1358 Org comes with a fast and intuitive table editor.  Spreadsheet-like
1359 calculations are supported in connection with the Emacs @file{calc}
1360 package
1361 @ifinfo
1362 (@pxref{Top,Calc,,Calc,Gnu Emacs Calculator Manual}).
1363 @end ifinfo
1364 @ifnotinfo
1365 (see the Emacs Calculator manual for more information about the Emacs
1366 calculator).
1367 @end ifnotinfo
1369 @menu
1370 * Built-in table editor::       Simple tables
1371 * Narrow columns::              Stop wasting space in tables
1372 * Column groups::               Grouping to trigger vertical lines
1373 * Orgtbl mode::                 The table editor as minor mode
1374 * The spreadsheet::             The table editor has spreadsheet capabilities
1375 @end menu
1377 @node Built-in table editor, Narrow columns, Tables, Tables
1378 @section The built-in table editor
1379 @cindex table editor, built-in
1381 Org makes it easy to format tables in plain ASCII.  Any line with
1382 @samp{|} as the first non-whitespace character is considered part of a
1383 table.  @samp{|} is also the column separator.  A table might look like
1384 this:
1386 @example
1387 | Name  | Phone | Age |
1388 |-------+-------+-----|
1389 | Peter |  1234 |  17 |
1390 | Anna  |  4321 |  25 |
1391 @end example
1393 A table is re-aligned automatically each time you press @key{TAB} or
1394 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
1395 the next field (@key{RET} to the next row) and creates new table rows
1396 at the end of the table or before horizontal lines.  The indentation
1397 of the table is set by the first line.  Any line starting with
1398 @samp{|-} is considered as a horizontal separator line and will be
1399 expanded on the next re-align to span the whole table width.  So, to
1400 create the above table, you would only type
1402 @example
1403 |Name|Phone|Age|
1405 @end example
1407 @noindent and then press @key{TAB} to align the table and start filling in
1408 fields.
1410 When typing text into a field, Org treats @key{DEL},
1411 @key{Backspace}, and all character keys in a special way, so that
1412 inserting and deleting avoids shifting other fields.  Also, when
1413 typing @emph{immediately after the cursor was moved into a new field
1414 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
1415 field is automatically made blank.  If this behavior is too
1416 unpredictable for you, configure the variables
1417 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
1419 @table @kbd
1420 @tsubheading{Creation and conversion}
1421 @kindex C-c |
1422 @item C-c |
1423 Convert the active region to table. If every line contains at least one
1424 TAB character, the function assumes that the material is tab separated.
1425 If every line contains a comma, comma-separated values (CSV) are assumed.
1426 If not, lines are split at whitespace into fields.  You can use a prefix
1427 argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
1428 C-u} forces TAB, and a numeric argument N indicates that at least N
1429 consecutive spaces, or alternatively a TAB will be the separator.
1431 If there is no active region, this command creates an empty Org
1432 table.  But it's easier just to start typing, like
1433 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
1435 @tsubheading{Re-aligning and field motion}
1436 @kindex C-c C-c
1437 @item C-c C-c
1438 Re-align the table without moving the cursor.
1440 @kindex @key{TAB}
1441 @item @key{TAB}
1442 Re-align the table, move to the next field.  Creates a new row if
1443 necessary.
1445 @kindex S-@key{TAB}
1446 @item S-@key{TAB}
1447 Re-align, move to previous field.
1449 @kindex @key{RET}
1450 @item @key{RET}
1451 Re-align the table and move down to next row.  Creates a new row if
1452 necessary.  At the beginning or end of a line, @key{RET} still does
1453 NEWLINE, so it can be used to split a table.
1455 @tsubheading{Column and row editing}
1456 @kindex M-@key{left}
1457 @kindex M-@key{right}
1458 @item M-@key{left}
1459 @itemx M-@key{right}
1460 Move the current column left/right.
1462 @kindex M-S-@key{left}
1463 @item M-S-@key{left}
1464 Kill the current column.
1466 @kindex M-S-@key{right}
1467 @item M-S-@key{right}
1468 Insert a new column to the left of the cursor position.
1470 @kindex M-@key{up}
1471 @kindex M-@key{down}
1472 @item M-@key{up}
1473 @itemx M-@key{down}
1474 Move the current row up/down.
1476 @kindex M-S-@key{up}
1477 @item M-S-@key{up}
1478 Kill the current row or horizontal line.
1480 @kindex M-S-@key{down}
1481 @item M-S-@key{down}
1482 Insert a new row above the current row.  With a prefix argument, the line is
1483 created below the current one.
1485 @kindex C-c -
1486 @item C-c -
1487 Insert a horizontal line below current row. With a prefix argument, the line
1488 is created above the current line.
1490 @kindex C-c ^
1491 @item C-c ^
1492 Sort the table lines in the region.  The position of point indicates the
1493 column to be used for sorting, and the range of lines is the range
1494 between the nearest horizontal separator lines, or the entire table.  If
1495 point is before the first column, you will be prompted for the sorting
1496 column.  If there is an active region, the mark specifies the first line
1497 and the sorting column, while point should be in the last line to be
1498 included into the sorting.  The command prompts for the sorting type
1499 (alphabetically, numerically, or by time).  When called with a prefix
1500 argument, alphabetic sorting will be case-sensitive.
1502 @tsubheading{Regions}
1503 @kindex C-c C-x M-w
1504 @item C-c C-x M-w
1505 Copy a rectangular region from a table to a special clipboard.  Point
1506 and mark determine edge fields of the rectangle.  The process ignores
1507 horizontal separator lines.
1509 @kindex C-c C-x C-w
1510 @item C-c C-x C-w
1511 Copy a rectangular region from a table to a special clipboard, and
1512 blank all fields in the rectangle.  So this is the ``cut'' operation.
1514 @kindex C-c C-x C-y
1515 @item C-c C-x C-y
1516 Paste a rectangular region into a table.
1517 The upper right corner ends up in the current field.  All involved fields
1518 will be overwritten.  If the rectangle does not fit into the present table,
1519 the table is enlarged as needed.  The process ignores horizontal separator
1520 lines.
1522 @kindex C-c C-q
1523 @kindex M-@key{RET}
1524 @item C-c C-q
1525 @itemx M-@kbd{RET}
1526 Wrap several fields in a column like a paragraph.  If there is an active
1527 region, and both point and mark are in the same column, the text in the
1528 column is wrapped to minimum width for the given number of lines.  A numeric
1529 prefix argument may be used to change the number of desired lines.  If there
1530 is no region, the current field is split at the cursor position and the text
1531 fragment to the right of the cursor is prepended to the field one line
1532 down. If there is no region, but you specify a prefix argument, the current
1533 field is made blank, and the content is appended to the field above.
1535 @tsubheading{Calculations}
1536 @cindex formula, in tables
1537 @cindex calculations, in tables
1538 @cindex region, active
1539 @cindex active region
1540 @cindex Transient mark mode
1541 @kindex C-c +
1542 @item C-c +
1543 Sum the numbers in the current column, or in the rectangle defined by
1544 the active region.  The result is shown in the echo area and can
1545 be inserted with @kbd{C-y}.
1547 @kindex S-@key{RET}
1548 @item S-@key{RET}
1549 When current field is empty, copy from first non-empty field above.  When not
1550 empty, copy current field down to next row and move cursor along with it.
1551 Depending on the variable @code{org-table-copy-increment}, integer field
1552 values will be incremented during copy.  Integers that are too large will not
1553 be incremented.  Also, a @code{0} prefix argument temporarily dispables the
1554 increment.  This key is also used by CUA mode (@pxref{Cooperation}).
1556 @tsubheading{Miscellaneous}
1557 @kindex C-c `
1558 @item C-c `
1559 Edit the current field in a separate window.  This is useful for fields
1560 that are not fully visible (@pxref{Narrow columns}).  When called with a
1561 @kbd{C-u} prefix, just make the full field visible, so that it can be
1562 edited in place.
1564 @item M-x org-table-import
1565 Import a file as a table.  The table should be TAB- or whitespace
1566 separated.  Useful, for example, to import a spreadsheet table or data
1567 from a database, because these programs generally can write
1568 TAB-separated text files.  This command works by inserting the file into
1569 the buffer and then converting the region to a table.  Any prefix
1570 argument is passed on to the converter, which uses it to determine the
1571 separator.
1572 @item C-c |
1573 Tables can also be imported by pasting tabular text into the Org
1574 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
1575 @kbd{C-c |} command (see above under @i{Creation and conversion}).
1577 @item M-x org-table-export
1578 Export the table, by default as a TAB-separated file.  Useful for data
1579 exchange with, for example, spreadsheet or database programs.  The format
1580 used to export the file can be configured in the variable
1581 @code{org-table-export-default-format}.  You may also use properties
1582 @code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
1583 name and the format for table export in a subtree.  Org supports quite
1584 general formats for exported tables.  The exporter format is the same as the
1585 format used by Orgtbl radio tables, see @ref{Translator functions} for a
1586 detailed description.
1587 @end table
1589 If you don't like the automatic table editor because it gets in your
1590 way on lines which you would like to start with @samp{|}, you can turn
1591 it off with
1593 @lisp
1594 (setq org-enable-table-editor nil)
1595 @end lisp
1597 @noindent Then the only table command that still works is
1598 @kbd{C-c C-c} to do a manual re-align.
1600 @node Narrow columns, Column groups, Built-in table editor, Tables
1601 @section Narrow columns
1602 @cindex narrow columns in tables
1604 The width of columns is automatically determined by the table editor.
1605 Sometimes a single field or a few fields need to carry more text,
1606 leading to inconveniently wide columns.  To limit@footnote{This feature
1607 does not work on XEmacs.} the width of a column, one field anywhere in
1608 the column may contain just the string @samp{<N>} where @samp{N} is an
1609 integer specifying the width of the column in characters.  The next
1610 re-align will then set the width of this column to no more than this
1611 value.
1613 @example
1614 @group
1615 |---+------------------------------|               |---+--------|
1616 |   |                              |               |   | <6>    |
1617 | 1 | one                          |               | 1 | one    |
1618 | 2 | two                          |     ----\     | 2 | two    |
1619 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
1620 | 4 | four                         |               | 4 | four   |
1621 |---+------------------------------|               |---+--------|
1622 @end group
1623 @end example
1625 @noindent
1626 Fields that are wider become clipped and end in the string @samp{=>}.
1627 Note that the full text is still in the buffer, it is only invisible.
1628 To see the full text, hold the mouse over the field - a tool-tip window
1629 will show the full content.  To edit such a field, use the command
1630 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
1631 open a new window with the full field.  Edit it and finish with @kbd{C-c
1632 C-c}.
1634 When visiting a file containing a table with narrowed columns, the
1635 necessary character hiding has not yet happened, and the table needs to
1636 be aligned before it looks nice.  Setting the option
1637 @code{org-startup-align-all-tables} will realign all tables in a file
1638 upon visiting, but also slow down startup.  You can also set this option
1639 on a per-file basis with:
1641 @example
1642 #+STARTUP: align
1643 #+STARTUP: noalign
1644 @end example
1646 @node Column groups, Orgtbl mode, Narrow columns, Tables
1647 @section Column groups
1648 @cindex grouping columns in tables
1650 When Org exports tables, it does so by default without vertical
1651 lines because that is visually more satisfying in general.  Occasionally
1652 however, vertical lines can be useful to structure a table into groups
1653 of columns, much like horizontal lines can do for groups of rows.  In
1654 order to specify column groups, you can use a special row where the
1655 first field contains only @samp{/}.  The further fields can either
1656 contain @samp{<} to indicate that this column should start a group,
1657 @samp{>} to indicate the end of a column, or @samp{<>} to make a column
1658 a group of its own.  Boundaries between column groups will upon export be
1659 marked with vertical lines.  Here is an example:
1661 @example
1662 |   |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1663 |---+----+-----+-----+-----+---------+------------|
1664 | / | <> |   < |     |   > |       < |          > |
1665 | # |  1 |   1 |   1 |   1 |       1 |          1 |
1666 | # |  2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
1667 | # |  3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
1668 |---+----+-----+-----+-----+---------+------------|
1669 #+TBLFM: $3=$2^2::$4=$2^3::$5=$2^4::$6=sqrt($2)::$7=sqrt(sqrt(($2)))
1670 @end example
1672 It is also sufficient to just insert the column group starters after
1673 every vertical line you'd like to have:
1675 @example
1676 |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1677 |----+-----+-----+-----+---------+------------|
1678 | /  | <   |     |     | <       |            |
1679 @end example
1681 @node Orgtbl mode, The spreadsheet, Column groups, Tables
1682 @section The Orgtbl minor mode
1683 @cindex Orgtbl mode
1684 @cindex minor mode for tables
1686 If you like the intuitive way the Org table editor works, you
1687 might also want to use it in other modes like Text mode or Mail mode.
1688 The minor mode Orgtbl mode makes this possible.  You can always toggle
1689 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
1690 example in mail mode, use
1692 @lisp
1693 (add-hook 'mail-mode-hook 'turn-on-orgtbl)
1694 @end lisp
1696 Furthermore, with some special setup, it is possible to maintain tables
1697 in arbitrary syntax with Orgtbl mode.  For example, it is possible to
1698 construct La@TeX{} tables with the underlying ease and power of
1699 Orgtbl mode, including spreadsheet capabilities.  For details, see
1700 @ref{Tables in arbitrary syntax}.
1702 @node The spreadsheet,  , Orgtbl mode, Tables
1703 @section The spreadsheet
1704 @cindex calculations, in tables
1705 @cindex spreadsheet capabilities
1706 @cindex @file{calc} package
1708 The table editor makes use of the Emacs @file{calc} package to implement
1709 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
1710 derive fields from other fields.  While fully featured, Org's
1711 implementation is not identical to other spreadsheets.  For example,
1712 Org knows the concept of a @emph{column formula} that will be
1713 applied to all non-header fields in a column without having to copy the
1714 formula to each relevant field.
1716 @menu
1717 * References::                  How to refer to another field or range
1718 * Formula syntax for Calc::     Using Calc to compute stuff
1719 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
1720 * Field formulas::              Formulas valid for a single field
1721 * Column formulas::             Formulas valid for an entire column
1722 * Editing and debugging formulas::  Fixing formulas
1723 * Updating the table::          Recomputing all dependent fields
1724 * Advanced features::           Field names, parameters and automatic recalc
1725 @end menu
1727 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
1728 @subsection References
1729 @cindex references
1731 To compute fields in the table from other fields, formulas must
1732 reference other fields or ranges.  In Org, fields can be referenced
1733 by name, by absolute coordinates, and by relative coordinates.  To find
1734 out what the coordinates of a field are, press @kbd{C-c ?} in that
1735 field, or press @kbd{C-c @}} to toggle the display of a grid.
1737 @subsubheading Field references
1738 @cindex field references
1739 @cindex references, to fields
1741 Formulas can reference the value of another field in two ways.  Like in
1742 any other spreadsheet, you may reference fields with a letter/number
1743 combination like @code{B3}, meaning the 2nd field in the 3rd row.
1744 @c Such references are always fixed to that field, they don't change
1745 @c when you copy and paste a formula to a different field.  So
1746 @c Org's @code{B3} behaves like @code{$B$3} in other spreadsheets.
1748 @noindent
1749 Org also uses another, more general operator that looks like this:
1750 @example
1751 @@row$column
1752 @end example
1754 @noindent
1755 Column references can be absolute like @samp{1}, @samp{2},...@samp{N},
1756 or relative to the current column like @samp{+1} or @samp{-2}.
1758 The row specification only counts data lines and ignores horizontal
1759 separator lines (hlines).  You can use absolute row numbers
1760 @samp{1}...@samp{N}, and row numbers relative to the current row like
1761 @samp{+3} or @samp{-1}.  Or specify the row relative to one of the
1762 hlines: @samp{I} refers to the first hline@footnote{Note that only
1763 hlines are counted that @emph{separate} table lines.  If the table
1764 starts with a hline above the header, it does not count.}, @samp{II} to
1765 the second etc.  @samp{-I} refers to the first such line above the
1766 current line, @samp{+I} to the first such line below the current line.
1767 You can also write @samp{III+2} which is the second data line after the
1768 third hline in the table.  Relative row numbers like @samp{-3} will not
1769 cross hlines if the current line is too close to the hline.  Instead,
1770 the value directly at the hline is used.
1772 @samp{0} refers to the current row and column.  Also, if you omit
1773 either the column or the row part of the reference, the current
1774 row/column is implied.
1776 Org's references with @emph{unsigned} numbers are fixed references
1777 in the sense that if you use the same reference in the formula for two
1778 different fields, the same field will be referenced each time.
1779 Org's references with @emph{signed} numbers are floating
1780 references because the same reference operator can reference different
1781 fields depending on the field being calculated by the formula.
1783 Here are a few examples:
1785 @example
1786 @@2$3      @r{2nd row, 3rd column}
1787 C2        @r{same as previous}
1788 $5        @r{column 5 in the current row}
1789 E&        @r{same as previous}
1790 @@2        @r{current column, row 2}
1791 @@-1$-3    @r{the field one row up, three columns to the left}
1792 @@-I$2     @r{field just under hline above current row, column 2}
1793 @end example
1795 @subsubheading Range references
1796 @cindex range references
1797 @cindex references, to ranges
1799 You may reference a rectangular range of fields by specifying two field
1800 references connected by two dots @samp{..}.  If both fields are in the
1801 current row, you may simply use @samp{$2..$7}, but if at least one field
1802 is in a different row, you need to use the general @code{@@row$column}
1803 format at least for the first field (i.e the reference must start with
1804 @samp{@@} in order to be interpreted correctly).  Examples:
1806 @example
1807 $1..$3        @r{First three fields in the current row.}
1808 $P..$Q        @r{Range, using column names (see under Advanced)}
1809 @@2$1..@@4$3    @r{6 fields between these two fields.}
1810 A2..C4        @r{Same as above.}
1811 @@-1$-2..@@-1   @r{3 numbers from the column to the left, 2 up to current row}
1812 @end example
1814 @noindent Range references return a vector of values that can be fed
1815 into Calc vector functions.  Empty fields in ranges are normally
1816 suppressed, so that the vector contains only the non-empty fields (but
1817 see the @samp{E} mode switch below).  If there are no non-empty fields,
1818 @samp{[0]} is returned to avoid syntax errors in formulas.
1820 @subsubheading Named references
1821 @cindex named references
1822 @cindex references, named
1823 @cindex name, of column or field
1824 @cindex constants, in calculations
1826 @samp{$name} is interpreted as the name of a column, parameter or
1827 constant.  Constants are defined globally through the variable
1828 @code{org-table-formula-constants}, and locally (for the file) through a
1829 line like
1831 @example
1832 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
1833 @end example
1835 @noindent
1836 Also properties (@pxref{Properties and Columns}) can be used as
1837 constants in table formulas: For a property @samp{:Xyz:} use the name
1838 @samp{$PROP_Xyz}, and the property will be searched in the current
1839 outline entry and in the hierarchy above it.  If you have the
1840 @file{constants.el} package, it will also be used to resolve constants,
1841 including natural constants like @samp{$h} for Planck's constant, and
1842 units like @samp{$km} for kilometers@footnote{@file{Constant.el} can
1843 supply the values of constants in two different unit systems, @code{SI}
1844 and @code{cgs}.  Which one is used depends on the value of the variable
1845 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
1846 @code{constSI} and @code{constcgs} to set this value for the current
1847 buffer.}.  Column names and parameters can be specified in special table
1848 lines.  These are described below, see @ref{Advanced features}.  All
1849 names must start with a letter, and further consist of letters and
1850 numbers.
1852 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
1853 @subsection Formula syntax for Calc
1854 @cindex formula syntax, Calc
1855 @cindex syntax, of formulas
1857 A formula can be any algebraic expression understood by the Emacs
1858 @file{Calc} package.  @b{Note that @file{calc} has the
1859 non-standard convention that @samp{/} has lower precedence than
1860 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
1861 evaluation by @code{calc-eval} (@pxref{Calling Calc from
1862 Your Programs,calc-eval,Calling Calc from Your Lisp Programs,Calc,GNU
1863 Emacs Calc Manual}),
1864 @c FIXME:  The link to the Calc manual in HTML does not work.
1865 variable substitution takes place according to the rules described above.
1866 @cindex vectors, in table calculations
1867 The range vectors can be directly fed into the Calc vector functions
1868 like @samp{vmean} and @samp{vsum}.
1870 @cindex format specifier
1871 @cindex mode, for @file{calc}
1872 A formula can contain an optional mode string after a semicolon.  This
1873 string consists of flags to influence Calc and other modes during
1874 execution.  By default, Org uses the standard Calc modes (precision
1875 12, angular units degrees, fraction and symbolic modes off).  The display
1876 format, however, has been changed to @code{(float 5)} to keep tables
1877 compact.  The default settings can be configured using the variable
1878 @code{org-calc-default-modes}.
1880 @example
1881 p20           @r{switch the internal precision to 20 digits}
1882 n3 s3 e2 f4   @r{normal, scientific, engineering, or fixed display format}
1883 D R           @r{angle modes: degrees, radians}
1884 F S           @r{fraction and symbolic modes}
1885 N             @r{interpret all fields as numbers, use 0 for non-numbers}
1886 T             @r{force text interpretation}
1887 E             @r{keep empty fields in ranges}
1888 @end example
1890 @noindent
1891 In addition, you may provide a @code{printf} format specifier to
1892 reformat the final result.  A few examples:
1894 @example
1895 $1+$2                @r{Sum of first and second field}
1896 $1+$2;%.2f           @r{Same, format result to two decimals}
1897 exp($2)+exp($1)      @r{Math functions can be used}
1898 $0;%.1f              @r{Reformat current cell to 1 decimal}
1899 ($3-32)*5/9          @r{Degrees F -> C conversion}
1900 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
1901 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
1902 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
1903 vmean($2..$7)        @r{Compute column range mean, using vector function}
1904 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
1905 taylor($3,x=7,2)     @r{taylor series of $3, at x=7, second degree}
1906 @end example
1908 Calc also contains a complete set of logical operations.  For example
1910 @example
1911 if($1<20,teen,string(""))  @r{``teen'' if age $1 less than 20, else empty}
1912 @end example
1914 @node Formula syntax for Lisp, Field formulas, Formula syntax for Calc, The spreadsheet
1915 @subsection Emacs Lisp forms as formulas
1916 @cindex Lisp forms, as table formulas
1918 It is also possible to write a formula in Emacs Lisp; this can be useful
1919 for string manipulation and control structures, if the Calc's
1920 functionality is not enough.  If a formula starts with a single quote
1921 followed by an opening parenthesis, then it is evaluated as a lisp form.
1922 The evaluation should return either a string or a number.  Just as with
1923 @file{calc} formulas, you can specify modes and a printf format after a
1924 semicolon.  With Emacs Lisp forms, you need to be conscious about the way
1925 field references are interpolated into the form.  By default, a
1926 reference will be interpolated as a Lisp string (in double quotes)
1927 containing the field.  If you provide the @samp{N} mode switch, all
1928 referenced elements will be numbers (non-number fields will be zero) and
1929 interpolated as Lisp numbers, without quotes.  If you provide the
1930 @samp{L} flag, all fields will be interpolated literally, without quotes.
1931 I.e., if you want a reference to be interpreted as a string by the Lisp
1932 form, enclose the reference operator itself in double quotes, like
1933 @code{"$3"}.  Ranges are inserted as space-separated fields, so you can
1934 embed them in list or vector syntax.  A few examples, note how the
1935 @samp{N} mode is used when we do computations in lisp.
1937 @example
1938 @r{Swap the first two characters of the content of column 1}
1939   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
1940 @r{Add columns 1 and 2, equivalent to the Calc's @code{$1+$2}}
1941   '(+ $1 $2);N
1942 @r{Compute the sum of columns 1-4, like Calc's @code{vsum($1..$4)}}
1943   '(apply '+ '($1..$4));N
1944 @end example
1946 @node Field formulas, Column formulas, Formula syntax for Lisp, The spreadsheet
1947 @subsection Field formulas
1948 @cindex field formula
1949 @cindex formula, for individual table field
1951 To assign a formula to a particular field, type it directly into the
1952 field, preceded by @samp{:=}, for example @samp{:=$1+$2}.  When you
1953 press @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in
1954 the field, the formula will be stored as the formula for this field,
1955 evaluated, and the current field replaced with the result.
1957 Formulas are stored in a special line starting with @samp{#+TBLFM:}
1958 directly below the table.  If you typed the equation in the 4th field of
1959 the 3rd data line in the table, the formula will look like
1960 @samp{@@3$4=$1+$2}.  When inserting/deleting/swapping column and rows
1961 with the appropriate commands, @i{absolute references} (but not relative
1962 ones) in stored formulas are modified in order to still reference the
1963 same field.  Of cause this is not true if you edit the table structure
1964 with normal editing commands - then you must fix the equations yourself.
1966 Instead of typing an equation into the field, you may also use the
1967 following command
1969 @table @kbd
1970 @kindex C-u C-c =
1971 @item C-u C-c =
1972 Install a new formula for the current field.  The command prompts for a
1973 formula, with default taken from the @samp{#+TBLFM:} line, applies
1974 it to the current field and stores it.
1975 @end table
1977 @node Column formulas, Editing and debugging formulas, Field formulas, The spreadsheet
1978 @subsection Column formulas
1979 @cindex column formula
1980 @cindex formula, for table column
1982 Often in a table, the same formula should be used for all fields in a
1983 particular column.  Instead of having to copy the formula to all fields
1984 in that column, Org allows to assign a single formula to an entire
1985 column.  If the table contains horizontal separator hlines, everything
1986 before the first such line is considered part of the table @emph{header}
1987 and will not be modified by column formulas.
1989 To assign a formula to a column, type it directly into any field in the
1990 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
1991 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the
1992 field, the formula will be stored as the formula for the current column,
1993 evaluated and the current field replaced with the result.  If the field
1994 contains only @samp{=}, the previously stored formula for this column is
1995 used.  For each column, Org will only remember the most recently
1996 used formula.  In the @samp{TBLFM:} line, column formulas will look like
1997 @samp{$4=$1+$2}.
1999 Instead of typing an equation into the field, you may also use the
2000 following command:
2002 @table @kbd
2003 @kindex C-c =
2004 @item C-c =
2005 Install a new formula for the current column and replace current field with
2006 the result of the formula.  The command prompts for a formula, with default
2007 taken from the @samp{#+TBLFM} line, applies it to the current field and
2008 stores it.  With a numeric prefix argument(e.g. @kbd{C-5 C-c =}) the command
2009 will apply it to that many consecutive fields in the current column.
2010 @end table
2012 @node Editing and debugging formulas, Updating the table, Column formulas, The spreadsheet
2013 @subsection Editing and debugging formulas
2014 @cindex formula editing
2015 @cindex editing, of table formulas
2017 You can edit individual formulas in the minibuffer or directly in the
2018 field.  Org can also prepare a special buffer with all active
2019 formulas of a table.  When offering a formula for editing, Org
2020 converts references to the standard format (like @code{B3} or @code{D&})
2021 if possible.  If you prefer to only work with the internal format (like
2022 @code{@@3$2} or @code{$4}), configure the variable
2023 @code{org-table-use-standard-references}.
2025 @table @kbd
2026 @kindex C-c =
2027 @kindex C-u C-c =
2028 @item C-c =
2029 @itemx C-u C-c =
2030 Edit the formula associated with the current column/field in the
2031 minibuffer.  See @ref{Column formulas} and @ref{Field formulas}.
2032 @kindex C-u C-u C-c =
2033 @item C-u C-u C-c =
2034 Re-insert the active formula (either a
2035 field formula, or a column formula) into the current field, so that you
2036 can edit it directly in the field.  The advantage over editing in the
2037 minibuffer is that you can use the command @kbd{C-c ?}.
2038 @kindex C-c ?
2039 @item C-c ?
2040 While editing a formula in a table field, highlight the field(s)
2041 referenced by the reference at the cursor position in the formula.
2042 @kindex C-c @}
2043 @item C-c @}
2044 Toggle the display of row and column numbers for a table, using
2045 overlays.  These are updated each time the table is aligned, you can
2046 force it with @kbd{C-c C-c}.
2047 @kindex C-c @{
2048 @item C-c @{
2049 Toggle the formula debugger on and off.  See below.
2050 @kindex C-c '
2051 @item C-c '
2052 Edit all formulas for the current table in a special buffer, where the
2053 formulas will be displayed one per line.  If the current field has an
2054 active formula, the cursor in the formula editor will mark it.
2055 While inside the special buffer, Org will automatically highlight
2056 any field or range reference at the cursor position.  You may edit,
2057 remove and add formulas, and use the following commands:
2058 @table @kbd
2059 @kindex C-c C-c
2060 @kindex C-x C-s
2061 @item C-c C-c
2062 @itemx C-x C-s
2063 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
2064 prefix, also apply the new formulas to the entire table.
2065 @kindex C-c C-q
2066 @item C-c C-q
2067 Exit the formula editor without installing changes.
2068 @kindex C-c C-r
2069 @item C-c C-r
2070 Toggle all references in the formula editor between standard (like
2071 @code{B3}) and internal (like @code{@@3$2}).
2072 @kindex @key{TAB}
2073 @item @key{TAB}
2074 Pretty-print or indent lisp formula at point.  When in a line containing
2075 a lisp formula, format the formula according to Emacs Lisp rules.
2076 Another @key{TAB} collapses the formula back again.  In the open
2077 formula, @key{TAB} re-indents just like in Emacs lisp mode.
2078 @kindex M-@key{TAB}
2079 @item M-@key{TAB}
2080 Complete Lisp symbols, just like in Emacs lisp mode.
2081 @kindex S-@key{up}
2082 @kindex S-@key{down}
2083 @kindex S-@key{left}
2084 @kindex S-@key{right}
2085 @item S-@key{up}/@key{down}/@key{left}/@key{right}
2086 Shift the reference at point.  For example, if the reference is
2087 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
2088 This also works for relative references, and for hline references.
2089 @kindex M-S-@key{up}
2090 @kindex M-S-@key{down}
2091 @item M-S-@key{up}/@key{down}
2092 Move the test line for column formulas in the Org buffer up and
2093 down.
2094 @kindex M-@key{up}
2095 @kindex M-@key{down}
2096 @item M-@key{up}/@key{down}
2097 Scroll the window displaying the table.
2098 @kindex C-c @}
2099 @item C-c @}
2100 Turn the coordinate grid in the table on and off.
2101 @end table
2102 @end table
2104 Making a table field blank does not remove the formula associated with
2105 the field, because that is stored in a different line (the @samp{TBLFM}
2106 line) - during the next recalculation the field will be filled again.
2107 To remove a formula from a field, you have to give an empty reply when
2108 prompted for the formula, or to edit the @samp{#+TBLFM} line.
2110 @kindex C-c C-c
2111 You may edit the @samp{#+TBLFM} directly and re-apply the changed
2112 equations with @kbd{C-c C-c} in that line, or with the normal
2113 recalculation commands in the table.
2115 @subsubheading Debugging formulas
2116 @cindex formula debugging
2117 @cindex debugging, of table formulas
2118 When the evaluation of a formula leads to an error, the field content
2119 becomes the string @samp{#ERROR}.  If you would like see what is going
2120 on during variable substitution and calculation in order to find a bug,
2121 turn on formula debugging in the @code{Tbl} menu and repeat the
2122 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
2123 field.  Detailed information will be displayed.
2125 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
2126 @subsection Updating the table
2127 @cindex recomputing table fields
2128 @cindex updating, table
2130 Recalculation of a table is normally not automatic, but needs to be
2131 triggered by a command.  See @ref{Advanced features} for a way to make
2132 recalculation at least semi-automatically.
2134 In order to recalculate a line of a table or the entire table, use the
2135 following commands:
2137 @table @kbd
2138 @kindex C-c *
2139 @item C-c *
2140 Recalculate the current row by first applying the stored column formulas
2141 from left to right, and all field formulas in the current row.
2143 @kindex C-u C-c *
2144 @item C-u C-c *
2145 @kindex C-u C-c C-c
2146 @itemx C-u C-c C-c
2147 Recompute the entire table, line by line.  Any lines before the first
2148 hline are left alone, assuming that these are part of the table header.
2150 @kindex C-u C-u C-c *
2151 @kindex C-u C-u C-c C-c
2152 @item C-u C-u C-c *
2153 @itemx C-u C-u C-c C-c
2154 Iterate the table by recomputing it until no further changes occur.
2155 This may be necessary if some computed fields use the value of other
2156 fields that are computed @i{later} in the calculation sequence.
2157 @end table
2159 @node Advanced features,  , Updating the table, The spreadsheet
2160 @subsection Advanced features
2162 If you want the recalculation of fields to happen automatically, or if
2163 you want to be able to assign @i{names} to fields and columns, you need
2164 to reserve the first column of the table for special marking characters.
2165 @table @kbd
2166 @kindex C-#
2167 @item C-#
2168 Rotate the calculation mark in first column through the states @samp{},
2169 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  The meaning of these characters
2170 is discussed below.  When there is an active region, change all marks in
2171 the region.
2172 @end table
2174 Here is an example of a table that collects exam results of students and
2175 makes use of these features:
2177 @example
2178 @group
2179 |---+---------+--------+--------+--------+-------+------|
2180 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2181 |---+---------+--------+--------+--------+-------+------|
2182 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2183 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2184 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2185 |---+---------+--------+--------+--------+-------+------|
2186 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
2187 | # | Sara    |      6 |     14 |     19 |    39 |  7.8 |
2188 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
2189 |---+---------+--------+--------+--------+-------+------|
2190 |   | Average |        |        |        |  29.7 |      |
2191 | ^ |         |        |        |        |    at |      |
2192 | $ | max=50  |        |        |        |       |      |
2193 |---+---------+--------+--------+--------+-------+------|
2194 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
2195 @end group
2196 @end example
2198 @noindent @b{Important}: Please note that for these special tables,
2199 recalculating the table with @kbd{C-u C-c *} will only affect rows that
2200 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
2201 to the field itself.  The column formulas are not applied in rows with
2202 empty first field.
2204 @cindex marking characters, tables
2205 The marking characters have the following meaning:
2206 @table @samp
2207 @item !
2208 The fields in this line define names for the columns, so that you may
2209 refer to a column as @samp{$Tot} instead of @samp{$6}.
2210 @item ^
2211 This row defines names for the fields @emph{above} the row.  With such
2212 a definition, any formula in the table may use @samp{$m1} to refer to
2213 the value @samp{10}.  Also, if you assign a formula to a names field, it
2214 will be stored as @samp{$name=...}.
2215 @item _
2216 Similar to @samp{^}, but defines names for the fields in the row
2217 @emph{below}.
2218 @item $
2219 Fields in this row can define @emph{parameters} for formulas.  For
2220 example, if a field in a @samp{$} row contains @samp{max=50}, then
2221 formulas in this table can refer to the value 50 using @samp{$max}.
2222 Parameters work exactly like constants, only that they can be defined on
2223 a per-table basis.
2224 @item #
2225 Fields in this row are automatically recalculated when pressing
2226 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
2227 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
2228 lines will be left alone by this command.
2229 @item *
2230 Selects this line for global recalculation with @kbd{C-u C-c *}, but
2231 not for automatic recalculation.  Use this when automatic
2232 recalculation slows down editing too much.
2233 @item
2234 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
2235 All lines that should be recalculated should be marked with @samp{#}
2236 or @samp{*}.
2237 @item /
2238 Do not export this line.  Useful for lines that contain the narrowing
2239 @samp{<N>} markers.
2240 @end table
2242 Finally, just to whet your appetite on what can be done with the
2243 fantastic @file{calc} package, here is a table that computes the Taylor
2244 series of degree @code{n} at location @code{x} for a couple of
2245 functions.
2247 @example
2248 @group
2249 |---+-------------+---+-----+--------------------------------------|
2250 |   | Func        | n | x   | Result                               |
2251 |---+-------------+---+-----+--------------------------------------|
2252 | # | exp(x)      | 1 | x   | 1 + x                                |
2253 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
2254 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
2255 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
2256 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
2257 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
2258 |---+-------------+---+-----+--------------------------------------|
2259 #+TBLFM: $5=taylor($2,$4,$3);n3
2260 @end group
2261 @end example
2263 @node Hyperlinks, TODO Items, Tables, Top
2264 @chapter Hyperlinks
2265 @cindex hyperlinks
2267 Like HTML, Org provides links inside a file, external links to
2268 other files, Usenet articles, emails, and much more.
2270 @menu
2271 * Link format::                 How links in Org are formatted
2272 * Internal links::              Links to other places in the current file
2273 * External links::              URL-like links to the world
2274 * Handling links::              Creating, inserting and following
2275 * Using links outside Org::     Linking from my C source code?
2276 * Link abbreviations::          Shortcuts for writing complex links
2277 * Search options::              Linking to a specific location
2278 * Custom searches::             When the default search is not enough
2279 @end menu
2281 @node Link format, Internal links, Hyperlinks, Hyperlinks
2282 @section Link format
2283 @cindex link format
2284 @cindex format, of links
2286 Org will recognize plain URL-like links and activate them as
2287 clickable links.  The general link format, however, looks like this:
2289 @example
2290 [[link][description]]       @r{or alternatively}           [[link]]
2291 @end example
2293 Once a link in the buffer is complete (all brackets present), Org
2294 will change the display so that @samp{description} is displayed instead
2295 of @samp{[[link][description]]} and @samp{link} is displayed instead of
2296 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
2297 which by default is an underlined face.  You can directly edit the
2298 visible part of a link.  Note that this can be either the @samp{link}
2299 part (if there is no description) or the @samp{description} part.  To
2300 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
2301 cursor on the link.
2303 If you place the cursor at the beginning or just behind the end of the
2304 displayed text and press @key{BACKSPACE}, you will remove the
2305 (invisible) bracket at that location.  This makes the link incomplete
2306 and the internals are again displayed as plain text.  Inserting the
2307 missing bracket hides the link internals again.  To show the
2308 internal structure of all links, use the menu entry
2309 @code{Org->Hyperlinks->Literal links}.
2311 @node Internal links, External links, Link format, Hyperlinks
2312 @section Internal links
2313 @cindex internal links
2314 @cindex links, internal
2315 @cindex targets, for links
2317 If the link does not look like a URL, it is considered to be internal in
2318 the current file.  Links such as @samp{[[My Target]]} or @samp{[[My
2319 Target][Find my target]]} lead to a text search in the current file.
2320 The link can be followed with @kbd{C-c C-o} when the cursor is on the
2321 link, or with a mouse click (@pxref{Handling links}).  The preferred
2322 match for such a link is a dedicated target: the same string in double
2323 angular brackets.  Targets may be located anywhere; sometimes it is
2324 convenient to put them into a comment line. For example
2326 @example
2327 # <<My Target>>
2328 @end example
2330 @noindent In HTML export (@pxref{HTML export}), such targets will become
2331 named anchors for direct access through @samp{http} links@footnote{Note
2332 that text before the first headline is usually not exported, so the
2333 first such target should be after the first headline.}.
2335 If no dedicated target exists, Org will search for the words in the
2336 link.  In the above example the search would be for @samp{my target}.
2337 Links starting with a star like @samp{*My Target} restrict the search to
2338 headlines.  When searching, Org mode will first try an exact match, but
2339 then move on to more and more lenient searches.  For example, the link
2340 @samp{[[*My Targets]]} will find any of the following:
2342 @example
2343 ** My targets
2344 ** TODO my targets are bright
2345 ** my 20 targets are
2346 @end example
2348 To insert a link targeting a headline, in-buffer completion can be used.
2349 Just type a star followed by a few optional letters into the buffer and
2350 press @kbd{M-@key{TAB}}.  All headlines in the current buffer will be
2351 offered as completions.  @xref{Handling links}, for more commands
2352 creating links.
2354 Following a link pushes a mark onto Org's own mark ring.  You can
2355 return to the previous position with @kbd{C-c &}.  Using this command
2356 several times in direct succession goes back to positions recorded
2357 earlier.
2359 @menu
2360 * Radio targets::               Make targets trigger links in plain text
2361 @end menu
2363 @node Radio targets,  , Internal links, Internal links
2364 @subsection Radio targets
2365 @cindex radio targets
2366 @cindex targets, radio
2367 @cindex links, radio targets
2369 Org can automatically turn any occurrences of certain target names
2370 in normal text into a link.  So without explicitly creating a link, the
2371 text connects to the target radioing its position.  Radio targets are
2372 enclosed by triple angular brackets.  For example, a target @samp{<<<My
2373 Target>>>} causes each occurrence of @samp{my target} in normal text to
2374 become activated as a link.  The Org file is scanned automatically
2375 for radio targets only when the file is first loaded into Emacs.  To
2376 update the target list during editing, press @kbd{C-c C-c} with the
2377 cursor on or at a target.
2379 @node External links, Handling links, Internal links, Hyperlinks
2380 @section External links
2381 @cindex links, external
2382 @cindex external links
2383 @cindex links, external
2384 @cindex Gnus links
2385 @cindex BBDB links
2386 @cindex IRC links
2387 @cindex URL links
2388 @cindex file links
2389 @cindex VM links
2390 @cindex RMAIL links
2391 @cindex WANDERLUST links
2392 @cindex MH-E links
2393 @cindex USENET links
2394 @cindex SHELL links
2395 @cindex Info links
2396 @cindex elisp links
2398 Org supports links to files, websites, Usenet and email messages,
2399 BBDB database entries and links to both IRC conversations and their
2400 logs.  External links are URL-like locators.  They start with a short
2401 identifying string followed by a colon.  There can be no space after
2402 the colon.  The following list shows examples for each link type.
2404 @example
2405 http://www.astro.uva.nl/~dominik          @r{on the web}
2406 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
2407 /home/dominik/images/jupiter.jpg          @r{same as above}
2408 file:papers/last.pdf                      @r{file, relative path}
2409 ./papers/last.pdf                         @r{same as above}
2410 news:comp.emacs                           @r{Usenet link}
2411 mailto:adent@@galaxy.net                 @r{Mail link}
2412 vm:folder                                 @r{VM folder link}
2413 vm:folder#id                              @r{VM message link}
2414 vm://myself@@some.where.org/folder#id    @r{VM on remote machine}
2415 wl:folder                                 @r{WANDERLUST folder link}
2416 wl:folder#id                              @r{WANDERLUST message link}
2417 mhe:folder                                @r{MH-E folder link}
2418 mhe:folder#id                             @r{MH-E message link}
2419 rmail:folder                              @r{RMAIL folder link}
2420 rmail:folder#id                           @r{RMAIL message link}
2421 gnus:group                                @r{Gnus group link}
2422 gnus:group#id                             @r{Gnus article link}
2423 bbdb:Richard Stallman                     @r{BBDB link}
2424 irc:/irc.com/#emacs/bob                   @r{IRC link}
2425 shell:ls *.org                            @r{A shell command}
2426 elisp:(find-file-other-frame "Elisp.org") @r{An elisp form to evaluate}
2427 @end example
2429 A link should be enclosed in double brackets and may contain a
2430 descriptive text to be displayed instead of the URL (@pxref{Link
2431 format}), for example:
2433 @example
2434 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
2435 @end example
2437 @noindent
2438 If the description is a file name or URL that points to an image, HTML
2439 export (@pxref{HTML export}) will inline the image as a clickable
2440 button.  If there is no description at all and the link points to an
2441 image,
2442 that image will be inlined into the exported HTML file.
2444 @cindex angular brackets, around links
2445 @cindex plain text external links
2446 Org also finds external links in the normal text and activates them
2447 as links.  If spaces must be part of the link (for example in
2448 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
2449 about the end of the link, enclose them in angular brackets.
2451 @node Handling links, Using links outside Org, External links, Hyperlinks
2452 @section Handling links
2453 @cindex links, handling
2455 Org provides methods to create a link in the correct syntax, to
2456 insert it into an Org file, and to follow the link.
2458 @table @kbd
2459 @kindex C-c l
2460 @cindex storing links
2461 @item C-c l
2462 Store a link to the current location.  This is a @emph{global} command
2463 which can be used in any buffer to create a link.  The link will be
2464 stored for later insertion into an Org buffer (see below).  For
2465 Org files, if there is a @samp{<<target>>} at the cursor, the
2466 link points to the target.  Otherwise it points to the current
2467 headline.  For VM, Rmail, Wanderlust, MH-E, Gnus and BBDB buffers, the
2468 link will indicate the current article/entry.  For W3 and W3M buffers,
2469 the link goes to the current URL.  For IRC links, if you set the
2470 variable @code{org-irc-link-to-logs} to non-nil then @kbd{C-c l} will
2471 store a @samp{file:/} style link to the relevant point in the logs for
2472 the current conversation. Otherwise an @samp{irc:/} style link to the
2473 user/channel/server under the point will be stored.  For any other
2474 files, the link will point to the file, with a search string
2475 (@pxref{Search options}) pointing to the contents of the current line.
2476 If there is an active region, the selected words will form the basis
2477 of the search string.  If the automatically created link is not
2478 working correctly or accurately enough, you can write custom functions
2479 to select the search string and to do the search for particular file
2480 types - see @ref{Custom searches}.  The key binding @kbd{C-c l} is
2481 only a suggestion - see @ref{Installation}.
2483 @kindex C-c C-l
2484 @cindex link completion
2485 @cindex completion, of links
2486 @cindex inserting links
2487 @item C-c C-l
2488 Insert a link.  This prompts for a link to be inserted into the buffer.  You
2489 can just type a link, using text for an internal link, or one of the link
2490 type prefixes mentioned in the examples above.  All links stored during the
2491 current session are part of the history for this prompt, so you can access
2492 them with @key{up} and @key{down} (or @kbd{M-p/n}).  Completion, on the other
2493 hand, will help you to insert valid link prefixes like @samp{http:} or
2494 @samp{ftp:}, including the prefixes defined through link abbreviations
2495 (@pxref{Link abbreviations}).  The link will be inserted into the
2496 buffer@footnote{After insertion of a stored link, the link will be removed
2497 from the list of stored links.  To keep it in the list later use, use a
2498 triple @kbd{C-u} prefix argument to @kbd{C-c C-l}, or configure the option
2499 @code{org-keep-stored-link-after-insertion}.}, along with a descriptive text.
2500 If some text was selected when this command is called, the selected text
2501 becomes the default description.@* Note that you don't have to use this
2502 command to insert a link.  Links in Org are plain text, and you can type
2503 or paste them straight into the buffer.  By using this command, the links are
2504 automatically enclosed in double brackets, and you will be asked for the
2505 optional descriptive text.
2507 @c  If the link is a @samp{file:} link and
2508 @c the linked file is located in the same directory as the current file or
2509 @c a subdirectory of it, the path of the file will be inserted relative to
2510 @c the current directory.
2512 @kindex C-u C-c C-l
2513 @cindex file name completion
2514 @cindex completion, of file names
2515 @item C-u C-c C-l
2516 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
2517 a file will be inserted and you may use file name completion to select
2518 the name of the file.  The path to the file is inserted relative to the
2519 directory of the current org file, if the linked file is in the current
2520 directory or in a sub-directory of it, or if the path is written relative
2521 to the current directory using @samp{../}.  Otherwise an absolute path
2522 is used, if possible with @samp{~/} for your home directory.  You can
2523 force an absolute path with two @kbd{C-u} prefixes.
2525 @item C-c C-l @r{(with cursor on existing link)}
2526 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
2527 link and description parts of the link.
2529 @cindex following links
2530 @kindex C-c C-o
2531 @item C-c C-o
2532 Open link at point.  This will launch a web browser for URLs (using
2533 @command{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB
2534 for the corresponding links, and execute the command in a shell link.
2535 When the cursor is on an internal link, this commands runs the
2536 corresponding search.  When the cursor is on a TAG list in a headline,
2537 it creates the corresponding TAGS view.  If the cursor is on a time
2538 stamp, it compiles the agenda for that date.  Furthermore, it will visit
2539 text and remote files in @samp{file:} links with Emacs and select a
2540 suitable application for local non-text files.  Classification of files
2541 is based on file extension only.  See option @code{org-file-apps}.  If
2542 you want to override the default application and visit the file with
2543 Emacs, use a @kbd{C-u} prefix.
2545 @kindex mouse-2
2546 @kindex mouse-1
2547 @item mouse-2
2548 @itemx mouse-1
2549 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
2550 would.  Under Emacs 22, also @kbd{mouse-1} will follow a link.
2552 @kindex mouse-3
2553 @item mouse-3
2554 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
2555 internal links to be displayed in another window@footnote{See the
2556 variable @code{org-display-internal-link-with-indirect-buffer}}.
2558 @cindex mark ring
2559 @kindex C-c %
2560 @item C-c %
2561 Push the current position onto the mark ring, to be able to return
2562 easily. Commands following an internal link do this automatically.
2564 @cindex links, returning to
2565 @kindex C-c &
2566 @item C-c &
2567 Jump back to a recorded position.  A position is recorded by the
2568 commands following internal links, and by @kbd{C-c %}.  Using this
2569 command several times in direct succession moves through a ring of
2570 previously recorded positions.
2572 @kindex C-c C-x C-n
2573 @kindex C-c C-x C-p
2574 @cindex links, finding next/previous
2575 @item C-c C-x C-n
2576 @itemx C-c C-x C-p
2577 Move forward/backward to the next link in the buffer.  At the limit of
2578 the buffer, the search fails once, and then wraps around.  The key
2579 bindings for this are really too long, you might want to bind this also
2580 to @kbd{C-n} and @kbd{C-p}
2581 @lisp
2582 (add-hook 'org-load-hook
2583   (lambda ()
2584     (define-key 'org-mode-map "\C-n" 'org-next-link)
2585     (define-key 'org-mode-map "\C-p" 'org-previous-link)))
2586 @end lisp
2587 @end table
2589 @node Using links outside Org, Link abbreviations, Handling links, Hyperlinks
2590 @section Using links outside Org
2592 You can insert and follow links that have Org syntax not only in
2593 Org, but in any Emacs buffer.  For this, you should create two
2594 global commands, like this (please select suitable global keys
2595 yourself):
2597 @lisp
2598 (global-set-key "\C-c L" 'org-insert-link-global)
2599 (global-set-key "\C-c o" 'org-open-at-point-global)
2600 @end lisp
2602 @node Link abbreviations, Search options, Using links outside Org, Hyperlinks
2603 @section Link abbreviations
2604 @cindex link abbreviations
2605 @cindex abbreviation, links
2607 Long URLs can be cumbersome to type, and often many similar links are
2608 needed in a document.  For this you can use link abbreviations.  An
2609 abbreviated link looks like this
2611 @example
2612 [[linkword:tag][description]]
2613 @end example
2615 @noindent
2616 where the tag is optional.  Such abbreviations are resolved according to
2617 the information in the variable @code{org-link-abbrev-alist} that
2618 relates the linkwords to replacement text.  Here is an example:
2620 @lisp
2621 @group
2622 (setq org-link-abbrev-alist
2623   '(("bugzilla" . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
2624     ("google"   . "http://www.google.com/search?q=")
2625     ("ads"      . "http://adsabs.harvard.edu/cgi-bin/
2626                    nph-abs_connect?author=%s&db_key=AST")))
2627 @end group
2628 @end lisp
2630 If the replacement text contains the string @samp{%s}, it will be
2631 replaced with the tag.  Otherwise the tag will be appended to the string
2632 in order to create the link.  You may also specify a function that will
2633 be called with the tag as the only argument to create the link.
2635 With the above setting, you could link to a specific bug with
2636 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
2637 @code{[[google:OrgMode]]} and find out what the Org author is
2638 doing besides Emacs hacking with @code{[[ads:Dominik,C]]}.
2640 If you need special abbreviations just for a single Org buffer, you
2641 can define them in the file with
2643 @example
2644 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
2645 #+LINK: google    http://www.google.com/search?q=%s
2646 @end example
2648 @noindent
2649 In-buffer completion @pxref{Completion} can be used after @samp{[} to
2650 complete link abbreviations.
2652 @node Search options, Custom searches, Link abbreviations, Hyperlinks
2653 @section Search options in file links
2654 @cindex search option in file links
2655 @cindex file links, searching
2657 File links can contain additional information to make Emacs jump to a
2658 particular location in the file when following a link.  This can be a
2659 line number or a search option after a double@footnote{For backward
2660 compatibility, line numbers can also follow a single colon.} colon. For
2661 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
2662 links}) to a file, it encodes the words in the current line as a search
2663 string that can be used to find this line back later when following the
2664 link with @kbd{C-c C-o}.
2666 Here is the syntax of the different ways to attach a search to a file
2667 link, together with an explanation:
2669 @example
2670 [[file:~/code/main.c::255]]
2671 [[file:~/xx.org::My Target]]
2672 [[file:~/xx.org::*My Target]]
2673 [[file:~/xx.org::/regexp/]]
2674 @end example
2676 @table @code
2677 @item 255
2678 Jump to line 255.
2679 @item My Target
2680 Search for a link target @samp{<<My Target>>}, or do a text search for
2681 @samp{my target}, similar to the search in internal links, see
2682 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
2683 link will become an HTML reference to the corresponding named anchor in
2684 the linked file.
2685 @item *My Target
2686 In an Org file, restrict search to headlines.
2687 @item /regexp/
2688 Do a regular expression search for @code{regexp}.  This uses the Emacs
2689 command @code{occur} to list all matches in a separate window.  If the
2690 target file is in Org mode, @code{org-occur} is used to create a
2691 sparse tree with the matches.
2692 @c If the target file is a directory,
2693 @c @code{grep} will be used to search all files in the directory.
2694 @end table
2696 As a degenerate case, a file link with an empty file name can be used
2697 to search the current file.  For example, @code{[[file:::find me]]} does
2698 a search for @samp{find me} in the current file, just as
2699 @samp{[[find me]]} would.
2701 @node Custom searches,  , Search options, Hyperlinks
2702 @section Custom Searches
2703 @cindex custom search strings
2704 @cindex search strings, custom
2706 The default mechanism for creating search strings and for doing the
2707 actual search related to a file link may not work correctly in all
2708 cases.  For example, BibTeX database files have many entries like
2709 @samp{year="1993"} which would not result in good search strings,
2710 because the only unique identification for a BibTeX entry is the
2711 citation key.
2713 If you come across such a problem, you can write custom functions to set
2714 the right search string for a particular file type, and to do the search
2715 for the string in the file.  Using @code{add-hook}, these functions need
2716 to be added to the hook variables
2717 @code{org-create-file-search-functions} and
2718 @code{org-execute-file-search-functions}.  See the docstring for these
2719 variables for more information.  Org actually uses this mechanism
2720 for Bib@TeX{} database files, and you can use the corresponding code as
2721 an implementation example.  See the file @file{org-bibtex.el}.
2723 @node TODO Items, Tags, Hyperlinks, Top
2724 @chapter TODO Items
2725 @cindex TODO items
2727 Org mode does not maintain TODO lists as separate documents@footnote{Of
2728 course, you can make a document that contains inly long lists of TODO items,
2729 but this is not required.}.  Instead, TODO items are an integral part of the
2730 notes file, because TODO items usually come up while taking notes!  With Org
2731 mode, simply mark any entry in a tree as being a TODO item.  In this way,
2732 information is not duplicated, and the entire context from which the TODO
2733 item emerged is always present.
2735 Of course, this technique for managing TODO items scatters them
2736 throughout your notes file.  Org mode compensates for this by providing
2737 methods to give you an overview of all the things that you have to do.
2739 @menu
2740 * TODO basics::                 Marking and displaying TODO entries
2741 * TODO extensions::             Workflow and assignments
2742 * Progress logging::            Dates and notes for progress
2743 * Priorities::                  Some things are more important than others
2744 * Breaking down tasks::         Splitting a task into manageable pieces
2745 * Checkboxes::                  Tick-off lists
2746 @end menu
2748 @node TODO basics, TODO extensions, TODO Items, TODO Items
2749 @section Basic TODO functionality
2751 Any headline becomes a TODO item when it starts with the word
2752 @samp{TODO}, for example:
2754 @example
2755 *** TODO Write letter to Sam Fortune
2756 @end example
2758 @noindent
2759 The most important commands to work with TODO entries are:
2761 @table @kbd
2762 @kindex C-c C-t
2763 @cindex cycling, of TODO states
2764 @item C-c C-t
2765 Rotate the TODO state of the current item among
2767 @example
2768 ,-> (unmarked) -> TODO -> DONE --.
2769 '--------------------------------'
2770 @end example
2772 The same rotation can also be done ``remotely'' from the timeline and
2773 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
2775 @kindex C-u C-c C-t
2776 @item C-u C-c C-t
2777 Select a specific keyword using completion or (if it has been set up)
2778 the fast selection interface.  For the latter, you need to assign keys
2779 to TODO states, see @ref{Per-file keywords} and @ref{Setting tags} for
2780 more information.
2782 @kindex S-@key{right}
2783 @kindex S-@key{left}
2784 @item S-@key{right}
2785 @itemx S-@key{left}
2786 Select the following/preceding TODO state, similar to cycling.  Useful
2787 mostly if more than two TODO states are possible (@pxref{TODO
2788 extensions}).
2789 @kindex C-c C-v
2790 @kindex C-c / t
2791 @cindex sparse tree, for TODO
2792 @item C-c C-v
2793 @itemx C-c / t
2794 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds
2795 the entire buffer, but shows all TODO items and the headings hierarchy
2796 above them.  With a prefix argument, search for a specific TODO.  You will be
2797 prompted for the keyword, and you can also give a list of keywords like
2798 @code{KWD1|KWD2|...}.  With numeric prefix argument N, show the tree for the
2799 Nth keyword in the variable @code{org-todo-keywords}.  With two prefix
2800 arguments, find all TODO and DONE entries.
2801 @kindex C-c a t
2802 @item C-c a t
2803 Show the global TODO list.  Collects the TODO items from all agenda
2804 files (@pxref{Agenda Views}) into a single buffer.  The new buffer will
2805 be in @code{agenda-mode}, which provides commands to examine and
2806 manipulate the TODO entries from the new buffer (@pxref{Agenda
2807 commands}).  @xref{Global TODO list}, for more information.
2808 @kindex S-M-@key{RET}
2809 @item S-M-@key{RET}
2810 Insert a new TODO entry below the current one.
2811 @end table
2813 @node TODO extensions, Progress logging, TODO basics, TODO Items
2814 @section Extended use of TODO keywords
2815 @cindex extended TODO keywords
2817 By default, marked TODO entries have one of only two states: TODO and
2818 DONE.  Org mode allows you to classify TODO items in more complex ways
2819 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With
2820 special setup, the TODO keyword system can work differently in different
2821 files.
2823 Note that @i{tags} are another way to classify headlines in general and
2824 TODO items in particular (@pxref{Tags}).
2826 @menu
2827 * Workflow states::             From TODO to DONE in steps
2828 * TODO types::                  I do this, Fred does the rest
2829 * Multiple sets in one file::   Mixing it all, and still finding your way
2830 * Fast access to TODO states::  Single letter selection of a state
2831 * Per-file keywords::           Different files, different requirements
2832 * Faces for TODO keywords::     Highlighting states
2833 @end menu
2835 @node Workflow states, TODO types, TODO extensions, TODO extensions
2836 @subsection TODO keywords as workflow states
2837 @cindex TODO workflow
2838 @cindex workflow states as TODO keywords
2840 You can use TODO keywords to indicate different @emph{sequential} states
2841 in the process of working on an item, for example@footnote{Changing
2842 this variable only becomes effective after restarting Org mode in a
2843 buffer.}:
2845 @lisp
2846 (setq org-todo-keywords
2847   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
2848 @end lisp
2850 The vertical bar separates the TODO keywords (states that @emph{need
2851 action}) from the DONE states (which need @emph{no further action}).  If
2852 you don't provide the separator bar, the last state is used as the DONE
2853 state.
2854 @cindex completion, of TODO keywords
2855 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
2856 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED.  You may
2857 also use a numeric prefix argument to quickly select a specific state.  For
2858 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY.
2859 Or you can use @kbd{S-left} to go backward through the sequence.  If you
2860 define many keywords, you can use in-buffer completion
2861 (@pxref{Completion}) or even a special one-key selection scheme
2862 (@pxref{Fast access to TODO states}) to insert these words into the
2863 buffer.  Changing a TODO state can be logged with a timestamp, see
2864 @ref{Tracking TODO state changes} for more information.
2866 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
2867 @subsection TODO keywords as types
2868 @cindex TODO types
2869 @cindex names as TODO keywords
2870 @cindex types as TODO keywords
2872 The second possibility is to use TODO keywords to indicate different
2873 @emph{types} of action items.  For example, you might want to indicate
2874 that items are for ``work'' or ``home''.  Or, when you work with several
2875 people on a single project, you might want to assign action items
2876 directly to persons, by using their names as TODO keywords.  This would
2877 be set up like this:
2879 @lisp
2880 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
2881 @end lisp
2883 In this case, different keywords do not indicate a sequence, but rather
2884 different types.  So the normal work flow would be to assign a task to a
2885 person, and later to mark it DONE.  Org mode supports this style by adapting
2886 the workings of the command @kbd{C-c C-t}@footnote{This is also true for the
2887 @kbd{t} command in the timeline and agenda buffers.}.  When used several
2888 times in succession, it will still cycle through all names, in order to first
2889 select the right type for a task.  But when you return to the item after some
2890 time and execute @kbd{C-c C-t} again, it will switch from any name directly
2891 to DONE.  Use prefix arguments or completion to quickly select a specific
2892 name.  You can also review the items of a specific TODO type in a sparse tree
2893 by using a numeric prefix to @kbd{C-c C-v}.  For example, to see all things
2894 Lucy has to do, you would use @kbd{C-3 C-c C-v}.  To collect Lucy's items
2895 from all agenda files into a single buffer, you would use the numeric prefix
2896 argument as well when creating the global TODO list: @kbd{C-3 C-c t}.
2898 @node Multiple sets in one file, Fast access to TODO states, TODO types, TODO extensions
2899 @subsection Multiple keyword sets in one file
2900 @cindex TODO keyword sets
2902 Sometimes you may want to use different sets of TODO keywords in
2903 parallel.  For example, you may want to have the basic
2904 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
2905 separate state indicating that an item has been canceled (so it is not
2906 DONE, but also does not require action).  Your setup would then look
2907 like this:
2909 @lisp
2910 (setq org-todo-keywords
2911       '((sequence "TODO" "|" "DONE")
2912         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
2913         (sequence "|" "CANCELED")))
2914 @end lisp
2916 The keywords should all be different, this helps Org mode to keep track
2917 of which subsequence should be used for a given entry.  In this setup,
2918 @kbd{C-c C-t} only operates within a subsequence, so it switches from
2919 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
2920 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
2921 select the correct sequence.  Besides the obvious ways like typing a
2922 keyword or using completion, you may also apply the following commands:
2924 @table @kbd
2925 @kindex C-S-@key{right}
2926 @kindex C-S-@key{left}
2927 @item C-S-@key{right}
2928 @itemx C-S-@key{left}
2929 These keys jump from one TODO subset to the next.  In the above example,
2930 @kbd{C-S-@key{right}} would jump from @code{TODO} or @code{DONE} to
2931 @code{REPORT}, and any of the words in the second row to @code{CANCELED}.
2932 @kindex S-@key{right}
2933 @kindex S-@key{left}
2934 @item S-@key{right}
2935 @itemx S-@key{left}
2936 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through
2937 @emph{all} keywords from all sets, so for example @kbd{S-@key{<right>}}
2938 would switch from @code{DONE} to @code{REPORT} in the example above.
2939 @end table
2941 @node Fast access to TODO states, Per-file keywords, Multiple sets in one file, TODO extensions
2942 @subsection Fast access to TODO states
2944 If you would like to quickly change an entry to an arbitrary TODO state
2945 instead of cycling through the states, you can set up keys for
2946 single-letter access to the states.  This is done by adding the section
2947 key after each keyword, in parenthesis.  For example:
2949 @lisp
2950 (setq org-todo-keywords
2951       '((sequence "TODO(t)" "|" "DONE(d)")
2952         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
2953         (sequence "|" "CANCELED(c)")))
2954 @end lisp
2956 If you then press @code{C-u C-c C-t} followed by the selection key, the
2957 entry will be switched to this state.  @key{SPC} can be used to remove
2958 any TODO keyword from an entry.  Should you like this way of selecting
2959 TODO states a lot, you might want to set the variable
2960 @code{org-use-fast-todo-selection} to @code{t} and make this behavior
2961 the default.  Check also the variable
2962 @code{org-fast-tag-selection-include-todo}, it allows to change the TODO
2963 state through the tags interface (@pxref{Setting tags}), in case you
2964 like to mingle the two concepts.
2966 @node Per-file keywords, Faces for TODO keywords, Fast access to TODO states, TODO extensions
2967 @subsection Setting up keywords for individual files
2968 @cindex keyword options
2969 @cindex per-file keywords
2971 It can be very useful to use different aspects of the TODO mechanism in
2972 different files.  For file-local settings, you need to add special lines
2973 to the file which set the keywords and interpretation for that file
2974 only.  For example, to set one of the two examples discussed above, you
2975 need one of the following lines, starting in column zero anywhere in the
2976 file:
2978 @example
2979 #+SEQ_TODO: TODO FEEDBACK VERIFY | DONE CANCELED
2980 @end example
2982 @example
2983 #+TYP_TODO: Fred Sara Lucy Mike | DONE
2984 @end example
2986 A setup for using several sets in parallel would be:
2988 @example
2989 #+SEQ_TODO: TODO | DONE
2990 #+SEQ_TODO: REPORT BUG KNOWNCAUSE | FIXED
2991 #+SEQ_TODO: | CANCELED
2992 @end example
2994 @cindex completion, of option keywords
2995 @kindex M-@key{TAB}
2996 @noindent To make sure you are using the correct keyword, type
2997 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
2999 @cindex DONE, final TODO keyword
3000 Remember that the keywords after the vertical bar (or the last keyword
3001 if no bar is there) must always mean that the item is DONE (although you
3002 may use a different word).  After changing one of these lines, use
3003 @kbd{C-c C-c} with the cursor still in the line to make the changes
3004 known to Org mode@footnote{Org mode parses these lines only when
3005 Org mode is activated after visiting a file.  @kbd{C-c C-c} with the
3006 cursor in a line starting with @samp{#+} is simply restarting Org mode
3007 for the current buffer.}.
3009 @node Faces for TODO keywords,  , Per-file keywords, TODO extensions
3010 @subsection Faces for TODO keywords
3011 @cindex faces, for TODO keywords
3013 Org mode highlights TODO keywords with special faces: @code{org-todo}
3014 for keywords indicating that an item still has to be acted upon, and
3015 @code{org-done} for keywords indicating that an item is finished.  If
3016 you are using more than 2 different states, you might want to use
3017 special faces for some of them.  This can be done using the variable
3018 @code{org-todo-keyword-faces}.  For example:
3020 @lisp
3021 (setq org-todo-keyword-faces
3022       '(("TODO"      . org-warning)
3023         ("DEFERRED"  . shadow)
3024         ("CANCELED"  . (:foreground "blue" :weight bold))))
3025 @end lisp
3027 While using a list with face properties as shown for CANCELED
3028 @emph{should} work, this does not aways seem to be the case.  If
3029 necessary, define a special face and use that.
3031 @page
3032 @node Progress logging, Priorities, TODO extensions, TODO Items
3033 @section Progress logging
3034 @cindex progress logging
3035 @cindex logging, of progress
3037 Org mode can automatically record a time stamp and possibly a note when
3038 you mark a TODO item as DONE, or even each time you change the state of
3039 a TODO item.  This system is highly configurable, settings can be on a
3040 per-keyword basis and can be localized to a file or even a subtree.  For
3041 information on how to clock working time for a task, see @ref{Clocking
3042 work time}.
3044 @menu
3045 * Closing items::               When was this entry marked DONE?
3046 * Tracking TODO state changes::  When did the status change?
3047 @end menu
3049 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
3050 @subsection Closing items
3052 The most basic logging is to keep track of @emph{when} a certain TODO
3053 item was finished.  This is achieved with@footnote{The corresponding
3054 in-buffer setting is: @code{#+STARTUP: logdone}}.
3056 @lisp
3057 (setq org-log-done 'time)
3058 @end lisp
3060 @noindent
3061 Then each time you turn an entry from a TODO (not-done) state into any
3062 of the DONE states, a line @samp{CLOSED: [timestamp]} will be inserted
3063 just after the headline.  If you turn the entry back into a TODO item
3064 through further state cycling, that line will be removed again.  If you
3065 want to record a note along with the timestamp, use@footnote{The
3066 corresponding in-buffer setting is: @code{#+STARTUP: lognotedone}}
3068 @lisp
3069 (setq org-log-done 'note)
3070 @end lisp
3072 @noindent
3073 You will then be prompted for a note, and that note will be stored below
3074 the entry with a @samp{Closing Note} heading.
3076 In the timeline (@pxref{Timeline}) and in the agenda
3077 (@pxref{Weekly/daily agenda}), you can then use the @kbd{l} key to
3078 display the TODO items with a @samp{CLOSED} timestamp on each day,
3079 giving you an overview of what has been done.
3081 @node Tracking TODO state changes,  , Closing items, Progress logging
3082 @subsection Tracking TODO state changes
3084 When TODO keywords are used as workflow states (@pxref{Workflow
3085 states}), you might want to keep track of when a state change occurred
3086 and maybe take a note about this change.  Since it is normally too much
3087 to record a note for every state, Org mode expects configuration on a
3088 per-keyword basis for this.  This is achieved by adding special markers
3089 @samp{!} (for a time stamp) and @samp{@@} (for a note) in parenthesis
3090 after each keyword.  For example, with the setting
3092 @lisp
3093 (setq org-todo-keywords
3094   '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
3095 @end lisp
3097 @noindent
3098 you not only define global TODO keywords and fast access keys, but also
3099 request that a time is recorded when the entry is turned into
3100 DONE@footnote{It is possible that Org mode will record two time stamps
3101 when you are using both @code{org-log-done} and state change logging.
3102 However, it will never prompt for two notes - if you have configured
3103 both, the state change recording note will take precedence and cancel
3104 the @samp{Closing Note}.}, and that a note is recorded when switching to
3105 WAIT or CANCELED.  The setting for WAIT is even more special: The
3106 @samp{!} after the slash means that in addition to the note taken when
3107 entering the state, a time stamp should be recorded when @i{leaving} the
3108 WAIT state, if and only if the @i{target} state does not configure
3109 logging for entering it.  So it has no effect when switching from WAIT
3110 to DONE, because DONE is configured to record a timestamp only.  But
3111 when switching from WAIT back to TODO, the @samp{/!} in the WAIT
3112 setting now triggers a timestamp even though TODO has no logging
3113 configured.
3115 You can use the exact same syntax for setting logging preferences local
3116 to a buffer:
3117 @example
3118 #+SEQ_TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
3119 @end example
3121 In order to define logging settings that are local to a subtree or a
3122 single item, define a LOGGING property in this entry.  Any non-empty
3123 LOGGING property resets all logging settings to nil.  You may then turn
3124 on logging for this specific tree using STARTUP keywords like
3125 @code{lognotedone} or @code{logrepeat}, as well as adding state specific
3126 settings like @code{TODO(!)}.  For example
3128 @example
3129 * TODO Log each state with only a time
3130   :PROPERTIES:
3131   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
3132   :END:
3133 * TODO Only log when switching to WAIT, and when repeating
3134   :PROPERTIES:
3135   :LOGGING: WAIT(@@) logrepeat
3136   :END:
3137 * TODO No logging at all
3138   :PROPERTIES:
3139   :LOGGING: nil
3140   :END:
3141 @end example
3144 @node Priorities, Breaking down tasks, Progress logging, TODO Items
3145 @section Priorities
3146 @cindex priorities
3148 If you use Org mode extensively, you may end up enough TODO items that
3149 it starts to make sense to prioritize them.  Prioritizing can be done by
3150 placing a @emph{priority cookie} into the headline of a TODO item, like
3151 this
3153 @example
3154 *** TODO [#A] Write letter to Sam Fortune
3155 @end example
3157 @noindent
3158 By default, Org mode supports three priorities: @samp{A}, @samp{B}, and
3159 @samp{C}.  @samp{A} is the highest priority.  An entry without a cookie
3160 is treated as priority @samp{B}.  Priorities make a difference only in
3161 the agenda (@pxref{Weekly/daily agenda}); outside the agenda, they have
3162 no inherent meaning to Org mode.
3164 Priorities can be attached to any outline tree entries; they do not need
3165 to be TODO items.
3167 @table @kbd
3168 @kindex @kbd{C-c ,}
3169 @item @kbd{C-c ,}
3170 Set the priority of the current headline.  The command prompts for a
3171 priority character @samp{A}, @samp{B} or @samp{C}.  When you press
3172 @key{SPC} instead, the priority cookie is removed from the headline.
3173 The priorities can also be changed ``remotely'' from the timeline and
3174 agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
3176 @kindex S-@key{up}
3177 @kindex S-@key{down}
3178 @item S-@key{up}
3179 @itemx S-@key{down}
3180 Increase/decrease priority of current headline@footnote{See also the
3181 option @code{org-priority-start-cycle-with-default'}.}.  Note that these
3182 keys are also used to modify time stamps (@pxref{Creating timestamps}).
3183 Furthermore, these keys are also used by CUA mode (@pxref{Conflicts}).
3184 @end table
3186 You can change the range of allowed priorities by setting the variables
3187 @code{org-highest-priority}, @code{org-lowest-priority}, and
3188 @code{org-default-priority}.  For an individual buffer, you may set
3189 these values (highest, lowest, default) like this (please make sure that
3190 the highest priority is earlier in the alphabet than the lowest
3191 priority):
3193 @example
3194 #+PRIORITIES: A C B
3195 @end example
3197 @node Breaking down tasks, Checkboxes, Priorities, TODO Items
3198 @section Breaking tasks down into subtasks
3199 @cindex tasks, breaking down
3201 It is often advisable to break down large tasks into smaller, manageable
3202 subtasks.  You can do this by creating an outline tree below a TODO item,
3203 with detailed subtasks on the tree@footnote{To keep subtasks out of the
3204 global TODO list, see the @code{org-agenda-todo-list-sublevels}.}.  To keep
3205 the overview over the fraction of subtasks that are already completed, insert
3206 either @samp{[/]} or @samp{[%]} anywhere in the headline.  These cookies will
3207 be updates each time the todo status of a child changes.  For example:
3209 @example
3210 * Organize Party [33%]
3211 ** TODO Call people [1/2]
3212 *** TODO Peter
3213 *** DONE Sarah
3214 ** TODO Buy food
3215 ** DONE Talk to neighbor
3216 @end example
3218 If you would like a TODO entry to automatically change to DONE when all
3219 chilrden are done, you can use the following setup:
3221 @example
3222 (defun org-summary-todo (n-done n-not-done)
3223   "Switch entry to DONE when all subentries are done, to TODO otherwise."
3224   (let (org-log-done org-log-states)   ; turn off logging
3225     (org-todo (if (= n-not-done 0) "DONE" "TODO"))))
3227 (add-hook 'org-after-todo-statistics-hook 'org-summary-todo)
3228 @end example
3231 Another possibility is the use of checkboxes to identify (a hierarchy of) a
3232 large number of subtasks (@pxref{Checkboxes}).
3235 @node Checkboxes,  , Breaking down tasks, TODO Items
3236 @section Checkboxes
3237 @cindex checkboxes
3239 Every item in a plain list (@pxref{Plain lists}) can be made into a
3240 checkbox by starting it with the string @samp{[ ]}.  This feature is
3241 similar to TODO items (@pxref{TODO Items}), but is more lightweight.
3242 Checkboxes are not included into the global TODO list, so they are often
3243 great to split a task into a number of simple steps.  Or you can use
3244 them in a shopping list.  To toggle a checkbox, use @kbd{C-c C-c}, or
3245 use the mouse (thanks to Piotr Zielinski's @file{org-mouse.el}).
3247 Here is an example of a checkbox list.
3249 @example
3250 * TODO Organize party [2/4]
3251   - [-] call people [1/3]
3252     - [ ] Peter
3253     - [X] Sarah
3254     - [ ] Sam
3255   - [X] order food
3256   - [ ] think about what music to play
3257   - [X] talk to the neighbors
3258 @end example
3260 Checkboxes work hierarchically, so if a checkbox item has children that
3261 are checkboxes, toggling one of the children checkboxes will make the
3262 parent checkbox reflect if none, some, or all of the children are
3263 checked.
3265 @cindex statistics, for checkboxes
3266 @cindex checkbox statistics
3267 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are
3268 cookies indicating how many checkboxes present in this entry have been
3269 checked off, and the total number of checkboxes are present.  This can
3270 give you an idea on how many checkboxes remain, even without opening a
3271 folded entry.  The cookies can be placed into a headline or into (the
3272 first line of) a plain list item. Each cookie covers all checkboxes
3273 structurally below the headline/item on which the cookie appear.  You
3274 have to insert the cookie yourself by typing either @samp{[/]} or
3275 @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m} result, as in
3276 the examples above.  With @samp{[%]} you get information about the
3277 percentage of checkboxes checked (in the above example, this would be
3278 @samp{[50%]} and @samp{[33%]}, respectively).
3280 @noindent The following commands work with checkboxes:
3282 @table @kbd
3283 @kindex C-c C-c
3284 @item C-c C-c
3285 Toggle checkbox at point.  With a prefix argument, set it to @samp{[-]},
3286 which is considered to be an intermediate state.
3287 @kindex C-c C-x C-b
3288 @item C-c C-x C-b
3289 Toggle checkbox at point.
3290 @itemize @minus
3291 @item
3292 If there is an active region, toggle the first checkbox in the region
3293 and set all remaining boxes to the same status as the first.  If you
3294 want to toggle all boxes in the region independently, use a prefix
3295 argument.
3296 @item
3297 If the cursor is in a headline, toggle checkboxes in the region between
3298 this headline and the next (so @emph{not} the entire subtree).
3299 @item
3300 If there is no active region, just toggle the checkbox at point.
3301 @end itemize
3302 @kindex M-S-@key{RET}
3303 @item M-S-@key{RET}
3304 Insert a new item with a checkbox.
3305 This works only if the cursor is already in a plain list item
3306 (@pxref{Plain lists}).
3307 @kindex C-c #
3308 @item C-c #
3309 Update the checkbox statistics in the current outline entry.  When
3310 called with a @kbd{C-u} prefix, update the entire file.  Checkbox
3311 statistic cookies are updated automatically if you toggle checkboxes
3312 with @kbd{C-c C-c} and make new ones with @kbd{M-S-@key{RET}}.  If you
3313 delete boxes or add/change them by hand, use this command to get things
3314 back into synch.  Or simply toggle any checkbox twice with @kbd{C-c C-c}.
3315 @end table
3317 @node Tags, Properties and Columns, TODO Items, Top
3318 @chapter Tags
3319 @cindex tags
3320 @cindex headline tagging
3321 @cindex matching, tags
3322 @cindex sparse tree, tag based
3324 An excellent way to implement labels and contexts for cross-correlating
3325 information is to assign @i{tags} to headlines.  Org mode has extensive
3326 support for tags.
3328 Every headline can contain a list of tags; they occur at the end of the
3329 headline.  Tags are normal words containing letters, numbers, @samp{_},
3330 and @samp{@@}.  Tags must be preceded and followed by a single colon,
3331 e.g., @samp{:work:}.  Several tags can be specified, as in
3332 @samp{:work:urgent:}.
3334 @menu
3335 * Tag inheritance::             Tags use the tree structure of the outline
3336 * Setting tags::                How to assign tags to a headline
3337 * Tag searches::                Searching for combinations of tags
3338 @end menu
3340 @node Tag inheritance, Setting tags, Tags, Tags
3341 @section Tag inheritance
3342 @cindex tag inheritance
3343 @cindex inheritance, of tags
3344 @cindex sublevels, inclusion into tags match
3346 @i{Tags} make use of the hierarchical structure of outline trees.  If a
3347 heading has a certain tag, all subheadings will inherit the tag as
3348 well.  For example, in the list
3350 @example
3351 * Meeting with the French group      :work:
3352 ** Summary by Frank                  :boss:notes:
3353 *** TODO Prepare slides for him      :action:
3354 @end example
3356 @noindent
3357 the final heading will have the tags @samp{:work:}, @samp{:boss:},
3358 @samp{:notes:}, and @samp{:action:} even though the final heading is not
3359 explicitly marked with those tags.  You can also set tags that all entries in
3360 a file should inherit as if these tags would be defined in a hypothetical
3361 level zero that surounds the entire file.
3363 @example
3364 #+FILETAGS: :Peter:Boss:Secret:
3365 @end example
3367 @noindent
3368 To limit tag inheritance to specific tags, or to turn it off entirely, use
3369 the variable @code{org-use-tag-inheritance}.
3371 When a headline matches during a tags search while tag inheritance is turned
3372 on, all the sublevels in the same tree will match as well@footnote{This is
3373 only true if the the search does not involve more complex tests including
3374 properties (@pxref{Property searches}).}.  The list of matches may then
3375 become very long.  If you only want to see the first tags match in a subtree,
3376 configure the variable @code{org-tags-match-list-sublevels}.
3378 @node Setting tags, Tag searches, Tag inheritance, Tags
3379 @section Setting tags
3380 @cindex setting tags
3381 @cindex tags, setting
3383 @kindex M-@key{TAB}
3384 Tags can simply be typed into the buffer at the end of a headline.
3385 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
3386 also a special command for inserting tags:
3388 @table @kbd
3389 @kindex C-c C-c
3390 @item C-c C-c
3391 @cindex completion, of tags
3392 Enter new tags for the current headline.  Org mode will either offer
3393 completion or a special single-key interface for setting tags, see
3394 below.  After pressing @key{RET}, the tags will be inserted and aligned
3395 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
3396 tags in the current buffer will be aligned to that column, just to make
3397 things look nice.  TAGS are automatically realigned after promotion,
3398 demotion, and TODO state changes (@pxref{TODO basics}).
3399 @end table
3401 Org will support tag insertion based on a @emph{list of tags}.  By
3402 default this list is constructed dynamically, containing all tags
3403 currently used in the buffer.  You may also globally specify a hard list
3404 of tags with the variable @code{org-tag-alist}.  Finally you can set
3405 the default tags for a given file with lines like
3407 @example
3408 #+TAGS: @@work @@home @@tennisclub
3409 #+TAGS: laptop car pc sailboat
3410 @end example
3412 If you have globally defined your preferred set of tags using the
3413 variable @code{org-tag-alist}, but would like to use a dynamic tag list
3414 in a specific file, add an empty TAGS option line to that file:
3416 @example
3417 #+TAGS:
3418 @end example
3420 By default Org mode uses the standard minibuffer completion facilities for
3421 entering tags.  However, it also implements another, quicker, tag selection
3422 method called @emph{fast tag selection}.  This allows you to select and
3423 deselect tags with just a single key press.  For this to work well you should
3424 assign unique letters to most of your commonly used tags.  You can do this
3425 globally by configuring the variable @code{org-tag-alist} in your
3426 @file{.emacs} file.  For example, you may find the need to tag many items in
3427 different files with @samp{:@@home:}.  In this case you can set something
3428 like:
3430 @lisp
3431 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
3432 @end lisp
3434 @noindent If the tag is only relevant to the file you are working on then you
3435 can, instead, set the TAGS option line as:
3437 @example
3438 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
3439 @end example
3441 @noindent
3442 You can also group together tags that are mutually exclusive.  By using
3443 braces, as in:
3445 @example
3446 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
3447 @end example
3449 @noindent you indicate that at most one of @samp{@@work}, @samp{@@home},
3450 and @samp{@@tennisclub} should be selected.  Multiple such groups are allowed.
3452 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
3453 these lines to activate any changes.
3455 @noindent
3456 To set these mutually exclusive groups in the variable @code{org-mode-alist}
3457 you must use the dummy tags @code{:startgroup} and @code{:endgroup} instead
3458 of the braces.  The previous example would be set globally by the following
3459 configuration:
3461 @lisp
3462 (setq org-tag-alist '((:startgroup . nil)
3463                       ("@@work" . ?w) ("@@home" . ?h)
3464                       ("@@tennisclub" . ?t)
3465                       (:endgroup . nil)
3466                       ("laptop" . ?l) ("pc" . ?p)))
3467 @end lisp
3469 If at least one tag has a selection key then pressing @kbd{C-c C-c} will
3470 automatically present you with a special interface, listing inherited tags,
3471 the tags of the current headline, and a list of all valid tags with
3472 corresponding keys@footnote{Keys will automatically be assigned to tags which
3473 have no configured keys.}.  In this interface, you can use the following
3474 keys:
3476 @table @kbd
3477 @item a-z...
3478 Pressing keys assigned to tags will add or remove them from the list of
3479 tags in the current line.  Selecting a tag in a group of mutually
3480 exclusive tags will turn off any other tags from that group.
3481 @kindex @key{TAB}
3482 @item @key{TAB}
3483 Enter a tag in the minibuffer, even if the tag is not in the predefined
3484 list.  You will be able to complete on all tags present in the buffer.
3485 @kindex @key{SPC}
3486 @item @key{SPC}
3487 Clear all tags for this line.
3488 @kindex @key{RET}
3489 @item @key{RET}
3490 Accept the modified set.
3491 @item C-g
3492 Abort without installing changes.
3493 @item q
3494 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
3495 @item !
3496 Turn off groups of mutually exclusive tags.  Use this to (as an
3497 exception) assign several tags from such a group.
3498 @item C-c
3499 Toggle auto-exit after the next change (see below).
3500 If you are using expert mode, the first @kbd{C-c} will display the
3501 selection window.
3502 @end table
3504 @noindent
3505 This method lets you assign tags to a headline with very few keys.  With
3506 the above setup, you could clear the current tags and set @samp{@@home},
3507 @samp{laptop} and @samp{pc} tags with just the following keys: @kbd{C-c
3508 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to
3509 @samp{@@work} would be done with @kbd{C-c C-c w @key{RET}} or
3510 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
3511 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
3512 @key{RET} @key{RET}}.
3514 If you find that most of the time, you need only a single key press to
3515 modify your list of tags, set the variable
3516 @code{org-fast-tag-selection-single-key}.  Then you no longer have to
3517 press @key{RET} to exit fast tag selection - it will immediately exit
3518 after the first change.  If you then occasionally need more keys, press
3519 @kbd{C-c} to turn off auto-exit for the current tag selection process
3520 (in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
3521 C-c}).  If you set the variable to the value @code{expert}, the special
3522 window is not even shown for single-key tag selection, it comes up only
3523 when you press an extra @kbd{C-c}.
3525 @node Tag searches,  , Setting tags, Tags
3526 @section Tag searches
3527 @cindex tag searches
3528 @cindex searching for tags
3530 Once a system of tags has been set up, it can be used to collect related
3531 information into special lists.
3533 @table @kbd
3534 @kindex C-c \
3535 @kindex C-c / T
3536 @item C-c \
3537 @itemx C-c / T
3538 Create a sparse tree with all headlines matching a tags search.  With a
3539 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
3540 @kindex C-c a m
3541 @item C-c a m
3542 Create a global list of tag matches from all agenda files.
3543 @xref{Matching tags and properties}.
3544 @kindex C-c a M
3545 @item C-c a M
3546 Create a global list of tag matches from all agenda files, but check
3547 only TODO items and force checking subitems (see variable
3548 @code{org-tags-match-list-sublevels}).
3549 @end table
3551 @cindex Boolean logic, for tag searches
3552 A @i{tags} search string can use Boolean operators @samp{&} for AND and
3553 @samp{|} for OR.  @samp{&} binds more strongly than @samp{|}.
3554 Parenthesis are currently not implemented.  A tag may also be preceded
3555 by @samp{-}, to select against it, and @samp{+} is syntactic sugar for
3556 positive selection.  The AND operator @samp{&} is optional when @samp{+}
3557 or @samp{-} is present.  Examples:
3559 @table @samp
3560 @item +work-boss
3561 Select headlines tagged @samp{:work:}, but discard those also tagged
3562 @samp{:boss:}.
3563 @item work|laptop
3564 Selects lines tagged @samp{:work:} or @samp{:laptop:}.
3565 @item work|laptop&night
3566 Like before, but require the @samp{:laptop:} lines to be tagged also
3567 @samp{:night:}.
3568 @end table
3570 @cindex TODO keyword matching, with tags search
3571 If you are using multi-state TODO keywords (@pxref{TODO extensions}), it
3572 can be useful to also match on the TODO keyword.  This can be done by
3573 adding a condition after a slash to a tags match.  The syntax is similar
3574 to the tag matches, but should be applied with consideration: For
3575 example, a positive selection on several TODO keywords can not
3576 meaningfully be combined with boolean AND.  However, @emph{negative
3577 selection} combined with AND can be meaningful.  To make sure that only
3578 lines are checked that actually have any TODO keyword, use @kbd{C-c a
3579 M}, or equivalently start the TODO part after the slash with @samp{!}.
3580 Examples:
3582 @table @samp
3583 @item work/WAITING
3584 Select @samp{:work:}-tagged TODO lines with the specific TODO
3585 keyword @samp{WAITING}.
3586 @item work/!-WAITING-NEXT
3587 Select @samp{:work:}-tagged TODO lines that are neither @samp{WAITING}
3588 nor @samp{NEXT}
3589 @item work/+WAITING|+NEXT
3590 Select @samp{:work:}-tagged TODO lines that are either @samp{WAITING} or
3591 @samp{NEXT}.
3592 @end table
3594 @cindex regular expressions, with tags search
3595 Any element of the tag/todo match can be a regular expression - in this
3596 case it must be enclosed in curly braces.  For example,
3597 @samp{work+@{^boss.*@}} matches headlines that contain the tag
3598 @samp{:work:} and any tag @i{starting} with @samp{boss}.
3600 @cindex level, require for tags/property match
3601 @cindex category, require for tags/property match
3602 You can also require a headline to be of a certain level or category, by
3603 writing instead of any TAG an expression like @samp{LEVEL=3} or
3604 @samp{CATEGORY="work"}, respectively.  For example, a search
3605 @samp{+LEVEL=3+boss/-DONE} lists all level three headlines that have the
3606 tag @samp{boss} and are @emph{not} marked with the TODO keyword DONE.
3608 @node Properties and Columns, Dates and Times, Tags, Top
3609 @chapter Properties and Columns
3610 @cindex properties
3612 Properties are a set of key-value pairs associated with an entry.  There
3613 are two main applications for properties in Org mode.  First, properties
3614 are like tags, but with a value.  Second, you can use properties to
3615 implement (very basic) database capabilities in an Org buffer.  For
3616 an example of the first application, imagine maintaining a file where
3617 you document bugs and plan releases of a piece of software.  Instead of
3618 using tags like @code{:release_1:}, @code{:release_2:}, one can use a
3619 property, say @code{:Release:}, that in different subtrees has different
3620 values, such as @code{1.0} or @code{2.0}.  For an example of the second
3621 application of properties, imagine keeping track of your music CD's,
3622 where properties could be things such as the album artist, date of
3623 release, number of tracks, and so on.
3625 Properties can be conveniently edited and viewed in column view
3626 (@pxref{Column view}).
3628 @menu
3629 * Property syntax::             How properties are spelled out
3630 * Special properties::          Access to other Org mode features
3631 * Property searches::           Matching property values
3632 * Property inheritance::        Passing values down the tree
3633 * Column view::                 Tabular viewing and editing
3634 * Property API::                Properties for Lisp programmers
3635 @end menu
3637 @node Property syntax, Special properties, Properties and Columns, Properties and Columns
3638 @section Property syntax
3639 @cindex property syntax
3640 @cindex drawer, for properties
3642 Properties are key-value pairs.  They need to be inserted into a special
3643 drawer (@pxref{Drawers}) with the name @code{PROPERTIES}.  Each property
3644 is specified on a single line, with the key (surrounded by colons)
3645 first, and the value after it.  Here is an example:
3647 @example
3648 * CD collection
3649 ** Classic
3650 *** Goldberg Variations
3651     :PROPERTIES:
3652     :Title:     Goldberg Variations
3653     :Composer:  J.S. Bach
3654     :Artist:    Glen Gould
3655     :Publisher: Deutsche Grammphon
3656     :NDisks:    1
3657     :END:
3658 @end example
3660 You may define the allowed values for a particular property @samp{:Xyz:}
3661 by setting a property @samp{:Xyz_ALL:}.  This special property is
3662 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
3663 the entire tree.  When allowed values are defined, setting the
3664 corresponding property becomes easier and is less prone to typing
3665 errors.  For the example with the CD collection, we can predefine
3666 publishers and the number of disks in a box like this:
3668 @example
3669 * CD collection
3670   :PROPERTIES:
3671   :NDisks_ALL:  1 2 3 4
3672   :Publisher_ALL: "Deutsche Grammophon" Phillips EMI
3673   :END:
3674 @end example
3676 If you want to set properties that can be inherited by any entry in a
3677 file, use a line like
3679 @example
3680 #+PROPERTY: NDisks_ALL 1 2 3 4
3681 @end example
3683 Property values set with the global variable
3684 @code{org-global-properties} can be inherited by all entries in all
3685 Org files.
3687 @noindent
3688 The following commands help to work with properties:
3690 @table @kbd
3691 @kindex M-@key{TAB}
3692 @item M-@key{TAB}
3693 After an initial colon in a line, complete property keys.  All keys used
3694 in the current file will be offered as possible completions.
3695 @kindex C-c C-x p
3696 @item C-c C-x p
3697 Set a property.  This prompts for a property name and a value.  If
3698 necessary, the property drawer is created as well.
3699 @item M-x org-insert-property-drawer
3700 Insert a property drawer into the current entry.  The drawer will be
3701 inserted early in the entry, but after the lines with planning
3702 information like deadlines.
3703 @kindex C-c C-c
3704 @item C-c C-c
3705 With the cursor in a property drawer, this executes property commands.
3706 @item C-c C-c s
3707 Set a property in the current entry.  Both the property and the value
3708 can be inserted using completion.
3709 @kindex S-@key{right}
3710 @kindex S-@key{left}
3711 @item S-@key{left}/@key{right}
3712 Switch property at point to the next/previous allowed value.
3713 @item C-c C-c d
3714 Remove a property from the current entry.
3715 @item C-c C-c D
3716 Globally remove a property, from all entries in the current file.
3717 @item C-c C-c c
3718 Compute the property at point, using the operator and scope from the
3719 nearest column format definition.
3720 @end table
3722 @node Special properties, Property searches, Property syntax, Properties and Columns
3723 @section Special properties
3724 @cindex properties, special
3726 Special properties provide alternative access method to Org mode
3727 features discussed in the previous chapters, like the TODO state or the
3728 priority of an entry.  This interface exists so that you can include
3729 these states into columns view (@pxref{Column view}), or to use them in
3730 queries.  The following property names are special and should not be
3731 used as keys in the properties drawer:
3733 @example
3734 TODO         @r{The TODO keyword of the entry.}
3735 TAGS         @r{The tags defined directly in the headline.}
3736 ALLTAGS      @r{All tags, including inherited ones.}
3737 PRIORITY     @r{The priority of the entry, a string with a single letter.}
3738 DEADLINE     @r{The deadline time string, without the angular brackets.}
3739 SCHEDULED    @r{The scheduling time stamp, without the angular brackets.}
3740 TIMESTAMP    @r{The first keyword-less time stamp in the entry.}
3741 TIMESTAMP_IA @r{The first inactive time stamp in the entry.}
3742 CLOCKSUM     @r{The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}}
3743              @r{must be run first to compute the values.}
3744 @end example
3746 @node Property searches, Property inheritance, Special properties, Properties and Columns
3747 @section Property searches
3748 @cindex properties, searching
3749 @cindex searching, of properties
3751 To create sparse trees and special lists with selection based on properties,
3752 the same commands are used as for tag searches (@pxref{Tag searches}), and
3753 the same logic applies.  For example, here is a search string:
3755 @example
3756 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2         \
3757          +With=@{Sarah\|Denny@}+SCHEDULED>="<2008-10-11>"
3758 @end example
3760 @noindent
3761 The type of comparison will depend on how the comparison value is written:
3762 @itemize @minus
3763 @item
3764 If the comparison value is a plain number, a numerical comparison is done,
3765 and the allowed operators are @samp{<}, @samp{=}, @samp{>}, @samp{<=},
3766 @samp{>=}, and @samp{<>}.
3767 @item
3768 If the comparison value is enclosed in double
3769 quotes, a string comparison is done, and the same operators are allowed.  
3770 @item
3771 If the comparison value is enclosed in double quotes @emph{and} angular
3772 brackets (like @samp{DEADLINE<="<2008-12-24 18:30>"}), both values are
3773 assumed to be date/time specifications in the standard Org way@footnote{The
3774 only special values that will be recognized are @samp{"<now>"} for now, and
3775 @samp{"<today"} today at 0:00 hours, i.e. without a time specification.}, and
3776 the comparison will be done accordingly.
3777 @item
3778 If the comparison value is enclosed
3779 in curly braces, a regexp match is performed, with @samp{=} meaning that the
3780 regexp matches the property value, and @samp{<>} meaning that it does not
3781 match.  
3782 @end itemize
3784 So the search string in the example finds entries tagged @samp{:work:} but
3785 not @samp{:boss:}, which also have a priority value @samp{A}, a
3786 @samp{:Coffee:} property with the value @samp{unlimited}, an @samp{Effort}
3787 property that is numerically smaller than 2, a @samp{:With:} property that is
3788 matched by the regular expression @samp{Sarah\|Denny}, and that are scheduled
3789 on or after October 11, 2008.
3791 You can configure Org mode to use property inheritance during a search, but
3792 beware that this can slow down searches considerably.  See @ref{Property
3793 inheritance} for details.
3795 There is also a special command for creating sparse trees based on a
3796 single property:
3798 @table @kbd
3799 @kindex C-c / p
3800 @item C-c / p
3801 Create a sparse tree based on the value of a property.  This first
3802 prompts for the name of a property, and then for a value.  A sparse tree
3803 is created with all entries that define this property with the given
3804 value.  If you enclose the value into curly braces, it is interpreted as
3805 a regular expression and matched against the property values.
3806 @end table
3808 @node Property inheritance, Column view, Property searches, Properties and Columns
3809 @section Property Inheritance
3810 @cindex properties, inheritance
3811 @cindex inheritance, of properties
3813 The outline structure of Org mode documents lends itself for an
3814 inheritance model of properties: If the parent in a tree has a certain
3815 property, the children can inherit this property.  Org mode does not
3816 turn this on by default, because it can slow down property searches
3817 significantly and is often not needed.  However, if you find inheritance
3818 useful, you can turn it on by setting the variable
3819 @code{org-use-property-inheritance}.  It may be set to @code{t}, to make
3820 all properties inherited from the parent, to a list of properties
3821 that should be inherited, or to a regular expression that matches
3822 inherited properties.
3824 Org mode has a few properties for which inheritance is hard-coded, at
3825 least for the special applications for which they are used:
3827 @table @code
3828 @item COLUMNS
3829 The @code{:COLUMNS:} property defines the format of column view
3830 (@pxref{Column view}).  It is inherited in the sense that the level
3831 where a @code{:COLUMNS:} property is defined is used as the starting
3832 point for a column view table, independently of the location in the
3833 subtree from where columns view is turned on.
3834 @item CATEGORY
3835 For agenda view, a category set through a @code{:CATEGORY:} property
3836 applies to the entire subtree.
3837 @item ARCHIVE
3838 For archiving, the @code{:ARCHIVE:} property may define the archive
3839 location for the entire subtree (@pxref{Moving subtrees}).
3840 @item LOGGING
3841 The LOGGING property may define logging settings for an entry or a
3842 subtree (@pxref{Tracking TODO state changes}).
3843 @end table
3845 @node Column view, Property API, Property inheritance, Properties and Columns
3846 @section Column view
3848 A great way to view and edit properties in an outline tree is
3849 @emph{column view}.  In column view, each outline item is turned into a
3850 table row.  Columns in this table provide access to properties of the
3851 entries.  Org mode implements columns by overlaying a tabular structure
3852 over the headline of each item.  While the headlines have been turned
3853 into a table row, you can still change the visibility of the outline
3854 tree.  For example, you get a compact table by switching to CONTENTS
3855 view (@kbd{S-@key{TAB} S-@key{TAB}}, or simply @kbd{c} while column view
3856 is active), but you can still open, read, and edit the entry below each
3857 headline.  Or, you can switch to column view after executing a sparse
3858 tree command and in this way get a table only for the selected items.
3859 Column view also works in agenda buffers (@pxref{Agenda Views}) where
3860 queries have collected selected items, possibly from a number of files.
3862 @menu
3863 * Defining columns::            The COLUMNS format property
3864 * Using column view::           How to create and use column view
3865 * Capturing column view::       A dynamic block for column view
3866 @end menu
3868 @node Defining columns, Using column view, Column view, Column view
3869 @subsection Defining columns
3870 @cindex column view, for properties
3871 @cindex properties, column view
3873 Setting up a column view first requires defining the columns.  This is
3874 done by defining a column format line.
3876 @menu
3877 * Scope of column definitions::  Where defined, where valid?
3878 * Column attributes::           Appearance and content of a column
3879 @end menu
3881 @node Scope of column definitions, Column attributes, Defining columns, Defining columns
3882 @subsubsection Scope of column definitions
3884 To define a column format for an entire file, use a line like
3886 @example
3887 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
3888 @end example
3890 To specify a format that only applies to a specific tree, add a
3891 @code{:COLUMNS:} property to the top node of that tree, for example:
3893 @example
3894 ** Top node for columns view
3895    :PROPERTIES:
3896    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
3897    :END:
3898 @end example
3900 If a @code{:COLUMNS:} property is present in an entry, it defines columns
3901 for the entry itself, and for the entire subtree below it.  Since the
3902 column definition is part of the hierarchical structure of the document,
3903 you can define columns on level 1 that are general enough for all
3904 sublevels, and more specific columns further down, when you edit a
3905 deeper part of the tree.
3907 @node Column attributes,  , Scope of column definitions, Defining columns
3908 @subsubsection Column attributes
3909 A column definition sets the attributes of a column.  The general
3910 definition looks like this:
3912 @example
3913  %[width]property[(title)][@{summary-type@}]
3914 @end example
3916 @noindent
3917 Except for the percent sign and the property name, all items are
3918 optional.  The individual parts have the following meaning:
3920 @example
3921 width           @r{An integer specifying the width of the column in characters.}
3922                 @r{If omitted, the width will be determined automatically.}
3923 property        @r{The property that should be edited in this column.}
3924 (title)         @r{The header text for the column. If omitted, the}
3925                 @r{property name is used.}
3926 @{summary-type@}  @r{The summary type.  If specified, the column values for}
3927                 @r{parent nodes are computed from the children.}
3928                 @r{Supported summary types are:}
3929                 @{+@}       @r{Sum numbers in this column.}
3930                 @{+;%.1f@}  @r{Like @samp{+}, but format result with @samp{%.1f}.}
3931                 @{$@}       @r{Currency, short for @samp{+;%.2f}.}
3932                 @{:@}       @r{Sum times, HH:MM:SS, plain numbers are hours.}
3933                 @{X@}       @r{Checkbox status, [X] if all children are [X].}
3934                 @{X/@}      @r{Checkbox status, [n/m].}
3935                 @{X%@}      @r{Checkbox status, [n%].}
3936 @end example
3938 @noindent
3939 Here is an example for a complete columns definition, along with allowed
3940 values.
3942 @example
3943 :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.}
3944                    %10Time_Estimate@{:@} %CLOCKSUM
3945 :Owner_ALL:    Tammy Mark Karl Lisa Don
3946 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
3947 :Approved_ALL: "[ ]" "[X]"
3948 @end example
3950 The first column, @samp{%25ITEM}, means the first 25 characters of the
3951 item itself, i.e. of the headline.  You probably always should start the
3952 column definition with the @samp{ITEM} specifier.  The other specifiers
3953 create columns @samp{Owner} with a list of names as allowed values, for
3954 @samp{Status} with four different possible values, and for a checkbox
3955 field @samp{Approved}.  When no width is given after the @samp{%}
3956 character, the column will be exactly as wide as it needs to be in order
3957 to fully display all values.  The @samp{Approved} column does have a
3958 modified title (@samp{Approved?}, with a question mark).  Summaries will
3959 be created for the @samp{Time_Estimate} column by adding time duration
3960 expressions like HH:MM, and for the @samp{Approved} column, by providing
3961 an @samp{[X]} status if all children have been checked.  The
3962 @samp{CLOCKSUM} column is special, it lists the sum of CLOCK intervals
3963 in the subtree.
3965 @node Using column view, Capturing column view, Defining columns, Column view
3966 @subsection Using column view
3968 @table @kbd
3969 @tsubheading{Turning column view on and off}
3970 @kindex C-c C-x C-c
3971 @item C-c C-x C-c
3972 Create the column view for the local environment.  This command searches
3973 the hierarchy, up from point, for a @code{:COLUMNS:} property that defines
3974 a format.  When one is found, the column view table is established for
3975 the entire tree, starting from the entry that contains the @code{:COLUMNS:}
3976 property.  If none is found, the format is taken from the @code{#+COLUMNS}
3977 line or from the variable @code{org-columns-default-format}, and column
3978 view is established for the current entry and its subtree.
3979 @kindex r
3980 @item r
3981 Recreate the column view, to include recent changes made in the buffer.
3982 @kindex g
3983 @item g
3984 Same as @kbd{r}.
3985 @kindex q
3986 @item q
3987 Exit column view.
3988 @tsubheading{Editing values}
3989 @item @key{left} @key{right} @key{up} @key{down}
3990 Move through the column view from field to field.
3991 @kindex S-@key{left}
3992 @kindex S-@key{right}
3993 @item  S-@key{left}/@key{right}
3994 Switch to the next/previous allowed value of the field.  For this, you
3995 have to have specified allowed values for a property.
3996 @item 1..9,0
3997 Directly select the nth allowed value, @kbd{0} selects the 10th value.
3998 @kindex n
3999 @kindex p
4000 @itemx  n / p
4001 Same as @kbd{S-@key{left}/@key{right}}
4002 @kindex e
4003 @item e
4004 Edit the property at point.  For the special properties, this will
4005 invoke the same interface that you normally use to change that
4006 property.  For example, when editing a TAGS property, the tag completion
4007 or fast selection interface will pop up.
4008 @kindex C-c C-c
4009 @item C-c C-c
4010 When there is a checkbox at point, toggle it.
4011 @kindex v
4012 @item v
4013 View the full value of this property.  This is useful if the width of
4014 the column is smaller than that of the value.
4015 @kindex a
4016 @item a
4017 Edit the list of allowed values for this property.  If the list is found
4018 in the hierarchy, the modified values is stored there.  If no list is
4019 found, the new value is stored in the first entry that is part of the
4020 current column view.
4021 @tsubheading{Modifying the table structure}
4022 @kindex <
4023 @kindex >
4024 @item < / >
4025 Make the column narrower/wider by one character.
4026 @kindex S-M-@key{right}
4027 @item S-M-@key{right}
4028 Insert a new column, to the left of the current column.
4029 @kindex S-M-@key{left}
4030 @item S-M-@key{left}
4031 Delete the current column.
4032 @end table
4034 @node Capturing column view,  , Using column view, Column view
4035 @subsection Capturing column view
4037 Since column view is just an overlay over a buffer, it cannot be
4038 exported or printed directly.  If you want to capture a column view, use
4039 this @code{columnview} dynamic block (@pxref{Dynamic blocks}).  The frame
4040 of this block looks like this:
4042 @cindex #+BEGIN: columnview
4043 @example
4044 * The column view
4045 #+BEGIN: columnview :hlines 1 :id "label"
4047 #+END:
4048 @end example
4050 @noindent This dynamic block has the following parameters:
4052 @table @code
4053 @item :id
4054 This is most important parameter.  Column view is a feature that is
4055 often localized to a certain (sub)tree, and the capture block might be
4056 in a different location in the file.  To identify the tree whose view to
4057 capture, you can use 3 values:
4058 @example
4059 local     @r{use the tree in which the capture block is located}
4060 global    @r{make a global view, including all headings in the file}
4061 "label"   @r{call column view in the tree that has an @code{:ID:}}
4062           @r{property with the value @i{label}.  You can use}
4063           @r{@kbd{M-x org-id-copy} to create a globally unique ID for}
4064           @r{the current entry and copy it to the kill-ring.}
4065 @end example
4066 @item :hlines
4067 When @code{t}, insert a hline after every line.  When a number N, insert
4068 a hline before each headline with level @code{<= N}.
4069 @item :vlines
4070 When set to @code{t}, enforce column groups to get vertical lines.
4071 @item :maxlevel
4072 When set to a number, don't capture entries below this level.
4073 @item :skip-empty-rows
4074 When set to @code{t}, skip row where the only non-empty specifier of the
4075 column view is @code{ITEM}.
4077 @end table
4079 @noindent
4080 The following commands insert or update the dynamic block:
4082 @table @kbd
4083 @kindex C-c C-x i
4084 @item C-c C-x i
4085 Insert a dynamic block capturing a column view.  You will be prompted
4086 for the scope or id of the view.
4087 @kindex C-c C-c
4088 @item C-c C-c
4089 @kindex C-c C-x C-u
4090 @itemx C-c C-x C-u
4091 Update dynamical block at point.  The cursor needs to be in the
4092 @code{#+BEGIN} line of the dynamic block.
4093 @kindex C-u C-c C-x C-u
4094 @item C-u C-c C-x C-u
4095 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
4096 you have several clock table blocks in a buffer.
4097 @end table
4099 You can add formulas to the column view table and you may add plotting
4100 instructions in front of the table - these will survive an update of the
4101 block.  If there is a @code{#+TBLFM:} after the table, the table will
4102 actually be recalculated automatically after an update.
4104 @node Property API,  , Column view, Properties and Columns
4105 @section The Property API
4106 @cindex properties, API
4107 @cindex API, for properties
4109 There is a full API for accessing and changing properties.  This API can
4110 be used by Emacs Lisp programs to work with properties and to implement
4111 features based on them.  For more information see @ref{Using the
4112 property API}.
4114 @node Dates and Times, Remember, Properties and Columns, Top
4115 @chapter Dates and Times
4116 @cindex dates
4117 @cindex times
4118 @cindex time stamps
4119 @cindex date stamps
4121 To assist project planning, TODO items can be labeled with a date and/or
4122 a time.  The specially formatted string carrying the date and time
4123 information is called a @emph{timestamp} in Org mode.  This may be a
4124 little confusing because timestamp is often used as indicating when
4125 something was created or last changed.  However, in Org mode this term
4126 is used in a much wider sense.
4128 @menu
4129 * Timestamps::                  Assigning a time to a tree entry
4130 * Creating timestamps::         Commands which insert timestamps
4131 * Deadlines and scheduling::    Planning your work
4132 * Clocking work time::          Tracking how long you spend on a task
4133 * Effort estimates::            Planning work effort in advance
4134 @end menu
4137 @node Timestamps, Creating timestamps, Dates and Times, Dates and Times
4138 @section Timestamps, deadlines and scheduling
4139 @cindex time stamps
4140 @cindex ranges, time
4141 @cindex date stamps
4142 @cindex deadlines
4143 @cindex scheduling
4145 A time stamp is a specification of a date (possibly with time or a range
4146 of times) in a special format, either @samp{<2003-09-16 Tue>} or
4147 @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16 Tue
4148 12:00-12:30>}@footnote{This is the standard ISO date/time format.  To
4149 use an alternative format, see @ref{Custom time format}.}.  A time stamp
4150 can appear anywhere in the headline or body of an Org tree entry.  Its
4151 presence causes entries to be shown on specific dates in the agenda
4152 (@pxref{Weekly/daily agenda}).  We distinguish:
4154 @table @var
4155 @item Plain time stamp; Event; Appointment
4156 @cindex timestamp
4157 A simple time stamp just assigns a date/time to an item.  This is just
4158 like writing down an appointment or event in a paper agenda.  In the
4159 timeline and agenda displays, the headline of an entry associated with a
4160 plain time stamp will be shown exactly on that date.
4162 @example
4163 * Meet Peter at the movies <2006-11-01 Wed 19:15>
4164 * Discussion on climate change <2006-11-02 Thu 20:00-22:00>
4165 @end example
4167 @item Time stamp with repeater interval
4168 @cindex timestamp, with repeater interval
4169 A time stamp may contain a @emph{repeater interval}, indicating that it
4170 applies not only on the given date, but again and again after a certain
4171 interval of N days (d), weeks (w), months(m), or years(y).  The
4172 following will show up in the agenda every Wednesday:
4174 @example
4175 * Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
4176 @end example
4178 @item Diary-style sexp entries
4179 For more complex date specifications, Org mode supports using the
4180 special sexp diary entries implemented in the Emacs calendar/diary
4181 package.  For example
4183 @example
4184 * The nerd meeting on every 2nd Thursday of the month
4185   <%%(diary-float t 4 2)>
4186 @end example
4188 @item Time/Date range
4189 @cindex timerange
4190 @cindex date range
4191 Two time stamps connected by @samp{--} denote a range.  The headline
4192 will be shown on the first and last day of the range, and on any dates
4193 that are displayed and fall in the range.  Here is an example:
4195 @example
4196 ** Meeting in Amsterdam
4197    <2004-08-23 Mon>--<2004-08-26 Thu>
4198 @end example
4200 @item Inactive time stamp
4201 @cindex timestamp, inactive
4202 @cindex inactive timestamp
4203 Just like a plain time stamp, but with square brackets instead of
4204 angular ones.  These time stamps are inactive in the sense that they do
4205 @emph{not} trigger an entry to show up in the agenda.
4207 @example
4208 * Gillian comes late for the fifth time [2006-11-01 Wed]
4209 @end example
4211 @end table
4213 @node Creating timestamps, Deadlines and scheduling, Timestamps, Dates and Times
4214 @section Creating timestamps
4215 @cindex creating timestamps
4216 @cindex timestamps, creating
4218 For Org mode to recognize time stamps, they need to be in the specific
4219 format.  All commands listed below produce time stamps in the correct
4220 format.
4222 @table @kbd
4223 @kindex C-c .
4224 @item C-c .
4225 Prompt for a date and insert a corresponding time stamp.  When the cursor is
4226 at an existing time stamp in the buffer, the command is used to modify this
4227 timestamp instead of inserting a new one.  When this command is used twice in
4228 succession, a time range is inserted.
4230 @kindex C-u C-c .
4231 @item C-u C-c .
4232 Like @kbd{C-c .}, but use the alternative format which contains date
4233 and time.  The default time can be rounded to multiples of 5 minutes,
4234 see the option @code{org-time-stamp-rounding-minutes}.
4236 @kindex C-c !
4237 @item C-c !
4238 Like @kbd{C-c .}, but insert an inactive time stamp that will not cause
4239 an agenda entry.
4241 @kindex C-c <
4242 @item C-c <
4243 Insert a time stamp corresponding to the cursor date in the Calendar.
4245 @kindex C-c >
4246 @item C-c >
4247 Access the Emacs calendar for the current date.  If there is a
4248 timestamp in the current line, go to the corresponding date
4249 instead.
4251 @kindex C-c C-o
4252 @item C-c C-o
4253 Access the agenda for the date given by the time stamp or -range at
4254 point (@pxref{Weekly/daily agenda}).
4256 @kindex S-@key{left}
4257 @kindex S-@key{right}
4258 @item S-@key{left}
4259 @itemx S-@key{right}
4260 Change date at cursor by one day.  These key bindings conflict with
4261 CUA mode (@pxref{Conflicts}).
4263 @kindex S-@key{up}
4264 @kindex S-@key{down}
4265 @item S-@key{up}
4266 @itemx S-@key{down}
4267 Change the item under the cursor in a timestamp.  The cursor can be on a
4268 year, month, day, hour or minute.  Note that if the cursor is in a
4269 headline and not at a time stamp, these same keys modify the priority of
4270 an item.  (@pxref{Priorities}). The key bindings also conflict with
4271 CUA mode (@pxref{Conflicts}).
4273 @kindex C-c C-y
4274 @cindex evaluate time range
4275 @item C-c C-y
4276 Evaluate a time range by computing the difference between start and end.
4277 With a prefix argument, insert result after the time range (in a table: into
4278 the following column).
4279 @end table
4282 @menu
4283 * The date/time prompt::        How Org mode helps you entering date and time
4284 * Custom time format::          Making dates look different
4285 @end menu
4287 @node The date/time prompt, Custom time format, Creating timestamps, Creating timestamps
4288 @subsection The date/time prompt
4289 @cindex date, reading in minibuffer
4290 @cindex time, reading in minibuffer
4292 When Org mode prompts for a date/time, the default is shown as an ISO
4293 date, and the prompt therefore seems to ask for an ISO date.  But it
4294 will in fact accept any string containing some date and/or time
4295 information, and it is really smart about interpreting your input.  You
4296 can, for example, use @kbd{C-y} to paste a (possibly multi-line) string
4297 copied from an email message.  Org mode will find whatever information
4298 is in there and derive anything you have not specified from the
4299 @emph{default date and time}.  The default is usually the current date
4300 and time, but when modifying an existing time stamp, or when entering
4301 the second stamp of a range, it is taken from the stamp in the buffer.
4302 When filling in information, Org mode assumes that most of the time you
4303 will want to enter a date in the future: If you omit the month/year and
4304 the given day/month is @i{before} today, it will assume that you mean a
4305 future date@footnote{See the variable
4306 @code{org-read-date-prefer-future}.}.
4308 For example, lets assume that today is @b{June 13, 2006}.  Here is how
4309 various inputs will be interpreted, the items filled in by Org mode are
4310 in @b{bold}.
4312 @example
4313 3-2-5         --> 2003-02-05
4314 14            --> @b{2006}-@b{06}-14
4315 12            --> @b{2006}-@b{07}-12
4316 Fri           --> nearest Friday (defaultdate or later)
4317 sep 15        --> @b{2006}-11-15
4318 feb 15        --> @b{2007}-02-15
4319 sep 12 9      --> 2009-09-12
4320 12:45         --> @b{2006}-@b{06}-@b{13} 12:45
4321 22 sept 0:34  --> @b{2006}-09-22 0:34
4322 w4            --> ISO week for of the current year @b{2006}
4323 2012 w4 fri   --> Friday of ISO week 4 in 2012
4324 2012-w04-5    --> Same as above
4325 @end example
4327 Furthermore you can specify a relative date by giving, as the
4328 @emph{first} thing in the input: a plus/minus sign, a number and a
4329 letter [dwmy] to indicate change in days weeks, months, years.  With a
4330 single plus or minus, the date is always relative to today.  With a
4331 double plus or minus, it is relative to the default date.  If instead of
4332 a single letter, you use the abbreviation of day name, the date will be
4333 the nth such day.  E.g.
4335 @example
4336 +0            --> today
4337 .             --> today
4338 +4d           --> four days from today
4339 +4            --> same as above
4340 +2w           --> two weeks from today
4341 ++5           --> five days from default date
4342 +2tue         --> second tuesday from now.
4343 @end example
4345 The function understands English month and weekday abbreviations.  If
4346 you want to use unabbreviated names and/or other languages, configure
4347 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
4349 @cindex calendar, for selecting date
4350 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
4351 you don't need/want the calendar, configure the variable
4352 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
4353 prompt, either by clicking on a date in the calendar, or by pressing
4354 @key{RET}, the date selected in the calendar will be combined with the
4355 information entered at the prompt.  You can control the calendar fully
4356 from the minibuffer:
4358 @kindex <
4359 @kindex >
4360 @kindex mouse-1
4361 @kindex S-@key{right}
4362 @kindex S-@key{left}
4363 @kindex S-@key{down}
4364 @kindex S-@key{up}
4365 @kindex M-S-@key{right}
4366 @kindex M-S-@key{left}
4367 @kindex @key{RET}
4368 @example
4369 > / <          @r{Scroll calendar forward/backward by one month.}
4370 mouse-1        @r{Select date by clicking on it.}
4371 S-@key{right}/@key{left}     @r{One day forward/backward.}
4372 S-@key{down}/@key{up}     @r{One week forward/backward.}
4373 M-S-@key{right}/@key{left}   @r{One month forward/backward.}
4374 @key{RET}           @r{Choose date in calendar.}
4375 @end example
4377 The actions of the date/time prompt may seem complex, but I assure you they
4378 will grow on you, and you will start getting annoyed by pretty much any other
4379 way of entering a date/time out there.  To help you understand what is going
4380 on, the current interpretation of your input will be displayed live in the
4381 minibuffer@footnote{If you find this distracting, turn the display of with
4382 @code{org-read-date-display-live}.}.
4384 @node Custom time format,  , The date/time prompt, Creating timestamps
4385 @subsection Custom time format
4386 @cindex custom date/time format
4387 @cindex time format, custom
4388 @cindex date format, custom
4390 Org mode uses the standard ISO notation for dates and times as it is
4391 defined in ISO 8601.  If you cannot get used to this and require another
4392 representation of date and time to keep you happy, you can get it by
4393 customizing the variables @code{org-display-custom-times} and
4394 @code{org-time-stamp-custom-formats}.
4396 @table @kbd
4397 @kindex C-c C-x C-t
4398 @item C-c C-x C-t
4399 Toggle the display of custom formats for dates and times.
4400 @end table
4402 @noindent
4403 Org mode needs the default format for scanning, so the custom date/time
4404 format does not @emph{replace} the default format - instead it is put
4405 @emph{over} the default format using text properties.  This has the
4406 following consequences:
4407 @itemize @bullet
4408 @item
4409 You cannot place the cursor onto a time stamp anymore, only before or
4410 after.
4411 @item
4412 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
4413 each component of a time stamp.  If the cursor is at the beginning of
4414 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
4415 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
4416 time will be changed by one minute.
4417 @item
4418 If the time stamp contains a range of clock times or a repeater, these
4419 will not be overlayed, but remain in the buffer as they were.
4420 @item
4421 When you delete a time stamp character-by-character, it will only
4422 disappear from the buffer after @emph{all} (invisible) characters
4423 belonging to the ISO timestamp have been removed.
4424 @item
4425 If the custom time stamp format is longer than the default and you are
4426 using dates in tables, table alignment will be messed up.  If the custom
4427 format is shorter, things do work as expected.
4428 @end itemize
4431 @node Deadlines and scheduling, Clocking work time, Creating timestamps, Dates and Times
4432 @section Deadlines and scheduling
4434 A time stamp may be preceded by special keywords to facilitate planning:
4436 @table @var
4437 @item DEADLINE
4438 @cindex DEADLINE keyword
4440 Meaning: the task (most likely a TODO item, though not necessarily) is supposed
4441 to be finished on that date.
4443 On the deadline date, the task will be listed in the agenda.  In
4444 addition, the agenda for @emph{today} will carry a warning about the
4445 approaching or missed deadline, starting
4446 @code{org-deadline-warning-days} before the due date, and continuing
4447 until the entry is marked DONE.  An example:
4449 @example
4450 *** TODO write article about the Earth for the Guide
4451     The editor in charge is [[bbdb:Ford Prefect]]
4452     DEADLINE: <2004-02-29 Sun>
4453 @end example
4455 You can specify a different lead time for warnings for a specific
4456 deadlines using the following syntax.  Here is an example with a warning
4457 period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.
4459 @item SCHEDULED
4460 @cindex SCHEDULED keyword
4462 Meaning: you are planning to start working on that task on the given
4463 date.
4465 The headline will be listed under the given date@footnote{It will still
4466 be listed on that date after it has been marked DONE.  If you don't like
4467 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
4468 addition, a reminder that the scheduled date has passed will be present
4469 in the compilation for @emph{today}, until the entry is marked DONE.
4470 I.e., the task will automatically be forwarded until completed.
4472 @example
4473 *** TODO Call Trillian for a date on New Years Eve.
4474     SCHEDULED: <2004-12-25 Sat>
4475 @end example
4477 @noindent
4478 @b{Important:} Scheduling an item in Org mode should @i{not} be
4479 understood in the same way that we understand @i{scheduling a meeting}.
4480 Setting a date for a meeting is just a simple appointment, you should
4481 mark this entry with a simple plain time stamp, to get this item shown
4482 on the date where it applies.  This is a frequent mis-understanding from
4483 Org-users.  In Org mode, @i{scheduling} means setting a date when you
4484 want to start working on an action item.
4485 @end table
4487 You may use time stamps with repeaters in scheduling and deadline
4488 entries.  Org mode will issue early and late warnings based on the
4489 assumption that the time stamp represents the @i{nearest instance} of
4490 the repeater.  However, the use of diary sexp entries like
4492 @code{<%%(diary-float t 42)>}
4494 in scheduling and deadline timestamps is limited.  Org mode does not
4495 know enough about the internals of each sexp function to issue early and
4496 late warnings.  However, it will show the item on each day where the
4497 sexp entry matches.
4499 @menu
4500 * Inserting deadline/schedule::  Planning items
4501 * Repeated tasks::              Items that show up again and again
4502 @end menu
4504 @node Inserting deadline/schedule, Repeated tasks, Deadlines and scheduling, Deadlines and scheduling
4505 @subsection Inserting deadlines or schedules
4507 The following commands allow to quickly insert a deadline or to schedule
4508 an item:
4510 @table @kbd
4512 @kindex C-c C-d
4513 @item C-c C-d
4514 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will
4515 happen in the line directly following the headline.  When called with a
4516 prefix arg, an existing deadline will be removed from the entry.
4517 @c FIXME Any CLOSED timestamp will be removed.????????
4519 @kindex C-c / d
4520 @cindex sparse tree, for deadlines
4521 @item C-c / d
4522 Create a sparse tree with all deadlines that are either past-due, or
4523 which will become due within @code{org-deadline-warning-days}.
4524 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
4525 prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows
4526 all deadlines due tomorrow.
4528 @kindex C-c C-s
4529 @item C-c C-s
4530 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
4531 happen in the line directly following the headline.  Any CLOSED
4532 timestamp will be removed.  When called with a prefix argument, remove
4533 the scheduling date from the entry.
4535 @kindex C-c C-x C-k
4536 @kindex k a
4537 @kindex k s
4538 @item C-c C-x C-k
4539 Mark the current entry for agenda action.  After you have marked the entry
4540 like this, you can open the agenda or the calendar to find an appropriate
4541 date.  With the cursor on the selected date, press @kbd{k s} or @kbd{k d} to
4542 schedule the marked item.
4543 @end table
4545 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
4546 @subsection Repeated tasks
4548 Some tasks need to be repeated again and again.  Org mode helps to
4549 organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
4550 or plain time stamp.  In the following example
4551 @example
4552 ** TODO Pay the rent
4553    DEADLINE: <2005-10-01 Sat +1m>
4554 @end example
4555 the @code{+1m} is a repeater; the intended interpretation is that the
4556 task has a deadline on <2005-10-01> and repeats itself every (one) month
4557 starting from that time.  If you need both a repeater and a special
4558 warning period in a deadline entry, the repeater comes first and the
4559 warning period last: @code{DEADLINE: <2005-10-01 Sat +1m -3d>}.
4561 Deadlines and scheduled items produce entries in the agenda when they
4562 are over-due, so it is important to be able to mark such an entry as
4563 completed once you have done so.  When you mark a DEADLINE or a SCHEDULE
4564 with the TODO keyword DONE, it will no longer produce entries in the
4565 agenda.  The problem with this is, however, that then also the
4566 @emph{next} instance of the repeated entry will not be active.  Org mode
4567 deals with this in the following way: When you try to mark such an entry
4568 DONE (using @kbd{C-c C-t}), it will shift the base date of the repeating
4569 time stamp by the repeater interval, and immediately set the entry state
4570 back to TODO.  In the example above, setting the state to DONE would
4571 actually switch the date like this:
4573 @example
4574 ** TODO Pay the rent
4575    DEADLINE: <2005-11-01 Tue +1m>
4576 @end example
4578 A timestamp@footnote{You can change this using the option
4579 @code{org-log-repeat}, or the @code{#+STARTUP} options @code{logrepeat},
4580 @code{lognoterepeat}, and @code{nologrepeat}.  With @code{lognoterepeat}, you
4581 will aslo be prompted for a note.} will be added under the deadline, to keep
4582 a record that you actually acted on the previous instance of this deadline.
4584 As a consequence of shifting the base date, this entry will no longer be
4585 visible in the agenda when checking past dates, but all future instances
4586 will be visible.
4588 With the @samp{+1m} cookie, the date shift will always be exactly one
4589 month.  So if you have not payed the rent for three months, marking this
4590 entry DONE will still keep it as an overdue deadline.  Depending on the
4591 task, this may not be the best way to handle it.  For example, if you
4592 forgot to call you father for 3 weeks, it does not make sense to call
4593 him 3 times in a single day to make up for it.  Finally, there are tasks
4594 like changing batteries which should always repeat a certain time
4595 @i{after} the last time you did it.  For these tasks, Org mode has
4596 special repeaters markers with @samp{++} and @samp{.+}.  For example:
4598 @example
4599 ** TODO Call Father
4600    DEADLINE: <2008-02-10 Sun ++1w>
4601    Marking this DONE will shift the date by at least one week,
4602    but also by as many weeks as it takes to get this date into
4603    the future.  However, it stays on a Sunday, even if you called
4604    and marked it done on Saturday.
4605 ** TODO Check the batteries in the smoke detectors
4606    DEADLINE: <2005-11-01 Tue .+1m>
4607    Marking this DONE will shift the date to one month after
4608    today.
4609 @end example
4611 You may have both scheduling and deadline information for a specific
4612 task - just make sure that the repeater intervals on both are the same.
4614 @node Clocking work time, Effort estimates, Deadlines and scheduling, Dates and Times
4615 @section Clocking work time
4617 Org mode allows you to clock the time you spent on specific tasks in a
4618 project.  When you start working on an item, you can start the clock.
4619 When you stop working on that task, or when you mark the task done, the
4620 clock is stopped and the corresponding time interval is recorded.  It
4621 also computes the total time spent on each subtree of a project.
4623 @table @kbd
4624 @kindex C-c C-x C-i
4625 @item C-c C-x C-i
4626 Start the clock on the current item (clock-in).  This inserts the CLOCK
4627 keyword together with a timestamp.  If this is not the first clocking of
4628 this item, the multiple CLOCK lines will be wrapped into a
4629 @code{:CLOCK:} drawer (see also the variable
4630 @code{org-clock-into-drawer}).  When called with a @kbd{C-u} prefix argument,
4631 select the task from a list of recently clocked tasks.  With two @kbd{C-u
4632 C-u} prefixes, clock into the task at point and mark it as the default task.
4633 The default task will always be available when selecting a clocking task,
4634 with letter @kbd{d}.
4635 @kindex C-c C-x C-o
4636 @item C-c C-x C-o
4637 Stop the clock (clock-out).  The inserts another timestamp at the same
4638 location where the clock was last started.  It also directly computes
4639 the resulting time in inserts it after the time range as @samp{=>
4640 HH:MM}.  See the variable @code{org-log-note-clock-out} for the
4641 possibility to record an additional note together with the clock-out
4642 time stamp@footnote{The corresponding in-buffer setting is:
4643 @code{#+STARTUP: lognoteclock-out}}.
4644 @kindex C-c C-y
4645 @item C-c C-y
4646 Recompute the time interval after changing one of the time stamps.  This
4647 is only necessary if you edit the time stamps directly.  If you change
4648 them with @kbd{S-@key{cursor}} keys, the update is automatic.
4649 @kindex C-c C-t
4650 @item C-c C-t
4651 Changing the TODO state of an item to DONE automatically stops the clock
4652 if it is running in this same item.
4653 @kindex C-c C-x C-x
4654 @item C-c C-x C-x
4655 Cancel the current clock.  This is useful if a clock was started by
4656 mistake, or if you ended up working on something else.
4657 @kindex C-c C-x C-j
4658 @item C-c C-x C-j
4659 Jump to the entry that contains the currently running clock.  With a
4660 @kbd{C-u} prefix arg, select the target task from a list of recently clocked
4661 tasks.
4662 @kindex C-c C-x C-d
4663 @item C-c C-x C-d
4664 Display time summaries for each subtree in the current buffer.  This
4665 puts overlays at the end of each headline, showing the total time
4666 recorded under that heading, including the time of any subheadings. You
4667 can use visibility cycling to study the tree, but the overlays disappear
4668 when you change the buffer (see variable
4669 @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
4670 @kindex C-c C-x C-r
4671 @item C-c C-x C-r
4672 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
4673 report as an Org mode table into the current file.  When the cursor is
4674 at an existing clock table, just update it.  When called with a prefix
4675 argument, jump to the first clock report in the current document and
4676 update it.
4677 @cindex #+BEGIN: clocktable
4678 @example
4679 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
4680 #+END: clocktable
4681 @end example
4682 @noindent
4683 If such a block already exists at point, its content is replaced by the
4684 new table.  The @samp{BEGIN} line can specify options:
4685 @example
4686 :maxlevel    @r{Maximum level depth to which times are listed in the table.}
4687 :emphasize   @r{When @code{t}, emphasize level one and level two items}
4688 :scope       @r{The scope to consider.  This can be any of the following:}
4689              nil        @r{the current buffer or narrowed region}
4690              file       @r{the full current buffer}
4691              subtree    @r{the subtree where the clocktable is located}
4692              treeN      @r{the surrounding level N tree, for example @code{tree3}}
4693              tree       @r{the surrounding level 1 tree}
4694              agenda     @r{all agenda files}
4695              ("file"..) @r{scan these files}
4696              file-with-archives    @r{current file and its archives}
4697              agenda-with-archives  @r{all agenda files, including archives}
4698 :block       @r{The time block to consider.  This block is specified either}
4699              @r{absolute, or relative to the current time and may be any of}
4700              @r{these formats:}
4701              2007-12-31    @r{New year eve 2007}
4702              2007-12       @r{December 2007}
4703              2007-W50      @r{ISO-week 50 in 2007}
4704              2007          @r{the year 2007}
4705              today, yesterday, today-N          @r{a relative day}
4706              thisweek, lastweek, thisweek-N     @r{a relative week}
4707              thismonth, lastmonth, thismonth-N  @r{a relative month}
4708              thisyear, lastyear, thisyear-N     @r{a relative year}
4709              @r{Use @kbd{S-@key{left}/@key{right}} keys to shift the time interval.}
4710 :tstart      @r{A time string specifying when to start considering times}
4711 :tend        @r{A time string specifying when to stop considering times}
4712 :step        @r{@code{week} or @code{day}, to split the table into chunks.}
4713              @r{To use this, @code{:block} or @code{:tstart}, @code{:tend} are needed.}
4714 :link        @r{Link the item headlines in the table to their origins}
4715 @end example
4716 So to get a clock summary of the current level 1 tree, for the current
4717 day, you could write
4718 @example
4719 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
4720 #+END: clocktable
4721 @end example
4722 and to use a specific time range you could write@footnote{Note that all
4723 parameters must be specified in a single line - the line is broken here
4724 only to fit it onto the manual.}
4725 @example
4726 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
4727                     :tend "<2006-08-10 Thu 12:00>"
4728 #+END: clocktable
4729 @end example
4730 @kindex C-c C-c
4731 @item C-c C-c
4732 @kindex C-c C-x C-u
4733 @itemx C-c C-x C-u
4734 Update dynamical block at point.  The cursor needs to be in the
4735 @code{#+BEGIN} line of the dynamic block.
4736 @kindex C-u C-c C-x C-u
4737 @item C-u C-c C-x C-u
4738 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
4739 you have several clock table blocks in a buffer.
4740 @kindex S-@key{left}
4741 @kindex S-@key{right}
4742 @item S-@key{left}
4743 @itemx S-@key{right}
4744 Shift the current @code{:block} interval and update the table.  The cursor
4745 needs to be in the @code{#+BEGIN: clocktable} line for this command.  If
4746 @code{:block} is @code{today}, it will be shifted to @code{today-1} etc.
4747 @end table
4749 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
4750 the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
4751 worked on or closed during a day.
4753 @node Effort estimates,  , Clocking work time, Dates and Times
4754 @section Effort estimates
4755 @cindex Effort estimates
4757 If you want to plan your work in a very detailed way, or if you need to
4758 produce offers with quotations of the estimated work effort, you may want to
4759 assign effort estimates to entries.  If you are also clocking your work, you
4760 may later want to compare the planned effort with the actual working time, a
4761 great way to improve planning estimates.  Effort estimates are stored in a
4762 special property @samp{Effort}@footnote{You may change the property being
4763 used with the variable @code{org-effort-property}.}.  Clearly the best way to
4764 work with effort estimates is through column view (@pxref{Column view}).  You
4765 should start by setting up discrete values for effort estimates, and a
4766 @code{COLUMNS} format that displays these values together with clock sums (if
4767 you want to clock your time).  For a specific buffer you can use
4769 @example
4770 #+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00 8:00
4771 #+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort)@{:@} %CLOCKSUM
4772 @end example
4774 @noindent
4775 or you can set up these values globally by customizing the variables
4776 @code{org-global-properties} and @code{org-columns-default-format}.  In
4777 particular if you want to use this setup also in the agenda, a global setup
4778 may be advised.
4780 The way to assign estimates to individual items is then to switch to column
4781 mode, and to use @kbd{S-@key{right}} and @kbd{S-@key{left}} to change the
4782 value.  The values you enter will immediately be summed up in the hierarchy.
4783 In the column next to it, any clocked time will be displayed.
4785 If you switch to column view in the daily/weekly agenda, the effort column
4786 will summarize the estimated work effort for each day@footnote{Please note
4787 the pitfalls of summing hierarchical data in a flat list (@pxref{Agenda
4788 column view}).}, and you can use this to find space in your schedule.  To get
4789 an overview of the entire part of the day that is committed, you can set the
4790 option @code{org-agenda-columns-add-appointments-to-effort-sum}.  The
4791 appointments on a day that take place over a specified time interval will
4792 then also be added to the load estimate of the day.
4794 @node Remember, Agenda Views, Dates and Times, Top
4795 @chapter Remember
4796 @cindex @file{remember.el}
4798 The @i{Remember} package by John Wiegley lets you store quick notes with
4799 little interruption of your work flow.  See
4800 @uref{http://www.emacswiki.org/cgi-bin/wiki/RememberMode} for more
4801 information.  It is an excellent way to add new notes and tasks to
4802 Org files.  Org significantly expands the possibilities of
4803 @i{remember}: You may define templates for different note types, and
4804 associate target files and headlines with specific templates.  It also
4805 allows you to select the location where a note should be stored
4806 interactively, on the fly.
4808 @menu
4809 * Setting up Remember::         Some code for .emacs to get things going
4810 * Remember templates::          Define the outline of different note types
4811 * Storing notes::               Directly get the note to where it belongs
4812 * Refiling notes::              Moving a note or task to a project
4813 @end menu
4815 @node Setting up Remember, Remember templates, Remember, Remember
4816 @section Setting up Remember
4818 The following customization will tell @i{remember} to use org files as
4819 target, and to create annotations compatible with Org links.
4821 @example
4822 (org-remember-insinuate)
4823 (setq org-directory "~/path/to/my/orgfiles/")
4824 (setq org-default-notes-file (concat org-directory "/notes.org"))
4825 (define-key global-map "\C-cr" 'org-remember)
4826 @end example
4828 The last line binds the command @code{org-remember} to a global
4829 key@footnote{Please select your own key, @kbd{C-c r} is only a
4830 suggestion.}.  @code{org-remember} basically just calls @code{remember},
4831 but it makes a few things easier: If there is an active region, it will
4832 automatically copy the region into the remember buffer.  It also allows
4833 to jump to the buffer and location where remember notes are being
4834 stored: Just call @code{org-remember} with a prefix argument.  If you
4835 use two prefix arguments, Org jumps to the location where the last
4836 remember note was stored.
4838 You can also call @code{org-remember} in a special way from the agenda,
4839 using the @kbd{k r} key combination.  With this access, any time stamps
4840 inserted by the selected remember template (see below) will default to
4841 the cursor date in the agenda, rather than to the current date.
4843 @node Remember templates, Storing notes, Setting up Remember, Remember
4844 @section Remember templates
4845 @cindex templates, for remember
4847 In combination with Org, you can use templates to generate
4848 different types of @i{remember} notes.  For example, if you would like
4849 to use one template to create general TODO entries, another one for
4850 journal entries, and a third one for collecting random ideas, you could
4851 use:
4853 @example
4854 (setq org-remember-templates
4855  '(("Todo" ?t "* TODO %?\n  %i\n  %a" "~/org/TODO.org" "Tasks")
4856    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org")
4857    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
4858 @end example
4860 @noindent In these entries, the first string is just a name, and the
4861 character specifies how to select the template.  It is useful if the
4862 character is also the first letter of the name.  The next string specifies
4863 the template.  Two more (optional) strings give the file in which, and the
4864 headline under which the new note should be stored.  The file (if not present
4865 or @code{nil}) defaults to @code{org-default-notes-file}, the heading to
4866 @code{org-remember-default-headline}.  If the file name is not an absolute
4867 path, it will be interpreted relative to @code{org-directory}.  The heading
4868 can also be the symbols @code{top} or @code{bottom} to send note as level 1
4869 entries to the beginning or end of the file, respectively.
4871 An optional sixth element specifies the contexts in which the user can select
4872 the template.  This element can be a list of major modes or a function.
4873 @code{org-remember} will first check whether the function returns @code{t} or
4874 if we are in any of the listed major mode, and exclude templates fo which
4875 this condition is not fulfilled.  Templates that do not specify this element
4876 at all, or that use @code{nil} or @code{t} as a value will always be
4877 selectable.
4879 So for example:
4881 @example
4882 (setq org-remember-templates
4883  '(("Bug" ?b "* BUG %?\n  %i\n  %a" "~/org/BUGS.org" "Bugs" (emacs-lisp-mode))
4884    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org" "X" my-check)
4885    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
4886 @end example
4888 The first template will only be available when invoking @code{org-remember}
4889 from an buffer in @code{emacs-lisp-mode}.  The second template will only be
4890 available when the function @code{my-check} returns @code{t}.  The third
4891 template will be proposed in any context.
4893 When you call @kbd{M-x org-remember} (or @kbd{M-x remember}) to remember
4894 something, Org will prompt for a key to select the template (if you have
4895 more than one template) and then prepare the buffer like
4896 @example
4897 * TODO
4898   [[file:link to where you called remember]]
4899 @end example
4901 @noindent
4902 During expansion of the template, special @kbd{%}-escapes allow dynamic
4903 insertion of content:
4904 @example
4905 %^@{prompt@}  @r{prompt the user for a string and replace this sequence with it.}
4906             @r{You may specify a default value and a completion table with}
4907             @r{%^@{prompt|default|completion2|completion3...@}}
4908             @r{The arrow keys access a prompt-specific history.}
4909 %a          @r{annotation, normally the link created with @code{org-store-link}}
4910 %A          @r{like @code{%a}, but prompt for the description part}
4911 %i          @r{initial content, the region when remember is called with C-u.}
4912             @r{The entire text will be indented like @code{%i} itself.}
4913 %t          @r{time stamp, date only}
4914 %T          @r{time stamp with date and time}
4915 %u, %U      @r{like the above, but inactive time stamps}
4916 %^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
4917             @r{You may define a prompt like @code{%^@{Birthday@}t}}
4918 %n          @r{user name (taken from @code{user-full-name})}
4919 %c          @r{Current kill ring head.}
4920 %x          @r{Content of the X clipboard.}
4921 %^C         @r{Interactive selection of which kill or clip to use.}
4922 %^L         @r{Like @code{%^C}, but insert as link.}
4923 %^g         @r{prompt for tags, with completion on tags in target file.}
4924 %^G         @r{prompt for tags, with completion all tags in all agenda files.}
4925 %^@{prop@}p   @r{Prompt the user for a value for property @code{prop}}
4926 %:keyword   @r{specific information for certain link types, see below}
4927 %[pathname] @r{insert the contents of the file given by @code{pathname}}
4928 %(sexp)     @r{evaluate elisp @code{(sexp)} and replace with the result}
4929 %!          @r{immediately store note after completing the template}
4930             @r{(skipping the @kbd{C-c C-c} that normally triggers storing)}
4931 %&          @r{jump to target location immediately after storing note}
4932 @end example
4934 @noindent
4935 For specific link types, the following keywords will be
4936 defined@footnote{If you define your own link types (@pxref{Adding
4937 hyperlink types}), any property you store with
4938 @code{org-store-link-props} can be accessed in remember templates in a
4939 similar way.}:
4941 @example
4942 Link type          |  Available keywords
4943 -------------------+----------------------------------------------
4944 bbdb               |  %:name %:company
4945 bbdb               |  %::server %:port %:nick
4946 vm, wl, mh, rmail  |  %:type %:subject %:message-id
4947                    |  %:from %:fromname %:fromaddress
4948                    |  %:to   %:toname   %:toaddress
4949                    |  %: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}.}}
4950 gnus               |  %:group, @r{for messages also all email fields}
4951 w3, w3m            |  %:url
4952 info               |  %:file %:node
4953 calendar           |  %:date"
4954 @end example
4956 @noindent
4957 To place the cursor after template expansion use:
4959 @example
4960 %?          @r{After completing the template, position cursor here.}
4961 @end example
4963 @noindent
4964 If you change your mind about which template to use, call
4965 @code{org-remember} in the remember buffer.  You may then select a new
4966 template that will be filled with the previous context information.
4968 @node Storing notes, Refiling notes, Remember templates, Remember
4969 @section Storing notes
4971 When you are finished preparing a note with @i{remember}, you have to press
4972 @kbd{C-c C-c} to file the note away.  If you have started the clock in the
4973 remember buffer, you will first be asked if you want to clock out
4974 now@footnote{To avoid this query, configure the variable
4975 @code{org-remember-clock-out-on-exit}.}.  If you answer @kbd{n}, the clock
4976 will continue to run after the note was filed away.
4978 The handler will then store the note in the file and under the headline
4979 specified in the template, or it will use the default file and headlines.
4980 The window configuration will be restored, sending you back to the working
4981 context before the call to @code{remember}.  To re-use the location found
4982 during the last call to @code{remember}, exit the remember buffer with
4983 @kbd{C-0 C-c C-c}, i.e. specify a zero prefix argument to @kbd{C-c C-c}.
4985 If you want to store the note directly to a different place, use
4986 @kbd{C-1 C-c C-c} instead to exit remember@footnote{Configure the
4987 variable @code{org-remember-store-without-prompt} to make this behavior
4988 the default.}.  The handler will then first prompt for a target file -
4989 if you press @key{RET}, the value specified for the template is used.
4990 Then the command offers the headings tree of the selected file, with the
4991 cursor position at the default headline (if you had specified one in the
4992 template).  You can either immediately press @key{RET} to get the note
4993 placed there.  Or you can use the following keys to find a different
4994 location:
4995 @example
4996 @key{TAB}         @r{Cycle visibility.}
4997 @key{down} / @key{up}   @r{Next/previous visible headline.}
4998 n / p        @r{Next/previous visible headline.}
4999 f / b        @r{Next/previous headline same level.}
5000 u            @r{One level up.}
5001 @c 0-9          @r{Digit argument.}
5002 @end example
5003 @noindent
5004 Pressing @key{RET} or @key{left} or @key{right}
5005 then leads to the following result.
5007 @multitable @columnfractions 0.2 0.15 0.65
5008 @item @b{Cursor position} @tab @b{Key} @tab @b{Note gets inserted}
5009 @item on headline     @tab @key{RET}              @tab as sublevel of the heading at cursor, first or last
5010 @item                 @tab                        @tab depending on @code{org-reverse-note-order}.
5011 @item                 @tab @key{left}/@key{right} @tab as same level, before/after current heading
5012 @item buffer-start    @tab @key{RET} @tab as level 2 heading at end of file or level 1 at beginning
5013 @item                 @tab @tab depending on @code{org-reverse-note-order}.
5014 @item not on headline @tab @key{RET}
5015       @tab at cursor position, level taken from context.
5016 @end multitable
5018 Before inserting the text into a tree, the function ensures that the
5019 text has a headline, i.e. a first line that starts with a @samp{*}.  If
5020 not, a headline is constructed from the current date and some additional
5021 data.  If you have indented the text of the note below the headline, the
5022 indentation will be adapted if inserting the note into the tree requires
5023 demotion from level 1.
5025 @node Refiling notes,  , Storing notes, Remember
5026 @section Refiling notes
5027 @cindex refiling notes
5029 Remember is usually used to quickly capture notes and tasks into one or
5030 a few capture lists.  When reviewing the captured data, you may want to
5031 refile some of the entries into a different list, for example into a
5032 project.  Cutting, finding the right location and then pasting the note
5033 is cumbersome.  To simplify this process, you can use the following
5034 special command:
5036 @table @kbd
5037 @kindex C-c C-w
5038 @item C-c C-w
5039 Refile the entry at point.  This command offers possible locations for
5040 refiling the entry and lets you select one with completion.  The item is
5041 filed below the target heading as a subitem.  Depending on
5042 @code{org-reverse-note-order}, it will be either the first of last
5043 subitem.@* By default, all level 1 headlines in the current buffer are
5044 considered to be targets, but you can have more complex definitions
5045 across a number of files.  See the variable @code{org-refile-targets}
5046 for details.  If you would like to select a location via a file-pathlike
5047 completion along the outline path, see the variable
5048 @code{org-refile-use-outline-path}.
5049 @kindex C-u C-c C-w
5050 @item C-u C-c C-w
5051 Use the refile interface to jump to a heading.
5052 @kindex C-u C-u C-c C-w
5053 @item C-u C-u C-c C-w
5054 Jump to the location where @code{org-refile} last moved a tree to.
5055 @end table
5057 @node Agenda Views, Embedded LaTeX, Remember, Top
5058 @chapter Agenda Views
5059 @cindex agenda views
5061 Due to the way Org works, TODO items, time-stamped items, and
5062 tagged headlines can be scattered throughout a file or even a number of
5063 files.  To get an overview of open action items, or of events that are
5064 important for a particular date, this information must be collected,
5065 sorted and displayed in an organized way.
5067 Org can select items based on various criteria, and display them
5068 in a separate buffer.  Seven different view types are provided:
5070 @itemize @bullet
5071 @item
5072 an @emph{agenda} that is like a calendar and shows information
5073 for specific dates,
5074 @item
5075 a @emph{TODO list} that covers all unfinished
5076 action items,
5077 @item
5078 a @emph{match view}, showings headlines based on the tags, properties and
5079 TODO state associated with them,
5080 @item
5081 a @emph{timeline view} that shows all events in a single Org file,
5082 in time-sorted view,
5083 @item
5084 a @emph{keyword search view} that shows all entries from multiple files
5085 that contain specified keywords.
5086 @item
5087 a @emph{stuck projects view} showing projects that currently don't move
5088 along, and
5089 @item
5090 @emph{custom views} that are special tag/keyword searches and
5091 combinations of different views.
5092 @end itemize
5094 @noindent
5095 The extracted information is displayed in a special @emph{agenda
5096 buffer}.  This buffer is read-only, but provides commands to visit the
5097 corresponding locations in the original Org files, and even to
5098 edit these files remotely.
5100 Two variables control how the agenda buffer is displayed and whether the
5101 window configuration is restored when the agenda exits:
5102 @code{org-agenda-window-setup} and
5103 @code{org-agenda-restore-windows-after-quit}.
5105 @menu
5106 * Agenda files::                Files being searched for agenda information
5107 * Agenda dispatcher::           Keyboard access to agenda views
5108 * Built-in agenda views::       What is available out of the box?
5109 * Presentation and sorting::    How agenda items are prepared for display
5110 * Agenda commands::             Remote editing of Org trees
5111 * Custom agenda views::         Defining special searches and views
5112 * Agenda column view::          Using column view for collected entries
5113 @end menu
5115 @node Agenda files, Agenda dispatcher, Agenda Views, Agenda Views
5116 @section Agenda files
5117 @cindex agenda files
5118 @cindex files for agenda
5120 The information to be shown is normally collected from all @emph{agenda
5121 files}, the files listed in the variable
5122 @code{org-agenda-files}@footnote{If the value of that variable is not a
5123 list, but a single file name, then the list of agenda files will be
5124 maintained in that external file.}. If a directory is part of this list,
5125 all files with the extension @file{.org} in this directory will be part
5126 of the list.
5128 Thus even if you only work with a single Org file, this file should
5129 be put into that list@footnote{When using the dispatcher, pressing
5130 @kbd{<} before selecting a command will actually limit the command to
5131 the current file, and ignore @code{org-agenda-files} until the next
5132 dispatcher command.}.  You can customize @code{org-agenda-files}, but
5133 the easiest way to maintain it is through the following commands
5135 @cindex files, adding to agenda list
5136 @table @kbd
5137 @kindex C-c [
5138 @item C-c [
5139 Add current file to the list of agenda files.  The file is added to
5140 the front of the list.  If it was already in the list, it is moved to
5141 the front.  With a prefix argument, file is added/moved to the end.
5142 @kindex C-c ]
5143 @item C-c ]
5144 Remove current file from the list of agenda files.
5145 @kindex C-,
5146 @kindex C-'
5147 @item C-,
5148 @itemx C-'
5149 Cycle through agenda file list, visiting one file after the other.
5150 @kindex M-x org-iswitchb
5151 @item M-x org-iswitchb
5152 Command to use an @code{iswitchb}-like interface to switch to and between Org
5153 buffers.
5154 @end table
5156 @noindent
5157 The Org menu contains the current list of files and can be used
5158 to visit any of them.
5160 If you would like to focus the agenda temporarily onto a file not in
5161 this list, or onto just one file in the list or even only a subtree in a
5162 file, this can be done in different ways.  For a single agenda command,
5163 you may press @kbd{<} once or several times in the dispatcher
5164 (@pxref{Agenda dispatcher}).  To restrict the agenda scope for an
5165 extended period, use the following commands:
5167 @table @kbd
5168 @kindex C-c C-x <
5169 @item C-c C-x <
5170 Permanently restrict the agenda to the current subtree.  When with a
5171 prefix argument, or with the cursor before the first headline in a file,
5172 the agenda scope is set to the entire file.  This restriction remains in
5173 effect until removed with @kbd{C-c C-x >}, or by typing either @kbd{<}
5174 or @kbd{>} in the agenda dispatcher.  If there is a window displaying an
5175 agenda view, the new restriction takes effect immediately.
5176 @kindex C-c C-x <
5177 @item C-c C-x <
5178 Remove the permanent restriction created by @kbd{C-c C-x <}.
5179 @end table
5181 @noindent
5182 When working with @file{Speedbar}, you can use the following commands in
5183 the Speedbar frame:
5184 @table @kbd
5185 @kindex <
5186 @item < @r{in the speedbar frame}
5187 Permanently restrict the agenda to the item at the cursor in the
5188 Speedbar frame, either an Org file or a subtree in such a file.
5189 If there is a window displaying an agenda view, the new restriction takes
5190 effect immediately.
5191 @kindex <
5192 @item > @r{in the speedbar frame}
5193 Lift the restriction again.
5194 @end table
5196 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda Views
5197 @section The agenda dispatcher
5198 @cindex agenda dispatcher
5199 @cindex dispatching agenda commands
5200 The views are created through a dispatcher that should be bound to a
5201 global key, for example @kbd{C-c a} (@pxref{Installation}).  In the
5202 following we will assume that @kbd{C-c a} is indeed how the dispatcher
5203 is accessed and list keyboard access to commands accordingly.  After
5204 pressing @kbd{C-c a}, an additional letter is required to execute a
5205 command.  The dispatcher offers the following default commands:
5206 @table @kbd
5207 @item a
5208 Create the calendar-like agenda (@pxref{Weekly/daily agenda}).
5209 @item t @r{/} T
5210 Create a list of all TODO items (@pxref{Global TODO list}).
5211 @item m @r{/} M
5212 Create a list of headlines matching a TAGS expression (@pxref{Matching
5213 tags and properties}).
5214 @item L
5215 Create the timeline view for the current buffer (@pxref{Timeline}).
5216 @item s
5217 Create a list of entries selected by a boolean expression of keywords
5218 and/or regular expressions that must or must not occur in the entry.
5219 @item /
5220 Search for a regular expression in all agenda files and additionally in
5221 the files listed in @code{org-agenda-multi-occur-extra-files}.  This
5222 uses the Emacs command @code{multi-occur}.  A prefix argument can be
5223 used to specify the number of context lines for each match, default is
5225 @item # @r{/} !
5226 Create a list of stuck projects (@pxref{Stuck projects}).
5227 @item <
5228 Restrict an agenda command to the current buffer@footnote{For backward
5229 compatibility, you can also press @kbd{1} to restrict to the current
5230 buffer.}.  After pressing @kbd{<}, you still need to press the character
5231 selecting the command.
5232 @item < <
5233 If there is an active region, restrict the following agenda command to
5234 the region.  Otherwise, restrict it to the current subtree@footnote{For
5235 backward compatibility, you can also press @kbd{0} to restrict to the
5236 current buffer.}.  After pressing @kbd{< <}, you still need to press the
5237 character selecting the command.
5238 @end table
5240 You can also define custom commands that will be accessible through the
5241 dispatcher, just like the default commands.  This includes the
5242 possibility to create extended agenda buffers that contain several
5243 blocks together, for example the weekly agenda, the global TODO list and
5244 a number of special tags matches.  @xref{Custom agenda views}.
5246 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda Views
5247 @section The built-in agenda views
5249 In this section we describe the built-in views.
5251 @menu
5252 * Weekly/daily agenda::         The calendar page with current tasks
5253 * Global TODO list::            All unfinished action items
5254 * Matching tags and properties::  Structured information with fine-tuned search
5255 * Timeline::                    Time-sorted view for single file
5256 * Keyword search::              Finding entries by keyword
5257 * Stuck projects::              Find projects you need to review
5258 @end menu
5260 @node Weekly/daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
5261 @subsection The weekly/daily agenda
5262 @cindex agenda
5263 @cindex weekly agenda
5264 @cindex daily agenda
5266 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
5267 paper agenda, showing all the tasks for the current week or day.
5269 @table @kbd
5270 @cindex org-agenda, command
5271 @kindex C-c a a
5272 @item C-c a a
5273 Compile an agenda for the current week from a list of org files.  The
5274 agenda shows the entries for each day.  With a numeric
5275 prefix@footnote{For backward compatibility, the universal prefix
5276 @kbd{C-u} causes all TODO entries to be listed before the agenda.  This
5277 feature is deprecated, use the dedicated TODO list, or a block agenda
5278 instead.}  (like @kbd{C-u 2 1 C-c a a}) you may set the number of days
5279 to be displayed (see also the variable @code{org-agenda-ndays})
5280 @end table
5282 Remote editing from the agenda buffer means, for example, that you can
5283 change the dates of deadlines and appointments from the agenda buffer.
5284 The commands available in the Agenda buffer are listed in @ref{Agenda
5285 commands}.
5287 @subsubheading Calendar/Diary integration
5288 @cindex calendar integration
5289 @cindex diary integration
5291 Emacs contains the calendar and diary by Edward M. Reingold.  The
5292 calendar displays a three-month calendar with holidays from different
5293 countries and cultures.  The diary allows you to keep track of
5294 anniversaries, lunar phases, sunrise/set, recurrent appointments
5295 (weekly, monthly) and more.  In this way, it is quite complementary to
5296 Org.  It can be very useful to combine output from Org with
5297 the diary.
5299 In order to include entries from the Emacs diary into Org mode's
5300 agenda, you only need to customize the variable
5302 @lisp
5303 (setq org-agenda-include-diary t)
5304 @end lisp
5306 @noindent After that, everything will happen automatically.  All diary
5307 entries including holidays, anniversaries etc will be included in the
5308 agenda buffer created by Org mode.  @key{SPC}, @key{TAB}, and
5309 @key{RET} can be used from the agenda buffer to jump to the diary
5310 file in order to edit existing diary entries.  The @kbd{i} command to
5311 insert new entries for the current date works in the agenda buffer, as
5312 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
5313 Sunrise/Sunset times, show lunar phases and to convert to other
5314 calendars, respectively.  @kbd{c} can be used to switch back and forth
5315 between calendar and agenda.
5317 If you are using the diary only for sexp entries and holidays, it is
5318 faster to not use the above setting, but instead to copy or even move
5319 the entries into an Org file. Org mode evaluates diary-style sexp
5320 entries, and does it faster because there is no overhead for first
5321 creating the diary display.  Note that the sexp entries must start at
5322 the left margin, no white space is allowed before them.  For example,
5323 the following segment of an Org file will be processed and entries
5324 will be made in the agenda:
5326 @example
5327 * Birthdays and similar stuff
5328 #+CATEGORY: Holiday
5329 %%(org-calendar-holiday)   ; special function for holiday names
5330 #+CATEGORY: Ann
5331 %%(diary-anniversary 14  5 1956) Arthur Dent is %d years old
5332 %%(diary-anniversary  2 10 1869) Mahatma Gandhi would be %d years old
5333 @end example
5335 @subsubheading Appointment reminders
5336 @cindex @file{appt.el}
5337 @cindex appointment reminders
5339 Org can interact with Emacs appointments notification facility.
5341 To add all the appointments of your agenda files, use the command
5342 @code{org-agenda-to-appt}.  This commands also lets you filter through
5343 the list of your appointments and add only those belonging to a specific
5344 category or matching a regular expression. See the docstring for
5345 details.
5347 @node Global TODO list, Matching tags and properties, Weekly/daily agenda, Built-in agenda views
5348 @subsection The global TODO list
5349 @cindex global TODO list
5350 @cindex TODO list, global
5352 The global TODO list contains all unfinished TODO items, formatted and
5353 collected into a single place.
5355 @table @kbd
5356 @kindex C-c a t
5357 @item C-c a t
5358 Show the global TODO list.  This collects the TODO items from all
5359 agenda files (@pxref{Agenda Views}) into a single buffer.  The buffer is in
5360 @code{agenda-mode}, so there are commands to examine and manipulate
5361 the TODO entries directly from that buffer (@pxref{Agenda commands}).
5362 @kindex C-c a T
5363 @item C-c a T
5364 @cindex TODO keyword matching
5365 Like the above, but allows selection of a specific TODO keyword.  You
5366 can also do this by specifying a prefix argument to @kbd{C-c a t}.  With
5367 a @kbd{C-u} prefix you are prompted for a keyword, and you may also
5368 specify several keywords by separating them with @samp{|} as boolean OR
5369 operator.  With a numeric prefix, the Nth keyword in
5370 @code{org-todo-keywords} is selected.
5371 @kindex r
5372 The @kbd{r} key in the agenda buffer regenerates it, and you can give
5373 a prefix argument to this command to change the selected TODO keyword,
5374 for example @kbd{3 r}.  If you often need a search for a specific
5375 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
5376 Matching specific TODO keywords can also be done as part of a tags
5377 search (@pxref{Tag searches}).
5378 @end table
5380 Remote editing of TODO items means that you can change the state of a
5381 TODO entry with a single key press.  The commands available in the
5382 TODO list are described in @ref{Agenda commands}.
5384 @cindex sublevels, inclusion into TODO list
5385 Normally the global TODO list simply shows all headlines with TODO
5386 keywords.  This list can become very long.  There are two ways to keep
5387 it more compact:
5388 @itemize @minus
5389 @item
5390 Some people view a TODO item that has been @emph{scheduled} for
5391 execution (@pxref{Timestamps}) as no longer @emph{open}.  Configure the
5392 variable @code{org-agenda-todo-ignore-scheduled} to exclude scheduled
5393 items from the global TODO list.
5394 @item
5395 TODO items may have sublevels to break up the task into subtasks.  In
5396 such cases it may be enough to list only the highest level TODO headline
5397 and omit the sublevels from the global list.  Configure the variable
5398 @code{org-agenda-todo-list-sublevels} to get this behavior.
5399 @end itemize
5401 @node Matching tags and properties, Timeline, Global TODO list, Built-in agenda views
5402 @subsection Matching tags and properties
5403 @cindex matching, of tags
5404 @cindex matching, of properties
5405 @cindex tags view
5406 @cindex match view
5408 If headlines in the agenda files are marked with @emph{tags}
5409 (@pxref{Tags}), you can select headlines based on the tags that apply
5410 to them and collect them into an agenda buffer.
5412 @table @kbd
5413 @kindex C-c a m
5414 @item C-c a m
5415 Produce a list of all headlines that match a given set of tags.  The
5416 command prompts for a selection criterion, which is a boolean logic
5417 expression with tags, like @samp{+work+urgent-withboss} or
5418 @samp{work|home} (@pxref{Tags}).  If you often need a specific search,
5419 define a custom command for it (@pxref{Agenda dispatcher}).
5420 @kindex C-c a M
5421 @item C-c a M
5422 Like @kbd{C-c a m}, but only select headlines that are also TODO items
5423 and force checking subitems (see variable
5424 @code{org-tags-match-list-sublevels}).  Matching specific TODO keywords
5425 together with a tags match is also possible, see @ref{Tag searches}.
5426 @end table
5428 The commands available in the tags list are described in @ref{Agenda
5429 commands}.
5431 @node Timeline, Keyword search, Matching tags and properties, Built-in agenda views
5432 @subsection Timeline for a single file
5433 @cindex timeline, single file
5434 @cindex time-sorted view
5436 The timeline summarizes all time-stamped items from a single Org mode
5437 file in a @emph{time-sorted view}.  The main purpose of this command is
5438 to give an overview over events in a project.
5440 @table @kbd
5441 @kindex C-c a L
5442 @item C-c a L
5443 Show a time-sorted view of the org file, with all time-stamped items.
5444 When called with a @kbd{C-u} prefix, all unfinished TODO entries
5445 (scheduled or not) are also listed under the current date.
5446 @end table
5448 @noindent
5449 The commands available in the timeline buffer are listed in
5450 @ref{Agenda commands}.
5452 @node Keyword search, Stuck projects, Timeline, Built-in agenda views
5453 @subsection Keyword search
5454 @cindex keyword search
5455 @cindex searching, for keywords
5457 This agenda view is a general text search facility for Org mode entries.
5458 It is particularly useful to find notes.
5460 @table @kbd
5461 @kindex C-c a s
5462 @item C-c a s
5463 This is a special search that lets you select entries by keywords or
5464 regular expression, using a boolean logic.  For example, the search
5465 string
5467 @example
5468 +computer +wifi -ethernet -@{8\.11[bg]@}
5469 @end example
5471 @noindent
5472 will search for note entries that contain the keywords @code{computer}
5473 and @code{wifi}, but not the keyword @code{ethernet}, and which are also
5474 not matched by the regular expression @code{8\.11[bg]}, meaning to
5475 exclude both 8.11b and 8.11g.
5477 Note that in addition to the agenda files, this command will also search
5478 the files listed in @code{org-agenda-text-search-extra-files}.
5479 @end table
5481 @node Stuck projects,  , Keyword search, Built-in agenda views
5482 @subsection Stuck projects
5484 If you are following a system like David Allen's GTD to organize your
5485 work, one of the ``duties'' you have is a regular review to make sure
5486 that all projects move along.  A @emph{stuck} project is a project that
5487 has no defined next actions, so it will never show up in the TODO lists
5488 Org mode produces.  During the review, you need to identify such
5489 projects and define next actions for them.
5491 @table @kbd
5492 @kindex C-c a #
5493 @item C-c a #
5494 List projects that are stuck.
5495 @kindex C-c a !
5496 @item C-c a !
5497 Customize the variable @code{org-stuck-projects} to define what a stuck
5498 project is and how to find it.
5499 @end table
5501 You almost certainly will have to configure this view before it will
5502 work for you.  The built-in default assumes that all your projects are
5503 level-2 headlines, and that a project is not stuck if it has at least
5504 one entry marked with a TODO keyword TODO or NEXT or NEXTACTION.
5506 Lets assume that you, in your own way of using Org mode, identify
5507 projects with a tag PROJECT, and that you use a TODO keyword MAYBE to
5508 indicate a project that should not be considered yet.  Lets further
5509 assume that the TODO keyword DONE marks finished projects, and that NEXT
5510 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
5511 is a next action even without the NEXT tag.  Finally, if the project
5512 contains the special word IGNORE anywhere, it should not be listed
5513 either.  In this case you would start by identifying eligible projects
5514 with a tags/todo match @samp{+PROJECT/-MAYBE-DONE}, and then check for
5515 TODO, NEXT, @@SHOP, and IGNORE in the subtree to identify projects that
5516 are not stuck.  The correct customization for this is
5518 @lisp
5519 (setq org-stuck-projects
5520       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
5521                                "\\<IGNORE\\>"))
5522 @end lisp
5525 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda Views
5526 @section Presentation and sorting
5527 @cindex presentation, of agenda items
5529 Before displaying items in an agenda view, Org mode visually prepares
5530 the items and sorts them.  Each item occupies a single line.  The line
5531 starts with a @emph{prefix} that contains the @emph{category}
5532 (@pxref{Categories}) of the item and other important information.  You can
5533 customize the prefix using the option @code{org-agenda-prefix-format}.
5534 The prefix is followed by a cleaned-up version of the outline headline
5535 associated with the item.
5537 @menu
5538 * Categories::                  Not all tasks are equal
5539 * Time-of-day specifications::  How the agenda knows the time
5540 * Sorting of agenda items::     The order of things
5541 @end menu
5543 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
5544 @subsection Categories
5546 @cindex category
5547 The category is a broad label assigned to each agenda item.  By default,
5548 the category is simply derived from the file name, but you can also
5549 specify it with a special line in the buffer, like this@footnote{For
5550 backward compatibility, the following also works: If there are several
5551 such lines in a file, each specifies the category for the text below it.
5552 The first category also applies to any text before the first CATEGORY
5553 line.  However, using this method is @emph{strongly} deprecated as it is
5554 incompatible with the outline structure of the document.  The correct
5555 method for setting multiple categories in a buffer is using a
5556 property.}:
5558 @example
5559 #+CATEGORY: Thesis
5560 @end example
5562 @noindent
5563 If you would like to have a special CATEGORY for a single entry or a
5564 (sub)tree, give the entry a @code{:CATEGORY:} property with the location
5565 as the value (@pxref{Properties and Columns}).
5567 @noindent
5568 The display in the agenda buffer looks best if the category is not
5569 longer than 10 characters.
5571 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
5572 @subsection Time-of-day specifications
5573 @cindex time-of-day specification
5575 Org mode checks each agenda item for a time-of-day specification.  The
5576 time can be part of the time stamp that triggered inclusion into the
5577 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
5578 ranges can be specified with two time stamps, like
5580 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
5582 In the headline of the entry itself, a time(range) may also appear as
5583 plain text (like @samp{12:45} or a @samp{8:30-1pm}).  If the agenda
5584 integrates the Emacs diary (@pxref{Weekly/daily agenda}), time
5585 specifications in diary entries are recognized as well.
5587 For agenda display, Org mode extracts the time and displays it in a
5588 standard 24 hour format as part of the prefix.  The example times in
5589 the previous paragraphs would end up in the agenda like this:
5591 @example
5592     8:30-13:00 Arthur Dent lies in front of the bulldozer
5593    12:45...... Ford Prefect arrives and takes Arthur to the pub
5594    19:00...... The Vogon reads his poem
5595    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
5596 @end example
5598 @cindex time grid
5599 If the agenda is in single-day mode, or for the display of today, the
5600 timed entries are embedded in a time grid, like
5602 @example
5603     8:00...... ------------------
5604     8:30-13:00 Arthur Dent lies in front of the bulldozer
5605    10:00...... ------------------
5606    12:00...... ------------------
5607    12:45...... Ford Prefect arrives and takes Arthur to the pub
5608    14:00...... ------------------
5609    16:00...... ------------------
5610    18:00...... ------------------
5611    19:00...... The Vogon reads his poem
5612    20:00...... ------------------
5613    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
5614 @end example
5616 The time grid can be turned on and off with the variable
5617 @code{org-agenda-use-time-grid}, and can be configured with
5618 @code{org-agenda-time-grid}.
5620 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
5621 @subsection Sorting of agenda items
5622 @cindex sorting, of agenda items
5623 @cindex priorities, of agenda items
5624 Before being inserted into a view, the items are sorted.  How this is
5625 done depends on the type of view.
5626 @itemize @bullet
5627 @item
5628 For the daily/weekly agenda, the items for each day are sorted.  The
5629 default order is to first collect all items containing an explicit
5630 time-of-day specification.  These entries will be shown at the beginning
5631 of the list, as a @emph{schedule} for the day.  After that, items remain
5632 grouped in categories, in the sequence given by @code{org-agenda-files}.
5633 Within each category, items are sorted by priority (@pxref{Priorities}),
5634 which is composed of the base priority (2000 for priority @samp{A}, 1000
5635 for @samp{B}, and 0 for @samp{C}), plus additional increments for
5636 overdue scheduled or deadline items.
5637 @item
5638 For the TODO list, items remain in the order of categories, but within
5639 each category, sorting takes place according to priority
5640 (@pxref{Priorities}).
5641 @item
5642 For tags matches, items are not sorted at all, but just appear in the
5643 sequence in which they are found in the agenda files.
5644 @end itemize
5646 Sorting can be customized using the variable
5647 @code{org-agenda-sorting-strategy}, and may also include criteria based on
5648 the estimated effort of an entry.
5649 @c FIXME: link!!!!!!!!
5652 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda Views
5653 @section Commands in the agenda buffer
5654 @cindex commands, in agenda buffer
5656 Entries in the agenda buffer are linked back to the org file or diary
5657 file where they originate.  You are not allowed to edit the agenda
5658 buffer itself, but commands are provided to show and jump to the
5659 original entry location, and to edit the org-files ``remotely'' from
5660 the agenda buffer.  In this way, all information is stored only once,
5661 removing the risk that your agenda and note files may diverge.
5663 Some commands can be executed with mouse clicks on agenda lines.  For
5664 the other commands, the cursor needs to be in the desired line.
5666 @table @kbd
5667 @tsubheading{Motion}
5668 @cindex motion commands in agenda
5669 @kindex n
5670 @item n
5671 Next line (same as @key{up} and @kbd{C-p}).
5672 @kindex p
5673 @item p
5674 Previous line (same as @key{down} and @kbd{C-n}).
5675 @tsubheading{View/Go to org file}
5676 @kindex mouse-3
5677 @kindex @key{SPC}
5678 @item mouse-3
5679 @itemx @key{SPC}
5680 Display the original location of the item in another window.
5682 @kindex L
5683 @item L
5684 Display original location and recenter that window.
5686 @kindex mouse-2
5687 @kindex mouse-1
5688 @kindex @key{TAB}
5689 @item mouse-2
5690 @itemx mouse-1
5691 @itemx @key{TAB}
5692 Go to the original location of the item in another window.  Under Emacs
5693 22, @kbd{mouse-1} will also works for this.
5695 @kindex @key{RET}
5696 @itemx @key{RET}
5697 Go to the original location of the item and delete other windows.
5699 @kindex f
5700 @item f
5701 Toggle Follow mode.  In Follow mode, as you move the cursor through
5702 the agenda buffer, the other window always shows the corresponding
5703 location in the org file.  The initial setting for this mode in new
5704 agenda buffers can be set with the variable
5705 @code{org-agenda-start-with-follow-mode}.
5707 @kindex b
5708 @item b
5709 Display the entire subtree of the current item in an indirect buffer.  With a
5710 numeric prefix argument N, go up to level N and then take that tree.  If N is
5711 negative, go up that many levels.  With a @kbd{C-u} prefix, do not remove the
5712 previously used indirect buffer.
5714 @kindex l
5715 @item l
5716 Toggle Logbook mode.  In Logbook mode, entries that where marked DONE while
5717 logging was on (variable @code{org-log-done}) are shown in the agenda,
5718 as are entries that have been clocked on that day.
5720 @kindex v
5721 @item v
5722 Toggle Archives mode.  In archives mode, trees that are marked are also
5723 scanned when producing the agenda.  When you call this command with a
5724 @kbd{C-u} prefix argument, even all archive files are included.  To exit
5725 archives mode, press @kbd{v} again.
5727 @kindex R
5728 @item R
5729 Toggle Clockreport mode.  In clockreport mode, the daily/weekly agenda will
5730 always show a table with the clocked times for the timespan and file scope
5731 covered by the current agenda view.  The initial setting for this mode in new
5732 agenda buffers can be set with the variable
5733 @code{org-agenda-start-with-clockreport-mode}.
5735 @tsubheading{Change display}
5736 @cindex display changing, in agenda
5737 @kindex o
5738 @item o
5739 Delete other windows.
5741 @kindex d
5742 @kindex w
5743 @kindex m
5744 @kindex y
5745 @item d w m y
5746 Switch to day/week/month/year view.  When switching to day or week view,
5747 this setting becomes the default for subsequent agenda commands.  Since
5748 month and year views are slow to create, they do not become the default.
5749 A numeric prefix argument may be used to jump directly to a specific day
5750 of the year, ISO week, month, or year, respectively.  For example,
5751 @kbd{32 d} jumps to February 1st, @kbd{9 w} to ISO week number 9.  When
5752 setting day, week, or month view, a year may be encoded in the prefix
5753 argument as well.  For example, @kbd{200712 w} will jump to week 12 in
5754 2007.  If such a year specification has only one or two digits, it will
5755 be mapped to the interval 1938-2037.
5757 @kindex D
5758 @item D
5759 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
5761 @kindex G
5762 @item G
5763 Toggle the time grid on and off.  See also the variables
5764 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
5766 @kindex r
5767 @item r
5768 Recreate the agenda buffer, for example to reflect the changes
5769 after modification of the time stamps of items with S-@key{left} and
5770 S-@key{right}.  When the buffer is the global TODO list, a prefix
5771 argument is interpreted to create a selective list for a specific TODO
5772 keyword.
5773 @kindex g
5774 @item g
5775 Same as @kbd{r}.
5777 @kindex s
5778 @kindex C-x C-s
5779 @item s
5780 @itemx C-x C-s
5781 Save all Org buffers in the current Emacs session.
5783 @kindex @key{right}
5784 @item @key{right}
5785 Display the following @code{org-agenda-ndays} days.  For example, if
5786 the display covers a week, switch to the following week.  With prefix
5787 arg, go forward that many times @code{org-agenda-ndays} days.
5789 @kindex @key{left}
5790 @item @key{left}
5791 Display the previous dates.
5793 @kindex .
5794 @item .
5795 Go to today.
5797 @kindex C-c C-x C-c
5798 @item C-c C-x C-c
5799 Invoke column view (@pxref{Column view}) in the agenda buffer.  The column
5800 view format is taken from the entry at point, or (if there is no entry at
5801 point), from the first entry in the agenda view.  So whatever the format for
5802 that entry would be in the original buffer (taken from a property, from a
5803 @code{#+COLUMNS} line, or from the default variable
5804 @code{org-columns-default-format}), will be used in the agenda.
5806 @tsubheading{Secondary filtering and query editing}
5807 @cindex query editing, in agenda
5809 @kindex /
5810 @item /
5811 Filter the current agenda view with respect to a tag.  You will be prompted
5812 for a tag selection letter.  Pressing @key{TAB} at that prompt will offer use
5813 completion to select a tag (including any tags that do not have a selection
5814 character).  The command then hides all entries that do not contain or
5815 inherit this tag.  When called with prefix arg, remove the entries that
5816 @emph{do} have the tag.  A second @kbd{/} at the prompt will unhide any
5817 hidden entries.
5819 @kindex [
5820 @kindex ]
5821 @kindex @{
5822 @kindex @}
5823 @item [ ] @{ @}
5824 In the @i{search view} (@pxref{Keyword search}), these keys add new search
5825 words (@kbd{[} and @kbd{]}) or new regular expressions (@kbd{@{} and
5826 @kbd{@}}) to the query string.  The opening bracket/brace will add a positive
5827 search term prefixed by @samp{+}, indicating that this search term @i{must}
5828 occur/match in the entry.  The closing bracket/brace will add a negative
5829 search term which @i{must not} occur/match in the entry for it to be
5830 selected.
5833 @tsubheading{Remote editing}
5834 @cindex remote editing, from agenda
5836 @item 0-9
5837 Digit argument.
5839 @cindex undoing remote-editing events
5840 @cindex remote editing, undo
5841 @kindex C-_
5842 @item C-_
5843 Undo a change due to a remote editing command.  The change is undone
5844 both in the agenda buffer and in the remote buffer.
5846 @kindex t
5847 @item t
5848 Change the TODO state of the item, both in the agenda and in the
5849 original org file.
5851 @kindex C-k
5852 @item C-k
5853 Delete the current agenda item along with the entire subtree belonging
5854 to it in the original Org file.  If the text to be deleted remotely
5855 is longer than one line, the kill needs to be confirmed by the user.  See
5856 variable @code{org-agenda-confirm-kill}.
5858 @kindex a
5859 @item a
5860 Toggle the ARCHIVE tag for the current headline.
5862 @kindex A
5863 @item A
5864 Move the subtree corresponding to the current entry to its @emph{Archive
5865 Sibling}.
5867 @kindex $
5868 @item $
5869 Archive the subtree corresponding to the current headline.  This means the
5870 entry will be moved to the configured archive location, most likely a
5871 different file.
5873 @kindex T
5874 @item T
5875 Show all tags associated with the current item.  Because of
5876 inheritance, this may be more than the tags listed in the line itself.
5878 @kindex :
5879 @item :
5880 Set tags for the current headline.  If there is an active region in the
5881 agenda, change a tag for all headings in the region.
5883 @kindex ,
5884 @item ,
5885 Set the priority for the current item.  Org mode prompts for the
5886 priority character. If you reply with @key{SPC}, the priority cookie
5887 is removed from the entry.
5889 @kindex P
5890 @item P
5891 Display weighted priority of current item.
5893 @kindex +
5894 @kindex S-@key{up}
5895 @item +
5896 @itemx S-@key{up}
5897 Increase the priority of the current item.  The priority is changed in
5898 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
5899 key for this.
5901 @kindex -
5902 @kindex S-@key{down}
5903 @item -
5904 @itemx S-@key{down}
5905 Decrease the priority of the current item.
5907 @kindex C-c C-s
5908 @item C-c C-s
5909 Schedule this item
5911 @kindex C-c C-d
5912 @item C-c C-d
5913 Set a deadline for this item.
5915 @kindex k
5916 @item k
5917 Agenda actions, to set dates for selected items to the cursor date.
5918 This command also works in the calendar!  The command prompts for an
5919 additonal key:
5920 @example
5921 m   @r{Mark the entry at point for action.  You can also make entries}
5922     @r{in Org files with @kbd{C-c C-x C-k}.}
5923 d   @r{Set the deadline of the marked entry to the date at point.}
5924 s   @r{Schedule the marked entry at the date at point.}
5925 r   @r{Call @code{org-remember} with the cursor date as default date.}
5926 @end example
5927 Press @kbd{r} afterwards to refresh the agenda and see the effect of the
5928 command.
5930 @kindex S-@key{right}
5931 @item S-@key{right}
5932 Change the time stamp associated with the current line by one day into the
5933 future.  With a numeric prefix argument, change it by that many days.  For
5934 example, @kbd{3 6 5 S-@key{right}} will change it by a year.  The stamp is
5935 changed in the original org file, but the change is not directly reflected in
5936 the agenda buffer.  Use the @kbd{r} key to update the buffer.
5938 @kindex S-@key{left}
5939 @item S-@key{left}
5940 Change the time stamp associated with the current line by one day
5941 into the past.
5943 @kindex >
5944 @item >
5945 Change the time stamp associated with the current line to today.
5946 The key @kbd{>} has been chosen, because it is the same as @kbd{S-.}
5947 on my keyboard.
5949 @kindex I
5950 @item I
5951 Start the clock on the current item.  If a clock is running already, it
5952 is stopped first.
5954 @kindex O
5955 @item O
5956 Stop the previously started clock.
5958 @kindex X
5959 @item X
5960 Cancel the currently running clock.
5962 @kindex J
5963 @item J
5964 Jump to the running clock in another window.
5966 @tsubheading{Calendar commands}
5967 @cindex calendar commands, from agenda
5968 @kindex c
5969 @item c
5970 Open the Emacs calendar and move to the date at the agenda cursor.
5972 @item c
5973 When in the calendar, compute and show the Org mode agenda for the
5974 date at the cursor.
5976 @cindex diary entries, creating from agenda
5977 @kindex i
5978 @item i
5979 Insert a new entry into the diary.  Prompts for the type of entry
5980 (day, weekly, monthly, yearly, anniversary, cyclic) and creates a new
5981 entry in the diary, just as @kbd{i d} etc. would do in the calendar.
5982 The date is taken from the cursor position.
5984 @kindex M
5985 @item M
5986 Show the phases of the moon for the three months around current date.
5988 @kindex S
5989 @item S
5990 Show sunrise and sunset times.  The geographical location must be set
5991 with calendar variables, see documentation of the Emacs calendar.
5993 @kindex C
5994 @item C
5995 Convert the date at cursor into many other cultural and historic
5996 calendars.
5998 @kindex H
5999 @item H
6000 Show holidays for three month around the cursor date.
6002 @item M-x org-export-icalendar-combine-agenda-files
6003 Export a single iCalendar file containing entries from all agenda files.
6004 This is a globally available command, and also available in the agenda menu.
6006 @tsubheading{Exporting to a file}
6007 @kindex C-x C-w
6008 @item C-x C-w
6009 @cindex exporting agenda views
6010 @cindex agenda views, exporting
6011 Write the agenda view to a file.  Depending on the extension of the
6012 selected file name, the view will be exported as HTML (extension
6013 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}), or
6014 plain text (any other extension).  Use the variable
6015 @code{org-agenda-exporter-settings} to set options for @file{ps-print}
6016 and for @file{htmlize} to be used during export.
6018 @tsubheading{Quit and Exit}
6019 @kindex q
6020 @item q
6021 Quit agenda, remove the agenda buffer.
6023 @kindex x
6024 @cindex agenda files, removing buffers
6025 @item x
6026 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
6027 for the compilation of the agenda.  Buffers created by the user to
6028 visit org files will not be removed.
6029 @end table
6032 @node Custom agenda views, Agenda column view, Agenda commands, Agenda Views
6033 @section Custom agenda views
6034 @cindex custom agenda views
6035 @cindex agenda views, custom
6037 Custom agenda commands serve two purposes: to store and quickly access
6038 frequently used TODO and tags searches, and to create special composite
6039 agenda buffers.  Custom agenda commands will be accessible through the
6040 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
6042 @menu
6043 * Storing searches::            Type once, use often
6044 * Block agenda::                All the stuff you need in a single buffer
6045 * Setting Options::             Changing the rules
6046 * Exporting Agenda Views::      Writing agendas to files
6047 * Using the agenda elsewhere::  Using agenda information in other programs
6048 @end menu
6050 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
6051 @subsection Storing searches
6053 The first application of custom searches is the definition of keyboard
6054 shortcuts for frequently used searches, either creating an agenda
6055 buffer, or a sparse tree (the latter covering of course only the current
6056 buffer).
6057 @kindex C-c a C
6058 Custom commands are configured in the variable
6059 @code{org-agenda-custom-commands}.  You can customize this variable, for
6060 example by pressing @kbd{C-c a C}.  You can also directly set it with
6061 Emacs Lisp in @file{.emacs}.  The following example contains all valid
6062 search types:
6064 @lisp
6065 @group
6066 (setq org-agenda-custom-commands
6067       '(("w" todo "WAITING")
6068         ("W" todo-tree "WAITING")
6069         ("u" tags "+boss-urgent")
6070         ("v" tags-todo "+boss-urgent")
6071         ("U" tags-tree "+boss-urgent")
6072         ("f" occur-tree "\\<FIXME\\>")
6073         ("h" . "HOME+Name tags searches") ; description for "h" prefix
6074         ("hl" tags "+home+Lisa")
6075         ("hp" tags "+home+Peter")
6076         ("hk" tags "+home+Kim")))
6077 @end group
6078 @end lisp
6080 @noindent
6081 The initial string in each entry defines the keys you have to press
6082 after the dispatcher command @kbd{C-c a} in order to access the command.
6083 Usually this will be just a single character, but if you have many
6084 similar commands, you can also define two-letter combinations where the
6085 first character is the same in several combinations and serves as a
6086 prefix key@footnote{You can provide a description for a prefix key by
6087 inserting a cons cell with the prefix and the description.}.  The second
6088 parameter is the search type, followed by the string or regular
6089 expression to be used for the matching.  The example above will
6090 therefore define:
6092 @table @kbd
6093 @item C-c a w
6094 as a global search for TODO entries with @samp{WAITING} as the TODO
6095 keyword
6096 @item C-c a W
6097 as the same search, but only in the current buffer and displaying the
6098 results as a sparse tree
6099 @item C-c a u
6100 as a global tags search for headlines marked @samp{:boss:} but not
6101 @samp{:urgent:}
6102 @item C-c a v
6103 as the same search as @kbd{C-c a u}, but limiting the search to
6104 headlines that are also TODO items
6105 @item C-c a U
6106 as the same search as @kbd{C-c a u}, but only in the current buffer and
6107 displaying the result as a sparse tree
6108 @item C-c a f
6109 to create a sparse tree (again: current buffer only) with all entries
6110 containing the word @samp{FIXME}
6111 @item C-c a h
6112 as a prefix command for a HOME tags search where you have to press an
6113 additional key (@kbd{l}, @kbd{p} or @kbd{k}) to select a name (Lisa,
6114 Peter, or Kim) as additional tag to match.
6115 @end table
6117 @node Block agenda, Setting Options, Storing searches, Custom agenda views
6118 @subsection Block agenda
6119 @cindex block agenda
6120 @cindex agenda, with block views
6122 Another possibility is the construction of agenda views that comprise
6123 the results of @emph{several} commands, each of which creates a block in
6124 the agenda buffer.  The available commands include @code{agenda} for the
6125 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
6126 for the global TODO list (as constructed with @kbd{C-c a t}), and the
6127 matching commands discussed above: @code{todo}, @code{tags}, and
6128 @code{tags-todo}.  Here are two examples:
6130 @lisp
6131 @group
6132 (setq org-agenda-custom-commands
6133       '(("h" "Agenda and Home-related tasks"
6134          ((agenda "")
6135           (tags-todo "home")
6136           (tags "garden")))
6137         ("o" "Agenda and Office-related tasks"
6138          ((agenda "")
6139           (tags-todo "work")
6140           (tags "office")))))
6141 @end group
6142 @end lisp
6144 @noindent
6145 This will define @kbd{C-c a h} to create a multi-block view for stuff
6146 you need to attend to at home.  The resulting agenda buffer will contain
6147 your agenda for the current week, all TODO items that carry the tag
6148 @samp{home}, and also all lines tagged with @samp{garden}.  Finally the
6149 command @kbd{C-c a o} provides a similar view for office tasks.
6151 @node Setting Options, Exporting Agenda Views, Block agenda, Custom agenda views
6152 @subsection Setting options for custom commands
6153 @cindex options, for custom agenda views
6155 Org mode contains a number of variables regulating agenda construction
6156 and display.  The global variables define the behavior for all agenda
6157 commands, including the custom commands.  However, if you want to change
6158 some settings just for a single custom view, you can do so.  Setting
6159 options requires inserting a list of variable names and values at the
6160 right spot in @code{org-agenda-custom-commands}.  For example:
6162 @lisp
6163 @group
6164 (setq org-agenda-custom-commands
6165       '(("w" todo "WAITING"
6166          ((org-agenda-sorting-strategy '(priority-down))
6167           (org-agenda-prefix-format "  Mixed: ")))
6168         ("U" tags-tree "+boss-urgent"
6169          ((org-show-following-heading nil)
6170           (org-show-hierarchy-above nil)))
6171         ("N" search ""
6172          ((org-agenda-files '("~org/notes.org"))
6173           (org-agenda-text-search-extra-files nil)))))
6174 @end group
6175 @end lisp
6177 @noindent
6178 Now the @kbd{C-c a w} command will sort the collected entries only by
6179 priority, and the prefix format is modified to just say @samp{  Mixed: }
6180 instead of giving the category of the entry.  The sparse tags tree of
6181 @kbd{C-c a U} will now turn out ultra-compact, because neither the
6182 headline hierarchy above the match, nor the headline following the match
6183 will be shown.  The command @kbd{C-c a N} will do a text search limited
6184 to only a single file.
6186 For command sets creating a block agenda,
6187 @code{org-agenda-custom-commands} has two separate spots for setting
6188 options.  You can add options that should be valid for just a single
6189 command in the set, and options that should be valid for all commands in
6190 the set.  The former are just added to the command entry, the latter
6191 must come after the list of command entries.  Going back to the block
6192 agenda example (@pxref{Block agenda}), let's change the sorting strategy
6193 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
6194 the results for GARDEN tags query in the opposite order,
6195 @code{priority-up}.  This would look like this:
6197 @lisp
6198 @group
6199 (setq org-agenda-custom-commands
6200       '(("h" "Agenda and Home-related tasks"
6201          ((agenda)
6202           (tags-todo "home")
6203           (tags "garden"
6204                 ((org-agenda-sorting-strategy '(priority-up)))))
6205          ((org-agenda-sorting-strategy '(priority-down))))
6206         ("o" "Agenda and Office-related tasks"
6207          ((agenda)
6208           (tags-todo "work")
6209           (tags "office")))))
6210 @end group
6211 @end lisp
6213 As you see, the values and parenthesis setting is a little complex.
6214 When in doubt, use the customize interface to set this variable - it
6215 fully supports its structure.  Just one caveat: When setting options in
6216 this interface, the @emph{values} are just lisp expressions.  So if the
6217 value is a string, you need to add the double quotes around the value
6218 yourself.
6221 @node Exporting Agenda Views, Using the agenda elsewhere, Setting Options, Custom agenda views
6222 @subsection Exporting Agenda Views
6223 @cindex agenda views, exporting
6225 If you are away from your computer, it can be very useful to have a
6226 printed version of some agenda views to carry around.  Org mode can
6227 export custom agenda views as plain text, HTML@footnote{You need to
6228 install Hrvoje Niksic' @file{htmlize.el}.} postscript, and iCalendar
6229 files.  If you want to do this only occasionally, use the command
6231 @table @kbd
6232 @kindex C-x C-w
6233 @item C-x C-w
6234 @cindex exporting agenda views
6235 @cindex agenda views, exporting
6236 Write the agenda view to a file.  Depending on the extension of the
6237 selected file name, the view will be exported as HTML (extension
6238 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}),
6239 iCalendar (extension @file{.ics}), or plain text (any other extension).
6240 Use the variable @code{org-agenda-exporter-settings} to
6241 set options for @file{ps-print} and for @file{htmlize} to be used during
6242 export, for example
6244 @lisp
6245 (setq org-agenda-exporter-settings
6246       '((ps-number-of-columns 2)
6247         (ps-landscape-mode t)
6248         (htmlize-output-type 'css)))
6249 @end lisp
6250 @end table
6252 If you need to export certain agenda views frequently, you can associate
6253 any custom agenda command with a list of output file names
6254 @footnote{If you want to store standard views like the weekly agenda
6255 or the global TODO list as well, you need to define custom commands for
6256 them in order to be able to specify file names.}.  Here is an example
6257 that first does define custom commands for the agenda and the global
6258 todo list, together with a number of files to which to export them.
6259 Then we define two block agenda commands and specify file names for them
6260 as well.  File names can be relative to the current working directory,
6261 or absolute.
6263 @lisp
6264 @group
6265 (setq org-agenda-custom-commands
6266       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
6267         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
6268         ("h" "Agenda and Home-related tasks"
6269          ((agenda "")
6270           (tags-todo "home")
6271           (tags "garden"))
6272          nil
6273          ("~/views/home.html"))
6274         ("o" "Agenda and Office-related tasks"
6275          ((agenda)
6276           (tags-todo "work")
6277           (tags "office"))
6278          nil
6279          ("~/views/office.ps" "~/calendars/office.ics"))))
6280 @end group
6281 @end lisp
6283 The extension of the file name determines the type of export.  If it is
6284 @file{.html}, Org mode will use the @file{htmlize.el} package to convert
6285 the buffer to HTML and save it to this file name.  If the extension is
6286 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
6287 postscript output.  If the extension is @file{.ics}, iCalendar export is
6288 run export over all files that were used to construct the agenda, and
6289 limit the export to entries listed in the agenda now.  Any other
6290 extension produces a plain ASCII file.
6292 The export files are @emph{not} created when you use one of those
6293 commands interactively because this might use too much overhead.
6294 Instead, there is a special command to produce @emph{all} specified
6295 files in one step:
6297 @table @kbd
6298 @kindex C-c a e
6299 @item C-c a e
6300 Export all agenda views that have export file names associated with
6301 them.
6302 @end table
6304 You can use the options section of the custom agenda commands to also
6305 set options for the export commands.  For example:
6307 @lisp
6308 (setq org-agenda-custom-commands
6309       '(("X" agenda ""
6310          ((ps-number-of-columns 2)
6311           (ps-landscape-mode t)
6312           (org-agenda-prefix-format " [ ] ")
6313           (org-agenda-with-colors nil)
6314           (org-agenda-remove-tags t))
6315          ("theagenda.ps"))))
6316 @end lisp
6318 @noindent
6319 This command sets two options for the postscript exporter, to make it
6320 print in two columns in landscape format - the resulting page can be cut
6321 in two and then used in a paper agenda.  The remaining settings modify
6322 the agenda prefix to omit category and scheduling information, and
6323 instead include a checkbox to check off items.  We also remove the tags
6324 to make the lines compact, and we don't want to use colors for the
6325 black-and-white printer.  Settings specified in
6326 @code{org-agenda-exporter-settings} will also apply, but the settings
6327 in @code{org-agenda-custom-commands} take precedence.
6329 @noindent
6330 From the command line you may also use
6331 @example
6332 emacs -f org-batch-store-agenda-views -kill
6333 @end example
6334 @noindent
6335 or, if you need to modify some parameters
6336 @example
6337 emacs -eval '(org-batch-store-agenda-views                      \
6338               org-agenda-ndays 30                               \
6339               org-agenda-start-day "2007-11-01"                 \
6340               org-agenda-include-diary nil                      \
6341               org-agenda-files (quote ("~/org/project.org")))'  \
6342       -kill
6343 @end example
6344 @noindent
6345 which will create the agenda views restricted to the file
6346 @file{~/org/project.org}, without diary entries and with 30 days
6347 extent.
6349 @node Using the agenda elsewhere,  , Exporting Agenda Views, Custom agenda views
6350 @subsection Using agenda information outside of Org
6351 @cindex agenda, pipe
6352 @cindex Scripts, for agenda processing
6354 Org provides commands to access agenda information for the command
6355 line in emacs batch mode.  This extracted information can be sent
6356 directly to a printer, or it can be read by a program that does further
6357 processing of the data.  The first of these commands is the function
6358 @code{org-batch-agenda}, that produces an agenda view and sends it as
6359 ASCII text to STDOUT.  The command takes a single string as parameter.
6360 If the string has length 1, it is used as a key to one of the commands
6361 you have configured in @code{org-agenda-custom-commands}, basically any
6362 key you can use after @kbd{C-c a}.  For example, to directly print the
6363 current TODO list, you could use
6365 @example
6366 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
6367 @end example
6369 If the parameter is a string with 2 or more characters, it is used as a
6370 tags/todo match string.  For example, to print your local shopping list
6371 (all items with the tag @samp{shop}, but excluding the tag
6372 @samp{NewYork}), you could use
6374 @example
6375 emacs -batch -l ~/.emacs                                      \
6376       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
6377 @end example
6379 @noindent
6380 You may also modify parameters on the fly like this:
6382 @example
6383 emacs -batch -l ~/.emacs                                      \
6384    -eval '(org-batch-agenda "a"                               \
6385             org-agenda-ndays 30                               \
6386             org-agenda-include-diary nil                      \
6387             org-agenda-files (quote ("~/org/project.org")))'  \
6388    | lpr
6389 @end example
6391 @noindent
6392 which will produce a 30 day agenda, fully restricted to the Org file
6393 @file{~/org/projects.org}, not even including the diary.
6395 If you want to process the agenda data in more sophisticated ways, you
6396 can use the command @code{org-batch-agenda-csv} to get a comma-separated
6397 list of values for each agenda item.  Each line in the output will
6398 contain a number of fields separated by commas.  The fields in a line
6399 are:
6401 @example
6402 category     @r{The category of the item}
6403 head         @r{The headline, without TODO kwd, TAGS and PRIORITY}
6404 type         @r{The type of the agenda entry, can be}
6405                 todo               @r{selected in TODO match}
6406                 tagsmatch          @r{selected in tags match}
6407                 diary              @r{imported from diary}
6408                 deadline           @r{a deadline}
6409                 scheduled          @r{scheduled}
6410                 timestamp          @r{appointment, selected by timestamp}
6411                 closed             @r{entry was closed on date}
6412                 upcoming-deadline  @r{warning about nearing deadline}
6413                 past-scheduled     @r{forwarded scheduled item}
6414                 block              @r{entry has date block including date}
6415 todo         @r{The TODO keyword, if any}
6416 tags         @r{All tags including inherited ones, separated by colons}
6417 date         @r{The relevant date, like 2007-2-14}
6418 time         @r{The time, like 15:00-16:50}
6419 extra        @r{String with extra planning info}
6420 priority-l   @r{The priority letter if any was given}
6421 priority-n   @r{The computed numerical priority}
6422 @end example
6424 @noindent
6425 Time and date will only be given if a timestamp (or deadline/scheduled)
6426 lead to the selection of the item.
6428 A CSV list like this is very easy to use in a post processing script.
6429 For example, here is a Perl program that gets the TODO list from
6430 Emacs/Org and prints all the items, preceded by a checkbox:
6432 @example
6433 @group
6434 #!/usr/bin/perl
6436 # define the Emacs command to run
6437 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
6439 # run it and capture the output
6440 $agenda = qx@{$cmd 2>/dev/null@};
6442 # loop over all lines
6443 foreach $line (split(/\n/,$agenda)) @{
6445   # get the individual values
6446   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
6447    $priority_l,$priority_n) = split(/,/,$line);
6449   # proccess and print
6450   print "[ ] $head\n";
6452 @end group
6453 @end example
6455 @node Agenda column view,  , Custom agenda views, Agenda Views
6456 @section Using column view in the agenda
6457 @cindex column view, in agenda
6458 @cindex agenda, column view
6460 Column view (@pxref{Column view}) is normally used to view and edit
6461 properties embedded in the hierarchical structure of an Org file.  It can be
6462 quite useful to use column view also from the agenda, where entries are
6463 collected by certain criteria.
6465 @table @kbd
6466 @kindex C-c C-x C-c
6467 @item C-c C-x C-c
6468 Turn on column view in the agenda.
6469 @end table
6471 To understand how to use this properly, it is important to realize that the
6472 entries in the agenda are no longer in their proper outline environment.
6473 This causes the following issues:
6475 @enumerate
6476 @item
6477 Org needs to make a decision which @code{COLUMNS} format to use.  Since the
6478 entries in the agenda are collected from different files, and different files
6479 may have different @code{COLUMNS} formats, this is a non-trivial problem.
6480 Org first checks if the variable @code{org-overriding-columns-format} is
6481 currently set, and if yes takes the format from there.  Otherwise it takes
6482 the format associated with the first item in the agenda, or, if that item
6483 does not have a specific format (defined in a property, or in it's file), it
6484 uses @code{org-columns-default-format}.
6485 @item
6486 If any of the columns has a summary type defined (@pxref{Column attributes}),
6487 turning on column view in the agenda will visit all relevant agenda files and
6488 make sure that the computations of this property are up to date.  This is
6489 also true for the special @code{CLOCKSUM} property.  Org will then sum the
6490 values displayed in the agenda.  In the daily/weekly agenda, the sums will
6491 cover a single day, in all other views they cover the entire block.  It is
6492 vital to realize that the agenda may show the same entry @emph{twice} (for
6493 example as scheduled and as a deadline), and it may show two entries from the
6494 same hierarchy (for example a @emph{parent} and it's @emph{child}).  In these
6495 cases, the summation in the agenda will lead to incorrect results because
6496 some values will count double.
6497 @item
6498 When the column view in the agenda shows the @code{CLOCKSUM}, that is always
6499 the entire clocked time for this item.  So even in the daily/weekly agenda,
6500 the clocksum listed in column view may originate from times outside the
6501 current view.  This has the advantage that you can compare these values with
6502 a column listing the planned total effort for a task - one of the major
6503 applications for column view in the agenda.  If you want information about
6504 clocked time in the displayed period use clock table mode (press @kbd{R} in
6505 the agenda).
6506 @end enumerate
6509 @node Embedded LaTeX, Exporting, Agenda Views, Top
6510 @chapter Embedded LaTeX
6511 @cindex @TeX{} interpretation
6512 @cindex La@TeX{} interpretation
6514 Plain ASCII is normally sufficient for almost all note taking.  One
6515 exception, however, are scientific notes which need to be able to contain
6516 mathematical symbols and the occasional formula.  La@TeX{}@footnote{La@TeX{}
6517 is a macro system based on Donald E. Knuth's @TeX{} system.  Many of the
6518 features described here as ``La@TeX{}'' are really from @TeX{}, but for
6519 simplicity I am blurring this distinction.}  is widely used to typeset
6520 scientific documents. Org mode supports embedding La@TeX{} code into its
6521 files, because many academics are used to reading La@TeX{} source code, and
6522 because it can be readily processed into images for HTML production.
6524 It is not necessary to mark La@TeX{} macros and code in any special way.
6525 If you observe a few conventions, Org mode knows how to find it and what
6526 to do with it.
6528 @menu
6529 * Math symbols::                TeX macros for symbols and Greek letters
6530 * Subscripts and superscripts::  Simple syntax for raising/lowering text
6531 * LaTeX fragments::             Complex formulas made easy
6532 * Processing LaTeX fragments::  Previewing LaTeX processing
6533 * CDLaTeX mode::                Speed up entering of formulas
6534 @end menu
6536 @node Math symbols, Subscripts and superscripts, Embedded LaTeX, Embedded LaTeX
6537 @section Math symbols
6538 @cindex math symbols
6539 @cindex TeX macros
6541 You can use La@TeX{} macros to insert special symbols like @samp{\alpha}
6542 to indicate the Greek letter, or @samp{\to} to indicate an arrow.
6543 Completion for these macros is available, just type @samp{\} and maybe a
6544 few letters, and press @kbd{M-@key{TAB}} to see possible completions.
6545 Unlike La@TeX{} code, Org mode allows these macros to be present
6546 without surrounding math delimiters, for example:
6548 @example
6549 Angles are written as Greek letters \alpha, \beta and \gamma.
6550 @end example
6552 During HTML export (@pxref{HTML export}), these symbols are translated
6553 into the proper syntax for HTML, for the above examples this is
6554 @samp{&alpha;} and @samp{&rarr;}, respectively.  If you need such a symbol
6555 inside a word, terminate it like this: @samp{\Aacute@{@}stor}.
6557 @node Subscripts and superscripts, LaTeX fragments, Math symbols, Embedded LaTeX
6558 @section Subscripts and superscripts
6559 @cindex subscript
6560 @cindex superscript
6562 Just like in La@TeX{}, @samp{^} and @samp{_} are used to indicate super-
6563 and subscripts.  Again, these can be used without embedding them in
6564 math-mode delimiters.  To increase the readability of ASCII text, it is
6565 not necessary (but OK) to surround multi-character sub- and superscripts
6566 with curly braces.  For example
6568 @example
6569 The mass if the sun is M_sun = 1.989 x 10^30 kg.  The radius of
6570 the sun is R_@{sun@} = 6.96 x 10^8 m.
6571 @end example
6573 To avoid interpretation as raised or lowered text, you can quote
6574 @samp{^} and @samp{_} with a backslash: @samp{\_} and @samp{\^}.
6576 During HTML export (@pxref{HTML export}), subscript and superscripts
6577 are surrounded with @code{<sub>} and @code{<sup>} tags, respectively.
6579 @node LaTeX fragments, Processing LaTeX fragments, Subscripts and superscripts, Embedded LaTeX
6580 @section LaTeX fragments
6581 @cindex LaTeX fragments
6583 With symbols, sub- and superscripts, HTML is pretty much at its end when
6584 it comes to representing mathematical formulas@footnote{Yes, there is
6585 MathML, but that is not yet fully supported by many browsers, and there
6586 is no decent converter for turning La@TeX{} or ASCII representations of
6587 formulas into MathML. So for the time being, converting formulas into
6588 images seems the way to go.}. More complex expressions need a dedicated
6589 formula processor. To this end, Org mode can contain arbitrary La@TeX{}
6590 fragments. It provides commands to preview the typeset result of these
6591 fragments, and upon export to HTML, all fragments will be converted to
6592 images and inlined into the HTML document@footnote{The La@TeX{} export
6593 will not use images for displaying La@TeX{} fragments but include these
6594 fragments directly into the La@TeX{} code.}. For this to work you
6595 need to be on a system with a working La@TeX{} installation. You also
6596 need the @file{dvipng} program, available at
6597 @url{http://sourceforge.net/projects/dvipng/}. The La@TeX{} header that
6598 will be used when processing a fragment can be configured with the
6599 variable @code{org-format-latex-header}.
6601 La@TeX{} fragments don't need any special marking at all.  The following
6602 snippets will be identified as La@TeX{} source code:
6603 @itemize @bullet
6604 @item
6605 Environments of any kind.  The only requirement is that the
6606 @code{\begin} statement appears on a new line, preceded by only
6607 whitespace.
6608 @item
6609 Text within the usual La@TeX{} math delimiters.  To avoid conflicts with
6610 currency specifications, single @samp{$} characters are only recognized
6611 as math delimiters if the enclosed text contains at most two line breaks,
6612 is directly attached to the @samp{$} characters with no whitespace in
6613 between, and if the closing @samp{$} is followed by whitespace or
6614 punctuation.  For the other delimiters, there is no such restriction, so
6615 when in doubt, use @samp{\(...\)} as inline math delimiters.
6616 @end itemize
6618 @noindent For example:
6620 @example
6621 \begin@{equation@}                          % arbitrary environments,
6622 x=\sqrt@{b@}                                % even tables, figures
6623 \end@{equation@}                            % etc
6625 If $a^2=b$ and \( b=2 \), then the solution must be
6626 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
6627 @end example
6629 @noindent
6630 If you need any of the delimiter ASCII sequences for other purposes, you
6631 can configure the option @code{org-format-latex-options} to deselect the
6632 ones you do not wish to have interpreted by the La@TeX{} converter.
6634 @node Processing LaTeX fragments, CDLaTeX mode, LaTeX fragments, Embedded LaTeX
6635 @section Processing LaTeX fragments
6636 @cindex LaTeX fragments, preview
6638 La@TeX{} fragments can be processed to produce a preview images of the
6639 typeset expressions:
6641 @table @kbd
6642 @kindex C-c C-x C-l
6643 @item C-c C-x C-l
6644 Produce a preview image of the La@TeX{} fragment at point and overlay it
6645 over the source code.  If there is no fragment at point, process all
6646 fragments in the current entry (between two headlines).  When called
6647 with a prefix argument, process the entire subtree.  When called with
6648 two prefix arguments, or when the cursor is before the first headline,
6649 process the entire buffer.
6650 @kindex C-c C-c
6651 @item C-c C-c
6652 Remove the overlay preview images.
6653 @end table
6655 During HTML export (@pxref{HTML export}), all La@TeX{} fragments are
6656 converted into images and inlined into the document if the following
6657 setting is active:
6659 @lisp
6660 (setq org-export-with-LaTeX-fragments t)
6661 @end lisp
6663 @node CDLaTeX mode,  , Processing LaTeX fragments, Embedded LaTeX
6664 @section Using CDLaTeX to enter math
6665 @cindex CDLaTeX
6667 CDLaTeX mode is a minor mode that is normally used in combination with a
6668 major La@TeX{} mode like AUCTeX in order to speed-up insertion of
6669 environments and math templates.  Inside Org mode, you can make use of
6670 some of the features of CDLaTeX mode.  You need to install
6671 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
6672 AUCTeX) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
6673 Don't use CDLaTeX mode itself under Org mode, but use the light
6674 version @code{org-cdlatex-mode} that comes as part of Org mode.  Turn it
6675 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
6676 Org files with
6678 @lisp
6679 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
6680 @end lisp
6682 When this mode is enabled, the following features are present (for more
6683 details see the documentation of CDLaTeX mode):
6684 @itemize @bullet
6685 @kindex C-c @{
6686 @item
6687 Environment templates can be inserted with @kbd{C-c @{}.
6688 @item
6689 @kindex @key{TAB}
6690 The @key{TAB} key will do template expansion if the cursor is inside a
6691 La@TeX{} fragment@footnote{Org mode has a method to test if the cursor is
6692 inside such a fragment, see the documentation of the function
6693 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
6694 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
6695 correctly inside the first brace.  Another @key{TAB} will get you into
6696 the second brace.  Even outside fragments, @key{TAB} will expand
6697 environment abbreviations at the beginning of a line.  For example, if
6698 you write @samp{equ} at the beginning of a line and press @key{TAB},
6699 this abbreviation will be expanded to an @code{equation} environment.
6700 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
6701 @item
6702 @kindex _
6703 @kindex ^
6704 Pressing @kbd{_} and @kbd{^} inside a La@TeX{} fragment will insert these
6705 characters together with a pair of braces.  If you use @key{TAB} to move
6706 out of the braces, and if the braces surround only a single character or
6707 macro, they are removed again (depending on the variable
6708 @code{cdlatex-simplify-sub-super-scripts}).
6709 @item
6710 @kindex `
6711 Pressing the backquote @kbd{`} followed by a character inserts math
6712 macros, also outside La@TeX{} fragments.  If you wait more than 1.5 seconds
6713 after the backquote, a help window will pop up.
6714 @item
6715 @kindex '
6716 Pressing the normal quote @kbd{'} followed by another character modifies
6717 the symbol before point with an accent or a font.  If you wait more than
6718 1.5 seconds after the backquote, a help window will pop up.  Character
6719 modification will work only inside La@TeX{} fragments, outside the quote
6720 is normal.
6721 @end itemize
6723 @node Exporting, Publishing, Embedded LaTeX, Top
6724 @chapter Exporting
6725 @cindex exporting
6727 Org mode documents can be exported into a variety of other formats.  For
6728 printing and sharing of notes, ASCII export produces a readable and
6729 simple version of an Org file.  HTML export allows you to publish a
6730 notes file on the web, while the XOXO format provides a solid base for
6731 exchange with a broad range of other applications. La@TeX{} export lets
6732 you use Org mode and its structured editing functions to easily create
6733 La@TeX{} files.  To incorporate entries with associated times like
6734 deadlines or appointments into a desktop calendar program like iCal,
6735 Org mode can also produce extracts in the iCalendar format.  Currently
6736 Org mode only supports export, not import of these different formats.
6738 @menu
6739 * Markup rules::                Which structures are recognized?
6740 * Selective export::            Using tags to select and exclude trees
6741 * Export options::              Per-file export settings
6742 * The export dispatcher::       How to access exporter commands
6743 * ASCII export::                Exporting to plain ASCII
6744 * HTML export::                 Exporting to HTML
6745 * LaTeX export::                Exporting to LaTeX
6746 * XOXO export::                 Exporting to XOXO
6747 * iCalendar export::            Exporting in iCalendar format
6748 @end menu
6750 @node Markup rules, Selective export, Exporting, Exporting
6751 @section Markup rules
6753 When exporting Org mode documents,  the exporter tries to reflect the
6754 structure of the document as accurately as possible in the back-end.  Since
6755 export targets like HTML or La@TeX{} allow much richer formatting, Org mode
6756 has rules how to prepare text for rich export.  This section summarizes the
6757 markup rule used in an Org mode buffer.
6759 @menu
6760 * Document title::              How the document title is determined
6761 * Headings and sections::       The main structure of the exported document
6762 * Table of contents::           If, where, how to create a table of contents
6763 * Initial text::                Text before the first headline
6764 * Lists::                       Plain lists are exported
6765 * Paragraphs::                  What determines beginning and ending
6766 * Literal examples::            Source code and other examples
6767 * Include files::               Include the contents of a file during export
6768 * Tables exported::             Tables are exported richly
6769 * Footnotes::                   Numbers like [1]
6770 * Emphasis and monospace::      To bold or not to bold
6771 * TeX macros and LaTeX fragments::  Create special, rich export.
6772 * Horizontal rules::            A line across the page
6773 * Comment lines::               Some lines will not be exported
6774 @end menu
6776 @node Document title, Headings and sections, Markup rules, Markup rules
6777 @subheading Document title
6778 @cindex document title, markup rules
6780 @noindent
6781 The title of the exported document is taken from the special line
6783 @example
6784 #+TITLE: This is the title of the document
6785 @end example
6787 @noindent
6788 If this line does not exist, the title is derived from the first non-empty,
6789 non-comment line in the buffer.  If no such line exists, or if you have
6790 turned off exporting of the text before the first headline (see below), the
6791 title will be the file name without extension.
6793 If you are exporting only a subtree by marking is as the region, the heading
6794 of the subtree will become the title of the document.  If the subtree has a
6795 property @code{EXPORT_TITLE}, that will take precedence.
6797 @node Headings and sections, Table of contents, Document title, Markup rules
6798 @subheading Headings and sections
6799 @cindex headings and sections, markup rules
6801 The outline structure of the document as described in @ref{Document
6802 Structure} forms the basis for defining sections of the exported document.
6803 However, since the outline structure is also used for (for example) lists of
6804 tasks, only the first three outline levels will be used as headings.  Deeper
6805 levels will become itemized lists.  You can change the location of this
6806 switch, globally by setting the variable @code{org-headline-levels}, or on a
6807 per file basis with a line
6809 @example
6810 #+OPTIONS: H:4
6811 @end example
6813 @node Table of contents, Initial text, Headings and sections, Markup rules
6814 @subheading Table of contents
6815 @cindex table of contents, markup rules
6817 The table of contents is normally inserted directly before the first headline
6818 of the file.  If you would like to get it to a different location, insert the
6819 string @code{[TABLE-OF-CONTENTS]} on a line by itself at the desired
6820 location.  The depth of the table of contents is by default the same as the
6821 number of headline levels, but you can choose a smaller number or turn off
6822 the table of contents entirely by configuring the variable
6823 @code{org-export-with-toc}, or on a per-file basis with a line like
6825 @example
6826 #+OPTIONS: toc:2          (only to two levels in TOC)
6827 #+OPTIONS: toc:nil        (no TOC at all)
6828 @end example
6830 @node Initial text, Lists, Table of contents, Markup rules
6831 @subheading Text before the first headline
6832 @cindex text before first headline, markup rules
6833 @cindex #+TEXT
6835 Org mode normally exports the text before the first headline, and even uses
6836 the first line as the document title.  The text will be fully marked up.  If
6837 you need to include literal HTML or La@TeX{} code, use the special constructs
6838 described below in the sections for the individual exporters.
6840 Some people like to use the space before the first headline for setup and
6841 internal links and therefore would like to control the exported text before
6842 the first headline in a different way.  You can do so by setting the variable
6843 @code{org-export-skip-text-before-1st-heading} to @code{t}.  On a per-file
6844 basis, you can get the same effect with @samp{#+OPTIONS: skip:t}.
6846 @noindent
6847 If you still want to have some text before the first headline, use the
6848 @code{#+TEXT} construct:
6850 @example
6851 #+OPTIONS: skip:t
6852 #+TEXT: This text will go before the *first* headline.
6853 #+TEXT: [TABLE-OF-CONTENTS]
6854 #+TEXT: This goes between the table of contents and the first headline
6855 @end example
6857 @node Lists, Paragraphs, Initial text, Markup rules
6858 @subheading Lists
6859 @cindex lists, markup rules
6861 Plain lists as described in @ref{Plain lists} are translated to the back-ends
6862 syntax for such lists.  Most back-ends support unordered, ordered, and
6863 description lists.
6865 @node Paragraphs, Literal examples, Lists, Markup rules
6866 @subheading Paragraphs, line breaks, and quoting
6867 @cindex paragraphs, markup rules
6869 Paragraphs are separated by at least one empty line.  If you need to enforce
6870 a line break within a paragraph, use @samp{\\} at the end of a line.
6872 To keep the line breaks in a region, but otherwise use normal formatting, you
6873 can use this construct, which can also be used to format poetry.
6875 @example
6876 #+BEGIN_VERSE
6877  Great clouds overhead
6878  Tiny black birds rise and fall
6879  Snow covers Emacs
6881      -- AlexSchroeder
6882 #+END_VERSE
6883 @end example
6885 When quoting a passage from another document, it is customary to format this
6886 as a paragraph that is indented on both the left and the right margin.  You
6887 can include quotations in Org mode documents like this:
6889 @example
6890 #+BEGIN_QUOTE
6891 Everything should be made as simple as possible,
6892 but not any simpler -- Albert Einstein
6893 #+END_QUOTE
6894 @end example
6897 @node Literal examples, Include files, Paragraphs, Markup rules
6898 @subheading Literal examples
6899 @cindex literal examples, markup rules
6901 You can include literal examples that should not be subjected to
6902 markup.  Such examples will be typeset in monospace, so this is well suited
6903 for source code and similar examples.
6904 @cindex #+BEGIN_EXAMPLE
6906 @example
6907 #+BEGIN_EXAMPLE
6908 Some example from a text file.
6909 #+END_EXAMPLE
6910 @end example
6912 For simplicity when using small examples, you can also start the example
6913 lines with a colon:
6915 @example
6916 : Some example from a text file.
6917 @end example
6919 @cindex formatting source code, markup rules
6920 If the example is source code from a programming language, or any other text
6921 that can be marked up by font-lock in Emacs, you can ask for the example to
6922 look like the fontified Emacs buffer@footnote{Currently this works only for
6923 the HTML back-end, and requires the @file{htmlize.el} package version 1.34 or
6924 later.}.  This is done with the @samp{src} block, where you also need to
6925 specify the name of the major mode that should be used to fontify the
6926 example:
6927 @cindex #+BEGIN_SRC
6929 @example
6930 #+BEGIN_SRC emacs-lisp
6931 (defun org-xor (a b)
6932    "Exclusive or."
6933    (if a (not b) b))
6934 #+END_SRC
6935 @end example
6937 @table @kbd
6938 @kindex C-c '
6939 @item C-c '
6940 Edit the source code example at point in its native mode.  This works by
6941 switching to an indirect buffer, narrowing the buffer and switching to the
6942 other mode.  You need to exit by pressing @kbd{C-c '} again.  Fixed-width
6943 regions (where each line starts with a colon followed by a space) will be
6944 edited using @code{artist-mode}@footnote{You may select a different-mode with
6945 the variable @code{org-edit-fixed-width-region-mode}.} to allow creating
6946 ASCII drawings easily.  Using this command in an empty line will create a new
6947 fixed-width region.
6948 @end table
6951 @node Include files, Tables exported, Literal examples, Markup rules
6952 @subheading Include files
6953 @cindex include files, markup rules
6955 During export, you can include the content of another file.  For example, to
6956 include your .emacs file, you could use:
6957 @cindex #+INCLUDE
6959 @example
6960 #+INCLUDE: "~/.emacs" src emacs-lisp
6961 @end example
6963 The optional second and third parameter are the markup (@samp{quote},
6964 @samp{example}, or @samp{src}), and, if the markup is @samp{src}, the
6965 language for formatting the contents.  The markup is optional, if it is not
6966 given, the text will be assumed to be in Org mode format and will be
6967 processed normally.  The include line will also allow additional keyword
6968 parameters @code{:prefix1} and @code{:prefix} to specify prefixes for the
6969 first line and for each following line.  For example, to include a file as an
6970 item, use
6972 @example
6973 #+INCLUDE: "~/snippets/xx" :prefix1 "   + " :prefix "     "
6974 @end example
6976 @table @kbd
6977 @kindex C-c '
6978 @item C-c '
6979 Visit the include file at point.
6980 @end table
6982 @node Tables exported, Footnotes, Include files, Markup rules
6983 @subheading Tables
6984 @cindex tables, markup rules
6986 Both the native Org mode tables (@pxref{Tables}) and tables formatted with
6987 the @file{table.el} package will be exported properly.  For Org mode tables,
6988 the lines before the first horizontal separator line will become table header
6989 lines.
6991 @node Footnotes, Emphasis and monospace, Tables exported, Markup rules
6992 @subheading Footnotes
6993 @cindex footnotes, markup rules
6994 @cindex @file{footnote.el}
6996 @kindex C-c !
6997 Numbers in square brackets are treated as footnote markers, and lines
6998 starting with such a marker are interpreted as the footnote itself.  You can
6999 use the Emacs package @file{footnote.el} to create footnotes@footnote{The
7000 @file{footnote} package uses @kbd{C-c !} to invoke its commands.  This
7001 binding conflicts with the Org mode command for inserting inactive time
7002 stamps.  You could use the variable @code{footnote-prefix} to switch
7003 footnotes commands to another key.  Or, if you are too used to this binding,
7004 you could use @code{org-replace-disputed-keys} and @code{org-disputed-keys}
7005 to change the settings in Org.}.  For example:
7007 @example
7008 The Org homepage[1] now looks a lot better than it used to.
7010 [1] The link is: http://orgmode.org
7011 @end example
7013 @node Emphasis and monospace, TeX macros and LaTeX fragments, Footnotes, Markup rules
7014 @subheading Emphasis and monospace
7016 @cindex underlined text, markup rules
7017 @cindex bold text, markup rules
7018 @cindex italic text, markup rules
7019 @cindex verbatim text, markup rules
7020 @cindex code text, markup rules
7021 @cindex strike-through text, markup rules
7022 You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
7023 and @code{~verbatim~}, and, if you must, @samp{+strike-through+}.  Text
7024 in the code and verbatim string is not processed for Org mode specific
7025 syntax, it is exported verbatim.
7027 @node TeX macros and LaTeX fragments, Horizontal rules, Emphasis and monospace, Markup rules
7028 @subheading @TeX{} macros and La@TeX{} fragments
7029 @cindex LaTeX fragments, markup rules
7030 @cindex TeX macros, markup rules
7031 @cindex HTML entities
7032 @cindex LaTeX entities
7034 A @TeX{}-like syntax is used to specify special characters.  Where possible,
7035 these will be transformed into the native format of the exporter back-end.
7036 Strings like @code{\alpha} will be exported as @code{&alpha;} in the HTML
7037 output, and as @code{$\alpha$} in the La@TeX{} output.  Similarly,
7038 @code{\nbsp} will become @code{&nbsp;} in HTML and @code{~} in La@TeX{}.
7039 This applies for a large number of entities, with names taken from both HTML
7040 and La@TeX{}, see the variable @code{org-html-entities} for the complete
7041 list.  If you are unsure about a name, use @kbd{M-@key{TAB}} for completion
7042 after having types the backslash and maybe a few characters
7043 (@pxref{Completion}).
7045 La@TeX{} fragments are converted into images for HTML export, and they are
7046 written literally into the La@TeX{} export.  See also @ref{Embedded LaTeX}.
7048 Finally, @samp{\-} is treated as a shy hyphen, and @samp{--}, @samp{---}, and
7049 @samp{...} are all converted into special commands creating hyphens of
7050 different lengths or a compact set of dots.
7052 @node Horizontal rules, Comment lines, TeX macros and LaTeX fragments, Markup rules
7053 @subheading  Horizontal rules
7054 @cindex horizontal rules, markup rules
7055 A line consisting of only dashes, and at least 5 of them, will be
7056 exported as a horizontal line (@samp{<hr/>} in HTML).
7058 @node Comment lines,  , Horizontal rules, Markup rules
7059 @subheading Comment lines
7060 @cindex comment lines
7061 @cindex exporting, not
7063 Lines starting with @samp{#} in column zero are treated as comments and will
7064 never be exported.  Also entire subtrees starting with the word
7065 @samp{COMMENT} will never be exported.  Finally, regions surrounded by
7066 @samp{#+BEGIN_COMMENT} ... @samp{#+END_COMMENT} will not be exported.
7068 @table @kbd
7069 @kindex C-c ;
7070 @item C-c ;
7071 Toggle the COMMENT keyword at the beginning of an entry.
7072 @end table
7074 @node Selective export, Export options, Markup rules, Exporting
7075 @section Selective export
7076 @cindex export, selective by tags
7078 You may use tags to select the parts of a document that should be exported,
7079 or to exclude parts from export.  This behavior is governed by two variables:
7080 @code{org-export-select-tags} and @code{org-export-exclude-tags}.
7082 Org first checks if any of the @emph{select} tags is present in the buffer.
7083 If yes, all trees that do not carry one of these tags will be excluded.  If a
7084 selected tree is a subtree, the heading hierarchy above it will also be
7085 selected for export, but not the text below those headings.
7087 @noindent
7088 If none of the select tags is found, the whole buffer will be selected for
7089 export.
7091 @noindent
7092 Finally, all subtrees that are marked by any of the @emph{exclude} tags will
7093 be removed from the export buffer.
7095 @node Export options, The export dispatcher, Selective export, Exporting
7096 @section Export options
7097 @cindex options, for export
7099 @cindex completion, of option keywords
7100 The exporter recognizes special lines in the buffer which provide
7101 additional information.  These lines may be put anywhere in the file.
7102 The whole set of lines can be inserted into the buffer with @kbd{C-c
7103 C-e t}.  For individual lines, a good way to make sure the keyword is
7104 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
7105 (@pxref{Completion}).
7107 @table @kbd
7108 @kindex C-c C-e t
7109 @item C-c C-e t
7110 Insert template with export options, see example below.
7111 @end table
7113 @cindex #+TITLE:
7114 @cindex #+AUTHOR:
7115 @cindex #+DATE:
7116 @cindex #+EMAIL:
7117 @cindex #+LANGUAGE:
7118 @cindex #+TEXT:
7119 @cindex #+OPTIONS:
7120 @cindex #+LINK_UP:
7121 @cindex #+LINK_HOME:
7122 @cindex #+EXPORT_SELECT_TAGS:
7123 @cindex #+EXPORT_EXCLUDE_TAGS:
7124 @example
7125 #+TITLE:     the title to be shown (default is the buffer name)
7126 #+AUTHOR:    the author (default taken from @code{user-full-name})
7127 #+DATE:      A date, fixed, of a format string for @code{format-time-string}
7128 #+EMAIL:     his/her email address (default from @code{user-mail-address})
7129 #+LANGUAGE:  language for HTML, e.g. @samp{en} (@code{org-export-default-language})
7130 #+TEXT:      Some descriptive text to be inserted at the beginning.
7131 #+TEXT:      Several lines may be given.
7132 #+OPTIONS:   H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
7133 #+LINK_UP:   the ``up'' link of an exported page
7134 #+LINK_HOME: the ``home'' link of an exported page
7135 #+EXPORT_SELECT_TAGS:   Tags that select a tree for export
7136 #+EXPORT_EXCLUDE_TAGS:  Tags that exclude a tree from export
7137 @end example
7139 @noindent
7140 The OPTIONS line is a compact@footnote{If you want to configure many options
7141 this way, you can use several OPTIONS lines.} form to specify export settings.  Here
7142 you can:
7143 @cindex headline levels
7144 @cindex section-numbers
7145 @cindex table of contents
7146 @cindex line-break preservation
7147 @cindex quoted HTML tags
7148 @cindex fixed-width sections
7149 @cindex tables
7150 @cindex @TeX{}-like syntax for sub- and superscripts
7151 @cindex footnotes
7152 @cindex special strings
7153 @cindex emphasized text
7154 @cindex @TeX{} macros
7155 @cindex La@TeX{} fragments
7156 @cindex author info, in export
7157 @cindex time info, in export
7158 @example
7159 H:         @r{set the number of headline levels for export}
7160 num:       @r{turn on/off section-numbers}
7161 toc:       @r{turn on/off table of contents, or set level limit (integer)}
7162 \n:        @r{turn on/off line-break-preservation}
7163 @@:         @r{turn on/off quoted HTML tags}
7164 ::         @r{turn on/off fixed-width sections}
7165 |:         @r{turn on/off tables}
7166 ^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
7167            @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
7168            @r{the simple @code{a_b} will be left as it is.}
7169 -:         @r{turn on/off conversion of special strings.}
7170 f:         @r{turn on/off footnotes like this[1].}
7171 *:         @r{turn on/off emphasized text (bold, italic, underlined)}
7172 TeX:       @r{turn on/off simple @TeX{} macros in plain text}
7173 LaTeX:     @r{turn on/off La@TeX{} fragments}
7174 skip:      @r{turn on/off skipping the text before the first heading}
7175 author:    @r{turn on/off inclusion of author name/email into exported file}
7176 creator:   @r{turn on/off inclusion of creator info into exported file}
7177 timestamp: @r{turn on/off inclusion creation time into exported file}
7178 d:         @r{turn on/off inclusion of drawers}
7179 @end example
7181 These options take effect in both the HTML and La@TeX{} export, except
7182 for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
7183 @code{nil} for the La@TeX{} export.
7185 When exporting only a single subtree by selecting it with @kbd{C-c @@} before
7186 calling an export command, the subtree can overrule some of the file's export
7187 settings with properties @code{EXPORT_FILE_NAME}, @code{EXPORT_TITLE},
7188 @code{EXPORT_TEXT}, and @code{EXPORT_OPTIONS}.
7190 @node The export dispatcher, ASCII export, Export options, Exporting
7191 @section The export dispatcher
7192 @cindex dispatcher, for export commands
7194 All export commands can be reached using the export dispatcher, which is a
7195 prefix key that prompts for an additional key specifying the command.
7196 Normally the entire file is exported, but if there is an active region that
7197 contains one outline tree, the first heading is used as document title and
7198 the subtrees are exported.
7200 @table @kbd
7201 @kindex C-c C-e
7202 @item C-c C-e
7203 Dispatcher for export and publishing commands.  Displays a help-window
7204 listing the additional key(s) needed to launch an export or publishing
7205 command.  The prefix arg is passed through to the exporter.  If the option
7206 @code{org-export-run-in-background} is set, Org will run the command in the
7207 background if that seems useful for the specific command (i.e. commands that
7208 write to a file).
7209 @kindex C-c C-e v
7210 @item C-c C-e v
7211 Like @kbd{C-c C-e}, but only export the text that is currently visible
7212 (i.e. not hidden by outline visibility).
7213 @kindex C-u C-u C-c C-e
7214 @item C-u C-u C-c C-e
7215 Call an the exporter, but reverse the setting of
7216 @code{org-export-run-in-background}, i.e. request background processing if
7217 not set, or force processing in the current Emacs process if st.
7218 @end table
7220 @node ASCII export, HTML export, The export dispatcher, Exporting
7221 @section ASCII export
7222 @cindex ASCII export
7224 ASCII export produces a simple and very readable version of an Org mode
7225 file.
7227 @cindex region, active
7228 @cindex active region
7229 @cindex Transient mark mode
7230 @table @kbd
7231 @kindex C-c C-e a
7232 @item C-c C-e a
7233 Export as ASCII file.  For an org file @file{myfile.org}, the ASCII file
7234 will be @file{myfile.txt}.  The file will be overwritten without
7235 warning.  If there is an active region, only the region will be
7236 exported. If the selected region is a single tree@footnote{To select the
7237 current subtree, use @kbd{C-c @@}.}, the tree head will
7238 become the document title.  If the tree head entry has or inherits an
7239 @code{EXPORT_FILE_NAME} property, that name will be used for the
7240 export.
7241 @kindex C-c C-e v a
7242 @item C-c C-e v a
7243 Export only the visible part of the document.
7244 @end table
7246 @cindex headline levels, for exporting
7247 In the exported version, the first 3 outline levels will become
7248 headlines, defining a general document structure.  Additional levels
7249 will be exported as itemized lists.  If you want that transition to occur
7250 at a different level, specify it with a prefix argument.  For example,
7252 @example
7253 @kbd{C-1 C-c C-e a}
7254 @end example
7256 @noindent
7257 creates only top level headlines and does the rest as items.  When
7258 headlines are converted to items, the indentation of the text following
7259 the headline is changed to fit nicely under the item.  This is done with
7260 the assumption that the first body line indicates the base indentation of
7261 the body text.  Any indentation larger than this is adjusted to preserve
7262 the layout relative to the first line.  Should there be lines with less
7263 indentation than the first, these are left alone.
7265 @node HTML export, LaTeX export, ASCII export, Exporting
7266 @section HTML export
7267 @cindex HTML export
7269 Org mode contains an HTML (XHTML 1.0 strict) exporter with extensive
7270 HTML formatting, in ways similar to John Grubers @emph{markdown}
7271 language, but with additional support for tables.
7273 @menu
7274 * HTML Export commands::        How to invoke HTML export
7275 * Quoting HTML tags::           Using direct HTML in Org mode
7276 * Links::                       Transformation of links for HTML
7277 * Images::                      How to include images
7278 * CSS support::                 Changing the appearance of the output
7279 * Javascript support::          Info and Folding in a web browser
7280 @end menu
7282 @node HTML Export commands, Quoting HTML tags, HTML export, HTML export
7283 @subsection HTML export commands
7285 @cindex region, active
7286 @cindex active region
7287 @cindex Transient mark mode
7288 @table @kbd
7289 @kindex C-c C-e h
7290 @item C-c C-e h
7291 Export as HTML file @file{myfile.html}.  For an org file @file{myfile.org},
7292 the ASCII file will be @file{myfile.html}.  The file will be overwritten
7293 without warning.  If there is an active region, only the region will be
7294 exported. If the selected region is a single tree@footnote{To select the
7295 current subtree, use @kbd{C-c @@}.}, the tree head will become the document
7296 title.  If the tree head entry has or inherits an @code{EXPORT_FILE_NAME}
7297 property, that name will be used for the export.
7298 @kindex C-c C-e b
7299 @item C-c C-e b
7300 Export as HTML file and immediately open it with a browser.
7301 @kindex C-c C-e H
7302 @item C-c C-e H
7303 Export to a temporary buffer, do not create a file.
7304 @kindex C-c C-e R
7305 @item C-c C-e R
7306 Export the active region to a temporary buffer.  With a prefix argument, do
7307 not produce the file header and footer, but just the plain HTML section for
7308 the region.  This is good for cut-and-paste operations.
7309 @kindex C-c C-e v h
7310 @kindex C-c C-e v b
7311 @kindex C-c C-e v H
7312 @kindex C-c C-e v R
7313 @item C-c C-e v h
7314 @item C-c C-e v b
7315 @item C-c C-e v H
7316 @item C-c C-e v R
7317 Export only the visible part of the document.
7318 @item M-x org-export-region-as-html
7319 Convert the region to HTML under the assumption that it was Org mode
7320 syntax before.  This is a global command that can be invoked in any
7321 buffer.
7322 @item M-x org-replace-region-by-HTML
7323 Replace the active region (assumed to be in Org mode syntax) by HTML
7324 code.
7325 @end table
7327 @cindex headline levels, for exporting
7328 In the exported version, the first 3 outline levels will become headlines,
7329 defining a general document structure.  Additional levels will be exported as
7330 itemized lists.  If you want that transition to occur at a different level,
7331 specify it with a numeric prefix argument.  For example,
7333 @example
7334 @kbd{C-2 C-c C-e b}
7335 @end example
7337 @noindent
7338 creates two levels of headings and does the rest as items.
7340 @node Quoting HTML tags, Links, HTML Export commands, HTML export
7341 @subsection Quoting HTML tags
7343 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
7344 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
7345 which should be interpreted as such, mark them with @samp{@@} as in
7346 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
7347 simple tags.  For more extensive HTML that should be copied verbatim to
7348 the exported file use either
7350 @example
7351 #+HTML: Literal HTML code for export
7352 @end example
7354 @noindent or
7355 @cindex #+BEGIN_HTML
7357 @example
7358 #+BEGIN_HTML
7359 All lines between these markers are exported literally
7360 #+END_HTML
7361 @end example
7364 @node Links, Images, Quoting HTML tags, HTML export
7365 @subsection Links
7367 @cindex links, in HTML export
7368 @cindex internal links, in HTML export
7369 @cindex external links, in HTML export
7370 Internal links (@pxref{Internal links}) will continue to work in HTML
7371 files only if they match a dedicated @samp{<<target>>}.  Automatic links
7372 created by radio targets (@pxref{Radio targets}) will also work in the
7373 HTML file.  Links to external files will still work if the HTML file is
7374 in the same directory as the Org file.  Links to other @file{.org}
7375 files will be translated into HTML links under the assumption that an
7376 HTML version also exists of the linked file.  For information related to
7377 linking files while publishing them to a publishing directory see
7378 @ref{Publishing links}.
7380 If you want to specify attributes for links, you can do so using a special
7381 syntax.  Here is an example that sets @code{alt} and @code{title} attributes
7382 for an inlined image:
7384 @example
7385 [[./img/a.jpg@{@{alt="This is image A" title="Image with no action"@}@}]]
7386 @end example
7388 @node Images, CSS support, Links, HTML export
7389 @subsection Images
7391 @cindex images, inline in HTML
7392 @cindex inlining images in HTML
7393 HTML export can inline images given as links in the Org file, and
7394 it can make an image the clickable part of a link.  By
7395 default@footnote{but see the variable
7396 @code{org-export-html-inline-images}}, images are inlined if a link does
7397 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
7398 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
7399 @samp{the image} that points to the image.  If the description part
7400 itself is a @code{file:} link or a @code{http:} URL pointing to an
7401 image, this image will be inlined and activated so that clicking on the
7402 image will activate the link.  For example, to include a thumbnail that
7403 will link to a high resolution version of the image, you could use:
7405 @example
7406 [[file:highres.jpg][file:thumb.jpg]]
7407 @end example
7409 @noindent
7410 and you could use @code{http} addresses just as well.
7412 @node CSS support, Javascript support, Images, HTML export
7413 @subsection CSS support
7414 @cindex CSS, for HTML export
7415 @cindex HTML export, CSS
7417 You can also give style information for the exported file.  The HTML
7418 exporter assigns the following CSS classes to appropriate parts of the
7419 document - your style specifications may change these:
7420 @example
7421 .todo           @r{TODO keywords}
7422 .done           @r{the DONE keyword}
7423 .timestamp      @r{time stamp}
7424 .timestamp-kwd  @r{keyword associated with a time stamp, like SCHEDULED}
7425 .tag            @r{tag in a headline}
7426 .target         @r{target for links}
7427 @end example
7429 Each exported files contains a compact default style that defines these
7430 classes in a basic way.  You may overwrite these settings, or add to them by
7431 using the variables @code{org-export-html-style} (for Org-wide settings) and
7432 @code{org-export-html-style-extra} (for more granular settings, like
7433 file-local settings).  If you want to use a file-local style, you may use
7434 file variables, best wrapped into a COMMENT section at the end of the outline
7435 tree.  For example@footnote{Under Emacs 21, the continuation lines for a
7436 variable value should have no @samp{#} at the start of the line.}:
7438 @example
7439 * COMMENT html style specifications
7441 # Local Variables:
7442 # org-export-html-style-extra: 
7443 #  "<style>
7444 #   p  @{font-weight: normal; color: gray; @}
7445 #   h1 @{color: black; @}
7446 #   </style>"
7447 # End:
7448 @end example
7450 Remember to execute @kbd{M-x normal-mode} after changing this to make the new
7451 style immediately visible to Emacs.  This command restarts Org mode for the
7452 current buffer and forces Emacs to re-evaluate the local variables section in
7453 the buffer.
7455 @c FIXME: More about header and footer styles
7456 @c FIXME: Talk about links and targets.
7458 @node Javascript support,  , CSS support, HTML export
7459 @subsection Javascript supported display of web pages
7461 @emph{Sebastian Rose} has written a JavaScript program especially designed to
7462 enhance the web viewing experience of HTML files created with Org.  This
7463 program allows to view large files in two different ways.  The first one is
7464 an @emph{Info}-like mode where each section is displayed separately and
7465 navigation can be done with the @kbd{n} and @kbd{p} keys (and some other keys
7466 as well, press @kbd{?} for an overview of the available keys).  The second
7467 view type is a @emph{folding} view much like Org provides it inside Emacs.
7468 The script is available at @url{http://orgmode.org/org-info.js} and you can
7469 find the documentation for it at
7470 @url{http://orgmode.org/worg/code/org-info-js/org-info.js.html}.  We are
7471 serving the script from our site, but if you use it a lot, you might not want
7472 to be dependent on @url{orgmode.org} and prefer to install a local copy on
7473 your own web server.
7475 To use the script, you need to make sure that the @file{org-jsinfo.el} module
7476 gets loaded.  It should be loaded by default, try @kbd{M-x customize-variable
7477 @key{RET} org-modules @key{RET}} to convince yourself that this is indeed the
7478 case.  All it then takes to make use of the program is adding a single line
7479 to the Org file:
7481 @example
7482 #+INFOJS_OPT: view:info toc:nil
7483 @end example
7485 @noindent
7486 If this line is found, the HTML header will automatically contain the code
7487 needed to invoke the script.  Using the line above, you can set the following
7488 viewing options:
7490 @example
7491 path:    @r{The path to the script.  The default is to grab the script from}
7492          @r{@url{http://orgmode.org/org-info.js}, but you might want to have}
7493          @r{a local copy and use a path like @samp{../scripts/org-info.js}.}
7494 view:    @r{Initial view when website is first shown.  Possible values are:}
7495          info      @r{Info-like interface with one section per page.}
7496          overview  @r{Folding interface, initially showing only top-level.}
7497          content   @r{Folding interface, starting with all headlines visible.}
7498          showall   @r{Folding interface, all headlines and text visible.}
7499 sdepth:  @r{Maximum headline level that will still become an independent}
7500          @r{section for info and folding modes.  The default is taken from}
7501          @r{@code{org-headline-levels} (= the @code{H} switch in @code{#+OPTIONS}).}
7502          @r{If this is smaller than in @code{org-headline-levels}, each}
7503          @r{info/folding section can still contain children headlines.}
7504 toc:     @r{Should the table of content @emph{initially} be visible?}
7505          @r{Even when @code{nil}, you can always get to the toc with @kbd{i}.}
7506 tdepth:  @r{The depth of the table of contents.  The defaults are taken from}
7507          @r{the variables @code{org-headline-levels} and @code{org-export-with-toc}.}
7508 ftoc:    @r{Does the css of the page specify a fixed position for the toc?}
7509          @r{If yes, the toc will never be displayed as a section.}
7510 ltoc:    @r{Should there be short contents (children) in each section?}
7511 mouse:   @r{Headings are highlighted when the mouse is over them.  Should be}
7512          @r{@samp{underline} (default) or a background color like @samp{#cccccc}.}
7513 buttons: @r{Should view-toggle buttons be everywhere?  When @code{nil} (the}
7514          @r{default), only one such button will be present.}
7515 @end example
7517 You can choose default values for these options by customizing the variable
7518 @code{org-infojs-options}.  If you always want to apply the script to your
7519 pages, configure the variable @code{org-export-html-use-infojs}.
7521 @node LaTeX export, XOXO export, HTML export, Exporting
7522 @section LaTeX export
7523 @cindex LaTeX export
7525 Org mode contains a La@TeX{} exporter written by Bastien Guerry.
7527 @menu
7528 * LaTeX export commands::       How to invoke LaTeX export
7529 * Quoting LaTeX code::          Incorporating literal LaTeX code
7530 * Sectioning structure::        Changing sectioning in LaTeX output
7531 @end menu
7533 @node LaTeX export commands, Quoting LaTeX code, LaTeX export, LaTeX export
7534 @subsection LaTeX export commands
7536 @table @kbd
7537 @kindex C-c C-e l
7538 @item C-c C-e l
7539 Export as La@TeX{} file @file{myfile.tex}.  For an org file
7540 @file{myfile.org}, the ASCII file will be @file{myfile.tex}.  The file will
7541 be overwritten without warning.  If there is an active region, only the
7542 region will be exported. If the selected region is a single tree@footnote{To
7543 select the current subtree, use @kbd{C-c @@}.}, the tree head will become the
7544 document title.  If the tree head entry has or inherits an
7545 @code{EXPORT_FILE_NAME} property, that name will be used for the export.
7546 @kindex C-c C-e L
7547 @item C-c C-e L
7548 Export to a temporary buffer, do not create a file.
7549 @kindex C-c C-e v l
7550 @kindex C-c C-e v L
7551 @item C-c C-e v l
7552 @item C-c C-e v L
7553 Export only the visible part of the document.
7554 @item M-x org-export-region-as-latex
7555 Convert the region to La@TeX{} under the assumption that it was Org mode
7556 syntax before.  This is a global command that can be invoked in any
7557 buffer.
7558 @item M-x org-replace-region-by-latex
7559 Replace the active region (assumed to be in Org mode syntax) by La@TeX{}
7560 code.
7561 @end table
7563 @cindex headline levels, for exporting
7564 In the exported version, the first 3 outline levels will become
7565 headlines, defining a general document structure.  Additional levels
7566 will be exported as description lists.  The exporter can ignore them or
7567 convert them to a custom string depending on
7568 @code{org-latex-low-levels}.
7570 If you want that transition to occur at a different level, specify it
7571 with a numeric prefix argument. For example,
7573 @example
7574 @kbd{C-2 C-c C-e l}
7575 @end example
7577 @noindent
7578 creates two levels of headings and does the rest as items.
7580 @node Quoting LaTeX code, Sectioning structure, LaTeX export commands, LaTeX export
7581 @subsection Quoting LaTeX code
7583 Embedded La@TeX{} as described in @ref{Embedded LaTeX} will be correctly
7584 inserted into the La@TeX{} file.  Furthermore, you can add special code
7585 that should only be present in La@TeX{} export with the following
7586 constructs:
7588 @example
7589 #+LaTeX: Literal LaTeX code for export
7590 @end example
7592 @noindent or
7593 @cindex #+BEGIN_LaTeX
7595 @example
7596 #+BEGIN_LaTeX
7597 All lines between these markers are exported literally
7598 #+END_LaTeX
7599 @end example
7601 @node   Sectioning structure,  , Quoting LaTeX code, LaTeX export
7602 @subsection Sectioning structure
7603 @cindex LaTeX class
7604 @cindex LaTeX sectioning structure
7606 By default, the La@TeX{} output uses the class @code{article}.
7608 You can change this globally by setting a different value for
7609 @code{org-export-latex-default-class} or locally by adding an option
7610 like @code{#+LaTeX_CLASS: myclass} in your file.  The class should be
7611 listed in @code{org-export-latex-classes}, where you can also define the
7612 sectioning structure for each class.
7615 @node XOXO export, iCalendar export, LaTeX export, Exporting
7616 @section XOXO export
7617 @cindex XOXO export
7619 Org mode contains an exporter that produces XOXO-style output.
7620 Currently, this exporter only handles the general outline structure and
7621 does not interpret any additional Org mode features.
7623 @table @kbd
7624 @kindex C-c C-e x
7625 @item C-c C-e x
7626 Export as XOXO file @file{myfile.html}.
7627 @kindex C-c C-e v
7628 @item C-c C-e v x
7629 Export only the visible part of the document.
7630 @end table
7632 @node iCalendar export,  , XOXO export, Exporting
7633 @section iCalendar export
7634 @cindex iCalendar export
7636 Some people like to use Org mode for keeping track of projects, but still
7637 prefer a standard calendar application for anniversaries and appointments.
7638 In this case it can be useful to have deadlines and other time-stamped items
7639 in Org files show up in the calendar application.  Org mode can export
7640 calendar information in the standard iCalendar format.  If you also want to
7641 have TODO entries included in the export, configure the variable
7642 @code{org-icalendar-include-todo}.  iCalendar export will export plain time
7643 stamps as VEVENT, and TODO items as VTODO.  It will also create events from
7644 deadlines that are in non-TODO items.  Deadlines and scheduling dates in TODO
7645 items will be used to set the start and due dates for the todo
7646 entry@footnote{See the variables @code{org-icalendar-use-deadline} and
7647 @code{org-icalendar-use-scheduled}.}.  As categories, it will use the tags
7648 locally defined in the heading, and the file/tree category@footnote{To add
7649 inherited tags or the TODO state, configure the variable
7650 @code{org-icalendar-categories}.}. 
7652 The iCalendar standard requires each entry to have a globally unique
7653 identifier (UID).  Org creates these identifiers during export.  If you set
7654 the variable @code{org-icalendar-store-UID}, the UID will be stored in the
7655 @code{:ID:} property of the entry and re-used next time you report this
7656 entry.  Since a single entry can give rise to multiple iCalendar entries (as
7657 a timestamp, a deadline, a scheduled item, and as a TODO item), Org adds
7658 prefixes to the UID, depending on what triggered the inclusion of the entry.
7659 In this way the UID remains unique, but a synchronization program can still
7660 figure out from which entry all the different instances originate.
7662 @table @kbd
7663 @kindex C-c C-e i
7664 @item C-c C-e i
7665 Create iCalendar entries for the current file and store them in the same
7666 directory, using a file extension @file{.ics}.
7667 @kindex C-c C-e I
7668 @item C-c C-e I
7669 Like @kbd{C-c C-e i}, but do this for all files in
7670 @code{org-agenda-files}.  For each of these files, a separate iCalendar
7671 file will be written.
7672 @kindex C-c C-e c
7673 @item C-c C-e c
7674 Create a single large iCalendar file from all files in
7675 @code{org-agenda-files} and write it to the file given by
7676 @code{org-combined-agenda-icalendar-file}.
7677 @end table
7679 The export will honor SUMMARY, DESCRIPTION and LOCATION properties if
7680 the selected entries have them.  If not, the summary will be derived
7681 from the headline, and the description from the body (limited to
7682 @code{org-icalendar-include-body} characters).
7684 How this calendar is best read and updated, that depends on the application
7685 you are using.  The FAQ covers this issue.
7687 @node Publishing, Miscellaneous, Exporting, Top
7688 @chapter Publishing
7689 @cindex publishing
7691 Org includes@footnote{@file{org-publish.el} is not distributed with
7692 Emacs 21, if you are still using Emacs 21, you need you need to download
7693 this file separately.} a publishing management system that allows you to
7694 configure automatic HTML conversion of @emph{projects} composed of
7695 interlinked org files.  This system is called @emph{org-publish}.  You can
7696 also configure org-publish to automatically upload your exported HTML
7697 pages and related attachments, such as images and source code files, to
7698 a web server. Org-publish turns Org into a web-site authoring tool.
7700 You can also use Org-publish to convert files into La@TeX{}, or even
7701 combine HTML and La@TeX{} conversion so that files are available in both
7702 formats on the server@footnote{Since La@TeX{} files on a server are not
7703 that helpful, you surely want to perform further conversion on them --
7704 e.g. convert them to @code{PDF} format.}.
7706 Org-publish has been contributed to Org by David O'Toole.
7708 @menu
7709 * Configuration::               Defining projects
7710 * Sample configuration::        Example projects
7711 * Triggering publication::      Publication commands
7712 @end menu
7714 @node Configuration, Sample configuration, Publishing, Publishing
7715 @section Configuration
7717 Publishing needs significant configuration to specify files, destination
7718 and many other properties of a project.
7720 @menu
7721 * Project alist::               The central configuration variable
7722 * Sources and destinations::    From here to there
7723 * Selecting files::             What files are part of the project?
7724 * Publishing action::           Setting the function doing the publishing
7725 * Publishing options::          Tweaking HTML export
7726 * Publishing links::            Which links keep working after publishing?
7727 * Project page index::          Publishing a list of project files
7728 @end menu
7730 @node Project alist, Sources and destinations, Configuration, Configuration
7731 @subsection The variable @code{org-publish-project-alist}
7732 @cindex org-publish-project-alist
7733 @cindex projects, for publishing
7735 Org-publish is configured almost entirely through setting the value of
7736 one variable, called @code{org-publish-project-alist}.
7737 Each element of the list configures one project, and may be in one of
7738 the two following forms:
7740 @lisp
7741 ("project-name" :property value :property value ...)
7743 @r{or}
7745 ("project-name" :components ("project-name" "project-name" ...))
7747 @end lisp
7749 In both cases, projects are configured by specifying property values.
7750 A project defines the set of files that will be published, as well as
7751 the publishing configuration to use when publishing those files.  When
7752 a project takes the second form listed above, the individual members
7753 of the ``components'' property are taken to be components of the
7754 project, which group together files requiring different publishing
7755 options. When you publish such a ``meta-project'' all the components
7756 will also publish.
7758 @node Sources and destinations, Selecting files, Project alist, Configuration
7759 @subsection Sources and destinations for files
7760 @cindex directories, for publishing
7762 Most properties are optional, but some should always be set. In
7763 particular, org-publish needs to know where to look for source files,
7764 and where to put published files.
7766 @multitable @columnfractions 0.3 0.7
7767 @item @code{:base-directory}
7768 @tab Directory containing publishing source files
7769 @item @code{:publishing-directory}
7770 @tab Directory (possibly remote) where output files will be published.
7771 @item @code{:preparation-function}
7772 @tab Function called before starting the publishing process, for example to
7773 run @code{make} for updating files to be published.
7774 @item @code{:completion-function}
7775 @tab Function called after finishing the publishing process, for example to
7776 change permissions of the resulting files.
7777 @end multitable
7778 @noindent
7780 @node Selecting files, Publishing action, Sources and destinations, Configuration
7781 @subsection Selecting files
7782 @cindex files, selecting for publishing
7784 By default, all files with extension @file{.org} in the base directory
7785 are considered part of the project.  This can be modified by setting the
7786 properties
7787 @multitable @columnfractions 0.25 0.75
7788 @item @code{:base-extension}
7789 @tab Extension (without the dot!) of source files.  This actually is a
7790 regular expression.
7792 @item @code{:exclude}
7793 @tab Regular expression to match file names that should not be
7794 published, even though they have been selected on the basis of their
7795 extension.
7797 @item @code{:include}
7798 @tab List of files to be included regardless of @code{:base-extension}
7799 and @code{:exclude}.
7800 @end multitable
7802 @node Publishing action, Publishing options, Selecting files, Configuration
7803 @subsection Publishing action
7804 @cindex action, for publishing
7806 Publishing means that a file is copied to the destination directory and
7807 possibly transformed in the process.  The default transformation is to
7808 export Org files as HTML files, and this is done by the function
7809 @code{org-publish-org-to-html} which calls the HTML exporter
7810 (@pxref{HTML export}). But you also can publish your files in La@TeX{} by
7811 using the function @code{org-publish-org-to-latex} instead. Other files
7812 like images only need to be copied to the publishing destination. For
7813 non-Org files, you need to specify the publishing function.
7816 @multitable @columnfractions 0.3 0.7
7817 @item @code{:publishing-function}
7818 @tab Function executing the publication of a file.  This may also be a
7819 list of functions, which will all be called in turn.
7820 @end multitable
7822 The function must accept two arguments: a property list containing at
7823 least a @code{:publishing-directory} property, and the name of the file
7824 to be published.  It should take the specified file, make the necessary
7825 transformation (if any) and place the result into the destination folder.
7826 You can write your own publishing function, but @code{org-publish}
7827 provides one for attachments (files that only need to be copied):
7828 @code{org-publish-attachment}.
7830 @node Publishing options, Publishing links, Publishing action, Configuration
7831 @subsection Options for the HTML/LaTeX exporters
7832 @cindex options, for publishing
7834 The property list can be used to set many export options for the HTML
7835 and La@TeX{} exporters.  In most cases, these properties correspond to user
7836 variables in Org.  The table below lists these properties along
7837 with the variable they belong to.  See the documentation string for the
7838 respective variable for details.
7840 @multitable @columnfractions 0.3 0.7
7841 @item @code{:language}              @tab @code{org-export-default-language}
7842 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
7843 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
7844 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
7845 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
7846 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
7847 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
7848 @item @code{:special-strings}       @tab @code{org-export-with-special-strings}
7849 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
7850 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
7851 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
7852 @item @code{:timestamps}            @tab @code{org-export-with-timestamps}
7853 @item @code{:author-info}           @tab @code{org-export-author-info}
7854 @item @code{:creator-info}          @tab @code{org-export-creator-info}
7855 @item @code{:tags}                  @tab @code{org-export-with-tags}
7856 @item @code{:tables}                @tab @code{org-export-with-tables}
7857 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
7858 @item @code{:style}                 @tab @code{org-export-html-style}
7859 @item @code{:style-extra}           @tab @code{org-export-html-style-extra}
7860 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
7861 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
7862 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
7863 @item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
7864 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
7865 @item @code{:preamble}              @tab @code{org-export-html-preamble}
7866 @item @code{:postamble}             @tab @code{org-export-html-postamble}
7867 @item @code{:auto-preamble}         @tab @code{org-export-html-auto-preamble}
7868 @item @code{:auto-postamble}        @tab @code{org-export-html-auto-postamble}
7869 @item @code{:author}                @tab @code{user-full-name}
7870 @item @code{:email}                 @tab @code{user-mail-address}
7871 @item @code{:select-tags}           @tab @code{org-export-select-tags}
7872 @item @code{:exclude-tags}          @tab @code{org-export-exclude-tags}
7873 @end multitable
7875 If you use several email addresses, separate them by a semi-column.
7877 Most of the @code{org-export-with-*} variables have the same effect in
7878 both HTML and La@TeX{} exporters, except for @code{:TeX-macros} and
7879 @code{:LaTeX-fragments}, respectively @code{nil} and @code{t} in the
7880 La@TeX{} export.
7882 When a property is given a value in @code{org-publish-project-alist},
7883 its setting overrides the value of the corresponding user variable (if
7884 any) during publishing.  Options set within a file (@pxref{Export
7885 options}), however, override everything.
7887 @node Publishing links, Project page index, Publishing options, Configuration
7888 @subsection Links between published files
7889 @cindex links, publishing
7891 To create a link from one Org file to another, you would use
7892 something like @samp{[[file:foo.org][The foo]]} or simply
7893 @samp{file:foo.org.} (@pxref{Hyperlinks}).  Upon publishing this link
7894 becomes a link to @file{foo.html}.  In this way, you can interlink the
7895 pages of your "org web" project and the links will work as expected when
7896 you publish them to HTML.
7898 You may also link to related files, such as images. Provided you are
7899 careful with relative pathnames, and provided you have also configured
7900 @code{org-publish} to upload the related files, these links will work
7901 too. @ref{Complex example} for an example of this usage.
7903 Sometime an Org file to be published may contain links that are
7904 only valid in your production environment, but not in the publishing
7905 location.  In this case, use the property
7907 @multitable @columnfractions 0.4 0.6
7908 @item @code{:link-validation-function}
7909 @tab Function to validate links
7910 @end multitable
7912 @noindent
7913 to define a function for checking link validity.  This function must
7914 accept two arguments, the file name and a directory relative to which
7915 the file name is interpreted in the production environment.  If this
7916 function returns @code{nil}, then the HTML generator will only insert a
7917 description into the HTML file, but no link.  One option for this
7918 function is @code{org-publish-validate-link} which checks if the given
7919 file is part of any project in @code{org-publish-project-alist}.
7921 @node Project page index,  , Publishing links, Configuration
7922 @subsection Project page index
7923 @cindex index, of published pages
7925 The following properties may be used to control publishing of an
7926 index of files or summary page for a given project.
7928 @multitable @columnfractions 0.25 0.75
7929 @item @code{:auto-index}
7930 @tab When non-nil, publish an index during org-publish-current-project or
7931 org-publish-all.
7933 @item @code{:index-filename}
7934 @tab Filename for output of index. Defaults to @file{index.org} (which
7935 becomes @file{index.html}).
7937 @item @code{:index-title}
7938 @tab Title of index page. Defaults to name of file.
7940 @item @code{:index-function}
7941 @tab Plug-in function to use for generation of index.
7942 Defaults to @code{org-publish-org-index}, which generates a plain list
7943 of links to all files in the project.
7944 @end multitable
7946 @node Sample configuration, Triggering publication, Configuration, Publishing
7947 @section Sample configuration
7949 Below we provide two example configurations.  The first one is a simple
7950 project publishing only a set of Org files.  The second example is
7951 more complex, with a multi-component project.
7953 @menu
7954 * Simple example::              One-component publishing
7955 * Complex example::             A multi-component publishing example
7956 @end menu
7958 @node Simple example, Complex example, Sample configuration, Sample configuration
7959 @subsection Example: simple publishing configuration
7961 This example publishes a set of Org files to the @file{public_html}
7962 directory on the local machine.
7964 @lisp
7965 (setq org-publish-project-alist
7966       '(("org"
7967          :base-directory "~/org/"
7968          :publishing-directory "~/public_html"
7969          :section-numbers nil
7970          :table-of-contents nil
7971          :style "<link rel=stylesheet
7972                 href=\"../other/mystyle.css\"
7973                 type=\"text/css\">")))
7974 @end lisp
7976 @node Complex example,  , Simple example, Sample configuration
7977 @subsection Example: complex publishing configuration
7979 This more complicated example publishes an entire website, including
7980 org files converted to HTML, image files, emacs lisp source code, and
7981 style sheets. The publishing-directory is remote and private files are
7982 excluded.
7984 To ensure that links are preserved, care should be taken to replicate
7985 your directory structure on the web server, and to use relative file
7986 paths. For example, if your org files are kept in @file{~/org} and your
7987 publishable images in @file{~/images}, you'd link to an image with
7989 @example
7990 file:../images/myimage.png
7991 @end example
7993 On the web server, the relative path to the image should be the
7994 same. You can accomplish this by setting up an "images" folder in the
7995 right place on the web server, and publishing images to it.
7997 @lisp
7998 (setq org-publish-project-alist
7999       '(("orgfiles"
8000           :base-directory "~/org/"
8001           :base-extension "org"
8002           :publishing-directory "/ssh:user@@host:~/html/notebook/"
8003           :publishing-function org-publish-org-to-html
8004           :exclude "PrivatePage.org"   ;; regexp
8005           :headline-levels 3
8006           :section-numbers nil
8007           :table-of-contents nil
8008           :style "<link rel=stylesheet
8009                   href=\"../other/mystyle.css\" type=\"text/css\">"
8010           :auto-preamble t
8011           :auto-postamble nil)
8013          ("images"
8014           :base-directory "~/images/"
8015           :base-extension "jpg\\|gif\\|png"
8016           :publishing-directory "/ssh:user@@host:~/html/images/"
8017           :publishing-function org-publish-attachment)
8019          ("other"
8020           :base-directory "~/other/"
8021           :base-extension "css\\|el"
8022           :publishing-directory "/ssh:user@@host:~/html/other/"
8023           :publishing-function org-publish-attachment)
8024          ("website" :components ("orgfiles" "images" "other"))))
8025 @end lisp
8027 @node Triggering publication,  , Sample configuration, Publishing
8028 @section Triggering publication
8030 Once org-publish is properly configured, you can publish with the
8031 following functions:
8033 @table @kbd
8034 @item C-c C-e C
8035 Prompt for a specific project and publish all files that belong to it.
8036 @item C-c C-e P
8037 Publish the project containing the current file.
8038 @item C-c C-e F
8039 Publish only the current file.
8040 @item C-c C-e A
8041 Publish all projects.
8042 @end table
8044 Org uses timestamps to track when a file has changed. The above
8045 functions normally only publish changed files. You can override this and
8046 force publishing of all files by giving a prefix argument.
8048 @node Miscellaneous, Extensions, Publishing, Top
8049 @chapter Miscellaneous
8051 @menu
8052 * Completion::                  M-TAB knows what you need
8053 * Customization::               Adapting Org to your taste
8054 * In-buffer settings::          Overview of the #+KEYWORDS
8055 * The very busy C-c C-c key::   When in doubt, press C-c C-c
8056 * Clean view::                  Getting rid of leading stars in the outline
8057 * TTY keys::                    Using Org on a tty
8058 * Interaction::                 Other Emacs packages
8059 * Bugs::                        Things which do not work perfectly
8060 @end menu
8062 @node Completion, Customization, Miscellaneous, Miscellaneous
8063 @section Completion
8064 @cindex completion, of @TeX{} symbols
8065 @cindex completion, of TODO keywords
8066 @cindex completion, of dictionary words
8067 @cindex completion, of option keywords
8068 @cindex completion, of tags
8069 @cindex completion, of property keys
8070 @cindex completion, of link abbreviations
8071 @cindex @TeX{} symbol completion
8072 @cindex TODO keywords completion
8073 @cindex dictionary word completion
8074 @cindex option keyword completion
8075 @cindex tag completion
8076 @cindex link abbreviations, completion of
8078 Org supports in-buffer completion.  This type of completion does
8079 not make use of the minibuffer.  You simply type a few letters into
8080 the buffer and use the key to complete text right there.
8082 @table @kbd
8083 @kindex M-@key{TAB}
8084 @item M-@key{TAB}
8085 Complete word at point
8086 @itemize @bullet
8087 @item
8088 At the beginning of a headline, complete TODO keywords.
8089 @item
8090 After @samp{\}, complete @TeX{} symbols supported by the exporter.
8091 @item
8092 After @samp{*}, complete headlines in the current buffer so that they
8093 can be used in search links like @samp{[[*find this headline]]}.
8094 @item
8095 After @samp{:} in a headline, complete tags.  The list of tags is taken
8096 from the variable @code{org-tag-alist} (possibly set through the
8097 @samp{#+TAGS} in-buffer option, @pxref{Setting tags}), or it is created
8098 dynamically from all tags used in the current buffer.
8099 @item
8100 After @samp{:} and not in a headline, complete property keys.  The list
8101 of keys is constructed dynamically from all keys used in the current
8102 buffer.
8103 @item
8104 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
8105 @item
8106 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
8107 @samp{OPTIONS} which set file-specific options for Org mode.  When the
8108 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
8109 will insert example settings for this keyword.
8110 @item
8111 In the line after @samp{#+STARTUP: }, complete startup keywords,
8112 i.e. valid keys for this line.
8113 @item
8114 Elsewhere, complete dictionary words using Ispell.
8115 @end itemize
8116 @end table
8118 @node Customization, In-buffer settings, Completion, Miscellaneous
8119 @section Customization
8120 @cindex customization
8121 @cindex options, for customization
8122 @cindex variables, for customization
8124 There are more than 180 variables that can be used to customize
8125 Org.  For the sake of compactness of the manual, I am not
8126 describing the variables here.  A structured overview of customization
8127 variables is available with @kbd{M-x org-customize}.  Or select
8128 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
8129 settings can also be activated on a per-file basis, by putting special
8130 lines into the buffer (@pxref{In-buffer settings}).
8132 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
8133 @section Summary of in-buffer settings
8134 @cindex in-buffer settings
8135 @cindex special keywords
8137 Org mode uses special lines in the buffer to define settings on a
8138 per-file basis.  These lines start with a @samp{#+} followed by a
8139 keyword, a colon, and then individual words defining a setting.  Several
8140 setting words can be in the same line, but you can also have multiple
8141 lines for the keyword.  While these settings are described throughout
8142 the manual, here is a summary.  After changing any of those lines in the
8143 buffer, press @kbd{C-c C-c} with the cursor still in the line to
8144 activate the changes immediately.  Otherwise they become effective only
8145 when the file is visited again in a new Emacs session.
8147 @table @kbd
8148 @item #+ARCHIVE: %s_done::
8149 This line sets the archive location for the agenda file.  It applies for
8150 all subsequent lines until the next @samp{#+ARCHIVE} line, or the end
8151 of the file.  The first such line also applies to any entries before it.
8152 The corresponding variable is @code{org-archive-location}.
8153 @item #+CATEGORY:
8154 This line sets the category for the agenda file.  The category applies
8155 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
8156 end of the file.  The first such line also applies to any entries before it.
8157 @item #+COLUMNS: %25ITEM .....
8158 Set the default format for columns view.  This format applies when
8159 columns view is invoked in location where no @code{COLUMNS} property
8160 applies.
8161 @item #+CONSTANTS: name1=value1 ...
8162 Set file-local values for constants to be used in table formulas.  This
8163 line set the local variable @code{org-table-formula-constants-local}.
8164 The global version of this variable is
8165 @code{org-table-formula-constants}.
8166 @item #+FILETAGS: :tag1:tag2:tag3:
8167 Set tags that can be inherited by any entry in the file, including the
8168 top-level entries.
8169 @item #+DRAWERS: NAME1 .....
8170 Set the file-local set of drawers.  The corresponding global variable is
8171 @code{org-drawers}.
8172 @item #+LINK:  linkword replace
8173 These lines (several are allowed) specify link abbreviations.
8174 @xref{Link abbreviations}.  The corresponding variable is
8175 @code{org-link-abbrev-alist}.
8176 @item #+PRIORITIES: highest lowest default
8177 This line sets the limits and the default for the priorities.  All three
8178 must be either letters A-Z or numbers 0-9.  The highest priority must
8179 have a lower ASCII number that the lowest priority.
8180 @item #+PROPERTY: Property_Name Value
8181 This line sets a default inheritance value for entries in the current
8182 buffer, most useful for specifying the allowed values of a property.
8183 @item #+SETUPFILE: file
8184 This line defines a file that holds more in-buffer setup.  Normally this is
8185 entirely ignored.  Only when the buffer is parsed for option-setting lines
8186 (i.e. when starting Org mode for a file, when pressing @kbd{C-c C-c} in a
8187 settings line, or when exporting), then the contents of this file are parsed
8188 as if they had been included in the buffer.  In particlar, the file can be
8189 any other Org mode file with internal setup.  You can visit the file the
8190 cursor is in the line with @kbd{C-c '}.
8191 @item #+STARTUP:
8192 This line sets options to be used at startup of Org mode, when an
8193 Org file is being visited.  The first set of options deals with the
8194 initial visibility of the outline tree.  The corresponding variable for
8195 global default settings is @code{org-startup-folded}, with a default
8196 value @code{t}, which means @code{overview}.
8197 @cindex @code{overview}, STARTUP keyword
8198 @cindex @code{content}, STARTUP keyword
8199 @cindex @code{showall}, STARTUP keyword
8200 @example
8201 overview   @r{top-level headlines only}
8202 content    @r{all headlines}
8203 showall    @r{no folding at all, show everything}
8204 @end example
8205 Then there are options for aligning tables upon visiting a file.  This
8206 is useful in files containing narrowed table columns.  The corresponding
8207 variable is @code{org-startup-align-all-tables}, with a default value
8208 @code{nil}.
8209 @cindex @code{align}, STARTUP keyword
8210 @cindex @code{noalign}, STARTUP keyword
8211 @example
8212 align      @r{align all tables}
8213 noalign    @r{don't align tables on startup}
8214 @end example
8215 Logging closing and reinstating TODO items, and clock intervals
8216 (variables @code{org-log-done}, @code{org-log-note-clock-out}, and
8217 @code{org-log-repeat}) can be configured using these options.
8218 @cindex @code{logdone}, STARTUP keyword
8219 @cindex @code{lognotedone}, STARTUP keyword
8220 @cindex @code{nologdone}, STARTUP keyword
8221 @cindex @code{lognoteclock-out}, STARTUP keyword
8222 @cindex @code{nolognoteclock-out}, STARTUP keyword
8223 @cindex @code{logrepeat}, STARTUP keyword
8224 @cindex @code{lognoterepeat}, STARTUP keyword
8225 @cindex @code{nologrepeat}, STARTUP keyword
8226 @example
8227 logdone            @r{record a timestamp when an item is marked DONE}
8228 lognotedone        @r{record timestamp and a note when DONE}
8229 nologdone          @r{don't record when items are marked DONE}
8230 logrepeat          @r{record a time when reinstating a repeating item}
8231 lognoterepeat      @r{record a note when reinstating a repeating item}
8232 nologrepeat        @r{do not record when reinstating repeating item}
8233 lognoteclock-out   @r{record a note when clocking out}
8234 nolognoteclock-out @r{don't record a note when clocking out}
8235 @end example
8236 Here are the options for hiding leading stars in outline headings, and for
8237 indenting outlines.  The corresponding variables are
8238 @code{org-hide-leading-stars} and @code{org-odd-levels-only}, both with a
8239 default setting @code{nil} (meaning @code{showstars} and @code{oddeven}).
8240 @cindex @code{hidestars}, STARTUP keyword
8241 @cindex @code{showstars}, STARTUP keyword
8242 @cindex @code{odd}, STARTUP keyword
8243 @cindex @code{even}, STARTUP keyword
8244 @example
8245 hidestars  @r{make all but one of the stars starting a headline invisible.}
8246 showstars  @r{show all stars starting a headline}
8247 indent     @r{virtual indentation according to outline level}
8248 noindent   @r{no virtual indentation according to outline level}
8249 odd        @r{allow only odd outline levels (1,3,...)}
8250 oddeven    @r{allow all outline levels}
8251 @end example
8252 To turn on custom format overlays over time stamps (variables
8253 @code{org-put-time-stamp-overlays} and
8254 @code{org-time-stamp-overlay-formats}), use
8255 @cindex @code{customtime}, STARTUP keyword
8256 @example
8257 customtime @r{overlay custom time format}
8258 @end example
8259 The following options influence the table spreadsheet (variable
8260 @code{constants-unit-system}).
8261 @cindex @code{constcgs}, STARTUP keyword
8262 @cindex @code{constSI}, STARTUP keyword
8263 @example
8264 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
8265 constSI    @r{@file{constants.el} should use the SI unit system}
8266 @end example
8267 @item #+TAGS:  TAG1(c1) TAG2(c2)
8268 These lines (several such lines are allowed) specify the valid tags in
8269 this file, and (potentially) the corresponding @emph{fast tag selection}
8270 keys.  The corresponding variable is @code{org-tag-alist}.
8271 @item #+TBLFM:
8272 This line contains the formulas for the table directly above the line.
8273 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+OPTIONS, #+DATE:
8274 These lines provide settings for exporting files.  For more details see
8275 @ref{Export options}.
8276 @item #+SEQ_TODO:   #+TYP_TODO:
8277 These lines set the TODO keywords and their interpretation in the
8278 current file.  The corresponding variables are @code{org-todo-keywords}
8279 and @code{org-todo-interpretation}.
8280 @end table
8282 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
8283 @section The very busy C-c C-c key
8284 @kindex C-c C-c
8285 @cindex C-c C-c, overview
8287 The key @kbd{C-c C-c} has many purposes in Org, which are all
8288 mentioned scattered throughout this manual.  One specific function of
8289 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
8290 other circumstances it means something like @emph{Hey Org, look
8291 here and update according to what you see here}.  Here is a summary of
8292 what this means in different contexts.
8294 @itemize @minus
8295 @item
8296 If there are highlights in the buffer from the creation of a sparse
8297 tree, or from clock display, remove these highlights.
8298 @item
8299 If the cursor is in one of the special @code{#+KEYWORD} lines, this
8300 triggers scanning the buffer for these lines and updating the
8301 information.
8302 @item
8303 If the cursor is inside a table, realign the table.  This command
8304 works even if the automatic table editor has been turned off.
8305 @item
8306 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
8307 the entire table.
8308 @item
8309 If the cursor is inside a table created by the @file{table.el} package,
8310 activate that table.
8311 @item
8312 If the current buffer is a remember buffer, close the note and file it.
8313 With a prefix argument, file it, without further interaction, to the
8314 default location.
8315 @item
8316 If the cursor is on a @code{<<<target>>>}, update radio targets and
8317 corresponding links in this buffer.
8318 @item
8319 If the cursor is in a property line or at the start or end of a property
8320 drawer, offer property commands.
8321 @item
8322 If the cursor is in a plain list item with a checkbox, toggle the status
8323 of the checkbox.
8324 @item
8325 If the cursor is on a numbered item in a plain list, renumber the
8326 ordered list.
8327 @item
8328 If the cursor is on the @code{#+BEGIN} line of a dynamical block, the
8329 block is updated.
8330 @end itemize
8332 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
8333 @section A cleaner outline view
8334 @cindex hiding leading stars
8335 @cindex dynamic indentation
8336 @cindex odd-levels-only outlines
8337 @cindex clean outline view
8339 Some people find it noisy and distracting that the Org headlines are starting
8340 with a potentially large number of stars, and that text below the headlines
8341 is not indented.  This is not really a problem when you are writing a book
8342 where the outline headings are really section headlines.  However, in a more
8343 list-oriented outline, it is clear that an indented structure is a lot
8344 cleaner, as can be seen by comparing the two columns in the following
8345 example: 
8347 @example
8348 @group
8349 * Top level headline             |    * Top level headline
8350 ** Second level                  |      * Second level
8351 *** 3rd level                    |        * 3rd level
8352 some text                        |          some text
8353 *** 3rd level                    |        * 3rd level
8354 more text                        |          more text
8355 * Another top level headline     |    * Another top level headline
8356 @end group
8357 @end example
8359 @noindent
8360 It is non-trivial to make such a look work in Emacs, but Org contains three
8361 separate features that, combined, achieve just that.
8363 @enumerate
8364 @item 
8365 @emph{Indentation of text below headlines}@*
8366 You may indent text below each headline to make the left boundary line up
8367 with the headline, like
8369 @example
8370 *** 3rd level
8371     more text, now indented
8372 @end example
8374 A good way to get this indentation is by hand, and Org supports this with
8375 paragraph filling, line wrapping, and structure editing@footnote{See also the
8376 variable @code{org-adapt-indentation}.} preserving or adapting the
8377 indentation appropriate.  A different approach would be to have a way to
8378 automatically indent lines according to outline structure by adding overlays
8379 or text properties.  But I have not yet found a robust and efficient way to
8380 do this in large files.
8382 @item
8383 @emph{Hiding leading stars}@* You can modify the display in such a way that
8384 all leading stars become invisible.  To do this in a global way, configure
8385 the variable @code{org-hide-leading-stars} or change this on a per-file basis
8386 with
8388 @example
8389 #+STARTUP: hidestars
8390 @end example
8392 @noindent
8393 Note that the opposite behavior is selected with @code{showstars}.
8395 With hidden stars, the tree becomes:
8397 @example
8398 @group
8399 * Top level headline
8400  * Second level
8401   * 3rd level
8402   ...
8403 @end group
8404 @end example
8406 @noindent
8407 Note that the leading stars are not truly replaced by whitespace, they
8408 are only fontified with the face @code{org-hide} that uses the
8409 background color as font color.  If you are not using either white or
8410 black background, you may have to customize this face to get the wanted
8411 effect.  Another possibility is to set this font such that the extra
8412 stars are @i{almost} invisible, for example using the color
8413 @code{grey90} on a white background.
8415 @item
8416 Things become cleaner still if you skip all the even levels and use only odd
8417 levels 1, 3, 5..., effectively adding two stars to go from one outline level
8418 to the next.  In this way we get the outline view shown at the beginning of
8419 this section.  In order to make the structure editing and export commands
8420 handle this convention correctly, configure the variable
8421 @code{org-odd-levels-only}, or set this on a per-file basis with one of the
8422 following lines:
8424 @example
8425 #+STARTUP: odd
8426 #+STARTUP: oddeven
8427 @end example
8429 You can convert an Org file from single-star-per-level to the
8430 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
8431 RET} in that file.  The reverse operation is @kbd{M-x
8432 org-convert-to-oddeven-levels}.
8433 @end enumerate
8435 @node TTY keys, Interaction, Clean view, Miscellaneous
8436 @section Using Org on a tty
8437 @cindex tty key bindings
8439 Because Org contains a large number of commands, by default much of
8440 Org's core commands are bound to keys that are generally not
8441 accessible on a tty, such as the cursor keys (@key{left}, @key{right},
8442 @key{up}, @key{down}), @key{TAB} and @key{RET}, in particular when used
8443 together with modifiers like @key{Meta} and/or @key{Shift}.  To access
8444 these commands on a tty when special keys are unavailable, the following
8445 alternative bindings can be used.  The tty bindings below will likely be
8446 more cumbersome; you may find for some of the bindings below that a
8447 customized work-around suits you better.  For example, changing a time
8448 stamp is really only fun with @kbd{S-@key{cursor}} keys, whereas on a
8449 tty you would rather use @kbd{C-c .} to re-insert the timestamp.
8451 @multitable @columnfractions 0.15 0.2 0.2
8452 @item @b{Default} @tab @b{Alternative 1} @tab @b{Alternative 2}
8453 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab
8454 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{@key{Esc} @key{left}}
8455 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab
8456 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{@key{Esc} @key{right}}
8457 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab
8458 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{@key{Esc} @key{up}}
8459 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab
8460 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{@key{Esc} @key{down}}
8461 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab
8462 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab
8463 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{@key{Esc} @key{RET}}
8464 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab
8465 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab
8466 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab
8467 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab
8468 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab
8469 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab
8470 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab
8471 @end multitable
8473 @node Interaction, Bugs, TTY keys, Miscellaneous
8474 @section Interaction with other packages
8475 @cindex packages, interaction with other
8476 Org lives in the world of GNU Emacs and interacts in various ways
8477 with other code out there.
8479 @menu
8480 * Cooperation::                 Packages Org cooperates with
8481 * Conflicts::                   Packages that lead to conflicts
8482 @end menu
8484 @node Cooperation, Conflicts, Interaction, Interaction
8485 @subsection Packages that Org cooperates with
8487 @table @asis
8488 @cindex @file{calc.el}
8489 @item @file{calc.el} by Dave Gillespie
8490 Org uses the Calc package for implementing spreadsheet
8491 functionality in its tables (@pxref{The spreadsheet}).  Org
8492 checks for the availability of Calc by looking for the function
8493 @code{calc-eval} which should be autoloaded in your setup if Calc has
8494 been installed properly.  As of Emacs 22, Calc is part of the Emacs
8495 distribution.  Another possibility for interaction between the two
8496 packages is using Calc for embedded calculations. @xref{Embedded Mode,
8497 , Embedded Mode, Calc, GNU Emacs Calc Manual}.
8498 @cindex @file{constants.el}
8499 @item @file{constants.el} by Carsten Dominik
8500 In a table formula (@pxref{The spreadsheet}), it is possible to use
8501 names for natural constants or units.  Instead of defining your own
8502 constants in the variable @code{org-table-formula-constants}, install
8503 the @file{constants} package which defines a large number of constants
8504 and units, and lets you use unit prefixes like @samp{M} for
8505 @samp{Mega} etc.  You will need version 2.0 of this package, available
8506 at @url{http://www.astro.uva.nl/~dominik/Tools}. Org checks for
8507 the function @code{constants-get}, which has to be autoloaded in your
8508 setup.  See the installation instructions in the file
8509 @file{constants.el}.
8510 @item @file{cdlatex.el} by Carsten Dominik
8511 @cindex @file{cdlatex.el}
8512 Org mode can make use of the CDLaTeX package to efficiently enter
8513 La@TeX{} fragments into Org files. See @ref{CDLaTeX mode}.
8514 @item @file{imenu.el} by Ake Stenhoff and Lars Lindberg
8515 @cindex @file{imenu.el}
8516 Imenu allows menu access to an index of items in a file.  Org mode
8517 supports Imenu - all you need to do to get the index is the following:
8518 @lisp
8519 (add-hook 'org-mode-hook
8520           (lambda () (imenu-add-to-menubar "Imenu")))
8521 @end lisp
8522 By default the index is two levels deep - you can modify the depth using
8523 the option @code{org-imenu-depth}.
8524 @item @file{remember.el} by John Wiegley
8525 @cindex @file{remember.el}
8526 Org cooperates with remember, see @ref{Remember}.
8527 @file{Remember.el} is not part of Emacs, find it on the web.
8528 @item @file{speedbar.el} by Eric M. Ludlam
8529 @cindex @file{speedbar.el}
8530 Speedbar is a package that creates a special frame displaying files and
8531 index items in files.  Org mode supports Speedbar and allows you to
8532 drill into Org files directly from the Speedbar.  It also allows to
8533 restrict the scope of agenda commands to a file or a subtree by using
8534 the command @kbd{<} in the Speedbar frame.
8535 @cindex @file{table.el}
8536 @item @file{table.el} by Takaaki Ota
8537 @kindex C-c C-c
8538 @cindex table editor, @file{table.el}
8539 @cindex @file{table.el}
8541 Complex ASCII tables with automatic line wrapping, column- and
8542 row-spanning, and alignment can be created using the Emacs table
8543 package by Takaaki Ota (@uref{http://sourceforge.net/projects/table},
8544 and also part of Emacs 22).
8545 When @key{TAB} or @kbd{C-c C-c} is pressed in such a table, Org mode
8546 will call @command{table-recognize-table} and move the cursor into the
8547 table.  Inside a table, the keymap of Org mode is inactive.  In order
8548 to execute Org mode-related commands, leave the table.
8550 @table @kbd
8551 @kindex C-c C-c
8552 @item C-c C-c
8553 Recognize @file{table.el} table.  Works when the cursor is in a
8554 table.el table.
8556 @kindex C-c ~
8557 @item C-c ~
8558 Insert a table.el table.  If there is already a table at point, this
8559 command converts it between the table.el format and the Org mode
8560 format.  See the documentation string of the command
8561 @code{org-convert-table} for the restrictions under which this is
8562 possible.
8563 @end table
8564 @file{table.el} is part of Emacs 22.
8565 @cindex @file{footnote.el}
8566 @item @file{footnote.el} by Steven L. Baur
8567 Org mode recognizes numerical footnotes as provided by this package
8568 (@pxref{Footnotes}).
8569 @end table
8571 @node Conflicts,  , Cooperation, Interaction
8572 @subsection Packages that lead to conflicts with Org mode
8574 @table @asis
8576 @cindex @file{allout.el}
8577 @item @file{allout.el} by Ken Manheimer
8578 Startup of Org may fail with the error message
8579 @code{(wrong-type-argument keymapp nil)} when there is an outdated
8580 version @file{allout.el} on the load path, for example the version
8581 distributed with Emacs 21.x.  Upgrade to Emacs 22 and this problem will
8582 disappear.  If for some reason you cannot do this, make sure that org.el
8583 is loaded @emph{before} @file{allout.el}, for example by putting
8584 @code{(require 'org)} early enough into your @file{.emacs} file.
8586 @cindex @file{CUA.el}
8587 @item @file{CUA.el} by Kim. F. Storm
8588 Key bindings in Org conflict with the @kbd{S-<cursor>} keys used by
8589 CUA mode (as well as pc-select-mode and s-region-mode) to select and
8590 extend the region.  If you want to use one of these packages along with
8591 Org, configure the variable @code{org-replace-disputed-keys}.  When
8592 set, Org will move the following key bindings in Org files, and
8593 in the agenda buffer (but not during date selection).
8595 @example
8596 S-UP    -> M-p             S-DOWN  -> M-n
8597 S-LEFT  -> M--             S-RIGHT -> M-+
8598 @end example
8600 Yes, these are unfortunately more difficult to remember.  If you want
8601 to have other replacement keys, look at the variable
8602 @code{org-disputed-keys}.
8603 @item @file{windmove.el} by Hovav Shacham
8604 @cindex @file{windmove.el}
8605 Also this package uses the @kbd{S-<cursor>} keys, so everything written
8606 in the paragraph above about CUA mode also applies here.
8608 @cindex @file{footnote.el}
8609 @item @file{footnote.el} by Steven L. Baur
8610 Org supports the syntax of the footnote package, but only the
8611 numerical footnote markers.  Also, the default key for footnote
8612 commands, @kbd{C-c !} is already used by Org.  You could use the
8613 variable @code{footnote-prefix} to switch footnotes commands to another
8614 key.  Or, you could use @code{org-replace-disputed-keys} and
8615 @code{org-disputed-keys} to change the settings in Org.
8617 @end table
8620 @node Bugs,  , Interaction, Miscellaneous
8621 @section Bugs
8622 @cindex bugs
8624 Here is a list of things that should work differently, but which I
8625 have found too hard to fix.
8627 @itemize @bullet
8628 @item
8629 If a table field starts with a link, and if the corresponding table
8630 column is narrowed (@pxref{Narrow columns}) to a width too small to
8631 display the link, the field would look entirely empty even though it is
8632 not.  To prevent this, Org throws an error.  The work-around is to
8633 make the column wide enough to fit the link, or to add some text (at
8634 least 2 characters) before the link in the same field.
8635 @item
8636 Narrowing table columns does not work on XEmacs, because the
8637 @code{format} function does not transport text properties.
8638 @item
8639 Text in an entry protected with the @samp{QUOTE} keyword should not
8640 autowrap.
8641 @item
8642 When the application called by @kbd{C-c C-o} to open a file link fails
8643 (for example because the application does not exist or refuses to open
8644 the file), it does so silently.  No error message is displayed.
8645 @item
8646 Recalculating a table line applies the formulas from left to right.
8647 If a formula uses @emph{calculated} fields further down the row,
8648 multiple recalculation may be needed to get all fields consistent.  You
8649 may use the command @code{org-table-iterate} (@kbd{C-u C-c *}) to
8650 recalculate until convergence.
8651 @item
8652 The exporters work well, but could be made more efficient.
8653 @end itemize
8656 @node Extensions, Hacking, Miscellaneous, Top
8657 @appendix Extensions
8659 This appendix lists the extension modules that have been written for Org.
8660 Many of these extensions live in the @file{contrib} directory of the Org
8661 distribution, others are available somewhere on the web.
8663 @menu
8664 * Extensions in the contrib directory::  These come with the Org distro
8665 * Other extensions::            These you have to find on the web.
8666 @end menu
8668 @node Extensions in the contrib directory, Other extensions, Extensions, Extensions
8669 @section Extensions in the @file{contrib} directory
8671 @table @asis
8672 @item @file{org-annotate-file.el} by @i{Philip Jackson}
8673       Annotate a file with org syntax, in a separate file, with links back to
8674       the annotated file.
8675 @item @file{org-annotation-helper.el} by @i{Bastien Guerry and Daniel E. German} 
8676       Call @i{remember} directly from Firefox/Opera, or from Adobe Reader.
8677       When activating a special link or bookmark, Emacs receives a trigger to
8678       create a note with a link back to the website.  Requires some setup, a
8679       detailes description is in
8680       @file{contrib/packages/org-annotation-helper}.
8681 @item @file{org-bookmark.el} by @i{Tokuya Kameshima}
8682       Support for links to Emacs bookmarks.
8683 @item @file{org-depend.el} by @i{Carsten Dominik}
8684       TODO dependencies for Org-mode.  Make TODO state changes in one entry
8685       trigger changes in another, or be blocked by the state of another
8686       entry.  Also, easily create chains of TODO items with exactly one
8687       active item at any time.
8688 @item @file{org-elisp-symbol.el} by @i{Bastien Guerry}
8689       Org links to emacs-lisp symbols.  This can create annotated links that
8690       exactly point to the definition location of a variable of function.
8691 @item @file{org-eval.el} by @i{Carsten Dominik}
8692       The @code{<lisp>} tag, adapted from Emacs Wiki and Emacs Muse, allows
8693       to include text in a document that is the result of evaluating some
8694       code.  Other scripting languages like @code{perl} can be supported with
8695       this package as well.
8696 @item @file{org-expiry.el} by @i{Bastien Guerry}
8697       Expiry mechanism for Org entries.
8698 @item @file{org-indent.el} by @i{Carsten Dominik}
8699       Dynamic indentation of Org outlines.  The plan is to indent an outline
8700       according to level, but so far this is too hard for a proper and stable
8701       implementation.  Still, it works somewhat.
8702 @item @file{org-interactive-query.el} by @i{Christopher League}
8703       Interactive modification of tags queries.  After running a general
8704       query in Org, this package allows to narrow down the results by adding
8705       more tags or keywords.
8706 @item @file{org-mairix.el} by @i{Georg C. F. Greve}
8707       Hook mairix search into Org for different MUAs.
8708 @item @file{org-man.el} by @i{Carsten Dominik}
8709       Support for links to manpages in Org-mode.
8710 @item @file{org-mtags.el} by @i{Carsten Dominik}
8711       Support for some Muse-like tags in Org-mode.  This package allows you
8712       to write @code{<example>} and @code{<src>} and other syntax copied from
8713       Emacs Muse, right inside an Org file.  The goal here is to make it easy
8714       to publish the same file using either org-publish or Muse.
8715 @item @file{org-panel.el} by @i{Lennard Borgman}
8716       Simplified and display-aided access to some Org commands.
8717 @c @item @file{org-plot.el} by @i{Eric Schulte}
8718 @c      Plotting Org tables with Gnuplot.
8719 @item @file{org-registry.el} by @i{Bastien Guerry}
8720       A registry for Org links, to find out from where links point to a given
8721       file or location.
8722 @item @file{org2rem.el} by @i{Bastien Guerry}
8723       Convert org appointments into reminders for the @file{remind} program.
8724 @item @file{org-screen.el} by @i{Andrew Hyatt}
8725       Visit screen sessions through Org-mode links.
8726 @item @file{org-toc.el} by @i{Bastien Guerry}
8727       Table of contents in a separate buffer, with fast access to sections
8728       and easy visibility cycling.
8729 @item @file{orgtbl-sqlinsert.el} by @i{Jason Riedy}
8730       Convert Org-mode tables to SQL insertions.  Documentation for this can
8731       be found on the Worg pages.
8732 @end table
8735 @node Other extensions,  , Extensions in the contrib directory, Extensions
8736 @section Other extensions
8738 @i{TO BE DONE}
8740 @node Hacking, History and Acknowledgments, Extensions, Top
8741 @appendix Hacking
8743 This appendix covers some aspects where users can extend the functionality of
8744 Org.
8746 @menu
8747 * Adding hyperlink types::      New custom link types
8748 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
8749 * Dynamic blocks::              Automatically filled blocks
8750 * Special agenda views::        Customized views
8751 * Using the property API::      Writing programs that use entry properties
8752 * Using the mapping API::       Mapping over all or selected entries
8753 @end menu
8755 @node Adding hyperlink types, Tables in arbitrary syntax, Hacking, Hacking
8756 @section Adding hyperlink types
8757 @cindex hyperlinks, adding new types
8759 Org has a large number of hyperlink types built-in
8760 (@pxref{Hyperlinks}).  If you would like to add new link types, it
8761 provides an interface for doing so.  Lets look at an example file
8762 @file{org-man.el} that will add support for creating links like
8763 @samp{[[man:printf][The printf manpage]]} to show Unix manual pages inside
8764 emacs:
8766 @lisp
8767 ;;; org-man.el - Support for links to manpages in Org
8769 (require 'org)
8771 (org-add-link-type "man" 'org-man-open)
8772 (add-hook 'org-store-link-functions 'org-man-store-link)
8774 (defcustom org-man-command 'man
8775   "The Emacs command to be used to display a man page."
8776   :group 'org-link
8777   :type '(choice (const man) (const woman)))
8779 (defun org-man-open (path)
8780   "Visit the manpage on PATH.
8781 PATH should be a topic that can be thrown at the man command."
8782   (funcall org-man-command path))
8784 (defun org-man-store-link ()
8785   "Store a link to a manpage."
8786   (when (memq major-mode '(Man-mode woman-mode))
8787     ;; This is a man page, we do make this link
8788     (let* ((page (org-man-get-page-name))
8789            (link (concat "man:" page))
8790            (description (format "Manpage for %s" page)))
8791       (org-store-link-props
8792        :type "man"
8793        :link link
8794        :description description))))
8796 (defun org-man-get-page-name ()
8797   "Extract the page name from the buffer name."
8798   ;; This works for both `Man-mode' and `woman-mode'.
8799   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
8800       (match-string 1 (buffer-name))
8801     (error "Cannot create link to this man page")))
8803 (provide 'org-man)
8805 ;;; org-man.el ends here
8806 @end lisp
8808 @noindent
8809 You would activate this new link type in @file{.emacs} with
8811 @lisp
8812 (require 'org-man)
8813 @end lisp
8815 @noindent
8816 Lets go through the file and see what it does.
8817 @enumerate
8818 @item
8819 It does @code{(require 'org)} to make sure that @file{org.el} has been
8820 loaded.
8821 @item
8822 The next line calls @code{org-add-link-type} to define a new link type
8823 with prefix @samp{man}.  The call also contains the name of a function
8824 that will be called to follow such a link.
8825 @item
8826 The next line adds a function to @code{org-store-link-functions}, in
8827 order to allow the command @kbd{C-c l} to record a useful link in a
8828 buffer displaying a man page.
8829 @end enumerate
8831 The rest of the file defines the necessary variables and functions.
8832 First there is a customization variable that determines which emacs
8833 command should be used to display man pages.  There are two options,
8834 @code{man} and @code{woman}.  Then the function to follow a link is
8835 defined.  It gets the link path as an argument - in this case the link
8836 path is just a topic for the manual command.  The function calls the
8837 value of @code{org-man-command} to display the man page.
8839 Finally the function @code{org-man-store-link} is defined.  When you try
8840 to store a link with @kbd{C-c l}, also this function will be called to
8841 try to make a link.  The function must first decide if it is supposed to
8842 create the link for this buffer type, we do this by checking the value
8843 of the variable @code{major-mode}.  If not, the function must exit and
8844 return the value @code{nil}.  If yes, the link is created by getting the
8845 manual topic from the buffer name and prefixing it with the string
8846 @samp{man:}.  Then it must call the command @code{org-store-link-props}
8847 and set the @code{:type} and @code{:link} properties.  Optionally you
8848 can also set the @code{:description} property to provide a default for
8849 the link description when the link is later inserted into an Org
8850 buffer with @kbd{C-c C-l}.
8852 @node Tables in arbitrary syntax, Dynamic blocks, Adding hyperlink types, Hacking
8853 @section Tables and lists in arbitrary syntax
8854 @cindex tables, in other modes
8855 @cindex lists, in other modes
8856 @cindex Orgtbl mode
8858 Since Orgtbl mode can be used as a minor mode in arbitrary buffers, a
8859 frequent feature request has been to make it work with native tables in
8860 specific languages, for example La@TeX{}.  However, this is extremely
8861 hard to do in a general way, would lead to a customization nightmare,
8862 and would take away much of the simplicity of the Orgtbl mode table
8863 editor.
8866 This appendix describes a different approach.  We keep the Orgtbl mode
8867 table in its native format (the @i{source table}), and use a custom
8868 function to @i{translate} the table to the correct syntax, and to
8869 @i{install} it in the right location (the @i{target table}).  This puts
8870 the burden of writing conversion functions on the user, but it allows
8871 for a very flexible system.
8873 Bastien added the ability to do the same with lists.  You can use Org's
8874 facilities to edit and structure lists by turning @code{orgstruct-mode}
8875 on, then locally exporting such lists in another format (HTML, La@TeX{}
8876 or Texinfo.)
8879 @menu
8880 * Radio tables::                Sending and receiving
8881 * A LaTeX example::             Step by step, almost a tutorial
8882 * Translator functions::        Copy and modify
8883 * Radio lists::                 Doing the same for lists
8884 @end menu
8886 @node Radio tables, A LaTeX example, Tables in arbitrary syntax, Tables in arbitrary syntax
8887 @subsection Radio tables
8888 @cindex radio tables
8890 To define the location of the target table, you first need to create two
8891 lines that are comments in the current mode, but contain magic words for
8892 Orgtbl mode to find.  Orgtbl mode will insert the translated table
8893 between these lines, replacing whatever was there before.  For example:
8895 @example
8896 /* BEGIN RECEIVE ORGTBL table_name */
8897 /* END RECEIVE ORGTBL table_name */
8898 @end example
8900 @noindent
8901 Just above the source table, we put a special line that tells
8902 Orgtbl mode how to translate this table and where to install it.  For
8903 example:
8904 @example
8905 #+ORGTBL: SEND table_name translation_function arguments....
8906 @end example
8908 @noindent
8909 @code{table_name} is the reference name for the table that is also used
8910 in the receiver lines. @code{translation_function} is the Lisp function
8911 that does the translation.  Furthermore, the line can contain a list of
8912 arguments (alternating key and value) at the end.  The arguments will be
8913 passed as a property list to the translation function for
8914 interpretation.  A few standard parameters are already recognized and
8915 acted upon before the translation function is called:
8917 @table @code
8918 @item :skip N
8919 Skip the first N lines of the table.  Hlines do count as separate lines for
8920 this parameter!
8922 @item :skipcols (n1 n2 ...)
8923 List of columns that should be skipped.  If the table has a column with
8924 calculation marks, that column is automatically discarded as well.
8925 Please note that the translator function sees the table @emph{after} the
8926 removal of these columns, the function never knows that there have been
8927 additional columns.
8928 @end table
8930 @noindent
8931 The one problem remaining is how to keep the source table in the buffer
8932 without disturbing the normal workings of the file, for example during
8933 compilation of a C file or processing of a La@TeX{} file.  There are a
8934 number of different solutions:
8936 @itemize @bullet
8937 @item
8938 The table could be placed in a block comment if that is supported by the
8939 language.  For example, in C mode you could wrap the table between
8940 @samp{/*} and @samp{*/} lines.
8941 @item
8942 Sometimes it is possible to put the table after some kind of @i{END}
8943 statement, for example @samp{\bye} in TeX and @samp{\end@{document@}}
8944 in La@TeX{}.
8945 @item
8946 You can just comment the table line by line whenever you want to process
8947 the file, and uncomment it whenever you need to edit the table.  This
8948 only sounds tedious - the command @kbd{M-x orgtbl-toggle-comment} does
8949 make this comment-toggling very easy, in particular if you bind it to a
8950 key.
8951 @end itemize
8953 @node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
8954 @subsection A LaTeX example of radio tables
8955 @cindex LaTeX, and Orgtbl mode
8957 The best way to wrap the source table in La@TeX{} is to use the
8958 @code{comment} environment provided by @file{comment.sty}.  It has to be
8959 activated by placing @code{\usepackage@{comment@}} into the document
8960 header.  Orgtbl mode can insert a radio table skeleton@footnote{By
8961 default this works only for La@TeX{}, HTML, and Texinfo.  Configure the
8962 variable @code{orgtbl-radio-tables} to install templates for other
8963 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
8964 be prompted for a table name, lets say we use @samp{salesfigures}.  You
8965 will then get the following template:
8967 @cindex #+ORGTBL: SEND
8968 @example
8969 % BEGIN RECEIVE ORGTBL salesfigures
8970 % END RECEIVE ORGTBL salesfigures
8971 \begin@{comment@}
8972 #+ORGTBL: SEND salesfigures orgtbl-to-latex
8973 | | |
8974 \end@{comment@}
8975 @end example
8977 @noindent
8978 The @code{#+ORGTBL: SEND} line tells Orgtbl mode to use the function
8979 @code{orgtbl-to-latex} to convert the table into La@TeX{} and to put it
8980 into the receiver location with name @code{salesfigures}.  You may now
8981 fill in the table, feel free to use the spreadsheet features@footnote{If
8982 the @samp{#+TBLFM} line contains an odd number of dollar characters,
8983 this may cause problems with font-lock in LaTeX mode.  As shown in the
8984 example you can fix this by adding an extra line inside the
8985 @code{comment} environment that is used to balance the dollar
8986 expressions.  If you are using AUCTeX with the font-latex library, a
8987 much better solution is to add the @code{comment} environment to the
8988 variable @code{LaTeX-verbatim-environments}.}:
8990 @example
8991 % BEGIN RECEIVE ORGTBL salesfigures
8992 % END RECEIVE ORGTBL salesfigures
8993 \begin@{comment@}
8994 #+ORGTBL: SEND salesfigures orgtbl-to-latex
8995 | Month | Days | Nr sold | per day |
8996 |-------+------+---------+---------|
8997 | Jan   |   23 |      55 |     2.4 |
8998 | Feb   |   21 |      16 |     0.8 |
8999 | March |   22 |     278 |    12.6 |
9000 #+TBLFM: $4=$3/$2;%.1f
9001 % $ (optional extra dollar to keep font-lock happy, see footnote)
9002 \end@{comment@}
9003 @end example
9005 @noindent
9006 When you are done, press @kbd{C-c C-c} in the table to get the converted
9007 table inserted between the two marker lines.
9009 Now lets assume you want to make the table header by hand, because you
9010 want to control how columns are aligned etc.  In this case we make sure
9011 that the table translator does skip the first 2 lines of the source
9012 table, and tell the command to work as a @i{splice}, i.e. to not produce
9013 header and footer commands of the target table:
9015 @example
9016 \begin@{tabular@}@{lrrr@}
9017 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
9018 % BEGIN RECEIVE ORGTBL salesfigures
9019 % END RECEIVE ORGTBL salesfigures
9020 \end@{tabular@}
9022 \begin@{comment@}
9023 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
9024 | Month | Days | Nr sold | per day |
9025 |-------+------+---------+---------|
9026 | Jan   |   23 |      55 |     2.4 |
9027 | Feb   |   21 |      16 |     0.8 |
9028 | March |   22 |     278 |    12.6 |
9029 #+TBLFM: $4=$3/$2;%.1f
9030 \end@{comment@}
9031 @end example
9033 The La@TeX{} translator function @code{orgtbl-to-latex} is already part of
9034 Orgtbl mode.  It uses a @code{tabular} environment to typeset the table
9035 and marks horizontal lines with @code{\hline}.  Furthermore, it
9036 interprets the following parameters (see also @ref{Translator functions}):
9038 @table @code
9039 @item :splice nil/t
9040 When set to t, return only table body lines, don't wrap them into a
9041 tabular environment.  Default is nil.
9043 @item :fmt fmt
9044 A format to be used to wrap each field, should contain @code{%s} for the
9045 original field value.  For example, to wrap each field value in dollars,
9046 you could use @code{:fmt "$%s$"}.  This may also be a property list with
9047 column numbers and formats. for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
9048 A function of one argument can be used in place of the strings; the
9049 function must return a formatted string.
9051 @item :efmt efmt
9052 Use this format to print numbers with exponentials.  The format should
9053 have @code{%s} twice for inserting mantissa and exponent, for example
9054 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
9055 may also be a property list with column numbers and formats, for example
9056 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
9057 @code{efmt} has been applied to a value, @code{fmt} will also be
9058 applied.  Similar to @code{fmt}, functions of two arguments can be
9059 supplied instead of strings.
9060 @end table
9062 @node Translator functions, Radio lists, A LaTeX example, Tables in arbitrary syntax
9063 @subsection Translator functions
9064 @cindex HTML, and Orgtbl mode
9065 @cindex translator function
9067 Orgtbl mode has several translator functions built-in: @code{orgtbl-to-csv}
9068 (comma-separated values), @code{orgtbl-to-tsv} (TAB-separated values)
9069 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and @code{orgtbl-to-texinfo}.
9070 Except for @code{orgtbl-to-html}@footnote{The HTML translator uses the same
9071 code that produces tables during HTML export.}, these all use a generic
9072 translator, @code{orgtbl-to-generic}.  For example, @code{orgtbl-to-latex}
9073 itself is a very short function that computes the column definitions for the
9074 @code{tabular} environment, defines a few field and line separators and then
9075 hands over to the generic translator.  Here is the entire code:
9077 @lisp
9078 @group
9079 (defun orgtbl-to-latex (table params)
9080   "Convert the Orgtbl mode TABLE to LaTeX."
9081   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
9082                                org-table-last-alignment ""))
9083          (params2
9084           (list
9085            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
9086            :tend "\\end@{tabular@}"
9087            :lstart "" :lend " \\\\" :sep " & "
9088            :efmt "%s\\,(%s)" :hline "\\hline")))
9089     (orgtbl-to-generic table (org-combine-plists params2 params))))
9090 @end group
9091 @end lisp
9093 As you can see, the properties passed into the function (variable
9094 @var{PARAMS}) are combined with the ones newly defined in the function
9095 (variable @var{PARAMS2}).  The ones passed into the function (i.e. the
9096 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
9097 would like to use the La@TeX{} translator, but wanted the line endings to
9098 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
9099 overrule the default with
9101 @example
9102 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
9103 @end example
9105 For a new language, you can either write your own converter function in
9106 analogy with the La@TeX{} translator, or you can use the generic function
9107 directly.  For example, if you have a language where a table is started
9108 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
9109 started with @samp{!BL!}, ended with @samp{!EL!} and where the field
9110 separator is a TAB, you could call the generic translator like this (on
9111 a single line!):
9113 @example
9114 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
9115                               :lstart "!BL! " :lend " !EL!" :sep "\t"
9116 @end example
9118 @noindent
9119 Please check the documentation string of the function
9120 @code{orgtbl-to-generic} for a full list of parameters understood by
9121 that function and remember that you can pass each of them into
9122 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
9123 using the generic function.
9125 Of course you can also write a completely new function doing complicated
9126 things the generic translator cannot do.  A translator function takes
9127 two arguments.  The first argument is the table, a list of lines, each
9128 line either the symbol @code{hline} or a list of fields.  The second
9129 argument is the property list containing all parameters specified in the
9130 @samp{#+ORGTBL: SEND} line.  The function must return a single string
9131 containing the formatted table.  If you write a generally useful
9132 translator, please post it on @code{emacs-orgmode@@gnu.org} so that
9133 others can benefit from your work.
9135 @node  Radio lists,  , Translator functions, Tables in arbitrary syntax
9136 @subsection Radio lists
9137 @cindex radio lists
9138 @cindex org-list-insert-radio-list
9140 Sending and receiving radio lists works exactly the same way than
9141 sending and receiving radio tables (@pxref{Radio tables}) @footnote{You
9142 need to load the @code{org-export-latex.el} package to use radio lists
9143 since the relevant code is there for now.}.  As for radio tables, you
9144 can insert radio lists templates in HTML, La@TeX{} and Texinfo modes by
9145 calling @code{org-list-insert-radio-list}.
9147 Here are the differences with radio tables:
9149 @itemize @minus
9150 @item
9151 Use @code{ORGLST} instead of @code{ORGTBL}.
9152 @item
9153 The available translation functions for radio lists don't take
9154 parameters.
9155 @item
9156 `C-c C-c' will work when pressed on the first item of the list.
9157 @end itemize
9159 Here is a La@TeX{} example.  Let's say that you have this in your
9160 La@TeX{} file:
9162 @example
9163 % BEGIN RECEIVE ORGLST to-buy
9164 % END RECEIVE ORGLST to-buy
9165 \begin@{comment@}
9166 #+ORGLIST: SEND to-buy orgtbl-to-latex
9167 - a new house
9168 - a new computer
9169   + a new keyboard
9170   + a new mouse
9171 - a new life
9172 \end@{comment@}
9173 @end example
9175 Pressing `C-c C-c' on @code{a new house} and will insert the converted
9176 La@TeX{} list between the two marker lines.
9178 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Hacking
9179 @section Dynamic blocks
9180 @cindex dynamic blocks
9182 Org documents can contain @emph{dynamic blocks}.  These are
9183 specially marked regions that are updated by some user-written function.
9184 A good example for such a block is the clock table inserted by the
9185 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
9187 Dynamic block are enclosed by a BEGIN-END structure that assigns a name
9188 to the block and can also specify parameters for the function producing
9189 the content of the block.
9191 #+BEGIN:dynamic block
9192 @example
9193 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
9195 #+END:
9196 @end example
9198 Dynamic blocks are updated with the following commands
9200 @table @kbd
9201 @kindex C-c C-x C-u
9202 @item C-c C-x C-u
9203 Update dynamic block at point.
9204 @kindex C-u C-c C-x C-u
9205 @item C-u C-c C-x C-u
9206 Update all dynamic blocks in the current file.
9207 @end table
9209 Updating a dynamic block means to remove all the text between BEGIN and
9210 END, parse the BEGIN line for parameters and then call the specific
9211 writer function for this block to insert the new content.  If you want
9212 to use the original content in the writer function, you can use the
9213 extra parameter @code{:content}.
9215 For a block with name @code{myblock}, the writer function is
9216 @code{org-dblock-write:myblock} with as only parameter a property list
9217 with the parameters given in the begin line.  Here is a trivial example
9218 of a block that keeps track of when the block update function was last
9219 run:
9221 @example
9222 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
9224 #+END:
9225 @end example
9227 @noindent
9228 The corresponding block writer function could look like this:
9230 @lisp
9231 (defun org-dblock-write:block-update-time (params)
9232    (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
9233      (insert "Last block update at: "
9234              (format-time-string fmt (current-time)))))
9235 @end lisp
9237 If you want to make sure that all dynamic blocks are always up-to-date,
9238 you could add the function @code{org-update-all-dblocks} to a hook, for
9239 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
9240 written in a way that is does nothing in buffers that are not in
9241 @code{org-mode}.
9243 @node Special agenda views, Using the property API, Dynamic blocks, Hacking
9244 @section Special agenda views
9245 @cindex agenda views, user-defined
9247 Org provides a special hook that can be used to narrow down the
9248 selection made by any of the agenda views.  You may specify a function
9249 that is used at each match to verify if the match should indeed be part
9250 of the agenda view, and if not, how much should be skipped.
9252 Let's say you want to produce a list of projects that contain a WAITING
9253 tag anywhere in the project tree.  Let's further assume that you have
9254 marked all tree headings that define a project with the TODO keyword
9255 PROJECT.  In this case you would run a TODO search for the keyword
9256 PROJECT, but skip the match unless there is a WAITING tag anywhere in
9257 the subtree belonging to the project line.
9259 To achieve this, you must write a function that searches the subtree for
9260 the tag.  If the tag is found, the function must return @code{nil} to
9261 indicate that this match should not be skipped.  If there is no such
9262 tag, return the location of the end of the subtree, to indicate that
9263 search should continue from there.
9265 @lisp
9266 (defun my-skip-unless-waiting ()
9267   "Skip trees that are not waiting"
9268   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
9269     (if (re-search-forward ":waiting:" subtree-end t)
9270         nil          ; tag found, do not skip
9271       subtree-end))) ; tag not found, continue after end of subtree
9272 @end lisp
9274 Now you may use this function in an agenda custom command, for example
9275 like this:
9277 @lisp
9278 (org-add-agenda-custom-command
9279  '("b" todo "PROJECT"
9280    ((org-agenda-skip-function 'my-org-waiting-projects)
9281     (org-agenda-overriding-header "Projects waiting for something: "))))
9282 @end lisp
9284 Note that this also binds @code{org-agenda-overriding-header} to get a
9285 meaningful header in the agenda view.
9287 A general way to create custom searches is to base them on a search for
9288 entries with a certain level limit.  If you want to study all entries with
9289 your custom search function, simply do a search for @samp{LEVEL>0}, and then
9290 use @code{org-agenda-skip-function} to select the entries you really want to
9291 have.
9293 You may also put a Lisp form into @code{org-agenda-skip-function}.  In
9294 particular, you may use the functions @code{org-agenda-skip-entry-if}
9295 and @code{org-agenda-skip-subtree-if} in this form, for example:
9297 @table @code
9298 @item '(org-agenda-skip-entry-if 'scheduled)
9299 Skip current entry if it has been scheduled.
9300 @item '(org-agenda-skip-entry-if 'notscheduled)
9301 Skip current entry if it has not been scheduled.
9302 @item '(org-agenda-skip-entry-if 'deadline)
9303 Skip current entry if it has a deadline.
9304 @item '(org-agenda-skip-entry-if 'scheduled 'deadline)
9305 Skip current entry if it has a deadline, or if it is scheduled.
9306 @item '(org-agenda-skip-entry 'regexp "regular expression")
9307 Skip current entry if the regular expression matches in the entry.
9308 @item '(org-agenda-skip-entry 'notregexp "regular expression")
9309 Skip current entry unless the regular expression matches.
9310 @item '(org-agenda-skip-subtree-if 'regexp "regular expression")
9311 Same as above, but check and skip the entire subtree.
9312 @end table
9314 Therefore we could also have written the search for WAITING projects
9315 like this, even without defining a special function:
9317 @lisp
9318 (org-add-agenda-custom-command
9319  '("b" todo "PROJECT"
9320    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
9321                                 'regexp ":waiting:"))
9322     (org-agenda-overriding-header "Projects waiting for something: "))))
9323 @end lisp
9325 @node Using the property API, Using the mapping API, Special agenda views, Hacking
9326 @section Using the property API
9327 @cindex API, for properties
9328 @cindex properties, API
9330 Here is a description of the functions that can be used to work with
9331 properties.
9333 @defun org-entry-properties &optional pom which
9334 Get all properties of the entry at point-or-marker POM.
9335 This includes the TODO keyword, the tags, time strings for deadline,
9336 scheduled, and clocking, and any additional properties defined in the
9337 entry.  The return value is an alist, keys may occur multiple times
9338 if the property key was used several times.
9339 POM may also be nil, in which case the current entry is used.
9340 If WHICH is nil or `all', get all properties.  If WHICH is
9341 `special' or `standard', only get that subclass.
9342 @end defun
9343 @defun org-entry-get pom property &optional inherit
9344 Get value of PROPERTY for entry at point-or-marker POM.  By default,
9345 this only looks at properties defined locally in the entry.  If INHERIT
9346 is non-nil and the entry does not have the property, then also check
9347 higher levels of the hierarchy.  If INHERIT is the symbol
9348 @code{selective}, use inheritance if and only if the setting of
9349 @code{org-use-property-inheritance} selects PROPERTY for inheritance.
9350 @end defun
9352 @defun org-entry-delete pom property
9353 Delete the property PROPERTY from entry at point-or-marker POM.
9354 @end defun
9356 @defun org-entry-put pom property value
9357 Set PROPERTY to VALUE for entry at point-or-marker POM.
9358 @end defun
9360 @defun org-buffer-property-keys &optional include-specials
9361 Get all property keys in the current buffer.
9362 @end defun
9364 @defun org-insert-property-drawer
9365 Insert a property drawer at point.
9366 @end defun
9368 @defun org-entry-add-to-multivalued-property pom property value
9369 Treat the value of the property PROPERTY as a whitespace-separated list of
9370 values and make sure that VALUE is in this list.
9371 @end defun
9373 @defun org-entry-remove-from-multivalued-property pom property value
9374 Treat the value of the property PROPERTY as a whitespace-separated list of
9375 values and make sure that VALUE is @emph{not} in this list.
9376 @end defun
9378 @defun org-entry-member-in-multivalued-property pom property value
9379 Treat the value of the property PROPERTY as a whitespace-separated list of
9380 values and check if VALUE is in this list.
9381 @end defun
9383 @node Using the mapping API,  , Using the property API, Hacking
9384 @section Using the mapping API
9385 @cindex API, for mapping
9386 @cindex mapping entries, API
9388 Org has sophisticated mapping capabilities to find all entries satisfying
9389 certain criteria.  Internally, this functionality is used to produce agenda
9390 views, but there is also an API that can be used to execute arbitrary
9391 functions for each or selected entries.  The main entry point for this API
9392 is: 
9394 @defun org-map-entries func &optional match scope &rest skip
9395 Call FUNC at each headline selected by MATCH in SCOPE.
9397 FUNC is a function or a lisp form.  The function will be called without
9398 arguments, with the cursor positioned at the beginning of the headline.
9399 The return values of all calls to the function will be collected and
9400 returned as a list.
9402 MATCH is a tags/property/todo match as it is used in the agenda match view.
9403 Only headlines that are matched by this query will be considered during
9404 the iteration.  When MATCH is nil or t, all headlines will be
9405 visited by the iteration.
9407 SCOPE determines the scope of this command.  It can be any of:
9409 @example
9410 nil     @r{the current buffer, respecting the restriction if any}
9411 tree    @r{the subtree started with the entry at point}
9412 file    @r{the current buffer, without restriction}
9413 file-with-archives
9414         @r{the current buffer, and any archives associated with it}
9415 agenda  @r{all agenda files}
9416 agenda-with-archives
9417         @r{all agenda files with any archive files associated with them}
9418 (file1 file2 ...)
9419         @r{if this is a list, all files in the list will be scanned}
9420 @end example
9422 The remaining args are treated as settings for the skipping facilities of
9423 the scanner.  The following items can be given here:
9425 @example
9426 archive   @r{skip trees with the archive tag}
9427 comment   @r{skip trees with the COMMENT keyword}
9428 function or Lisp form
9429           @r{will be used as value for @code{org-agenda-skip-function},}
9430           @r{so whenever the the function returns t, FUNC}
9431           @r{will not be called for that entry and search will}
9432           @r{continue from the point where the function leaves it}
9433 @end example
9434 @end defun
9436 The function given to that mapping routine can really do anything you like.
9437 It can uce the property API (@pxref{Using the property API}) to gather more
9438 information about the entry, or in order to change metadate in the entry.
9439 Here are a couple of functions that might be handy:
9441 @defun org-todo &optional arg
9442 Change the TODO state of the entry, see the docstring of the functions for
9443 the many possible values for the argument ARG.
9444 @end defun
9446 @defun org-priority &optional action
9447 Change the priority of the entry, see the docstring of this function for the
9448 possible values for ACTION.
9449 @end defun
9451 @defun org-toggle-tag tag &optional onoff
9452 Toggle the tag TAG in the current entry.  Setting ONOFF to either @code{on}
9453 or @code{off} will not toggle tag, but ensure that it is either on or off.
9454 @end defun
9456 @defun org-promote
9457 Promote the current entry.
9458 @end defun
9460 @defun org-demote
9461 Demote the current entry.
9462 @end defun
9464 Here is a simple example that will turn all entries in the current file with
9465 a tag @code{TOMORROW} into TODO entries with the keyword @code{UPCOMING}.
9466 Entries in comment trees and in archive trees will be ignored.
9468 @lisp
9469 (org-map-entries
9470    '(org-todo "UPCOMING")
9471    "+TOMORROW" 'file 'archive 'comment)
9472 @end lisp
9474 The following example counts the number of entries with TODO keyword
9475 @code{WAITING}, in all agenda files.
9477 @lisp
9478 (length (org-map-entries t "/+WAITING" nil 'agenda))
9479 @end lisp
9481 @node History and Acknowledgments, Main Index, Hacking, Top
9482 @appendix History and Acknowledgments
9483 @cindex acknowledgments
9484 @cindex history
9485 @cindex thanks
9487 Org was borne in 2003, out of frustration over the user interface
9488 of the Emacs Outline mode.  I was trying to organize my notes and
9489 projects, and using Emacs seemed to be the natural way to go.  However,
9490 having to remember eleven different commands with two or three keys per
9491 command, only to hide and show parts of the outline tree, that seemed
9492 entirely unacceptable to me.  Also, when using outlines to take notes, I
9493 constantly want to restructure the tree, organizing it parallel to my
9494 thoughts and plans.  @emph{Visibility cycling} and @emph{structure
9495 editing} were originally implemented in the package
9496 @file{outline-magic.el}, but quickly moved to the more general
9497 @file{org.el}.  As this environment became comfortable for project
9498 planning, the next step was adding @emph{TODO entries}, basic @emph{time
9499 stamps}, and @emph{table support}.  These areas highlight the two main
9500 goals that Org still has today: To create a new, outline-based,
9501 plain text mode with innovative and intuitive editing features, and to
9502 incorporate project planning functionality directly into a notes file.
9504 A special thanks goes to @i{Bastien Guerry} who has not only writen a large
9505 number of extensions to Org (most of them integrated into the core by now),
9506 but has also helped the development and maintenance of Org so much that he
9507 should be considered co-author of this package.
9509 Since the first release, literally thousands of emails to me or on
9510 @code{emacs-orgmode@@gnu.org} have provided a constant stream of bug
9511 reports, feedback, new ideas, and sometimes patches and add-on code.
9512 Many thanks to everyone who has helped to improve this package.  I am
9513 trying to keep here a list of the people who had significant influence
9514 in shaping one or more aspects of Org.  The list may not be
9515 complete, if I have forgotten someone, please accept my apologies and
9516 let me know.
9518 @itemize @bullet
9520 @item
9521 @i{Russel Adams} came up with the idea for drawers.
9522 @item
9523 @i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}.
9524 @item
9525 @i{Christophe Bataillon} created the great unicorn logo that we use on the
9526 Org-mode website.
9527 @item
9528 @i{Alex Bochannek} provided a patch for rounding time stamps.
9529 @item
9530 @i{Charles Cave}'s suggestion sparked the implementation of templates
9531 for Remember.
9532 @item
9533 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
9534 specified time.
9535 @item
9536 @i{Gregory Chernov} patched support for lisp forms into table
9537 calculations and improved XEmacs compatibility, in particular by porting
9538 @file{nouline.el} to XEmacs.
9539 @item
9540 @i{Sacha Chua} suggested to copy some linking code from Planner.
9541 @item
9542 @i{Eddward DeVilla} proposed and tested checkbox statistics.  He also
9543 came up with the idea of properties, and that there should be an API for
9544 them.
9545 @item
9546 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
9547 inspired some of the early development, including HTML export.  He also
9548 asked for a way to narrow wide table columns.
9549 @item
9550 @i{Christian Egli} converted the documentation into Texinfo format,
9551 patched CSS formatting into the HTML exporter, and inspired the agenda.
9552 @item
9553 @i{David Emery} provided a patch for custom CSS support in exported
9554 HTML agendas.
9555 @item
9556 @i{Nic Ferrier} contributed mailcap and XOXO support.
9557 @item
9558 @i{Miguel A. Figueroa-Villanueva} implemented hierarchical checkboxes.
9559 @item
9560 @i{John Foerch} figured out how to make incremental search show context
9561 around a match in a hidden outline tree.
9562 @item
9563 @i{Niels Giesen} had the idea to automatically archive DONE trees.
9564 @item
9565 @i{Bastien Guerry} wrote the La@TeX{} exporter and @file{org-bibtex.el}, and
9566 has been prolific with patches, ideas, and bug reports.
9567 @item
9568 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
9569 @item
9570 @i{Bernt Hansen} has driven much of the support for auto-repeating tasks,
9571 task state change logging, and the clocktable.  His clear explanations have
9572 been critical when we started to adopt the GIT version control system.
9573 @item
9574 @i{Manuel Hermenegildo} has contributed various ideas, small fixed and
9575 patches.
9576 @item
9577 @i{Phil Jackson} wrote @file{org-irc.el}.
9578 @item
9579 @i{Scott Jaderholm} proposed footnotes, control over whitespace between
9580 folded entries, and column view for properties.
9581 @item
9582 @i{Tokuya Kameshima} wrote @file{org-wl.el} and @file{org-mew.el}.
9583 @item
9584 @i{Shidai Liu} ("Leo") asked for embedded La@TeX{} and tested it.  He also
9585 provided frequent feedback and some patches.
9586 @item
9587 @i{Jason F. McBrayer} suggested agenda export to CSV format.
9588 @item
9589 @i{Max Mikhanosha} came up with the idea of refiling.
9590 @item
9591 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
9592 basis.
9593 @item
9594 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
9595 happy.
9596 @item
9597 @i{Rick Moynihan} proposed to allow multiple TODO sequences in a file
9598 and to be able to quickly restrict the agenda to a subtree.
9599 @item
9600 @i{Todd Neal} provided patches for links to Info files and elisp forms.
9601 @item
9602 @i{Tim O'Callaghan} suggested in-file links, search options for general
9603 file links, and TAGS.
9604 @item
9605 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
9606 into Japanese.
9607 @item
9608 @i{Oliver Oppitz} suggested multi-state TODO items.
9609 @item
9610 @i{Scott Otterson} sparked the introduction of descriptive text for
9611 links, among other things.
9612 @item
9613 @i{Pete Phillips} helped during the development of the TAGS feature, and
9614 provided frequent feedback.
9615 @item
9616 @i{T.V. Raman} reported bugs and suggested improvements.
9617 @item
9618 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
9619 control.
9620 @item
9621 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
9622 @item
9623 @i{Sebastian Rose} wrote @file{org-info.js}, a Java script for displaying
9624 webpages derived from Org using an Info-like, or a folding interface with
9625 single key navigation.
9626 @item
9627 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
9628 conflict with @file{allout.el}.
9629 @item
9630 @i{Jason Riedy} generalized the send-receive mechanism for orgtbl tables with
9631 extensive patches.
9632 @item
9633 @i{Philip Rooke} created the Org reference card, provided lots
9634 of feedback, developed and applied standards to the Org documentation.
9635 @item
9636 @i{Christian Schlauer} proposed angular brackets around links, among
9637 other things.
9638 @item
9639 @i{Eric Schulte} wrote @file{org-plot.el}.
9640 @item
9641 Linking to VM/BBDB/Gnus was first inspired by @i{Tom Shannon}'s
9642 @file{organizer-mode.el}.
9643 @item
9644 @i{Ilya Shlyakhter} proposed the Archive Sibling.
9645 @item
9646 @i{Daniel Sinder} came up with the idea of internal archiving by locking
9647 subtrees.
9648 @item
9649 @i{Dale Smith} proposed link abbreviations.
9650 @item
9651 @i{James TD Smith} has contributed a large number of patches for useful
9652 tweaks and features.
9653 @item
9654 @i{Adam Spiers} asked for global linking commands, inspired the link
9655 extension system, added support for mairix, and proposed the mapping API.
9656 @item
9657 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
9658 chapter about publishing.
9659 @item
9660 @i{J@"urgen Vollmer} contributed code generating the table of contents
9661 in HTML output.
9662 @item
9663 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
9664 keyword.
9665 @item
9666 @i{David Wainberg} suggested archiving, and improvements to the linking
9667 system.
9668 @item
9669 @i{John Wiegley} wrote @file{emacs-wiki.el}, @file{planner.el}, and
9670 @file{muse.el}, which have similar goals as Org.  Initially the
9671 development of Org was fully independent because I was not aware of the
9672 existence of these packages.  But with time I have accasionally looked
9673 at John's code and learned a lot from it.  John has also contributed a
9674 number of great ideas and patches directly to Org, including the file
9675 @code{org-mac-message.el}'
9676 @item
9677 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
9678 linking to Gnus.
9679 @item
9680 @i{Roland Winkler} requested additional key bindings to make Org
9681 work on a tty.
9682 @item
9683 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
9684 and contributed various ideas and code snippets.
9685 @end itemize
9688 @node Main Index, Key Index, History and Acknowledgments, Top
9689 @unnumbered The Main Index
9691 @printindex cp
9693 @node Key Index,  , Main Index, Top
9694 @unnumbered Key Index
9696 @printindex ky
9698 @bye
9700 @ignore
9701         arch-tag: 7893d1Fe-cc57-4d13-b5e5-f494a1CBC7ac
9702 @end ignore
9704 @c Local variables:
9705 @c ispell-local-dictionary: "en_US-w_accents"
9706 @c ispell-local-pdict: "./.aspell.org.pws"
9707 @c fill-column: 77
9708 @c End: