Sync copyright fixes from downstream Emacs
[org-mode.git] / doc / org.texi
blob040c2f05c91ae44adec3dd3fc83cfc8aa4962253
1 \input texinfo
2 @c %**start of header
3 @setfilename ../../info/org
4 @settitle The Org Manual
6 @set VERSION 6.02b
7 @set DATE April 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.1 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
46 license is included in the section entitled ``GNU Free Documentation
47 License.''
49 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
50 this GNU Manual, like GNU software.  Copies published by the Free
51 Software Foundation raise funds for GNU development.''
52 @end quotation
53 @end copying
55 @titlepage
56 @title The Org Manual
58 @subtitle Release @value{VERSION}
59 @author by Carsten Dominik
61 @c The following two commands start the copyright page.
62 @page
63 @vskip 0pt plus 1filll
64 @insertcopying
65 @end titlepage
67 @c Output the table of contents at the beginning.
68 @contents
70 @ifnottex
71 @node Top, Introduction, (dir), (dir)
72 @top Org Mode Manual
74 @insertcopying
75 @end ifnottex
77 @menu
78 * Introduction::                Getting started
79 * Document Structure::          A tree works like your brain
80 * Tables::                      Pure magic for quick formatting
81 * Hyperlinks::                  Notes in context
82 * TODO Items::                  Every tree branch can be a TODO item
83 * Tags::                        Tagging headlines and matching sets of tags
84 * Properties and Columns::      Storing information about an entry
85 * Dates and Times::             Making items useful for planning
86 * Remember::                    Quickly adding nodes to the outline tree
87 * Agenda Views::                Collecting information into views
88 * Embedded LaTeX::              LaTeX fragments and formulas
89 * Exporting::                   Sharing and publishing of notes
90 * Publishing::                  Create a web site of linked Org files
91 * Miscellaneous::               All the rest which did not fit elsewhere
92 * Extensions and Hacking::      It is possible to write add-on code
93 * History and Acknowledgments::  How Org came into being
94 * Main Index::                  An index of Org's concepts and features
95 * Key Index::                   Key bindings and where they are described
97 @detailmenu
98  --- The Detailed Node Listing ---
100 Introduction
102 * Summary::                     Brief summary of what Org does
103 * Installation::                How to install a downloaded version of Org
104 * Activation::                  How to activate Org for certain buffers
105 * Feedback::                    Bug reports, ideas, patches etc.
106 * Conventions::                 Type-setting conventions in the manual
108 Document Structure
110 * Outlines::                    Org is based on Outline mode
111 * Headlines::                   How to typeset Org tree headlines
112 * Visibility cycling::          Show and hide, much simplified
113 * Motion::                      Jumping to other headlines
114 * Structure editing::           Changing sequence and level of headlines
115 * Archiving::                   Move done task trees to a different place
116 * Sparse trees::                Matches embedded in context
117 * Plain lists::                 Additional structure within an entry
118 * Drawers::                     Tucking stuff away
119 * Orgstruct mode::              Structure editing outside Org
121 Archiving
123 * ARCHIVE tag::                 Marking a tree as inactive
124 * Moving subtrees::             Moving a tree to an archive file
126 Tables
128 * Built-in table editor::       Simple tables
129 * Narrow columns::              Stop wasting space in tables
130 * Column groups::               Grouping to trigger vertical lines
131 * Orgtbl mode::                 The table editor as minor mode
132 * The spreadsheet::             The table editor has spreadsheet capabilities
134 The spreadsheet
136 * References::                  How to refer to another field or range
137 * Formula syntax for Calc::     Using Calc to compute stuff
138 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
139 * Field formulas::              Formulas valid for a single field
140 * Column formulas::             Formulas valid for an entire column
141 * Editing and debugging formulas::  Fixing formulas
142 * Updating the table::          Recomputing all dependent fields
143 * Advanced features::           Field names, parameters and automatic recalc
145 Hyperlinks
147 * Link format::                 How links in Org are formatted
148 * Internal links::              Links to other places in the current file
149 * External links::              URL-like links to the world
150 * Handling links::              Creating, inserting and following
151 * Using links outside Org::     Linking from my C source code?
152 * Link abbreviations::          Shortcuts for writing complex links
153 * Search options::              Linking to a specific location
154 * Custom searches::             When the default search is not enough
156 Internal links
158 * Radio targets::               Make targets trigger links in plain text
160 TODO Items
162 * TODO basics::                 Marking and displaying TODO entries
163 * TODO extensions::             Workflow and assignments
164 * Progress logging::            Dates and notes for progress
165 * Priorities::                  Some things are more important than others
166 * Breaking down tasks::         Splitting a task into manageable pieces
167 * Checkboxes::                  Tick-off lists
169 Extended use of TODO keywords
171 * Workflow states::             From TODO to DONE in steps
172 * TODO types::                  I do this, Fred does the rest
173 * Multiple sets in one file::   Mixing it all, and still finding your way
174 * Fast access to TODO states::  Single letter selection of a state
175 * Per-file keywords::           Different files, different requirements
176 * Faces for TODO keywords::     Highlighting states
178 Progress logging
180 * Closing items::               When was this entry marked DONE?
181 * Tracking TODO state changes::  When did the status change?
183 Tags
185 * Tag inheritance::             Tags use the tree structure of the outline
186 * Setting tags::                How to assign tags to a headline
187 * Tag searches::                Searching for combinations of tags
189 Properties and Columns
191 * Property syntax::             How properties are spelled out
192 * Special properties::          Access to other Org mode features
193 * Property searches::           Matching property values
194 * Property inheritance::        Passing values down the tree
195 * Column view::                 Tabular viewing and editing
196 * Property API::                Properties for Lisp programmers
198 Column view
200 * Defining columns::            The COLUMNS format property
201 * Using column view::           How to create and use column view
202 * Capturing column view::       A dynamic block for column view
204 Defining columns
206 * Scope of column definitions::  Where defined, where valid?
207 * Column attributes::           Appearance and content of a column
209 Dates and Times
211 * Timestamps::                  Assigning a time to a tree entry
212 * Creating timestamps::         Commands which insert timestamps
213 * Deadlines and scheduling::    Planning your work
214 * Clocking work time::          Tracking how long you spend on a task
215 * Effort estimates::            Planning work effort in advance
217 Creating timestamps
219 * The date/time prompt::        How Org mode helps you entering date and time
220 * Custom time format::          Making dates look different
222 Deadlines and scheduling
224 * Inserting deadline/schedule::  Planning items
225 * Repeated tasks::              Items that show up again and again
227 Remember
229 * Setting up Remember::         Some code for .emacs to get things going
230 * Remember templates::          Define the outline of different note types
231 * Storing notes::               Directly get the note to where it belongs
232 * Refiling notes::              Moving a note or task to a project
234 Agenda Views
236 * Agenda files::                Files being searched for agenda information
237 * Agenda dispatcher::           Keyboard access to agenda views
238 * Built-in agenda views::       What is available out of the box?
239 * Presentation and sorting::    How agenda items are prepared for display
240 * Agenda commands::             Remote editing of Org trees
241 * Custom agenda views::         Defining special searches and views
242 * Agenda column view::          Using column view for collected entries
244 The built-in agenda views
246 * Weekly/daily agenda::         The calendar page with current tasks
247 * Global TODO list::            All unfinished action items
248 * Matching tags and properties::  Structured information with fine-tuned search
249 * Timeline::                    Time-sorted view for single file
250 * Keyword search::              Finding entries by keyword
251 * Stuck projects::              Find projects you need to review
253 Presentation and sorting
255 * Categories::                  Not all tasks are equal
256 * Time-of-day specifications::  How the agenda knows the time
257 * Sorting of agenda items::     The order of things
259 Custom agenda views
261 * Storing searches::            Type once, use often
262 * Block agenda::                All the stuff you need in a single buffer
263 * Setting Options::             Changing the rules
264 * Exporting Agenda Views::      Writing agendas to files
265 * Using the agenda elsewhere::  Using agenda information in other programs
267 Embedded LaTeX
269 * Math symbols::                TeX macros for symbols and Greek letters
270 * Subscripts and superscripts::  Simple syntax for raising/lowering text
271 * LaTeX fragments::             Complex formulas made easy
272 * Processing LaTeX fragments::  Previewing LaTeX processing
273 * CDLaTeX mode::                Speed up entering of formulas
275 Exporting
277 * Markup rules::                Which structures are recognized?
278 * Export options::              Per-file export settings
279 * The export dispatcher::       How to access exporter commands
280 * ASCII export::                Exporting to plain ASCII
281 * HTML export::                 Exporting to HTML
282 * LaTeX export::                Exporting to LaTeX
283 * XOXO export::                 Exporting to XOXO
284 * iCalendar export::            Exporting in iCalendar format
286 Markup rules
288 * Document title::              How the document title is determined
289 * Headings and sections::       The main structure of the exported document
290 * Table of contents::           If, where, how to create a table of contents
291 * Initial text::                Text before the first headline
292 * Lists::                       Plain lists are exported
293 * Paragraphs::                  What determines beginning and ending
294 * Literal examples::            Source code and other examples
295 * Tables exported::             Tables are exported richly
296 * Footnotes::                   Numbers like [1]
297 * Emphasis and monospace::      To bold or not to bold
298 * TeX macros and LaTeX fragments::  Create special, rich export.
299 * Horizontal rules::            A line across the page
300 * Comment lines::               Some lines will not be exported
302 HTML export
304 * HTML Export commands::        How to invoke HTML export
305 * Quoting HTML tags::           Using direct HTML in Org mode
306 * Links::                       Transformation of links for HTML
307 * Images::                      How to include images
308 * CSS support::                 Changing the appearance of the output
309 * Javascript support::          Info and Folding in a web browser
311 LaTeX export
313 * LaTeX export commands::       How to invoke LaTeX export
314 * Quoting LaTeX code::          Incorporating literal LaTeX code
315 * Sectioning structure::        Changing sectioning in LaTeX output
317 Publishing
319 * Configuration::               Defining projects
320 * Sample configuration::        Example projects
321 * Triggering publication::      Publication commands
323 Configuration
325 * Project alist::               The central configuration variable
326 * Sources and destinations::    From here to there
327 * Selecting files::             What files are part of the project?
328 * Publishing action::           Setting the function doing the publishing
329 * Publishing options::          Tweaking HTML export
330 * Publishing links::            Which links keep working after publishing?
331 * Project page index::          Publishing a list of project files
333 Sample configuration
335 * Simple example::              One-component publishing
336 * Complex example::             A multi-component publishing example
338 Miscellaneous
340 * Completion::                  M-TAB knows what you need
341 * Customization::               Adapting Org to your taste
342 * In-buffer settings::          Overview of the #+KEYWORDS
343 * The very busy C-c C-c key::   When in doubt, press C-c C-c
344 * Clean view::                  Getting rid of leading stars in the outline
345 * TTY keys::                    Using Org on a tty
346 * Interaction::                 Other Emacs packages
347 * Bugs::                        Things which do not work perfectly
349 Interaction with other packages
351 * Cooperation::                 Packages Org cooperates with
352 * Conflicts::                   Packages that lead to conflicts
354 Extensions, Hooks and Hacking
356 * Extensions::                  Existing 3rd-party extensions
357 * Adding hyperlink types::      New custom link types
358 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
359 * Dynamic blocks::              Automatically filled blocks
360 * Special agenda views::        Customized views
361 * Using the property API::      Writing programs that use entry properties
363 Tables and lists in arbitrary syntax
365 * Radio tables::                Sending and receiving
366 * A LaTeX example::             Step by step, almost a tutorial
367 * Translator functions::        Copy and modify
368 * Radio lists::                 Doing the same for lists
370 @end detailmenu
371 @end menu
373 @node Introduction, Document Structure, Top, Top
374 @chapter Introduction
375 @cindex introduction
377 @menu
378 * Summary::                     Brief summary of what Org does
379 * Installation::                How to install a downloaded version of Org
380 * Activation::                  How to activate Org for certain buffers
381 * Feedback::                    Bug reports, ideas, patches etc.
382 * Conventions::                 Type-setting conventions in the manual
383 @end menu
385 @node Summary, Installation, Introduction, Introduction
386 @section Summary
387 @cindex summary
389 Org is a mode for keeping notes, maintaining TODO lists, and doing
390 project planning with a fast and effective plain-text system.
392 Org develops organizational tasks around NOTES files that contain
393 lists or information about projects as plain text.  Org is
394 implemented on top of Outline mode, which makes it possible to keep the
395 content of large files well structured.  Visibility cycling and
396 structure editing help to work with the tree.  Tables are easily created
397 with a built-in table editor.  Org supports TODO items, deadlines,
398 time stamps, and scheduling.  It dynamically compiles entries into an
399 agenda that utilizes and smoothly integrates much of the Emacs calendar
400 and diary.  Plain text URL-like links connect to websites, emails,
401 Usenet messages, BBDB entries, and any files related to the projects.
402 For printing and sharing of notes, an Org file can be exported as a
403 structured ASCII file, as HTML, or (TODO and agenda items only) as an
404 iCalendar file.  It can also serve as a publishing tool for a set of
405 linked web pages.
407 An important design aspect that distinguishes Org from for example
408 Planner/Muse is that it encourages to store every piece of information
409 only once.  In Planner, you have project pages, day pages and possibly
410 other files, duplicating some information such as tasks.  In Org,
411 you only have notes files.  In your notes you mark entries as tasks,
412 label them with tags and timestamps.  All necessary lists like a
413 schedule for the day, the agenda for a meeting, tasks lists selected by
414 tags etc are created dynamically when you need them.
416 Org keeps simple things simple.  When first fired up, it should
417 feel like a straightforward, easy to use outliner.  Complexity is not
418 imposed, but a large amount of functionality is available when you need
419 it.  Org is a toolbox and can be used in different ways, for
420 example as:
422 @example
423 @r{@bullet{} outline extension with visibility cycling and structure editing}
424 @r{@bullet{} ASCII system and table editor for taking structured notes}
425 @r{@bullet{} ASCII table editor with spreadsheet-like capabilities}
426 @r{@bullet{} TODO list editor}
427 @r{@bullet{} full agenda and planner with deadlines and work scheduling}
428 @r{@bullet{} environment to implement David Allen's GTD system}
429 @r{@bullet{} a basic database application}
430 @r{@bullet{} simple hypertext system, with HTML and LaTeX export}
431 @r{@bullet{} publishing tool to create a set of interlinked webpages}
432 @end example
434 Org's automatic, context sensitive table editor with spreadsheet
435 capabilities can be integrated into any major mode by activating the
436 minor Orgtbl mode.  Using a translation step, it can be used to maintain
437 tables in arbitrary file types, for example in La@TeX{}.  The structure
438 editing and list creation capabilities can be used outside Org with
439 the minor Orgstruct mode.
441 @cindex FAQ
442 There is a website for Org which provides links to the newest
443 version of Org, as well as additional information, frequently asked
444 questions (FAQ), links to tutorials etc.  This page is located at
445 @uref{http://orgmode.org}.
447 @page
450 @node Installation, Activation, Summary, Introduction
451 @section Installation
452 @cindex installation
453 @cindex XEmacs
455 @b{Important:} @i{If Org is part of the Emacs distribution or an
456 XEmacs package, please skip this section and go directly to
457 @ref{Activation}.}
459 If you have downloaded Org from the Web, either as a distribution @file{.zip}
460 or @file{.tar} file, or as a GIT archive, you must take the following steps
461 to install it: Go into the unpacked Org distribution directory and edit the
462 top section of the file @file{Makefile}.  You must set the name of the Emacs
463 binary (likely either @file{emacs} or @file{xemacs}), and the paths to the
464 directories where local Lisp and Info files are kept.  If you don't have
465 access to the system-wide directories, you can simply run Org directly from
466 the distribution directory by adding the @file{lisp} subdirectory to the
467 Emacs load path.  To do this, add the following line to @file{.emacs}:
469 @example
470 (setq load-path (cons "~/path/to/orgdir/lisp" load-path))
471 @end example
473 @noindent
474 If you plan to use code from the @file{contrib} subdirectory, do a similar
475 step for this directory:
477 @example
478 (setq load-path (cons "~/path/to/orgdir/contrib/lisp" load-path))
479 @end example
481 @b{XEmacs users now need to install the file @file{noutline.el} from
482 the @file{xemacs} sub-directory of the Org distribution.  Use the
483 command:}
485 @example
486 @b{make install-noutline}
487 @end example
489 @noindent Now byte-compile the Lisp files with the shell command:
491 @example
492 make
493 @end example
495 @noindent If you are running Org from the distribution directory, this is
496 all.  If you want to install into the system directories, use
498 @example
499 make install
500 make install-info
501 @end example
503 @noindent Then add to @file{.emacs}:
505 @lisp
506 ;; This line only if Org is not part of the X/Emacs distribution.
507 (require 'org-install)
508 @end lisp
511 @node Activation, Feedback, Installation, Introduction
512 @section Activation
513 @cindex activation
514 @cindex autoload
515 @cindex global key bindings
516 @cindex key bindings, global
518 @iftex
519 @b{Important:} @i{If you use copy-and-paste to copy lisp code from the
520 PDF documentation as viewed by Acrobat reader to your .emacs file, the
521 single quote character comes out incorrectly and the code will not work.
522 You need to fix the single quotes by hand, or copy from Info
523 documentation.}
524 @end iftex
526 Add the following lines to your @file{.emacs} file.  The last two lines
527 define @emph{global} keys for the commands @command{org-store-link},
528 @command{org-agenda}, and @command{org-iswitchb} - please choose suitable
529 keys yourself.
531 @lisp
532 ;; The following lines are always needed.  Choose your own keys.
533 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
534 (global-set-key "\C-cl" 'org-store-link)
535 (global-set-key "\C-ca" 'org-agenda)
536 (global-set-key "\C-cb" 'org-iswitchb)
537 @end lisp
539 Furthermore, you must activate @code{font-lock-mode} in Org
540 buffers, because significant functionality depends on font-locking being
541 active.  You can do this with either one of the following two lines
542 (XEmacs user must use the second option):
543 @lisp
544 (global-font-lock-mode 1)                     ; for all buffers
545 (add-hook 'org-mode-hook 'turn-on-font-lock)  ; Org buffers only
546 @end lisp
548 @cindex Org mode, turning on
549 With this setup, all files with extension @samp{.org} will be put
550 into Org mode.  As an alternative, make the first line of a file look
551 like this:
553 @example
554 MY PROJECTS    -*- mode: org; -*-
555 @end example
557 @noindent which will select Org mode for this buffer no matter what
558 the file's name is.  See also the variable
559 @code{org-insert-mode-line-in-empty-file}.
561 @node Feedback, Conventions, Activation, Introduction
562 @section Feedback
563 @cindex feedback
564 @cindex bug reports
565 @cindex maintainer
566 @cindex author
568 If you find problems with Org, or if you have questions, remarks,
569 or ideas about it, please contact the maintainer @value{MAINTAINER} at
570 @value{MAINTAINEREMAIL}.
572 For bug reports, please provide as much information as possible,
573 including the version information of Emacs (@kbd{C-h v emacs-version
574 @key{RET}}) and Org (@kbd{C-h v org-version @key{RET}}), as well as
575 the Org related setup in @file{.emacs}.  If an error occurs, a
576 backtrace can be very useful (see below on how to create one).  Often a
577 small example file helps, along with clear information about:
579 @enumerate
580 @item What exactly did you do?
581 @item What did you expect to happen?
582 @item What happened instead?
583 @end enumerate
584 @noindent Thank you for helping to improve this mode.
586 @subsubheading How to create a useful backtrace
588 @cindex backtrace of an error
589 If working with Org produces an error with a message you don't
590 understand, you may have hit a bug.  The best way to report this is by
591 providing, in addition to what was mentioned above, a @emph{Backtrace}.
592 This is information from the built-in debugger about where and how the
593 error occurred.  Here is how to produce a useful backtrace:
595 @enumerate
596 @item
597 Start a fresh Emacs or XEmacs, and make sure that it will load the
598 original Lisp code in @file{org.el} instead of the compiled version in
599 @file{org.elc}.  The backtrace contains much more information if it is
600 produced with uncompiled code.  To do this, either rename @file{org.elc}
601 to something else before starting Emacs, or ask Emacs explicitly to load
602 @file{org.el} by using the command line
603 @example
604 emacs -l /path/to/org.el
605 @end example
606 @item
607 Go to the @code{Options} menu and select @code{Enter Debugger on Error}
608 (XEmacs has this option in the @code{Troubleshooting} sub-menu).
609 @item
610 Do whatever you have to do to hit the error.  Don't forget to
611 document the steps you take.
612 @item
613 When you hit the error, a @file{*Backtrace*} buffer will appear on the
614 screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
615 attach it to your bug report.
616 @end enumerate
618 @node Conventions,  , Feedback, Introduction
619 @section Typesetting conventions used in this manual
621 Org uses three types of keywords: TODO keywords, tags, and property
622 names.  In this manual we use the following conventions:
624 @table @code
625 @item TODO
626 @itemx WAITING
627 TODO keywords are written with all capitals, even if they are
628 user-defined.
629 @item boss
630 @itemx ARCHIVE
631 User-defined tags are written in lowercase; built-in tags with special
632 meaning are written with all capitals.
633 @item Release
634 @itemx PRIORITY
635 User-defined properties are capitalized; built-in properties with
636 special meaning are written with all capitals.
637 @end table
639 @node Document Structure, Tables, Introduction, Top
640 @chapter Document Structure
641 @cindex document structure
642 @cindex structure of document
644 Org is based on outline mode and provides flexible commands to
645 edit the structure of the document.
647 @menu
648 * Outlines::                    Org is based on Outline mode
649 * Headlines::                   How to typeset Org tree headlines
650 * Visibility cycling::          Show and hide, much simplified
651 * Motion::                      Jumping to other headlines
652 * Structure editing::           Changing sequence and level of headlines
653 * Archiving::                   Move done task trees to a different place
654 * Sparse trees::                Matches embedded in context
655 * Plain lists::                 Additional structure within an entry
656 * Drawers::                     Tucking stuff away
657 * Orgstruct mode::              Structure editing outside Org
658 @end menu
660 @node Outlines, Headlines, Document Structure, Document Structure
661 @section Outlines
662 @cindex outlines
663 @cindex Outline mode
665 Org is implemented on top of Outline mode.  Outlines allow a
666 document to be organized in a hierarchical structure, which (at least
667 for me) is the best representation of notes and thoughts.  An overview
668 of this structure is achieved by folding (hiding) large parts of the
669 document to show only the general document structure and the parts
670 currently being worked on.  Org greatly simplifies the use of
671 outlines by compressing the entire show/hide functionality into a single
672 command @command{org-cycle}, which is bound to the @key{TAB} key.
674 @node Headlines, Visibility cycling, Outlines, Document Structure
675 @section Headlines
676 @cindex headlines
677 @cindex outline tree
679 Headlines define the structure of an outline tree.  The headlines in
680 Org start with one or more stars, on the left margin@footnote{See
681 the variable @code{org-special-ctrl-a/e} to configure special behavior
682 of @kbd{C-a} and @kbd{C-e} in headlines.}.  For example:
684 @example
685 * Top level headline
686 ** Second level
687 *** 3rd level
688     some text
689 *** 3rd level
690     more text
692 * Another top level headline
693 @end example
695 @noindent Some people find the many stars too noisy and would prefer an
696 outline that has whitespace followed by a single star as headline
697 starters.  @ref{Clean view} describes a setup to realize this.
699 An empty line after the end of a subtree is considered part of it and
700 will be hidden when the subtree is folded.  However, if you leave at
701 least two empty lines, one empty line will remain visible after folding
702 the subtree, in order to structure the collapsed view.  See the
703 variable @code{org-cycle-separator-lines} to modify this behavior.
705 @node Visibility cycling, Motion, Headlines, Document Structure
706 @section Visibility cycling
707 @cindex cycling, visibility
708 @cindex visibility cycling
709 @cindex trees, visibility
710 @cindex show hidden text
711 @cindex hide text
713 Outlines make it possible to hide parts of the text in the buffer.
714 Org uses just two commands, bound to @key{TAB} and
715 @kbd{S-@key{TAB}} to change the visibility in the buffer.
717 @cindex subtree visibility states
718 @cindex subtree cycling
719 @cindex folded, subtree visibility state
720 @cindex children, subtree visibility state
721 @cindex subtree, subtree visibility state
722 @table @kbd
723 @kindex @key{TAB}
724 @item @key{TAB}
725 @emph{Subtree cycling}: Rotate current subtree among the states
727 @example
728 ,-> FOLDED -> CHILDREN -> SUBTREE --.
729 '-----------------------------------'
730 @end example
732 The cursor must be on a headline for this to work@footnote{see, however,
733 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
734 beginning of the buffer and the first line is not a headline, then
735 @key{TAB} actually runs global cycling (see below)@footnote{see the
736 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
737 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
739 @cindex global visibility states
740 @cindex global cycling
741 @cindex overview, global visibility state
742 @cindex contents, global visibility state
743 @cindex show all, global visibility state
744 @kindex S-@key{TAB}
745 @item S-@key{TAB}
746 @itemx C-u @key{TAB}
747 @emph{Global cycling}: Rotate the entire buffer among the states
749 @example
750 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
751 '--------------------------------------'
752 @end example
754 When @kbd{S-@key{TAB}} is called with a numeric prefix argument N, the
755 CONTENTS view up to headlines of level N will be shown.  Note that inside
756 tables, @kbd{S-@key{TAB}} jumps to the previous field.
758 @cindex show all, command
759 @kindex C-c C-a
760 @item C-c C-a
761 Show all.
762 @kindex C-c C-r
763 @item C-c C-r
764 Reveal context around point, showing the current entry, the following heading
765 and the hierarchy above.  Useful for working near a location that has been
766 exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda command
767 (@pxref{Agenda commands}).  With a prefix argument show, on each
768 level, all sibling headings.
769 @kindex C-c C-x b
770 @item C-c C-x b
771 Show the current subtree in an indirect buffer@footnote{The indirect
772 buffer
773 @ifinfo
774 (@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
775 @end ifinfo
776 @ifnotinfo
777 (see the Emacs manual for more information about indirect buffers)
778 @end ifnotinfo
779 will contain the entire buffer, but will be narrowed to the current
780 tree.  Editing the indirect buffer will also change the original buffer,
781 but without affecting visibility in that buffer.}.  With a numeric
782 prefix argument N, go up to level N and then take that tree.  If N is
783 negative then go up that many levels.  With a @kbd{C-u} prefix, do not remove
784 the previously used indirect buffer.
785 @end table
787 When Emacs first visits an Org file, the global state is set to
788 OVERVIEW, i.e. only the top level headlines are visible.  This can be
789 configured through the variable @code{org-startup-folded}, or on a
790 per-file basis by adding one of the following lines anywhere in the
791 buffer:
793 @example
794 #+STARTUP: overview
795 #+STARTUP: content
796 #+STARTUP: showall
797 @end example
799 @node Motion, Structure editing, Visibility cycling, Document Structure
800 @section Motion
801 @cindex motion, between headlines
802 @cindex jumping, to headlines
803 @cindex headline navigation
804 The following commands jump to other headlines in the buffer.
806 @table @kbd
807 @kindex C-c C-n
808 @item C-c C-n
809 Next heading.
810 @kindex C-c C-p
811 @item C-c C-p
812 Previous heading.
813 @kindex C-c C-f
814 @item C-c C-f
815 Next heading same level.
816 @kindex C-c C-b
817 @item C-c C-b
818 Previous heading same level.
819 @kindex C-c C-u
820 @item C-c C-u
821 Backward to higher level heading.
822 @kindex C-c C-j
823 @item C-c C-j
824 Jump to a different place without changing the current outline
825 visibility.  Shows the document structure in a temporary buffer, where
826 you can use the following keys to find your destination:
827 @example
828 @key{TAB}         @r{Cycle visibility.}
829 @key{down} / @key{up}   @r{Next/previous visible headline.}
830 n / p        @r{Next/previous visible headline.}
831 f / b        @r{Next/previous headline same level.}
832 u            @r{One level up.}
833 0-9          @r{Digit argument.}
834 @key{RET}         @r{Select this location.}
835 @end example
836 @end table
838 @node Structure editing, Archiving, Motion, Document Structure
839 @section Structure editing
840 @cindex structure editing
841 @cindex headline, promotion and demotion
842 @cindex promotion, of subtrees
843 @cindex demotion, of subtrees
844 @cindex subtree, cut and paste
845 @cindex pasting, of subtrees
846 @cindex cutting, of subtrees
847 @cindex copying, of subtrees
848 @cindex subtrees, cut and paste
850 @table @kbd
851 @kindex M-@key{RET}
852 @item M-@key{RET}
853 Insert new heading with same level as current.  If the cursor is in a
854 plain list item, a new item is created (@pxref{Plain lists}).  To force
855 creation of a new headline, use a prefix argument, or first press @key{RET}
856 to get to the beginning of the next line.  When this command is used in
857 the middle of a line, the line is split and the rest of the line becomes
858 the new headline@footnote{If you do not want the line to be split,
859 customize the variable @code{org-M-RET-may-split-line}.}.  If the
860 command is used at the beginning of a headline, the new headline is
861 created before the current line.  If at the beginning of any other line,
862 the content of that line is made the new heading.  If the command is
863 used at the end of a folded subtree (i.e. behind the ellipses at the end
864 of a headline), then a headline like the current one will be inserted
865 after the end of the subtree.
866 @kindex C-@key{RET}
867 @item C-@key{RET}
868 Insert a new heading after the current subtree, same level as the
869 current headline.  This command works from anywhere in the entry.
870 @kindex M-S-@key{RET}
871 @item M-S-@key{RET}
872 Insert new TODO entry with same level as current heading.
873 @kindex M-@key{left}
874 @item M-@key{left}
875 Promote current heading by one level.
876 @kindex M-@key{right}
877 @item M-@key{right}
878 Demote current heading by one level.
879 @kindex M-S-@key{left}
880 @item M-S-@key{left}
881 Promote the current subtree by one level.
882 @kindex M-S-@key{right}
883 @item M-S-@key{right}
884 Demote the current subtree by one level.
885 @kindex M-S-@key{up}
886 @item M-S-@key{up}
887 Move subtree up (swap with previous subtree of same
888 level).
889 @kindex M-S-@key{down}
890 @item M-S-@key{down}
891 Move subtree down (swap with next subtree of same level).
892 @kindex C-c C-x C-w
893 @kindex C-c C-x C-k
894 @item C-c C-x C-w
895 @itemx C-c C-x C-k
896 Kill subtree, i.e. remove it from buffer but save in kill ring.
897 With a numeric prefix argument N, kill N sequential subtrees.
898 @kindex C-c C-x M-w
899 @item C-c C-x M-w
900 Copy subtree to kill ring.  With a numeric prefix argument N, copy the N
901 sequential subtrees.
902 @kindex C-c C-x C-y
903 @item C-c C-x C-y
904 Yank subtree from kill ring.  This does modify the level of the subtree to
905 make sure the tree fits in nicely at the yank position.  The yank level can
906 also be specified with a numeric prefix argument, or by yanking after a
907 headline marker like @samp{****}.
908 @kindex C-c C-w
909 @item C-c C-w
910 Refile entry to a different location.  @xref{Refiling notes}.
911 @kindex C-c ^
912 @item C-c ^
913 Sort same-level entries.  When there is an active region, all entries in the
914 region will be sorted.  Otherwise the children of the current headline are
915 sorted.  The command prompts for the sorting method, which can be
916 alphabetically, numerically, by time (using the first time stamp in each
917 entry), by priority, or by TODO keyword (in the sequence the keywords have
918 been defined in the setup).  Reverse sorting is possible as well.  You can
919 also supply your own function to extract the sorting key.  With a @kbd{C-u}
920 prefix, sorting will be case-sensitive.  With two @kbd{C-u C-u} prefixes,
921 duplicate entries will also be removed.
922 @kindex C-c *
923 @item C-c *
924 Turn a normal line or plain list item into a headline (so that it
925 becomes a subheading at its location).  Also turn a headline into a
926 normal line by removing the stars.  If there is an active region, turn
927 all lines in the region into headlines.  Or, if the first line is a
928 headline, remove the stars from all headlines in the region.
929 @end table
931 @cindex region, active
932 @cindex active region
933 @cindex Transient mark mode
934 When there is an active region (Transient mark mode), promotion and
935 demotion work on all headlines in the region.  To select a region of
936 headlines, it is best to place both point and mark at the beginning of a
937 line, mark at the beginning of the first headline, and point at the line
938 just after the last headline to change.  Note that when the cursor is
939 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
940 functionality.
942 @node Archiving, Sparse trees, Structure editing, Document Structure
943 @section Archiving
944 @cindex archiving
946 When a project represented by a (sub)tree is finished, you may want
947 to move the tree out of the way and to stop it from contributing to the
948 agenda.  Org mode knows two ways of archiving.  You can mark a tree with
949 the ARCHIVE tag, or you can move an entire (sub)tree to a different
950 location.
952 @menu
953 * ARCHIVE tag::                 Marking a tree as inactive
954 * Moving subtrees::             Moving a tree to an archive file
955 @end menu
957 @node ARCHIVE tag, Moving subtrees, Archiving, Archiving
958 @subsection The ARCHIVE tag
959 @cindex internal archiving
961 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
962 its location in the outline tree, but behaves in the following way:
963 @itemize @minus
964 @item
965 It does not open when you attempt to do so with a visibility cycling
966 command (@pxref{Visibility cycling}).  You can force cycling archived
967 subtrees with @kbd{C-@key{TAB}}, or by setting the option
968 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
969 @code{show-all} will open archived subtrees.
970 @item
971 During sparse tree construction (@pxref{Sparse trees}), matches in
972 archived subtrees are not exposed, unless you configure the option
973 @code{org-sparse-tree-open-archived-trees}.
974 @item
975 During agenda view construction (@pxref{Agenda Views}), the content of
976 archived trees is ignored unless you configure the option
977 @code{org-agenda-skip-archived-trees}.
978 @item
979 Archived trees are not exported (@pxref{Exporting}), only the headline
980 is.  Configure the details using the variable
981 @code{org-export-with-archived-trees}.
982 @end itemize
984 The following commands help managing the ARCHIVE tag:
986 @table @kbd
987 @kindex C-c C-x a
988 @item C-c C-x a
989 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
990 the headline changes to a shadowed face, and the subtree below it is
991 hidden.
992 @kindex C-u C-c C-x a
993 @item C-u C-c C-x a
994 Check if any direct children of the current headline should be archived.
995 To do this, each subtree is checked for open TODO entries.  If none are
996 found, the command offers to set the ARCHIVE tag for the child.  If the
997 cursor is @emph{not} on a headline when this command is invoked, the
998 level 1 trees will be checked.
999 @kindex C-@kbd{TAB}
1000 @item C-@kbd{TAB}
1001 Cycle a tree even if it is tagged with ARCHIVE.
1002 @end table
1004 @node Moving subtrees,  , ARCHIVE tag, Archiving
1005 @subsection Moving subtrees
1006 @cindex external archiving
1008 Once an entire project is finished, you may want to move it to a different
1009 location.  Org can move it to an @emph{Attic Sibling} in the same tree, to a
1010 different tree in the current file, or to a different file, the archive file.
1012 @table @kbd
1013 @kindex C-c C-x A
1014 @item C-c C-x A
1015 Move the current entry to the @emph{Attic Sibling}.  This is a sibling of the
1016 entry with the heading @samp{Attic} and the tag @samp{ARCHIVE}
1017 (@pxref{ARCHIVE tag}).  The entry becomes a child of that sibling and in this
1018 way retains a lot of its original context, including inherited tags and
1019 approximate position in the outline.
1020 @kindex C-c C-x C-s
1021 @item C-c C-x C-s
1022 Archive the subtree starting at the cursor position to the location
1023 given by @code{org-archive-location}.  Context information that could be
1024 lost like the file name, the category, inherited tags, and the TODO
1025 state will be store as properties in the entry.
1026 @kindex C-u C-c C-x C-s
1027 @item C-u C-c C-x C-s
1028 Check if any direct children of the current headline could be moved to
1029 the archive.  To do this, each subtree is checked for open TODO entries.
1030 If none are found, the command offers to move it to the archive
1031 location.  If the cursor is @emph{not} on a headline when this command
1032 is invoked, the level 1 trees will be checked.
1033 @end table
1035 @cindex archive locations
1036 The default archive location is a file in the same directory as the
1037 current file, with the name derived by appending @file{_archive} to the
1038 current file name.  For information and examples on how to change this,
1039 see the documentation string of the variable
1040 @code{org-archive-location}.  There is also an in-buffer option for
1041 setting this variable, for example@footnote{For backward compatibility,
1042 the following also works: If there are several such lines in a file,
1043 each specifies the archive location for the text below it.  The first
1044 such line also applies to any text before its definition.  However,
1045 using this method is @emph{strongly} deprecated as it is incompatible
1046 with the outline structure of the document.  The correct method for
1047 setting multiple archive locations in a buffer is using a property.}:
1049 @example
1050 #+ARCHIVE: %s_done::
1051 @end example
1053 @noindent
1054 If you would like to have a special ARCHIVE location for a single entry
1055 or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
1056 location as the value (@pxref{Properties and Columns}).
1058 When a subtree is moved, it receives a number of special properties that
1059 record context information like the file from where the entry came, it's
1060 outline path the archiving time etc.  Configure the variable
1061 @code{org-archive-save-context-info} to adjust the amount of information
1062 added.
1064 @node Sparse trees, Plain lists, Archiving, Document Structure
1065 @section Sparse trees
1066 @cindex sparse trees
1067 @cindex trees, sparse
1068 @cindex folding, sparse trees
1069 @cindex occur, command
1071 An important feature of Org mode is the ability to construct
1072 @emph{sparse trees} for selected information in an outline tree, so that
1073 the entire document is folded as much as possible, but the selected
1074 information is made visible along with the headline structure above
1075 it@footnote{See also the variables @code{org-show-hierarchy-above},
1076 @code{org-show-following-heading}, and @code{org-show-siblings} for
1077 detailed control on how much context is shown around each match.}.  Just
1078 try it out and you will see immediately how it works.
1080 Org mode contains several commands creating such trees, all these
1081 commands can be accessed through a dispatcher:
1083 @table @kbd
1084 @kindex C-c /
1085 @item C-c /
1086 This prompts for an extra key to select a sparse-tree creating command.
1087 @kindex C-c / r
1088 @item C-c / r
1089 Occur.  Prompts for a regexp and shows a sparse tree with all matches.
1090 If the match is in a headline, the headline is made visible.  If the
1091 match is in the body of an entry, headline and body are made visible.
1092 In order to provide minimal context, also the full hierarchy of
1093 headlines above the match is shown, as well as the headline following
1094 the match.  Each match is also highlighted; the highlights disappear
1095 when the buffer is changed by an editing command, or by pressing
1096 @kbd{C-c C-c}.  When called with a @kbd{C-u} prefix argument, previous
1097 highlights are kept, so several calls to this command can be stacked.
1098 @end table
1100 @noindent
1101 For frequently used sparse trees of specific search strings, you can
1102 use the variable @code{org-agenda-custom-commands} to define fast
1103 keyboard access to specific sparse trees.  These commands will then be
1104 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
1105 For example:
1107 @lisp
1108 (setq org-agenda-custom-commands
1109       '(("f" occur-tree "FIXME")))
1110 @end lisp
1112 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
1113 a sparse tree matching the string @samp{FIXME}.
1115 The other sparse tree commands select headings based on TODO keywords,
1116 tags, or properties and will be discussed later in this manual.
1118 @kindex C-c C-e v
1119 @cindex printing sparse trees
1120 @cindex visible text, printing
1121 To print a sparse tree, you can use the Emacs command
1122 @code{ps-print-buffer-with-faces} which does not print invisible parts
1123 of the document @footnote{This does not work under XEmacs, because
1124 XEmacs uses selective display for outlining, not text properties.}.
1125 Or you can use the command @kbd{C-c C-e v} to export only the visible
1126 part of the document and print the resulting file.
1128 @node Plain lists, Drawers, Sparse trees, Document Structure
1129 @section Plain lists
1130 @cindex plain lists
1131 @cindex lists, plain
1132 @cindex lists, ordered
1133 @cindex ordered lists
1135 Within an entry of the outline tree, hand-formatted lists can provide
1136 additional structure.  They also provide a way to create lists of
1137 checkboxes (@pxref{Checkboxes}).  Org supports editing such lists,
1138 and the HTML exporter (@pxref{Exporting}) parses and formats them.
1140 Org knows ordered lists, unordered lists, and description lists.
1141 @itemize @bullet
1142 @item
1143 @emph{Unordered} list items start with @samp{-}, @samp{+}, or
1144 @samp{*}@footnote{When using @samp{*} as a bullet, lines must be indented or
1145 they will be seen as top-level headlines.  Also, when you are hiding leading
1146 stars to get a clean outline view, plain list items starting with a star are
1147 visually indistinguishable from true headlines.  In short: even though
1148 @samp{*} is supported, it may be better to not use it for plain list items.}
1149 as bullets.
1150 @item
1151 @emph{Ordered} list items start with a numeral followed by either a period or
1152 a right parenthesis, such as @samp{1.} or @samp{1)}.
1153 @item
1154 @emph{Description} list items are like unordered list items, but contain the
1155 separator @samp{ :: } to separate the description @emph{term} from the
1156 desciption.
1157 @end itemize
1159 Items belonging to the same list must have the same indentation on the first
1160 line.  In particular, if an ordered list reaches number @samp{10.}, then the
1161 2--digit numbers must be written left-aligned with the other numbers in the
1162 list.  Indentation also determines the end of a list item.  It ends before
1163 the next line that is indented like the bullet/number, or less.  Empty lines
1164 are part of the previous item, so you can have several paragraphs in one
1165 item.  If you would like an empty line to terminate all currently open plain
1166 lists, configure the variable @code{org-empty-line-terminates-plain-lists}.
1167 Here is an example:
1169 @example
1170 @group
1171 ** Lord of the Rings
1172    My favorite scenes are (in this order)
1173    1. The attack of the Rohirrim
1174    2. Eowyns fight with the witch king
1175       + this was already my favorite scene in the book
1176       + I really like Miranda Otto.
1177    3. Peter Jackson being shot by Legolas
1178        - on DVD only
1179       He makes a really funny face when it happens.
1180    But in the end, not individual scenes matter but the film as a whole.
1181    Important actors in this film are:
1182    - @b{Elijah Wood} :: He plays the Frodo
1183    - @b{Sean Austin} :: He plays the Sam, Frodos friend.  I still remember
1184      him very well from his role as Mikey Walsh a in the Goonies.
1185 @end group
1186 @end example
1188 Org supports these lists by tuning filling and wrapping commands to
1189 deal with them correctly@footnote{Org only changes the filling
1190 settings for Emacs.  For XEmacs, you should use Kyle E. Jones'
1191 @file{filladapt.el}.  To turn this on,  put into @file{.emacs}:
1192 @code{(require 'filladapt)}}, and by exporting them properly
1193 (@pxref{Exporting}).
1195 The following commands act on items when the cursor is in the first line
1196 of an item (the line with the bullet or number).
1198 @table @kbd
1199 @kindex @key{TAB}
1200 @item @key{TAB}
1201 Items can be folded just like headline levels if you set the variable
1202 @code{org-cycle-include-plain-lists}.  The level of an item is then
1203 given by the indentation of the bullet/number.  Items are always
1204 subordinate to real headlines, however; the hierarchies remain
1205 completely separated.
1207 If @code{org-cycle-include-plain-lists} has not been set, @key{TAB}
1208 fixes the indentation of the current line in a heuristic way.
1209 @kindex M-@key{RET}
1210 @item M-@key{RET}
1211 Insert new item at current level.  With a prefix argument, force a new
1212 heading (@pxref{Structure editing}).  If this command is used in the middle
1213 of a line, the line is @emph{split} and the rest of the line becomes the new
1214 item@footnote{If you do not want the line to be split, customize the variable
1215 @code{org-M-RET-may-split-line}.}.  If this command is executed in the
1216 @emph{whitespace before a bullet or number}, the new item is created
1217 @emph{before} the current item.  If the command is executed in the white
1218 space before the text that is part of an item but does not contain the
1219 bullet, a bullet is added to the current line.
1220 @kindex M-S-@key{RET}
1221 @item M-S-@key{RET}
1222 Insert a new item with a checkbox (@pxref{Checkboxes}).
1223 @kindex S-@key{up}
1224 @kindex S-@key{down}
1225 @item S-@key{up}
1226 @itemx S-@key{down}
1227 Jump to the previous/next item in the current list.
1228 @kindex M-S-@key{up}
1229 @kindex M-S-@key{down}
1230 @item M-S-@key{up}
1231 @itemx M-S-@key{down}
1232 Move the item including subitems up/down (swap with previous/next item
1233 of same indentation).  If the list is ordered, renumbering is
1234 automatic.
1235 @kindex M-S-@key{left}
1236 @kindex M-S-@key{right}
1237 @item M-S-@key{left}
1238 @itemx M-S-@key{right}
1239 Decrease/increase the indentation of the item, including subitems.
1240 Initially, the item tree is selected based on current indentation.
1241 When these commands are executed several times in direct succession,
1242 the initially selected region is used, even if the new indentation
1243 would imply a different hierarchy.  To use the new hierarchy, break
1244 the command chain with a cursor motion or so.
1245 @kindex C-c C-c
1246 @item C-c C-c
1247 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1248 state of the checkbox.  If not, this command makes sure that all the
1249 items on this list level use the same bullet.  Furthermore, if this is
1250 an ordered list, make sure the numbering is OK.
1251 @kindex C-c -
1252 @item C-c -
1253 Cycle the entire list level through the different itemize/enumerate bullets
1254 (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}).  With a numeric prefix
1255 argument N, select the Nth bullet from this list.  If there is an active
1256 region when calling this, all lines will be converted to list items.  If the
1257 first line already was a list item, any item markers will be removed from the
1258 list.  Finally, even without an active region, a normal line will be
1259 converted into a list item.
1260 @end table
1262 @node Drawers, Orgstruct mode, Plain lists, Document Structure
1263 @section Drawers
1264 @cindex drawers
1265 @cindex visibility cycling, drawers
1267 Sometimes you want to keep information associated with an entry, but you
1268 normally don't want to see it.  For this, Org mode has @emph{drawers}.
1269 Drawers need to be configured with the variable
1270 @code{org-drawers}@footnote{You can define drawers on a per-file basis
1271 with a line like @code{#+DRAWERS: HIDDEN PROPERTIES STATE}}.  Drawers
1272 look like this:
1274 @example
1275 ** This is a headline
1276    Still outside the drawer
1277    :DRAWERNAME:
1278       This is inside the drawer.
1279    :END:
1280    After the drawer.
1281 @end example
1283 Visibility cycling (@pxref{Visibility cycling}) on the headline will
1284 hide and show the entry, but keep the drawer collapsed to a single line.
1285 In order to look inside the drawer, you need to move the cursor to the
1286 drawer line and press @key{TAB} there.  Org mode uses a drawer for
1287 storing properties (@pxref{Properties and Columns}), and another one for
1288 storing clock times (@pxref{Clocking work time}).
1290 @node Orgstruct mode,  , Drawers, Document Structure
1291 @section The Orgstruct minor mode
1292 @cindex Orgstruct mode
1293 @cindex minor mode for structure editing
1295 If you like the intuitive way the Org mode structure editing and list
1296 formatting works, you might want to use these commands in other modes
1297 like Text mode or Mail mode as well.  The minor mode Orgstruct mode
1298 makes this possible.  You can always toggle the mode with @kbd{M-x
1299 orgstruct-mode}.  To turn it on by default, for example in Mail mode,
1302 @lisp
1303 (add-hook 'mail-mode-hook 'turn-on-orgstruct)
1304 @end lisp
1306 When this mode is active and the cursor is on a line that looks to
1307 Org like a headline of the first line of a list item, most
1308 structure editing commands will work, even if the same keys normally
1309 have different functionality in the major mode you are using.  If the
1310 cursor is not in one of those special lines, Orgstruct mode lurks
1311 silently in the shadow.
1313 @node Tables, Hyperlinks, Document Structure, Top
1314 @chapter Tables
1315 @cindex tables
1316 @cindex editing tables
1318 Org comes with a fast and intuitive table editor.  Spreadsheet-like
1319 calculations are supported in connection with the Emacs @file{calc}
1320 package
1321 @ifinfo
1322 (@pxref{Top,Calc,,Calc,Gnu Emacs Calculator Manual}).
1323 @end ifinfo
1324 @ifnotinfo
1325 (see the Emacs Calculator manual for more information about the Emacs
1326 calculator).
1327 @end ifnotinfo
1329 @menu
1330 * Built-in table editor::       Simple tables
1331 * Narrow columns::              Stop wasting space in tables
1332 * Column groups::               Grouping to trigger vertical lines
1333 * Orgtbl mode::                 The table editor as minor mode
1334 * The spreadsheet::             The table editor has spreadsheet capabilities
1335 @end menu
1337 @node Built-in table editor, Narrow columns, Tables, Tables
1338 @section The built-in table editor
1339 @cindex table editor, built-in
1341 Org makes it easy to format tables in plain ASCII.  Any line with
1342 @samp{|} as the first non-whitespace character is considered part of a
1343 table.  @samp{|} is also the column separator.  A table might look like
1344 this:
1346 @example
1347 | Name  | Phone | Age |
1348 |-------+-------+-----|
1349 | Peter |  1234 |  17 |
1350 | Anna  |  4321 |  25 |
1351 @end example
1353 A table is re-aligned automatically each time you press @key{TAB} or
1354 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
1355 the next field (@key{RET} to the next row) and creates new table rows
1356 at the end of the table or before horizontal lines.  The indentation
1357 of the table is set by the first line.  Any line starting with
1358 @samp{|-} is considered as a horizontal separator line and will be
1359 expanded on the next re-align to span the whole table width.  So, to
1360 create the above table, you would only type
1362 @example
1363 |Name|Phone|Age|
1365 @end example
1367 @noindent and then press @key{TAB} to align the table and start filling in
1368 fields.
1370 When typing text into a field, Org treats @key{DEL},
1371 @key{Backspace}, and all character keys in a special way, so that
1372 inserting and deleting avoids shifting other fields.  Also, when
1373 typing @emph{immediately after the cursor was moved into a new field
1374 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
1375 field is automatically made blank.  If this behavior is too
1376 unpredictable for you, configure the variables
1377 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
1379 @table @kbd
1380 @tsubheading{Creation and conversion}
1381 @kindex C-c |
1382 @item C-c |
1383 Convert the active region to table. If every line contains at least one
1384 TAB character, the function assumes that the material is tab separated.
1385 If every line contains a comma, comma-separated values (CSV) are assumed.
1386 If not, lines are split at whitespace into fields.  You can use a prefix
1387 argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
1388 C-u} forces TAB, and a numeric argument N indicates that at least N
1389 consecutive spaces, or alternatively a TAB will be the separator.
1391 If there is no active region, this command creates an empty Org
1392 table.  But it's easier just to start typing, like
1393 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
1395 @tsubheading{Re-aligning and field motion}
1396 @kindex C-c C-c
1397 @item C-c C-c
1398 Re-align the table without moving the cursor.
1400 @kindex @key{TAB}
1401 @item @key{TAB}
1402 Re-align the table, move to the next field.  Creates a new row if
1403 necessary.
1405 @kindex S-@key{TAB}
1406 @item S-@key{TAB}
1407 Re-align, move to previous field.
1409 @kindex @key{RET}
1410 @item @key{RET}
1411 Re-align the table and move down to next row.  Creates a new row if
1412 necessary.  At the beginning or end of a line, @key{RET} still does
1413 NEWLINE, so it can be used to split a table.
1415 @tsubheading{Column and row editing}
1416 @kindex M-@key{left}
1417 @kindex M-@key{right}
1418 @item M-@key{left}
1419 @itemx M-@key{right}
1420 Move the current column left/right.
1422 @kindex M-S-@key{left}
1423 @item M-S-@key{left}
1424 Kill the current column.
1426 @kindex M-S-@key{right}
1427 @item M-S-@key{right}
1428 Insert a new column to the left of the cursor position.
1430 @kindex M-@key{up}
1431 @kindex M-@key{down}
1432 @item M-@key{up}
1433 @itemx M-@key{down}
1434 Move the current row up/down.
1436 @kindex M-S-@key{up}
1437 @item M-S-@key{up}
1438 Kill the current row or horizontal line.
1440 @kindex M-S-@key{down}
1441 @item M-S-@key{down}
1442 Insert a new row above the current row.  With a prefix argument, the line is
1443 created below the current one.
1445 @kindex C-c -
1446 @item C-c -
1447 Insert a horizontal line below current row. With a prefix argument, the line
1448 is created above the current line.
1450 @kindex C-c ^
1451 @item C-c ^
1452 Sort the table lines in the region.  The position of point indicates the
1453 column to be used for sorting, and the range of lines is the range
1454 between the nearest horizontal separator lines, or the entire table.  If
1455 point is before the first column, you will be prompted for the sorting
1456 column.  If there is an active region, the mark specifies the first line
1457 and the sorting column, while point should be in the last line to be
1458 included into the sorting.  The command prompts for the sorting type
1459 (alphabetically, numerically, or by time).  When called with a prefix
1460 argument, alphabetic sorting will be case-sensitive.
1462 @tsubheading{Regions}
1463 @kindex C-c C-x M-w
1464 @item C-c C-x M-w
1465 Copy a rectangular region from a table to a special clipboard.  Point
1466 and mark determine edge fields of the rectangle.  The process ignores
1467 horizontal separator lines.
1469 @kindex C-c C-x C-w
1470 @item C-c C-x C-w
1471 Copy a rectangular region from a table to a special clipboard, and
1472 blank all fields in the rectangle.  So this is the ``cut'' operation.
1474 @kindex C-c C-x C-y
1475 @item C-c C-x C-y
1476 Paste a rectangular region into a table.
1477 The upper right corner ends up in the current field.  All involved fields
1478 will be overwritten.  If the rectangle does not fit into the present table,
1479 the table is enlarged as needed.  The process ignores horizontal separator
1480 lines.
1482 @kindex C-c C-q
1483 @kindex M-@key{RET}
1484 @item C-c C-q
1485 @itemx M-@kbd{RET}
1486 Wrap several fields in a column like a paragraph.  If there is an active
1487 region, and both point and mark are in the same column, the text in the
1488 column is wrapped to minimum width for the given number of lines.  A numeric
1489 prefix argument may be used to change the number of desired lines.  If there
1490 is no region, the current field is split at the cursor position and the text
1491 fragment to the right of the cursor is prepended to the field one line
1492 down. If there is no region, but you specify a prefix argument, the current
1493 field is made blank, and the content is appended to the field above.
1495 @tsubheading{Calculations}
1496 @cindex formula, in tables
1497 @cindex calculations, in tables
1498 @cindex region, active
1499 @cindex active region
1500 @cindex Transient mark mode
1501 @kindex C-c +
1502 @item C-c +
1503 Sum the numbers in the current column, or in the rectangle defined by
1504 the active region.  The result is shown in the echo area and can
1505 be inserted with @kbd{C-y}.
1507 @kindex S-@key{RET}
1508 @item S-@key{RET}
1509 When current field is empty, copy from first non-empty field above.
1510 When not empty, copy current field down to next row and move cursor
1511 along with it.  Depending on the variable
1512 @code{org-table-copy-increment}, integer field values will be
1513 incremented during copy.  This key is also used by CUA mode
1514 (@pxref{Cooperation}).
1516 @tsubheading{Miscellaneous}
1517 @kindex C-c `
1518 @item C-c `
1519 Edit the current field in a separate window.  This is useful for fields
1520 that are not fully visible (@pxref{Narrow columns}).  When called with a
1521 @kbd{C-u} prefix, just make the full field visible, so that it can be
1522 edited in place.
1524 @item M-x org-table-import
1525 Import a file as a table.  The table should be TAB- or whitespace
1526 separated.  Useful, for example, to import a spreadsheet table or data
1527 from a database, because these programs generally can write
1528 TAB-separated text files.  This command works by inserting the file into
1529 the buffer and then converting the region to a table.  Any prefix
1530 argument is passed on to the converter, which uses it to determine the
1531 separator.
1532 @item C-c |
1533 Tables can also be imported by pasting tabular text into the Org
1534 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
1535 @kbd{C-c |} command (see above under @i{Creation and conversion}.
1537 @item M-x org-table-export
1538 Export the table, by default as a TAB-separated file.  Useful for data
1539 exchange with, for example, spreadsheet or database programs.  The format
1540 used to export the file can be configured in the variable
1541 @code{org-table-export-default-format}.  You may also use properties
1542 @code{TABLE_EXPORT_FILE} and @code{TABLE_EXPORT_FORMAT} to specify the file
1543 name and the format for table export in a subtree.
1544 @end table
1546 If you don't like the automatic table editor because it gets in your
1547 way on lines which you would like to start with @samp{|}, you can turn
1548 it off with
1550 @lisp
1551 (setq org-enable-table-editor nil)
1552 @end lisp
1554 @noindent Then the only table command that still works is
1555 @kbd{C-c C-c} to do a manual re-align.
1557 @node Narrow columns, Column groups, Built-in table editor, Tables
1558 @section Narrow columns
1559 @cindex narrow columns in tables
1561 The width of columns is automatically determined by the table editor.
1562 Sometimes a single field or a few fields need to carry more text,
1563 leading to inconveniently wide columns.  To limit@footnote{This feature
1564 does not work on XEmacs.} the width of a column, one field anywhere in
1565 the column may contain just the string @samp{<N>} where @samp{N} is an
1566 integer specifying the width of the column in characters.  The next
1567 re-align will then set the width of this column to no more than this
1568 value.
1570 @example
1571 @group
1572 |---+------------------------------|               |---+--------|
1573 |   |                              |               |   | <6>    |
1574 | 1 | one                          |               | 1 | one    |
1575 | 2 | two                          |     ----\     | 2 | two    |
1576 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
1577 | 4 | four                         |               | 4 | four   |
1578 |---+------------------------------|               |---+--------|
1579 @end group
1580 @end example
1582 @noindent
1583 Fields that are wider become clipped and end in the string @samp{=>}.
1584 Note that the full text is still in the buffer, it is only invisible.
1585 To see the full text, hold the mouse over the field - a tool-tip window
1586 will show the full content.  To edit such a field, use the command
1587 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
1588 open a new window with the full field.  Edit it and finish with @kbd{C-c
1589 C-c}.
1591 When visiting a file containing a table with narrowed columns, the
1592 necessary character hiding has not yet happened, and the table needs to
1593 be aligned before it looks nice.  Setting the option
1594 @code{org-startup-align-all-tables} will realign all tables in a file
1595 upon visiting, but also slow down startup.  You can also set this option
1596 on a per-file basis with:
1598 @example
1599 #+STARTUP: align
1600 #+STARTUP: noalign
1601 @end example
1603 @node Column groups, Orgtbl mode, Narrow columns, Tables
1604 @section Column groups
1605 @cindex grouping columns in tables
1607 When Org exports tables, it does so by default without vertical
1608 lines because that is visually more satisfying in general.  Occasionally
1609 however, vertical lines can be useful to structure a table into groups
1610 of columns, much like horizontal lines can do for groups of rows.  In
1611 order to specify column groups, you can use a special row where the
1612 first field contains only @samp{/}.  The further fields can either
1613 contain @samp{<} to indicate that this column should start a group,
1614 @samp{>} to indicate the end of a column, or @samp{<>} to make a column
1615 a group of its own.  Boundaries between column groups will upon export be
1616 marked with vertical lines.  Here is an example:
1618 @example
1619 |   |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1620 |---+----+-----+-----+-----+---------+------------|
1621 | / | <> |   < |     |   > |       < |          > |
1622 | # |  1 |   1 |   1 |   1 |       1 |          1 |
1623 | # |  2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
1624 | # |  3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
1625 |---+----+-----+-----+-----+---------+------------|
1626 #+TBLFM: $3=$2^2::$4=$2^3::$5=$2^4::$6=sqrt($2)::$7=sqrt(sqrt(($2))
1627 @end example
1629 It is also sufficient to just insert the column group starters after
1630 every vertical line you'd like to have:
1632 @example
1633 |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1634 |----+-----+-----+-----+---------+------------|
1635 | /  | <   |     |     | <       |            |
1636 @end example
1638 @node Orgtbl mode, The spreadsheet, Column groups, Tables
1639 @section The Orgtbl minor mode
1640 @cindex Orgtbl mode
1641 @cindex minor mode for tables
1643 If you like the intuitive way the Org table editor works, you
1644 might also want to use it in other modes like Text mode or Mail mode.
1645 The minor mode Orgtbl mode makes this possible.  You can always toggle
1646 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
1647 example in mail mode, use
1649 @lisp
1650 (add-hook 'mail-mode-hook 'turn-on-orgtbl)
1651 @end lisp
1653 Furthermore, with some special setup, it is possible to maintain tables
1654 in arbitrary syntax with Orgtbl mode.  For example, it is possible to
1655 construct La@TeX{} tables with the underlying ease and power of
1656 Orgtbl mode, including spreadsheet capabilities.  For details, see
1657 @ref{Tables in arbitrary syntax}.
1659 @node The spreadsheet,  , Orgtbl mode, Tables
1660 @section The spreadsheet
1661 @cindex calculations, in tables
1662 @cindex spreadsheet capabilities
1663 @cindex @file{calc} package
1665 The table editor makes use of the Emacs @file{calc} package to implement
1666 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
1667 derive fields from other fields.  While fully featured, Org's
1668 implementation is not identical to other spreadsheets.  For example,
1669 Org knows the concept of a @emph{column formula} that will be
1670 applied to all non-header fields in a column without having to copy the
1671 formula to each relevant field.
1673 @menu
1674 * References::                  How to refer to another field or range
1675 * Formula syntax for Calc::     Using Calc to compute stuff
1676 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
1677 * Field formulas::              Formulas valid for a single field
1678 * Column formulas::             Formulas valid for an entire column
1679 * Editing and debugging formulas::  Fixing formulas
1680 * Updating the table::          Recomputing all dependent fields
1681 * Advanced features::           Field names, parameters and automatic recalc
1682 @end menu
1684 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
1685 @subsection References
1686 @cindex references
1688 To compute fields in the table from other fields, formulas must
1689 reference other fields or ranges.  In Org, fields can be referenced
1690 by name, by absolute coordinates, and by relative coordinates.  To find
1691 out what the coordinates of a field are, press @kbd{C-c ?} in that
1692 field, or press @kbd{C-c @}} to toggle the display of a grid.
1694 @subsubheading Field references
1695 @cindex field references
1696 @cindex references, to fields
1698 Formulas can reference the value of another field in two ways.  Like in
1699 any other spreadsheet, you may reference fields with a letter/number
1700 combination like @code{B3}, meaning the 2nd field in the 3rd row.
1701 @c Such references are always fixed to that field, they don't change
1702 @c when you copy and paste a formula to a different field.  So
1703 @c Org's @code{B3} behaves like @code{$B$3} in other spreadsheets.
1705 @noindent
1706 Org also uses another, more general operator that looks like this:
1707 @example
1708 @@row$column
1709 @end example
1711 @noindent
1712 Column references can be absolute like @samp{1}, @samp{2},...@samp{N},
1713 or relative to the current column like @samp{+1} or @samp{-2}.
1715 The row specification only counts data lines and ignores horizontal
1716 separator lines (hlines).  You can use absolute row numbers
1717 @samp{1}...@samp{N}, and row numbers relative to the current row like
1718 @samp{+3} or @samp{-1}.  Or specify the row relative to one of the
1719 hlines: @samp{I} refers to the first hline@footnote{Note that only
1720 hlines are counted that @emph{separate} table lines.  If the table
1721 starts with a hline above the header, it does not count.}, @samp{II} to
1722 the second etc.  @samp{-I} refers to the first such line above the
1723 current line, @samp{+I} to the first such line below the current line.
1724 You can also write @samp{III+2} which is the second data line after the
1725 third hline in the table.  Relative row numbers like @samp{-3} will not
1726 cross hlines if the current line is too close to the hline.  Instead,
1727 the value directly at the hline is used.
1729 @samp{0} refers to the current row and column.  Also, if you omit
1730 either the column or the row part of the reference, the current
1731 row/column is implied.
1733 Org's references with @emph{unsigned} numbers are fixed references
1734 in the sense that if you use the same reference in the formula for two
1735 different fields, the same field will be referenced each time.
1736 Org's references with @emph{signed} numbers are floating
1737 references because the same reference operator can reference different
1738 fields depending on the field being calculated by the formula.
1740 Here are a few examples:
1742 @example
1743 @@2$3      @r{2nd row, 3rd column}
1744 C2        @r{same as previous}
1745 $5        @r{column 5 in the current row}
1746 E&        @r{same as previous}
1747 @@2        @r{current column, row 2}
1748 @@-1$-3    @r{the field one row up, three columns to the left}
1749 @@-I$2     @r{field just under hline above current row, column 2}
1750 @end example
1752 @subsubheading Range references
1753 @cindex range references
1754 @cindex references, to ranges
1756 You may reference a rectangular range of fields by specifying two field
1757 references connected by two dots @samp{..}.  If both fields are in the
1758 current row, you may simply use @samp{$2..$7}, but if at least one field
1759 is in a different row, you need to use the general @code{@@row$column}
1760 format at least for the first field (i.e the reference must start with
1761 @samp{@@} in order to be interpreted correctly).  Examples:
1763 @example
1764 $1..$3        @r{First three fields in the current row.}
1765 $P..$Q        @r{Range, using column names (see under Advanced)}
1766 @@2$1..@@4$3    @r{6 fields between these two fields.}
1767 A2..C4        @r{Same as above.}
1768 @@-1$-2..@@-1   @r{3 numbers from the column to the left, 2 up to current row}
1769 @end example
1771 @noindent Range references return a vector of values that can be fed
1772 into Calc vector functions.  Empty fields in ranges are normally
1773 suppressed, so that the vector contains only the non-empty fields (but
1774 see the @samp{E} mode switch below).  If there are no non-empty fields,
1775 @samp{[0]} is returned to avoid syntax errors in formulas.
1777 @subsubheading Named references
1778 @cindex named references
1779 @cindex references, named
1780 @cindex name, of column or field
1781 @cindex constants, in calculations
1783 @samp{$name} is interpreted as the name of a column, parameter or
1784 constant.  Constants are defined globally through the variable
1785 @code{org-table-formula-constants}, and locally (for the file) through a
1786 line like
1788 @example
1789 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
1790 @end example
1792 @noindent
1793 Also properties (@pxref{Properties and Columns}) can be used as
1794 constants in table formulas: For a property @samp{:Xyz:} use the name
1795 @samp{$PROP_Xyz}, and the property will be searched in the current
1796 outline entry and in the hierarchy above it.  If you have the
1797 @file{constants.el} package, it will also be used to resolve constants,
1798 including natural constants like @samp{$h} for Planck's constant, and
1799 units like @samp{$km} for kilometers@footnote{@file{Constant.el} can
1800 supply the values of constants in two different unit systems, @code{SI}
1801 and @code{cgs}.  Which one is used depends on the value of the variable
1802 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
1803 @code{constSI} and @code{constcgs} to set this value for the current
1804 buffer.}.  Column names and parameters can be specified in special table
1805 lines.  These are described below, see @ref{Advanced features}.  All
1806 names must start with a letter, and further consist of letters and
1807 numbers.
1809 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
1810 @subsection Formula syntax for Calc
1811 @cindex formula syntax, Calc
1812 @cindex syntax, of formulas
1814 A formula can be any algebraic expression understood by the Emacs
1815 @file{Calc} package.  @b{Note that @file{calc} has the
1816 non-standard convention that @samp{/} has lower precedence than
1817 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
1818 evaluation by @code{calc-eval} (@pxref{Calling Calc from
1819 Your Programs,calc-eval,Calling Calc from Your Lisp Programs,Calc,GNU
1820 Emacs Calc Manual}),
1821 @c FIXME:  The link to the Calc manual in HTML does not work.
1822 variable substitution takes place according to the rules described above.
1823 @cindex vectors, in table calculations
1824 The range vectors can be directly fed into the Calc vector functions
1825 like @samp{vmean} and @samp{vsum}.
1827 @cindex format specifier
1828 @cindex mode, for @file{calc}
1829 A formula can contain an optional mode string after a semicolon.  This
1830 string consists of flags to influence Calc and other modes during
1831 execution.  By default, Org uses the standard Calc modes (precision
1832 12, angular units degrees, fraction and symbolic modes off.  The display
1833 format, however, has been changed to @code{(float 5)} to keep tables
1834 compact.  The default settings can be configured using the variable
1835 @code{org-calc-default-modes}.
1837 @example
1838 p20           @r{switch the internal precision to 20 digits}
1839 n3 s3 e2 f4   @r{normal, scientific, engineering, or fixed display format}
1840 D R           @r{angle modes: degrees, radians}
1841 F S           @r{fraction and symbolic modes}
1842 N             @r{interpret all fields as numbers, use 0 for non-numbers}
1843 T             @r{force text interpretation}
1844 E             @r{keep empty fields in ranges}
1845 @end example
1847 @noindent
1848 In addition, you may provide a @code{printf} format specifier to
1849 reformat the final result.  A few examples:
1851 @example
1852 $1+$2                @r{Sum of first and second field}
1853 $1+$2;%.2f           @r{Same, format result to two decimals}
1854 exp($2)+exp($1)      @r{Math functions can be used}
1855 $0;%.1f              @r{Reformat current cell to 1 decimal}
1856 ($3-32)*5/9          @r{Degrees F -> C conversion}
1857 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
1858 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
1859 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
1860 vmean($2..$7)        @r{Compute column range mean, using vector function}
1861 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
1862 taylor($3,x=7,2)     @r{taylor series of $3, at x=7, second degree}
1863 @end example
1865 Calc also contains a complete set of logical operations.  For example
1867 @example
1868 if($1<20,teen,string(""))  @r{``teen'' if age $1 less than 20, else empty}
1869 @end example
1871 @node Formula syntax for Lisp, Field formulas, Formula syntax for Calc, The spreadsheet
1872 @subsection Emacs Lisp forms as formulas
1873 @cindex Lisp forms, as table formulas
1875 It is also possible to write a formula in Emacs Lisp; this can be useful
1876 for string manipulation and control structures, if the Calc's
1877 functionality is not enough.  If a formula starts with a single quote
1878 followed by an opening parenthesis, then it is evaluated as a lisp form.
1879 The evaluation should return either a string or a number.  Just as with
1880 @file{calc} formulas, you can specify modes and a printf format after a
1881 semicolon.  With Emacs Lisp forms, you need to be conscious about the way
1882 field references are interpolated into the form.  By default, a
1883 reference will be interpolated as a Lisp string (in double quotes)
1884 containing the field.  If you provide the @samp{N} mode switch, all
1885 referenced elements will be numbers (non-number fields will be zero) and
1886 interpolated as Lisp numbers, without quotes.  If you provide the
1887 @samp{L} flag, all fields will be interpolated literally, without quotes.
1888 I.e., if you want a reference to be interpreted as a string by the Lisp
1889 form, enclose the reference operator itself in double quotes, like
1890 @code{"$3"}.  Ranges are inserted as space-separated fields, so you can
1891 embed them in list or vector syntax.  A few examples, note how the
1892 @samp{N} mode is used when we do computations in lisp.
1894 @example
1895 @r{Swap the first two characters of the content of column 1}
1896   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
1897 @r{Add columns 1 and 2, equivalent to the Calc's @code{$1+$2}}
1898   '(+ $1 $2);N
1899 @r{Compute the sum of columns 1-4, like Calc's @code{vsum($1..$4)}}
1900   '(apply '+ '($1..$4));N
1901 @end example
1903 @node Field formulas, Column formulas, Formula syntax for Lisp, The spreadsheet
1904 @subsection Field formulas
1905 @cindex field formula
1906 @cindex formula, for individual table field
1908 To assign a formula to a particular field, type it directly into the
1909 field, preceded by @samp{:=}, for example @samp{:=$1+$2}.  When you
1910 press @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in
1911 the field, the formula will be stored as the formula for this field,
1912 evaluated, and the current field replaced with the result.
1914 Formulas are stored in a special line starting with @samp{#+TBLFM:}
1915 directly below the table.  If you typed the equation in the 4th field of
1916 the 3rd data line in the table, the formula will look like
1917 @samp{@@3$4=$1+$2}.  When inserting/deleting/swapping column and rows
1918 with the appropriate commands, @i{absolute references} (but not relative
1919 ones) in stored formulas are modified in order to still reference the
1920 same field.  Of cause this is not true if you edit the table structure
1921 with normal editing commands - then you must fix the equations yourself.
1923 Instead of typing an equation into the field, you may also use the
1924 following command
1926 @table @kbd
1927 @kindex C-u C-c =
1928 @item C-u C-c =
1929 Install a new formula for the current field.  The command prompts for a
1930 formula, with default taken from the @samp{#+TBLFM:} line, applies
1931 it to the current field and stores it.
1932 @end table
1934 @node Column formulas, Editing and debugging formulas, Field formulas, The spreadsheet
1935 @subsection Column formulas
1936 @cindex column formula
1937 @cindex formula, for table column
1939 Often in a table, the same formula should be used for all fields in a
1940 particular column.  Instead of having to copy the formula to all fields
1941 in that column, Org allows to assign a single formula to an entire
1942 column.  If the table contains horizontal separator hlines, everything
1943 before the first such line is considered part of the table @emph{header}
1944 and will not be modified by column formulas.
1946 To assign a formula to a column, type it directly into any field in the
1947 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
1948 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the
1949 field, the formula will be stored as the formula for the current column,
1950 evaluated and the current field replaced with the result.  If the field
1951 contains only @samp{=}, the previously stored formula for this column is
1952 used.  For each column, Org will only remember the most recently
1953 used formula.  In the @samp{TBLFM:} line, column formulas will look like
1954 @samp{$4=$1+$2}.
1956 Instead of typing an equation into the field, you may also use the
1957 following command:
1959 @table @kbd
1960 @kindex C-c =
1961 @item C-c =
1962 Install a new formula for the current column and replace current field with
1963 the result of the formula.  The command prompts for a formula, with default
1964 taken from the @samp{#+TBLFM} line, applies it to the current field and
1965 stores it.  With a numeric prefix argument(e.g. @kbd{C-5 C-c =}) the command
1966 will apply it to that many consecutive fields in the current column.
1967 @end table
1969 @node Editing and debugging formulas, Updating the table, Column formulas, The spreadsheet
1970 @subsection Editing and debugging formulas
1971 @cindex formula editing
1972 @cindex editing, of table formulas
1974 You can edit individual formulas in the minibuffer or directly in the
1975 field.  Org can also prepare a special buffer with all active
1976 formulas of a table.  When offering a formula for editing, Org
1977 converts references to the standard format (like @code{B3} or @code{D&})
1978 if possible.  If you prefer to only work with the internal format (like
1979 @code{@@3$2} or @code{$4}), configure the variable
1980 @code{org-table-use-standard-references}.
1982 @table @kbd
1983 @kindex C-c =
1984 @kindex C-u C-c =
1985 @item C-c =
1986 @itemx C-u C-c =
1987 Edit the formula associated with the current column/field in the
1988 minibuffer.  See @ref{Column formulas} and @ref{Field formulas}.
1989 @kindex C-u C-u C-c =
1990 @item C-u C-u C-c =
1991 Re-insert the active formula (either a
1992 field formula, or a column formula) into the current field, so that you
1993 can edit it directly in the field.  The advantage over editing in the
1994 minibuffer is that you can use the command @kbd{C-c ?}.
1995 @kindex C-c ?
1996 @item C-c ?
1997 While editing a formula in a table field, highlight the field(s)
1998 referenced by the reference at the cursor position in the formula.
1999 @kindex C-c @}
2000 @item C-c @}
2001 Toggle the display of row and column numbers for a table, using
2002 overlays.  These are updated each time the table is aligned, you can
2003 force it with @kbd{C-c C-c}.
2004 @kindex C-c @{
2005 @item C-c @{
2006 Toggle the formula debugger on and off.  See below.
2007 @kindex C-c '
2008 @item C-c '
2009 Edit all formulas for the current table in a special buffer, where the
2010 formulas will be displayed one per line.  If the current field has an
2011 active formula, the cursor in the formula editor will mark it.
2012 While inside the special buffer, Org will automatically highlight
2013 any field or range reference at the cursor position.  You may edit,
2014 remove and add formulas, and use the following commands:
2015 @table @kbd
2016 @kindex C-c C-c
2017 @kindex C-x C-s
2018 @item C-c C-c
2019 @itemx C-x C-s
2020 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
2021 prefix, also apply the new formulas to the entire table.
2022 @kindex C-c C-q
2023 @item C-c C-q
2024 Exit the formula editor without installing changes.
2025 @kindex C-c C-r
2026 @item C-c C-r
2027 Toggle all references in the formula editor between standard (like
2028 @code{B3}) and internal (like @code{@@3$2}).
2029 @kindex @key{TAB}
2030 @item @key{TAB}
2031 Pretty-print or indent lisp formula at point.  When in a line containing
2032 a lisp formula, format the formula according to Emacs Lisp rules.
2033 Another @key{TAB} collapses the formula back again.  In the open
2034 formula, @key{TAB} re-indents just like in Emacs lisp mode.
2035 @kindex M-@key{TAB}
2036 @item M-@key{TAB}
2037 Complete Lisp symbols, just like in Emacs lisp mode.
2038 @kindex S-@key{up}
2039 @kindex S-@key{down}
2040 @kindex S-@key{left}
2041 @kindex S-@key{right}
2042 @item S-@key{up}/@key{down}/@key{left}/@key{right}
2043 Shift the reference at point.  For example, if the reference is
2044 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
2045 This also works for relative references, and for hline references.
2046 @kindex M-S-@key{up}
2047 @kindex M-S-@key{down}
2048 @item M-S-@key{up}/@key{down}
2049 Move the test line for column formulas in the Org buffer up and
2050 down.
2051 @kindex M-@key{up}
2052 @kindex M-@key{down}
2053 @item M-@key{up}/@key{down}
2054 Scroll the window displaying the table.
2055 @kindex C-c @}
2056 @item C-c @}
2057 Turn the coordinate grid in the table on and off.
2058 @end table
2059 @end table
2061 Making a table field blank does not remove the formula associated with
2062 the field, because that is stored in a different line (the @samp{TBLFM}
2063 line) - during the next recalculation the field will be filled again.
2064 To remove a formula from a field, you have to give an empty reply when
2065 prompted for the formula, or to edit the @samp{#+TBLFM} line.
2067 @kindex C-c C-c
2068 You may edit the @samp{#+TBLFM} directly and re-apply the changed
2069 equations with @kbd{C-c C-c} in that line, or with the normal
2070 recalculation commands in the table.
2072 @subsubheading Debugging formulas
2073 @cindex formula debugging
2074 @cindex debugging, of table formulas
2075 When the evaluation of a formula leads to an error, the field content
2076 becomes the string @samp{#ERROR}.  If you would like see what is going
2077 on during variable substitution and calculation in order to find a bug,
2078 turn on formula debugging in the @code{Tbl} menu and repeat the
2079 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
2080 field.  Detailed information will be displayed.
2082 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
2083 @subsection Updating the table
2084 @cindex recomputing table fields
2085 @cindex updating, table
2087 Recalculation of a table is normally not automatic, but needs to be
2088 triggered by a command.  See @ref{Advanced features} for a way to make
2089 recalculation at least semi-automatically.
2091 In order to recalculate a line of a table or the entire table, use the
2092 following commands:
2094 @table @kbd
2095 @kindex C-c *
2096 @item C-c *
2097 Recalculate the current row by first applying the stored column formulas
2098 from left to right, and all field formulas in the current row.
2100 @kindex C-u C-c *
2101 @item C-u C-c *
2102 @kindex C-u C-c C-c
2103 @itemx C-u C-c C-c
2104 Recompute the entire table, line by line.  Any lines before the first
2105 hline are left alone, assuming that these are part of the table header.
2107 @kindex C-u C-u C-c *
2108 @kindex C-u C-u C-c C-c
2109 @item C-u C-u C-c *
2110 @itemx C-u C-u C-c C-c
2111 Iterate the table by recomputing it until no further changes occur.
2112 This may be necessary if some computed fields use the value of other
2113 fields that are computed @i{later} in the calculation sequence.
2114 @end table
2116 @node Advanced features,  , Updating the table, The spreadsheet
2117 @subsection Advanced features
2119 If you want the recalculation of fields to happen automatically, or if
2120 you want to be able to assign @i{names} to fields and columns, you need
2121 to reserve the first column of the table for special marking characters.
2122 @table @kbd
2123 @kindex C-#
2124 @item C-#
2125 Rotate the calculation mark in first column through the states @samp{},
2126 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  The meaning of these characters
2127 is discussed below.  When there is an active region, change all marks in
2128 the region.
2129 @end table
2131 Here is an example of a table that collects exam results of students and
2132 makes use of these features:
2134 @example
2135 @group
2136 |---+---------+--------+--------+--------+-------+------|
2137 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2138 |---+---------+--------+--------+--------+-------+------|
2139 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2140 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2141 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2142 |---+---------+--------+--------+--------+-------+------|
2143 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
2144 | # | Sara    |      6 |     14 |     19 |    39 |  7.8 |
2145 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
2146 |---+---------+--------+--------+--------+-------+------|
2147 |   | Average |        |        |        |  29.7 |      |
2148 | ^ |         |        |        |        |    at |      |
2149 | $ | max=50  |        |        |        |       |      |
2150 |---+---------+--------+--------+--------+-------+------|
2151 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
2152 @end group
2153 @end example
2155 @noindent @b{Important}: Please note that for these special tables,
2156 recalculating the table with @kbd{C-u C-c *} will only affect rows that
2157 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
2158 to the field itself.  The column formulas are not applied in rows with
2159 empty first field.
2161 @cindex marking characters, tables
2162 The marking characters have the following meaning:
2163 @table @samp
2164 @item !
2165 The fields in this line define names for the columns, so that you may
2166 refer to a column as @samp{$Tot} instead of @samp{$6}.
2167 @item ^
2168 This row defines names for the fields @emph{above} the row.  With such
2169 a definition, any formula in the table may use @samp{$m1} to refer to
2170 the value @samp{10}.  Also, if you assign a formula to a names field, it
2171 will be stored as @samp{$name=...}.
2172 @item _
2173 Similar to @samp{^}, but defines names for the fields in the row
2174 @emph{below}.
2175 @item $
2176 Fields in this row can define @emph{parameters} for formulas.  For
2177 example, if a field in a @samp{$} row contains @samp{max=50}, then
2178 formulas in this table can refer to the value 50 using @samp{$max}.
2179 Parameters work exactly like constants, only that they can be defined on
2180 a per-table basis.
2181 @item #
2182 Fields in this row are automatically recalculated when pressing
2183 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
2184 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
2185 lines will be left alone by this command.
2186 @item *
2187 Selects this line for global recalculation with @kbd{C-u C-c *}, but
2188 not for automatic recalculation.  Use this when automatic
2189 recalculation slows down editing too much.
2190 @item
2191 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
2192 All lines that should be recalculated should be marked with @samp{#}
2193 or @samp{*}.
2194 @item /
2195 Do not export this line.  Useful for lines that contain the narrowing
2196 @samp{<N>} markers.
2197 @end table
2199 Finally, just to whet your appetite on what can be done with the
2200 fantastic @file{calc} package, here is a table that computes the Taylor
2201 series of degree @code{n} at location @code{x} for a couple of
2202 functions.
2204 @example
2205 @group
2206 |---+-------------+---+-----+--------------------------------------|
2207 |   | Func        | n | x   | Result                               |
2208 |---+-------------+---+-----+--------------------------------------|
2209 | # | exp(x)      | 1 | x   | 1 + x                                |
2210 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
2211 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
2212 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
2213 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
2214 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
2215 |---+-------------+---+-----+--------------------------------------|
2216 #+TBLFM: $5=taylor($2,$4,$3);n3
2217 @end group
2218 @end example
2220 @node Hyperlinks, TODO Items, Tables, Top
2221 @chapter Hyperlinks
2222 @cindex hyperlinks
2224 Like HTML, Org provides links inside a file, external links to
2225 other files, Usenet articles, emails, and much more.
2227 @menu
2228 * Link format::                 How links in Org are formatted
2229 * Internal links::              Links to other places in the current file
2230 * External links::              URL-like links to the world
2231 * Handling links::              Creating, inserting and following
2232 * Using links outside Org::     Linking from my C source code?
2233 * Link abbreviations::          Shortcuts for writing complex links
2234 * Search options::              Linking to a specific location
2235 * Custom searches::             When the default search is not enough
2236 @end menu
2238 @node Link format, Internal links, Hyperlinks, Hyperlinks
2239 @section Link format
2240 @cindex link format
2241 @cindex format, of links
2243 Org will recognize plain URL-like links and activate them as
2244 clickable links.  The general link format, however, looks like this:
2246 @example
2247 [[link][description]]       @r{or alternatively}           [[link]]
2248 @end example
2250 Once a link in the buffer is complete (all brackets present), Org
2251 will change the display so that @samp{description} is displayed instead
2252 of @samp{[[link][description]]} and @samp{link} is displayed instead of
2253 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
2254 which by default is an underlined face.  You can directly edit the
2255 visible part of a link.  Note that this can be either the @samp{link}
2256 part (if there is no description) or the @samp{description} part.  To
2257 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
2258 cursor on the link.
2260 If you place the cursor at the beginning or just behind the end of the
2261 displayed text and press @key{BACKSPACE}, you will remove the
2262 (invisible) bracket at that location.  This makes the link incomplete
2263 and the internals are again displayed as plain text.  Inserting the
2264 missing bracket hides the link internals again.  To show the
2265 internal structure of all links, use the menu entry
2266 @code{Org->Hyperlinks->Literal links}.
2268 @node Internal links, External links, Link format, Hyperlinks
2269 @section Internal links
2270 @cindex internal links
2271 @cindex links, internal
2272 @cindex targets, for links
2274 If the link does not look like a URL, it is considered to be internal in
2275 the current file.  Links such as @samp{[[My Target]]} or @samp{[[My
2276 Target][Find my target]]} lead to a text search in the current file.
2277 The link can be followed with @kbd{C-c C-o} when the cursor is on the
2278 link, or with a mouse click (@pxref{Handling links}).  The preferred
2279 match for such a link is a dedicated target: the same string in double
2280 angular brackets.  Targets may be located anywhere; sometimes it is
2281 convenient to put them into a comment line. For example
2283 @example
2284 # <<My Target>>
2285 @end example
2287 @noindent In HTML export (@pxref{HTML export}), such targets will become
2288 named anchors for direct access through @samp{http} links@footnote{Note
2289 that text before the first headline is usually not exported, so the
2290 first such target should be after the first headline.}.
2292 If no dedicated target exists, Org will search for the words in the
2293 link.  In the above example the search would be for @samp{my target}.
2294 Links starting with a star like @samp{*My Target} restrict the search to
2295 headlines.  When searching, Org mode will first try an exact match, but
2296 then move on to more and more lenient searches.  For example, the link
2297 @samp{[[*My Targets]]} will find any of the following:
2299 @example
2300 ** My targets
2301 ** TODO my targets are bright
2302 ** my 20 targets are
2303 @end example
2305 To insert a link targeting a headline, in-buffer completion can be used.
2306 Just type a star followed by a few optional letters into the buffer and
2307 press @kbd{M-@key{TAB}}.  All headlines in the current buffer will be
2308 offered as completions.  @xref{Handling links}, for more commands
2309 creating links.
2311 Following a link pushes a mark onto Org's own mark ring.  You can
2312 return to the previous position with @kbd{C-c &}.  Using this command
2313 several times in direct succession goes back to positions recorded
2314 earlier.
2316 @menu
2317 * Radio targets::               Make targets trigger links in plain text
2318 @end menu
2320 @node Radio targets,  , Internal links, Internal links
2321 @subsection Radio targets
2322 @cindex radio targets
2323 @cindex targets, radio
2324 @cindex links, radio targets
2326 Org can automatically turn any occurrences of certain target names
2327 in normal text into a link.  So without explicitly creating a link, the
2328 text connects to the target radioing its position.  Radio targets are
2329 enclosed by triple angular brackets.  For example, a target @samp{<<<My
2330 Target>>>} causes each occurrence of @samp{my target} in normal text to
2331 become activated as a link.  The Org file is scanned automatically
2332 for radio targets only when the file is first loaded into Emacs.  To
2333 update the target list during editing, press @kbd{C-c C-c} with the
2334 cursor on or at a target.
2336 @node External links, Handling links, Internal links, Hyperlinks
2337 @section External links
2338 @cindex links, external
2339 @cindex external links
2340 @cindex links, external
2341 @cindex Gnus links
2342 @cindex BBDB links
2343 @cindex IRC links
2344 @cindex URL links
2345 @cindex file links
2346 @cindex VM links
2347 @cindex RMAIL links
2348 @cindex WANDERLUST links
2349 @cindex MH-E links
2350 @cindex USENET links
2351 @cindex SHELL links
2352 @cindex Info links
2353 @cindex elisp links
2355 Org supports links to files, websites, Usenet and email messages,
2356 BBDB database entries and links to both IRC conversations and their
2357 logs.  External links are URL-like locators.  They start with a short
2358 identifying string followed by a colon.  There can be no space after
2359 the colon.  The following list shows examples for each link type.
2361 @example
2362 http://www.astro.uva.nl/~dominik          @r{on the web}
2363 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
2364 file:papers/last.pdf                      @r{file, relative path}
2365 news:comp.emacs                           @r{Usenet link}
2366 mailto:adent@@galaxy.net                  @r{Mail link}
2367 vm:folder                                 @r{VM folder link}
2368 vm:folder#id                              @r{VM message link}
2369 vm://myself@@some.where.org/folder#id     @r{VM on remote machine}
2370 wl:folder                                 @r{WANDERLUST folder link}
2371 wl:folder#id                              @r{WANDERLUST message link}
2372 mhe:folder                                @r{MH-E folder link}
2373 mhe:folder#id                             @r{MH-E message link}
2374 rmail:folder                              @r{RMAIL folder link}
2375 rmail:folder#id                           @r{RMAIL message link}
2376 gnus:group                                @r{Gnus group link}
2377 gnus:group#id                             @r{Gnus article link}
2378 bbdb:Richard Stallman                     @r{BBDB link}
2379 irc:/irc.com/#emacs/bob                   @r{IRC link}
2380 shell:ls *.org                            @r{A shell command}
2381 elisp:(find-file-other-frame "Elisp.org") @r{An elisp form to evaluate}
2382 @end example
2384 A link should be enclosed in double brackets and may contain a
2385 descriptive text to be displayed instead of the URL (@pxref{Link
2386 format}), for example:
2388 @example
2389 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
2390 @end example
2392 @noindent
2393 If the description is a file name or URL that points to an image, HTML
2394 export (@pxref{HTML export}) will inline the image as a clickable
2395 button.  If there is no description at all and the link points to an
2396 image,
2397 that image will be inlined into the exported HTML file.
2399 @cindex angular brackets, around links
2400 @cindex plain text external links
2401 Org also finds external links in the normal text and activates them
2402 as links.  If spaces must be part of the link (for example in
2403 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
2404 about the end of the link, enclose them in angular brackets.
2406 @node Handling links, Using links outside Org, External links, Hyperlinks
2407 @section Handling links
2408 @cindex links, handling
2410 Org provides methods to create a link in the correct syntax, to
2411 insert it into an Org file, and to follow the link.
2413 @table @kbd
2414 @kindex C-c l
2415 @cindex storing links
2416 @item C-c l
2417 Store a link to the current location.  This is a @emph{global} command
2418 which can be used in any buffer to create a link.  The link will be
2419 stored for later insertion into an Org buffer (see below).  For
2420 Org files, if there is a @samp{<<target>>} at the cursor, the
2421 link points to the target.  Otherwise it points to the current
2422 headline.  For VM, Rmail, Wanderlust, MH-E, Gnus and BBDB buffers, the
2423 link will indicate the current article/entry.  For W3 and W3M buffers,
2424 the link goes to the current URL.  For IRC links, if you set the
2425 variable @code{org-irc-link-to-logs} to non-nil then @kbd{C-c l} will
2426 store a @samp{file:/} style link to the relevant point in the logs for
2427 the current conversation. Otherwise an @samp{irc:/} style link to the
2428 user/channel/server under the point will be stored.  For any other
2429 files, the link will point to the file, with a search string
2430 (@pxref{Search options}) pointing to the contents of the current line.
2431 If there is an active region, the selected words will form the basis
2432 of the search string.  If the automatically created link is not
2433 working correctly or accurately enough, you can write custom functions
2434 to select the search string and to do the search for particular file
2435 types - see @ref{Custom searches}.  The key binding @kbd{C-c l} is
2436 only a suggestion - see @ref{Installation}.
2438 @kindex C-c C-l
2439 @cindex link completion
2440 @cindex completion, of links
2441 @cindex inserting links
2442 @item C-c C-l
2443 Insert a link.  This prompts for a link to be inserted into the buffer.  You
2444 can just type a link, using text for an internal link, or one of the link
2445 type prefixes mentioned in the examples above.  All links stored during the
2446 current session are part of the history for this prompt, so you can access
2447 them with @key{up} and @key{down} (or @kbd{M-p/n}).  Completion, on the other
2448 hand, will help you to insert valid link prefixes like @samp{http:} or
2449 @samp{ftp:}, including the prefixes defined through link abbreviations
2450 (@pxref{Link abbreviations}).  The link will be inserted into the
2451 buffer@footnote{After insertion of a stored link, the link will be removed
2452 from the list of stored links.  To keep it in the list later use, use a
2453 triple @kbd{C-u} prefix argument to @kbd{C-c C-l}, or configure the option
2454 @code{org-keep-stored-link-after-insertion}.}, along with a descriptive text.
2455 If some text was selected when this command is called, the selected text
2456 becomes the default description.@* Note that you don't have to use this
2457 command to insert a link.  Links in Org are plain text, and you can type
2458 or paste them straight into the buffer.  By using this command, the links are
2459 automatically enclosed in double brackets, and you will be asked for the
2460 optional descriptive text.
2462 @c  If the link is a @samp{file:} link and
2463 @c the linked file is located in the same directory as the current file or
2464 @c a subdirectory of it, the path of the file will be inserted relative to
2465 @c the current directory.
2467 @kindex C-u C-c C-l
2468 @cindex file name completion
2469 @cindex completion, of file names
2470 @item C-u C-c C-l
2471 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
2472 a file will be inserted and you may use file name completion to select
2473 the name of the file.  The path to the file is inserted relative to the
2474 directory of the current org file, if the linked file is in the current
2475 directory or in a sub-directory of it, or if the path is written relative
2476 to the current directory using @samp{../}.  Otherwise an absolute path
2477 is used, if possible with @samp{~/} for your home directory.  You can
2478 force an absolute path with two @kbd{C-u} prefixes.
2480 @item C-c C-l @r{(with cursor on existing link)}
2481 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
2482 link and description parts of the link.
2484 @cindex following links
2485 @kindex C-c C-o
2486 @item C-c C-o
2487 Open link at point.  This will launch a web browser for URLs (using
2488 @command{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB
2489 for the corresponding links, and execute the command in a shell link.
2490 When the cursor is on an internal link, this commands runs the
2491 corresponding search.  When the cursor is on a TAG list in a headline,
2492 it creates the corresponding TAGS view.  If the cursor is on a time
2493 stamp, it compiles the agenda for that date.  Furthermore, it will visit
2494 text and remote files in @samp{file:} links with Emacs and select a
2495 suitable application for local non-text files.  Classification of files
2496 is based on file extension only.  See option @code{org-file-apps}.  If
2497 you want to override the default application and visit the file with
2498 Emacs, use a @kbd{C-u} prefix.
2500 @kindex mouse-2
2501 @kindex mouse-1
2502 @item mouse-2
2503 @itemx mouse-1
2504 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
2505 would.  Under Emacs 22, also @kbd{mouse-1} will follow a link.
2507 @kindex mouse-3
2508 @item mouse-3
2509 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
2510 internal links to be displayed in another window@footnote{See the
2511 variable @code{org-display-internal-link-with-indirect-buffer}}.
2513 @cindex mark ring
2514 @kindex C-c %
2515 @item C-c %
2516 Push the current position onto the mark ring, to be able to return
2517 easily. Commands following an internal link do this automatically.
2519 @cindex links, returning to
2520 @kindex C-c &
2521 @item C-c &
2522 Jump back to a recorded position.  A position is recorded by the
2523 commands following internal links, and by @kbd{C-c %}.  Using this
2524 command several times in direct succession moves through a ring of
2525 previously recorded positions.
2527 @kindex C-c C-x C-n
2528 @kindex C-c C-x C-p
2529 @cindex links, finding next/previous
2530 @item C-c C-x C-n
2531 @itemx C-c C-x C-p
2532 Move forward/backward to the next link in the buffer.  At the limit of
2533 the buffer, the search fails once, and then wraps around.  The key
2534 bindings for this are really too long, you might want to bind this also
2535 to @kbd{C-n} and @kbd{C-p}
2536 @lisp
2537 (add-hook 'org-load-hook
2538   (lambda ()
2539     (define-key 'org-mode-map "\C-n" 'org-next-link)
2540     (define-key 'org-mode-map "\C-p" 'org-previous-link)))
2541 @end lisp
2542 @end table
2544 @node Using links outside Org, Link abbreviations, Handling links, Hyperlinks
2545 @section Using links outside Org
2547 You can insert and follow links that have Org syntax not only in
2548 Org, but in any Emacs buffer.  For this, you should create two
2549 global commands, like this (please select suitable global keys
2550 yourself):
2552 @lisp
2553 (global-set-key "\C-c L" 'org-insert-link-global)
2554 (global-set-key "\C-c o" 'org-open-at-point-global)
2555 @end lisp
2557 @node Link abbreviations, Search options, Using links outside Org, Hyperlinks
2558 @section Link abbreviations
2559 @cindex link abbreviations
2560 @cindex abbreviation, links
2562 Long URLs can be cumbersome to type, and often many similar links are
2563 needed in a document.  For this you can use link abbreviations.  An
2564 abbreviated link looks like this
2566 @example
2567 [[linkword:tag][description]]
2568 @end example
2570 @noindent
2571 where the tag is optional.  Such abbreviations are resolved according to
2572 the information in the variable @code{org-link-abbrev-alist} that
2573 relates the linkwords to replacement text.  Here is an example:
2575 @lisp
2576 @group
2577 (setq org-link-abbrev-alist
2578   '(("bugzilla" . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
2579     ("google"   . "http://www.google.com/search?q=")
2580     ("ads"      . "http://adsabs.harvard.edu/cgi-bin/
2581                    nph-abs_connect?author=%s&db_key=AST")))
2582 @end group
2583 @end lisp
2585 If the replacement text contains the string @samp{%s}, it will be
2586 replaced with the tag.  Otherwise the tag will be appended to the string
2587 in order to create the link.  You may also specify a function that will
2588 be called with the tag as the only argument to create the link.
2590 With the above setting, you could link to a specific bug with
2591 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
2592 @code{[[google:OrgMode]]} and find out what the Org author is
2593 doing besides Emacs hacking with @code{[[ads:Dominik,C]]}.
2595 If you need special abbreviations just for a single Org buffer, you
2596 can define them in the file with
2598 @example
2599 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
2600 #+LINK: google    http://www.google.com/search?q=%s
2601 @end example
2603 @noindent
2604 In-buffer completion @pxref{Completion} can be used after @samp{[} to
2605 complete link abbreviations.
2607 @node Search options, Custom searches, Link abbreviations, Hyperlinks
2608 @section Search options in file links
2609 @cindex search option in file links
2610 @cindex file links, searching
2612 File links can contain additional information to make Emacs jump to a
2613 particular location in the file when following a link.  This can be a
2614 line number or a search option after a double@footnote{For backward
2615 compatibility, line numbers can also follow a single colon.} colon. For
2616 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
2617 links}) to a file, it encodes the words in the current line as a search
2618 string that can be used to find this line back later when following the
2619 link with @kbd{C-c C-o}.
2621 Here is the syntax of the different ways to attach a search to a file
2622 link, together with an explanation:
2624 @example
2625 [[file:~/code/main.c::255]]
2626 [[file:~/xx.org::My Target]]
2627 [[file:~/xx.org::*My Target]]
2628 [[file:~/xx.org::/regexp/]]
2629 @end example
2631 @table @code
2632 @item 255
2633 Jump to line 255.
2634 @item My Target
2635 Search for a link target @samp{<<My Target>>}, or do a text search for
2636 @samp{my target}, similar to the search in internal links, see
2637 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
2638 link will become an HTML reference to the corresponding named anchor in
2639 the linked file.
2640 @item *My Target
2641 In an Org file, restrict search to headlines.
2642 @item /regexp/
2643 Do a regular expression search for @code{regexp}.  This uses the Emacs
2644 command @code{occur} to list all matches in a separate window.  If the
2645 target file is in Org mode, @code{org-occur} is used to create a
2646 sparse tree with the matches.
2647 @c If the target file is a directory,
2648 @c @code{grep} will be used to search all files in the directory.
2649 @end table
2651 As a degenerate case, a file link with an empty file name can be used
2652 to search the current file.  For example, @code{[[file:::find me]]} does
2653 a search for @samp{find me} in the current file, just as
2654 @samp{[[find me]]} would.
2656 @node Custom searches,  , Search options, Hyperlinks
2657 @section Custom Searches
2658 @cindex custom search strings
2659 @cindex search strings, custom
2661 The default mechanism for creating search strings and for doing the
2662 actual search related to a file link may not work correctly in all
2663 cases.  For example, BibTeX database files have many entries like
2664 @samp{year="1993"} which would not result in good search strings,
2665 because the only unique identification for a BibTeX entry is the
2666 citation key.
2668 If you come across such a problem, you can write custom functions to set
2669 the right search string for a particular file type, and to do the search
2670 for the string in the file.  Using @code{add-hook}, these functions need
2671 to be added to the hook variables
2672 @code{org-create-file-search-functions} and
2673 @code{org-execute-file-search-functions}.  See the docstring for these
2674 variables for more information.  Org actually uses this mechanism
2675 for Bib@TeX{} database files, and you can use the corresponding code as
2676 an implementation example.  Search for @samp{BibTeX links} in the source
2677 file.
2679 @node TODO Items, Tags, Hyperlinks, Top
2680 @chapter TODO Items
2681 @cindex TODO items
2683 Org mode does not maintain TODO lists as separate documents.  Instead,
2684 TODO items are an integral part of the notes file, because TODO items
2685 usually come up while taking notes!  With Org mode, simply mark any
2686 entry in a tree as being a TODO item.  In this way, information is not
2687 duplicated, and the entire context from which the TODO item emerged is
2688 always present.
2690 Of course, this technique for managing TODO items scatters them
2691 throughout your notes file.  Org mode compensates for this by providing
2692 methods to give you an overview of all the things that you have to do.
2694 @menu
2695 * TODO basics::                 Marking and displaying TODO entries
2696 * TODO extensions::             Workflow and assignments
2697 * Progress logging::            Dates and notes for progress
2698 * Priorities::                  Some things are more important than others
2699 * Breaking down tasks::         Splitting a task into manageable pieces
2700 * Checkboxes::                  Tick-off lists
2701 @end menu
2703 @node TODO basics, TODO extensions, TODO Items, TODO Items
2704 @section Basic TODO functionality
2706 Any headline becomes a TODO item when it starts with the word
2707 @samp{TODO}, for example:
2709 @example
2710 *** TODO Write letter to Sam Fortune
2711 @end example
2713 @noindent
2714 The most important commands to work with TODO entries are:
2716 @table @kbd
2717 @kindex C-c C-t
2718 @cindex cycling, of TODO states
2719 @item C-c C-t
2720 Rotate the TODO state of the current item among
2722 @example
2723 ,-> (unmarked) -> TODO -> DONE --.
2724 '--------------------------------'
2725 @end example
2727 The same rotation can also be done ``remotely'' from the timeline and
2728 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
2730 @kindex C-u C-c C-t
2731 @item C-u C-c C-t
2732 Select a specific keyword using completion or (if it has been set up)
2733 the fast selection interface.  For the latter, you need to assign keys
2734 to TODO states, see @ref{Per-file keywords} and @ref{Setting tags} for
2735 more information.
2737 @kindex S-@key{right}
2738 @kindex S-@key{left}
2739 @item S-@key{right}
2740 @itemx S-@key{left}
2741 Select the following/preceding TODO state, similar to cycling.  Useful
2742 mostly if more than two TODO states are possible (@pxref{TODO
2743 extensions}).
2744 @kindex C-c C-v
2745 @kindex C-c / t
2746 @cindex sparse tree, for TODO
2747 @item C-c C-v
2748 @itemx C-c / t
2749 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds
2750 the entire buffer, but shows all TODO items and the headings hierarchy
2751 above them.  With a prefix argument, search for a specific TODO.  You will be
2752 prompted for the keyword, and you can also give a list of keywords like
2753 @code{KWD1|KWD2|...}.  With numeric prefix argument N, show the tree for the
2754 Nth keyword in the variable @code{org-todo-keywords}.  With two prefix
2755 arguments, find all TODO and DONE entries.
2756 @kindex C-c a t
2757 @item C-c a t
2758 Show the global TODO list.  Collects the TODO items from all agenda
2759 files (@pxref{Agenda Views}) into a single buffer.  The new buffer will
2760 be in @code{agenda-mode}, which provides commands to examine and
2761 manipulate the TODO entries from the new buffer (@pxref{Agenda
2762 commands}).  @xref{Global TODO list}, for more information.
2763 @kindex S-M-@key{RET}
2764 @item S-M-@key{RET}
2765 Insert a new TODO entry below the current one.
2766 @end table
2768 @node TODO extensions, Progress logging, TODO basics, TODO Items
2769 @section Extended use of TODO keywords
2770 @cindex extended TODO keywords
2772 By default, marked TODO entries have one of only two states: TODO and
2773 DONE.  Org mode allows you to classify TODO items in more complex ways
2774 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With
2775 special setup, the TODO keyword system can work differently in different
2776 files.
2778 Note that @i{tags} are another way to classify headlines in general and
2779 TODO items in particular (@pxref{Tags}).
2781 @menu
2782 * Workflow states::             From TODO to DONE in steps
2783 * TODO types::                  I do this, Fred does the rest
2784 * Multiple sets in one file::   Mixing it all, and still finding your way
2785 * Fast access to TODO states::  Single letter selection of a state
2786 * Per-file keywords::           Different files, different requirements
2787 * Faces for TODO keywords::     Highlighting states
2788 @end menu
2790 @node Workflow states, TODO types, TODO extensions, TODO extensions
2791 @subsection TODO keywords as workflow states
2792 @cindex TODO workflow
2793 @cindex workflow states as TODO keywords
2795 You can use TODO keywords to indicate different @emph{sequential} states
2796 in the process of working on an item, for example@footnote{Changing
2797 this variable only becomes effective after restarting Org mode in a
2798 buffer.}:
2800 @lisp
2801 (setq org-todo-keywords
2802   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
2803 @end lisp
2805 The vertical bar separates the TODO keywords (states that @emph{need
2806 action}) from the DONE states (which need @emph{no further action}.  If
2807 you don't provide the separator bar, the last state is used as the DONE
2808 state.
2809 @cindex completion, of TODO keywords
2810 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
2811 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED.  You may
2812 also use a numeric prefix argument to quickly select a specific state.  For
2813 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY.
2814 Or you can use @kbd{S-left} to go backward through the sequence.  If you
2815 define many keywords, you can use in-buffer completion
2816 (@pxref{Completion}) or even a special one-key selection scheme
2817 (@pxref{Fast access to TODO states}) to insert these words into the
2818 buffer.  Changing a TODO state can be logged with a timestamp, see
2819 @ref{Tracking TODO state changes} for more information.
2821 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
2822 @subsection TODO keywords as types
2823 @cindex TODO types
2824 @cindex names as TODO keywords
2825 @cindex types as TODO keywords
2827 The second possibility is to use TODO keywords to indicate different
2828 @emph{types} of action items.  For example, you might want to indicate
2829 that items are for ``work'' or ``home''.  Or, when you work with several
2830 people on a single project, you might want to assign action items
2831 directly to persons, by using their names as TODO keywords.  This would
2832 be set up like this:
2834 @lisp
2835 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
2836 @end lisp
2838 In this case, different keywords do not indicate a sequence, but rather
2839 different types.  So the normal work flow would be to assign a task to a
2840 person, and later to mark it DONE.  Org mode supports this style by adapting
2841 the workings of the command @kbd{C-c C-t}@footnote{This is also true for the
2842 @kbd{t} command in the timeline and agenda buffers.}.  When used several
2843 times in succession, it will still cycle through all names, in order to first
2844 select the right type for a task.  But when you return to the item after some
2845 time and execute @kbd{C-c C-t} again, it will switch from any name directly
2846 to DONE.  Use prefix arguments or completion to quickly select a specific
2847 name.  You can also review the items of a specific TODO type in a sparse tree
2848 by using a numeric prefix to @kbd{C-c C-v}.  For example, to see all things
2849 Lucy has to do, you would use @kbd{C-3 C-c C-v}.  To collect Lucy's items
2850 from all agenda files into a single buffer, you would use the numeric prefix
2851 argument as well when creating the global TODO list: @kbd{C-3 C-c t}.
2853 @node Multiple sets in one file, Fast access to TODO states, TODO types, TODO extensions
2854 @subsection Multiple keyword sets in one file
2855 @cindex TODO keyword sets
2857 Sometimes you may want to use different sets of TODO keywords in
2858 parallel.  For example, you may want to have the basic
2859 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
2860 separate state indicating that an item has been canceled (so it is not
2861 DONE, but also does not require action).  Your setup would then look
2862 like this:
2864 @lisp
2865 (setq org-todo-keywords
2866       '((sequence "TODO" "|" "DONE")
2867         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
2868         (sequence "|" "CANCELED")))
2869 @end lisp
2871 The keywords should all be different, this helps Org mode to keep track
2872 of which subsequence should be used for a given entry.  In this setup,
2873 @kbd{C-c C-t} only operates within a subsequence, so it switches from
2874 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
2875 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
2876 select the correct sequence.  Besides the obvious ways like typing a
2877 keyword or using completion, you may also apply the following commands:
2879 @table @kbd
2880 @kindex C-S-@key{right}
2881 @kindex C-S-@key{left}
2882 @item C-S-@key{right}
2883 @itemx C-S-@key{left}
2884 These keys jump from one TODO subset to the next.  In the above example,
2885 @kbd{C-S-@key{right}} would jump from @code{TODO} or @code{DONE} to
2886 @code{REPORT}, and any of the words in the second row to @code{CANCELED}.
2887 @kindex S-@key{right}
2888 @kindex S-@key{left}
2889 @item S-@key{right}
2890 @itemx S-@key{left}
2891 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through
2892 @emph{all} keywords from all sets, so for example @kbd{S-@key{<right>}}
2893 would switch from @code{DONE} to @code{REPORT} in the example above.
2894 @end table
2896 @node Fast access to TODO states, Per-file keywords, Multiple sets in one file, TODO extensions
2897 @subsection Fast access to TODO states
2899 If you would like to quickly change an entry to an arbitrary TODO state
2900 instead of cycling through the states, you can set up keys for
2901 single-letter access to the states.  This is done by adding the section
2902 key after each keyword, in parenthesis.  For example:
2904 @lisp
2905 (setq org-todo-keywords
2906       '((sequence "TODO(t)" "|" "DONE(d)")
2907         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
2908         (sequence "|" "CANCELED(c)")))
2909 @end lisp
2911 If you then press @code{C-u C-c C-t} followed by the selection key, the
2912 entry will be switched to this state.  @key{SPC} can be used to remove
2913 any TODO keyword from an entry.  Should you like this way of selecting
2914 TODO states a lot, you might want to set the variable
2915 @code{org-use-fast-todo-selection} to @code{t} and make this behavior
2916 the default.  Check also the variable
2917 @code{org-fast-tag-selection-include-todo}, it allows to change the TODO
2918 state through the tags interface (@pxref{Setting tags}), in case you
2919 like to mingle the two concepts.
2921 @node Per-file keywords, Faces for TODO keywords, Fast access to TODO states, TODO extensions
2922 @subsection Setting up keywords for individual files
2923 @cindex keyword options
2924 @cindex per-file keywords
2926 It can be very useful to use different aspects of the TODO mechanism in
2927 different files.  For file-local settings, you need to add special lines
2928 to the file which set the keywords and interpretation for that file
2929 only.  For example, to set one of the two examples discussed above, you
2930 need one of the following lines, starting in column zero anywhere in the
2931 file:
2933 @example
2934 #+SEQ_TODO: TODO FEEDBACK VERIFY | DONE CANCELED
2935 @end example
2937 @example
2938 #+TYP_TODO: Fred Sara Lucy Mike | DONE
2939 @end example
2941 A setup for using several sets in parallel would be:
2943 @example
2944 #+SEQ_TODO: TODO | DONE
2945 #+SEQ_TODO: REPORT BUG KNOWNCAUSE | FIXED
2946 #+SEQ_TODO: | CANCELED
2947 @end example
2949 @cindex completion, of option keywords
2950 @kindex M-@key{TAB}
2951 @noindent To make sure you are using the correct keyword, type
2952 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
2954 @cindex DONE, final TODO keyword
2955 Remember that the keywords after the vertical bar (or the last keyword
2956 if no bar is there) must always mean that the item is DONE (although you
2957 may use a different word).  After changing one of these lines, use
2958 @kbd{C-c C-c} with the cursor still in the line to make the changes
2959 known to Org mode@footnote{Org mode parses these lines only when
2960 Org mode is activated after visiting a file.  @kbd{C-c C-c} with the
2961 cursor in a line starting with @samp{#+} is simply restarting Org mode
2962 for the current buffer.}.
2964 @node Faces for TODO keywords,  , Per-file keywords, TODO extensions
2965 @subsection Faces for TODO keywords
2966 @cindex faces, for TODO keywords
2968 Org mode highlights TODO keywords with special faces: @code{org-todo}
2969 for keywords indicating that an item still has to be acted upon, and
2970 @code{org-done} for keywords indicating that an item is finished.  If
2971 you are using more than 2 different states, you might want to use
2972 special faces for some of them.  This can be done using the variable
2973 @code{org-todo-keyword-faces}.  For example:
2975 @lisp
2976 (setq org-todo-keyword-faces
2977       '(("TODO"      . org-warning)
2978         ("DEFERRED"  . shadow)
2979         ("CANCELED"  . (:foreground "blue" :weight bold))))
2980 @end lisp
2982 While using a list with face properties as shown for CANCELED
2983 @emph{should} work, this does not aways seem to be the case.  If
2984 necessary, define a special face and use that.
2986 @page
2987 @node Progress logging, Priorities, TODO extensions, TODO Items
2988 @section Progress logging
2989 @cindex progress logging
2990 @cindex logging, of progress
2992 Org mode can automatically record a time stamp and possibly a note when
2993 you mark a TODO item as DONE, or even each time you change the state of
2994 a TODO item.  This system is highly configurable, settings can be on a
2995 per-keyword basis and can be localized to a file or even a subtree.  For
2996 information on how to clock working time for a task, see @ref{Clocking
2997 work time}.
2999 @menu
3000 * Closing items::               When was this entry marked DONE?
3001 * Tracking TODO state changes::  When did the status change?
3002 @end menu
3004 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
3005 @subsection Closing items
3007 The most basic logging is to keep track of @emph{when} a certain TODO
3008 item was finished.  This is achieved with@footnote{The corresponding
3009 in-buffer setting is: @code{#+STARTUP: logdone}}.
3011 @lisp
3012 (setq org-log-done 'time)
3013 @end lisp
3015 @noindent
3016 Then each time you turn an entry from a TODO (not-done) state into any
3017 of the DONE states, a line @samp{CLOSED: [timestamp]} will be inserted
3018 just after the headline.  If you turn the entry back into a TODO item
3019 through further state cycling, that line will be removed again.  If you
3020 want to record a note along with the timestamp, use@footnote{The
3021 corresponding in-buffer setting is: @code{#+STARTUP: lognotedone}}
3023 @lisp
3024 (setq org-log-done 'note)
3025 @end lisp
3027 @noindent
3028 You will then be prompted for a note, and that note will be stored below
3029 the entry with a @samp{Closing Note} heading.
3031 In the timeline (@pxref{Timeline}) and in the agenda
3032 (@pxref{Weekly/daily agenda}), you can then use the @kbd{l} key to
3033 display the TODO items with a @samp{CLOSED} timestamp on each day,
3034 giving you an overview of what has been done.
3036 @node Tracking TODO state changes,  , Closing items, Progress logging
3037 @subsection Tracking TODO state changes
3039 When TODO keywords are used as workflow states (@pxref{Workflow
3040 states}), you might want to keep track of when a state change occurred
3041 and maybe take a note about this change.  Since it is normally too much
3042 to record a note for every state, Org mode expects configuration on a
3043 per-keyword basis for this.  This is achieved by adding special markers
3044 @samp{!} (for a time stamp) and @samp{@@} (for a note) in parenthesis
3045 after each keyword.  For example, with the setting
3047 @lisp
3048 (setq org-todo-keywords
3049   '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
3050 @end lisp
3052 @noindent
3053 you not only define global TODO keywords and fast access keys, but also
3054 request that a time is recorded when the entry is turned into
3055 DONE@footnote{It is possible that Org mode will record two time stamps
3056 when you are using both @code{org-log-done} and state change logging.
3057 However, it will never prompt for two notes - if you have configured
3058 both, the state change recording note will take precedence and cancel
3059 the @samp{Closing Note}.}, and that a note is recorded when switching to
3060 WAIT or CANCELED.  The setting for WAIT is even more special: The
3061 @samp{!} after the slash means that in addition to the note taken when
3062 entering the state, a time stamp should be recorded when @i{leaving} the
3063 WAIT state, if and only if the @i{target} state does not configure
3064 logging for entering it.  So it has no effect when switching from WAIT
3065 to DONE, because DONE is configured to record a timestamp only.  But
3066 when switching from WAIT back to TODO, the @samp{/!} in the WAIT
3067 setting now triggers a timestamp even though TODO has no logging
3068 configured.
3070 You can use the exact same syntax for setting logging preferences local
3071 to a buffer:
3072 @example
3073 #+SEQ_TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
3074 @end example
3076 In order to define logging settings that are local to a subtree or a
3077 single item, define a LOGGING property in this entry.  Any non-empty
3078 LOGGING property resets all logging settings to nil.  You may then turn
3079 on logging for this specific tree using STARTUP keywords like
3080 @code{lognotedone} or @code{logrepeat}, as well as adding state specific
3081 settings like @code{TODO(!)}.  For example
3083 @example
3084 * TODO Log each state with only a time
3085   :PROPERTIES:
3086   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
3087   :END:
3088 * TODO Only log when switching to WAIT, and when repeating
3089   :PROPERTIES:
3090   :LOGGING: WAIT(@@) logrepeat
3091   :END:
3092 * TODO No logging at all
3093   :PROPERTIES:
3094   :LOGGING: nil
3095   :END:
3096 @end example
3099 @node Priorities, Breaking down tasks, Progress logging, TODO Items
3100 @section Priorities
3101 @cindex priorities
3103 If you use Org mode extensively, you may end up enough TODO items that
3104 it starts to make sense to prioritize them.  Prioritizing can be done by
3105 placing a @emph{priority cookie} into the headline of a TODO item, like
3106 this
3108 @example
3109 *** TODO [#A] Write letter to Sam Fortune
3110 @end example
3112 @noindent
3113 By default, Org mode supports three priorities: @samp{A}, @samp{B}, and
3114 @samp{C}.  @samp{A} is the highest priority.  An entry without a cookie
3115 is treated as priority @samp{B}.  Priorities make a difference only in
3116 the agenda (@pxref{Weekly/daily agenda}); outside the agenda, they have
3117 no inherent meaning to Org mode.
3119 Priorities can be attached to any outline tree entries; they do not need
3120 to be TODO items.
3122 @table @kbd
3123 @kindex @kbd{C-c ,}
3124 @item @kbd{C-c ,}
3125 Set the priority of the current headline.  The command prompts for a
3126 priority character @samp{A}, @samp{B} or @samp{C}.  When you press
3127 @key{SPC} instead, the priority cookie is removed from the headline.
3128 The priorities can also be changed ``remotely'' from the timeline and
3129 agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
3131 @kindex S-@key{up}
3132 @kindex S-@key{down}
3133 @item S-@key{up}
3134 @itemx S-@key{down}
3135 Increase/decrease priority of current headline@footnote{See also the
3136 option @code{org-priority-start-cycle-with-default'}.}.  Note that these
3137 keys are also used to modify time stamps (@pxref{Creating timestamps}).
3138 Furthermore, these keys are also used by CUA mode (@pxref{Conflicts}).
3139 @end table
3141 You can change the range of allowed priorities by setting the variables
3142 @code{org-highest-priority}, @code{org-lowest-priority}, and
3143 @code{org-default-priority}.  For an individual buffer, you may set
3144 these values (highest, lowest, default) like this (please make sure that
3145 the highest priority is earlier in the alphabet than the lowest
3146 priority):
3148 @example
3149 #+PRIORITIES: A C B
3150 @end example
3152 @node Breaking down tasks, Checkboxes, Priorities, TODO Items
3153 @section Breaking tasks down into subtasks
3154 @cindex tasks, breaking down
3156 It is often advisable to break down large tasks into smaller, manageable
3157 subtasks.  You can do this by creating an outline tree below a TODO
3158 item, with detailed subtasks on the tree@footnote{To keep subtasks out
3159 of the global TODO list, see the
3160 @code{org-agenda-todo-list-sublevels}.}.  Another possibility is the use
3161 of checkboxes to identify (a hierarchy of) a large number of subtasks
3162 (@pxref{Checkboxes}).
3165 @node Checkboxes,  , Breaking down tasks, TODO Items
3166 @section Checkboxes
3167 @cindex checkboxes
3169 Every item in a plain list (@pxref{Plain lists}) can be made into a
3170 checkbox by starting it with the string @samp{[ ]}.  This feature is
3171 similar to TODO items (@pxref{TODO Items}), but is more lightweight.
3172 Checkboxes are not included into the global TODO list, so they are often
3173 great to split a task into a number of simple steps.  Or you can use
3174 them in a shopping list.  To toggle a checkbox, use @kbd{C-c C-c}, or
3175 use the mouse (thanks to Piotr Zielinski's @file{org-mouse.el}).
3177 Here is an example of a checkbox list.
3179 @example
3180 * TODO Organize party [2/4]
3181   - [-] call people [1/3]
3182     - [ ] Peter
3183     - [X] Sarah
3184     - [ ] Sam
3185   - [X] order food
3186   - [ ] think about what music to play
3187   - [X] talk to the neighbors
3188 @end example
3190 Checkboxes work hierarchically, so if a checkbox item has children that
3191 are checkboxes, toggling one of the children checkboxes will make the
3192 parent checkbox reflect if none, some, or all of the children are
3193 checked.
3195 @cindex statistics, for checkboxes
3196 @cindex checkbox statistics
3197 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are
3198 cookies indicating how many checkboxes present in this entry have been
3199 checked off, and the total number of checkboxes are present.  This can
3200 give you an idea on how many checkboxes remain, even without opening a
3201 folded entry.  The cookies can be placed into a headline or into (the
3202 first line of) a plain list item. Each cookie covers all checkboxes
3203 structurally below the headline/item on which the cookie appear.  You
3204 have to insert the cookie yourself by typing either @samp{[/]} or
3205 @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m} result, as in
3206 the examples above.  With @samp{[%]} you get information about the
3207 percentage of checkboxes checked (in the above example, this would be
3208 @samp{[50%]} and @samp{[33%]}, respectively).
3210 @noindent The following commands work with checkboxes:
3212 @table @kbd
3213 @kindex C-c C-c
3214 @item C-c C-c
3215 Toggle checkbox at point.  With a prefix argument, set it to @samp{[-]},
3216 which is considered to be an intermediate state.
3217 @kindex C-c C-x C-b
3218 @item C-c C-x C-b
3219 Toggle checkbox at point.
3220 @itemize @minus
3221 @item
3222 If there is an active region, toggle the first checkbox in the region
3223 and set all remaining boxes to the same status as the first.  If you
3224 want to toggle all boxes in the region independently, use a prefix
3225 argument.
3226 @item
3227 If the cursor is in a headline, toggle checkboxes in the region between
3228 this headline and the next (so @emph{not} the entire subtree).
3229 @item
3230 If there is no active region, just toggle the checkbox at point.
3231 @end itemize
3232 @kindex M-S-@key{RET}
3233 @item M-S-@key{RET}
3234 Insert a new item with a checkbox.
3235 This works only if the cursor is already in a plain list item
3236 (@pxref{Plain lists}).
3237 @kindex C-c #
3238 @item C-c #
3239 Update the checkbox statistics in the current outline entry.  When
3240 called with a @kbd{C-u} prefix, update the entire file.  Checkbox
3241 statistic cookies are updated automatically if you toggle checkboxes
3242 with @kbd{C-c C-c} and make new ones with @kbd{M-S-@key{RET}}.  If you
3243 delete boxes or add/change them by hand, use this command to get things
3244 back into synch.  Or simply toggle any checkbox twice with @kbd{C-c C-c}.
3245 @end table
3247 @node Tags, Properties and Columns, TODO Items, Top
3248 @chapter Tags
3249 @cindex tags
3250 @cindex headline tagging
3251 @cindex matching, tags
3252 @cindex sparse tree, tag based
3254 An excellent way to implement labels and contexts for cross-correlating
3255 information is to assign @i{tags} to headlines.  Org mode has extensive
3256 support for tags.
3258 Every headline can contain a list of tags; they occur at the end of the
3259 headline.  Tags are normal words containing letters, numbers, @samp{_},
3260 and @samp{@@}.  Tags must be preceded and followed by a single colon,
3261 e.g., @samp{:WORK:}.  Several tags can be specified, as in
3262 @samp{:work:URGENT:}.
3264 @menu
3265 * Tag inheritance::             Tags use the tree structure of the outline
3266 * Setting tags::                How to assign tags to a headline
3267 * Tag searches::                Searching for combinations of tags
3268 @end menu
3270 @node Tag inheritance, Setting tags, Tags, Tags
3271 @section Tag inheritance
3272 @cindex tag inheritance
3273 @cindex inheritance, of tags
3274 @cindex sublevels, inclusion into tags match
3276 @i{Tags} make use of the hierarchical structure of outline trees.  If a
3277 heading has a certain tag, all subheadings will inherit the tag as
3278 well.  For example, in the list
3280 @example
3281 * Meeting with the French group      :work:
3282 ** Summary by Frank                  :boss:notes:
3283 *** TODO Prepare slides for him      :action:
3284 @end example
3286 @noindent
3287 the final heading will have the tags @samp{:work:}, @samp{:boss:},
3288 @samp{:notes:}, and @samp{:action:} even though the final heading is not
3289 explicitly marked with those tags.  When executing tag searches and
3290 Org mode finds that a certain headline matches the search criterion, it
3291 will not check any sublevel headline, assuming that these also match and
3292 that the list of matches could become very long because of that.  If you
3293 do want the sublevels be tested and listed as well, you may set the
3294 variable @code{org-tags-match-list-sublevels}.  To limit tag inheritance
3295 to specific tags, or to turn it off entirely, use the variable
3296 @code{org-use-tag-inheritance}.
3298 @node Setting tags, Tag searches, Tag inheritance, Tags
3299 @section Setting tags
3300 @cindex setting tags
3301 @cindex tags, setting
3303 @kindex M-@key{TAB}
3304 Tags can simply be typed into the buffer at the end of a headline.
3305 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
3306 also a special command for inserting tags:
3308 @table @kbd
3309 @kindex C-c C-c
3310 @item C-c C-c
3311 @cindex completion, of tags
3312 Enter new tags for the current headline.  Org mode will either offer
3313 completion or a special single-key interface for setting tags, see
3314 below.  After pressing @key{RET}, the tags will be inserted and aligned
3315 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
3316 tags in the current buffer will be aligned to that column, just to make
3317 things look nice.  TAGS are automatically realigned after promotion,
3318 demotion, and TODO state changes (@pxref{TODO basics}).
3319 @end table
3321 Org will support tag insertion based on a @emph{list of tags}.  By
3322 default this list is constructed dynamically, containing all tags
3323 currently used in the buffer.  You may also globally specify a hard list
3324 of tags with the variable @code{org-tag-alist}.  Finally you can set
3325 the default tags for a given file with lines like
3327 @example
3328 #+TAGS: @@work @@home @@tennisclub
3329 #+TAGS: laptop car pc sailboat
3330 @end example
3332 If you have globally defined your preferred set of tags using the
3333 variable @code{org-tag-alist}, but would like to use a dynamic tag list
3334 in a specific file, add an empty TAGS option line to that file:
3336 @example
3337 #+TAGS:
3338 @end example
3340 By default Org mode uses the standard minibuffer completion facilities for
3341 entering tags.  However, it also implements another, quicker, tag selection
3342 method called @emph{fast tag selection}.  This allows you to select and
3343 deselect tags with just a single key press.  For this to work well you should
3344 assign unique letters to most of your commonly used tags.  You can do this
3345 globally by configuring the variable @code{org-tag-alist} in your
3346 @file{.emacs} file.  For example, you may find the need to tag many items in
3347 different files with @samp{:@@home:}.  In this case you can set something
3348 like:
3350 @lisp
3351 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
3352 @end lisp
3354 @noindent If the tag is only relevant to the file you are working on then you
3355 can, instead, set the TAGS option line as:
3357 @example
3358 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
3359 @end example
3361 @noindent
3362 You can also group together tags that are mutually exclusive.  By using
3363 braces, as in:
3365 @example
3366 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
3367 @end example
3369 @noindent you indicate that at most one of @samp{@@work}, @samp{@@home},
3370 and @samp{@@tennisclub} should be selected.  Multiple such groups are allowed.
3372 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
3373 these lines to activate any changes.
3375 @noindent
3376 To set these mutually exclusive groups in the variable @code{org-mode-alist}
3377 you must use the dummy tags @code{:startgroup} and @code{:endgroup} instead
3378 of the braces.  The previous example would be set globally by the following
3379 configuration:
3381 @lisp
3382 (setq org-tag-alist '((:startgroup . nil)
3383                       ("@@work" . ?w) ("@@home" . ?h)
3384                       ("@@tennisclub" . ?t)
3385                       (:endgroup . nil)
3386                       ("laptop" . ?l) ("pc" . ?p)))
3387 @end lisp
3389 If at least one tag has a selection key then pressing @kbd{C-c C-c} will
3390 automatically present you with a special interface, listing inherited tags,
3391 the tags of the current headline, and a list of all valid tags with
3392 corresponding keys@footnote{Keys will automatically be assigned to tags which
3393 have no configured keys.}.  In this interface, you can use the following
3394 keys:
3396 @table @kbd
3397 @item a-z...
3398 Pressing keys assigned to tags will add or remove them from the list of
3399 tags in the current line.  Selecting a tag in a group of mutually
3400 exclusive tags will turn off any other tags from that group.
3401 @kindex @key{TAB}
3402 @item @key{TAB}
3403 Enter a tag in the minibuffer, even if the tag is not in the predefined
3404 list.  You will be able to complete on all tags present in the buffer.
3405 @kindex @key{SPC}
3406 @item @key{SPC}
3407 Clear all tags for this line.
3408 @kindex @key{RET}
3409 @item @key{RET}
3410 Accept the modified set.
3411 @item C-g
3412 Abort without installing changes.
3413 @item q
3414 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
3415 @item !
3416 Turn off groups of mutually exclusive tags.  Use this to (as an
3417 exception) assign several tags from such a group.
3418 @item C-c
3419 Toggle auto-exit after the next change (see below).
3420 If you are using expert mode, the first @kbd{C-c} will display the
3421 selection window.
3422 @end table
3424 @noindent
3425 This method lets you assign tags to a headline with very few keys.  With
3426 the above setup, you could clear the current tags and set @samp{@@home},
3427 @samp{laptop} and @samp{pc} tags with just the following keys: @kbd{C-c
3428 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to
3429 @samp{@@work} would be done with @kbd{C-c C-c w @key{RET}} or
3430 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
3431 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
3432 @key{RET} @key{RET}}.
3434 If you find that most of the time, you need only a single key press to
3435 modify your list of tags, set the variable
3436 @code{org-fast-tag-selection-single-key}.  Then you no longer have to
3437 press @key{RET} to exit fast tag selection - it will immediately exit
3438 after the first change.  If you then occasionally need more keys, press
3439 @kbd{C-c} to turn off auto-exit for the current tag selection process
3440 (in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
3441 C-c}).  If you set the variable to the value @code{expert}, the special
3442 window is not even shown for single-key tag selection, it comes up only
3443 when you press an extra @kbd{C-c}.
3445 @node Tag searches,  , Setting tags, Tags
3446 @section Tag searches
3447 @cindex tag searches
3448 @cindex searching for tags
3450 Once a system of tags has been set up, it can be used to collect related
3451 information into special lists.
3453 @table @kbd
3454 @kindex C-c \
3455 @kindex C-c / T
3456 @item C-c \
3457 @itemx C-c / T
3458 Create a sparse tree with all headlines matching a tags search.  With a
3459 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
3460 @kindex C-c a m
3461 @item C-c a m
3462 Create a global list of tag matches from all agenda files.
3463 @xref{Matching tags and properties}.
3464 @kindex C-c a M
3465 @item C-c a M
3466 Create a global list of tag matches from all agenda files, but check
3467 only TODO items and force checking subitems (see variable
3468 @code{org-tags-match-list-sublevels}).
3469 @end table
3471 @cindex Boolean logic, for tag searches
3472 A @i{tags} search string can use Boolean operators @samp{&} for AND and
3473 @samp{|} for OR.  @samp{&} binds more strongly than @samp{|}.
3474 Parenthesis are currently not implemented.  A tag may also be preceded
3475 by @samp{-}, to select against it, and @samp{+} is syntactic sugar for
3476 positive selection.  The AND operator @samp{&} is optional when @samp{+}
3477 or @samp{-} is present.  Examples:
3479 @table @samp
3480 @item +work-boss
3481 Select headlines tagged @samp{:work:}, but discard those also tagged
3482 @samp{:boss:}.
3483 @item work|laptop
3484 Selects lines tagged @samp{:work:} or @samp{:laptop:}.
3485 @item work|laptop&night
3486 Like before, but require the @samp{:laptop:} lines to be tagged also
3487 @samp{:night:}.
3488 @end table
3490 @cindex TODO keyword matching, with tags search
3491 If you are using multi-state TODO keywords (@pxref{TODO extensions}), it
3492 can be useful to also match on the TODO keyword.  This can be done by
3493 adding a condition after a slash to a tags match.  The syntax is similar
3494 to the tag matches, but should be applied with consideration: For
3495 example, a positive selection on several TODO keywords can not
3496 meaningfully be combined with boolean AND.  However, @emph{negative
3497 selection} combined with AND can be meaningful.  To make sure that only
3498 lines are checked that actually have any TODO keyword, use @kbd{C-c a
3499 M}, or equivalently start the TODO part after the slash with @samp{!}.
3500 Examples:
3502 @table @samp
3503 @item work/WAITING
3504 Select @samp{:work:}-tagged TODO lines with the specific TODO
3505 keyword @samp{WAITING}.
3506 @item work/!-WAITING-NEXT
3507 Select @samp{:work:}-tagged TODO lines that are neither @samp{WAITING}
3508 nor @samp{NEXT}
3509 @item work/+WAITING|+NEXT
3510 Select @samp{:work:}-tagged TODO lines that are either @samp{WAITING} or
3511 @samp{NEXT}.
3512 @end table
3514 @cindex regular expressions, with tags search
3515 Any element of the tag/todo match can be a regular expression - in this
3516 case it must be enclosed in curly braces.  For example,
3517 @samp{work+@{^boss.*@}} matches headlines that contain the tag
3518 @samp{:work:} and any tag @i{starting} with @samp{boss}.
3520 @cindex level, require for tags/property match
3521 @cindex category, require for tags/property match
3522 You can also require a headline to be of a certain level or category, by
3523 writing instead of any TAG an expression like @samp{LEVEL=3} or
3524 @samp{CATEGORY="work"}, respectively.  For example, a search
3525 @samp{+LEVEL=3+boss/-DONE} lists all level three headlines that have the
3526 tag @samp{boss} and are @emph{not} marked with the TODO keyword DONE.
3528 @node Properties and Columns, Dates and Times, Tags, Top
3529 @chapter Properties and Columns
3530 @cindex properties
3532 Properties are a set of key-value pairs associated with an entry.  There
3533 are two main applications for properties in Org mode.  First, properties
3534 are like tags, but with a value.  Second, you can use properties to
3535 implement (very basic) database capabilities in an Org buffer.  For
3536 an example of the first application, imagine maintaining a file where
3537 you document bugs and plan releases of a piece of software.  Instead of
3538 using tags like @code{:release_1:}, @code{:release_2:}, one can use a
3539 property, say @code{:Release:}, that in different subtrees has different
3540 values, such as @code{1.0} or @code{2.0}.  For an example of the second
3541 application of properties, imagine keeping track of your music CD's,
3542 where properties could be things such as the album artist, date of
3543 release, number of tracks, and so on.
3545 Properties can be conveniently edited and viewed in column view
3546 (@pxref{Column view}).
3548 Properties are like tags, but with a value.  For example, in a file
3549 where you document bugs and plan releases of a piece of software,
3550 instead of using tags like @code{:release_1:}, @code{:release_2:}, it
3551 can be more efficient to use a property @code{:Release:} with a value
3552 @code{1.0} or @code{2.0}.  Second, you can use properties to implement
3553 (very basic) database capabilities in an Org buffer, for example to
3554 create a list of Music CD's you own.  You can edit and view properties
3555 conveniently in column view (@pxref{Column view}).
3557 @menu
3558 * Property syntax::             How properties are spelled out
3559 * Special properties::          Access to other Org mode features
3560 * Property searches::           Matching property values
3561 * Property inheritance::        Passing values down the tree
3562 * Column view::                 Tabular viewing and editing
3563 * Property API::                Properties for Lisp programmers
3564 @end menu
3566 @node Property syntax, Special properties, Properties and Columns, Properties and Columns
3567 @section Property syntax
3568 @cindex property syntax
3569 @cindex drawer, for properties
3571 Properties are key-value pairs.  They need to be inserted into a special
3572 drawer (@pxref{Drawers}) with the name @code{PROPERTIES}.  Each property
3573 is specified on a single line, with the key (surrounded by colons)
3574 first, and the value after it.  Here is an example:
3576 @example
3577 * CD collection
3578 ** Classic
3579 *** Goldberg Variations
3580     :PROPERTIES:
3581     :Title:     Goldberg Variations
3582     :Composer:  J.S. Bach
3583     :Artist:    Glen Gould
3584     :Publisher: Deutsche Grammphon
3585     :NDisks:    1
3586     :END:
3587 @end example
3589 You may define the allowed values for a particular property @samp{:Xyz:}
3590 by setting a property @samp{:Xyz_ALL:}.  This special property is
3591 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
3592 the entire tree.  When allowed values are defined, setting the
3593 corresponding property becomes easier and is less prone to typing
3594 errors.  For the example with the CD collection, we can predefine
3595 publishers and the number of disks in a box like this:
3597 @example
3598 * CD collection
3599   :PROPERTIES:
3600   :NDisks_ALL:  1 2 3 4
3601   :Publisher_ALL: "Deutsche Grammophon" Phillips EMI
3602   :END:
3603 @end example
3605 If you want to set properties that can be inherited by any entry in a
3606 file, use a line like
3608 @example
3609 #+PROPERTY: NDisks_ALL 1 2 3 4
3610 @end example
3612 Property values set with the global variable
3613 @code{org-global-properties} can be inherited by all entries in all
3614 Org files.
3616 @noindent
3617 The following commands help to work with properties:
3619 @table @kbd
3620 @kindex M-@key{TAB}
3621 @item M-@key{TAB}
3622 After an initial colon in a line, complete property keys.  All keys used
3623 in the current file will be offered as possible completions.
3624 @kindex C-c C-x p
3625 @item C-c C-x p
3626 Set a property.  This prompts for a property name and a value.  If
3627 necessary, the property drawer is created as well.
3628 @item M-x org-insert-property-drawer
3629 Insert a property drawer into the current entry.  The drawer will be
3630 inserted early in the entry, but after the lines with planning
3631 information like deadlines.
3632 @kindex C-c C-c
3633 @item C-c C-c
3634 With the cursor in a property drawer, this executes property commands.
3635 @item C-c C-c s
3636 Set a property in the current entry.  Both the property and the value
3637 can be inserted using completion.
3638 @kindex S-@key{right}
3639 @kindex S-@key{left}
3640 @item S-@key{left}/@key{right}
3641 Switch property at point to the next/previous allowed value.
3642 @item C-c C-c d
3643 Remove a property from the current entry.
3644 @item C-c C-c D
3645 Globally remove a property, from all entries in the current file.
3646 @item C-c C-c c
3647 Compute the property at point, using the operator and scope from the
3648 nearest column format definition.
3649 @end table
3651 @node Special properties, Property searches, Property syntax, Properties and Columns
3652 @section Special properties
3653 @cindex properties, special
3655 Special properties provide alternative access method to Org mode
3656 features discussed in the previous chapters, like the TODO state or the
3657 priority of an entry.  This interface exists so that you can include
3658 these states into columns view (@pxref{Column view}), or to use them in
3659 queries.  The following property names are special and should not be
3660 used as keys in the properties drawer:
3662 @example
3663 TODO         @r{The TODO keyword of the entry.}
3664 TAGS         @r{The tags defined directly in the headline.}
3665 ALLTAGS      @r{All tags, including inherited ones.}
3666 PRIORITY     @r{The priority of the entry, a string with a single letter.}
3667 DEADLINE     @r{The deadline time string, without the angular brackets.}
3668 SCHEDULED    @r{The scheduling time stamp, without the angular brackets.}
3669 TIMESTAMP    @r{The first keyword-less time stamp in the entry.}
3670 TIMESTAMP_IA @r{The first inactive time stamp in the entry.}
3671 CLOCKSUM     @r{The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}}
3672              @r{must be run first to compute the values.}
3673 @end example
3675 @node Property searches, Property inheritance, Special properties, Properties and Columns
3676 @section Property searches
3677 @cindex properties, searching
3678 @cindex searching, of properties
3680 To create sparse trees and special lists with selection based on properties,
3681 the same commands are used as for tag searches (@pxref{Tag searches}), and
3682 the same logic applies.  For example, here is a search string:
3684 @example
3685 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort<2+With=@{Sarah\|Denny@}
3686 @end example
3688 @noindent
3689 If the comparison value is a plain number, a numerical comparison is done,
3690 and the allowed operators are @samp{<}, @samp{=}, @samp{>}, @samp{<=},
3691 @samp{>=}, and @samp{<>}.  If the comparison value is enclosed in double
3692 quotes, a string comparison is done, and the same operators are allowed.  If
3693 the comparison value is enclosed in curly braces, a regexp match is
3694 performed, with @samp{=} meaning that the regexp matches the property value,
3695 and @samp{<>} meaning that it does not match.  So the search string in the
3696 example finds entries tagged @samp{:work:} but not @samp{:boss:}, which also
3697 have a priority value @samp{A}, a @samp{:Coffee:} property with the value
3698 @samp{unlimited}, an @samp{Effort} property that is numerically smaller than
3699 2, and a @samp{:With:} property that is matched by the regular expression
3700 @samp{Sarah\|Denny}.
3702 You can configure Org mode to use property inheritance during a search, but
3703 beware that this can slow down searches considerably.  See @ref{Property
3704 inheritance} for details.
3706 There is also a special command for creating sparse trees based on a
3707 single property:
3709 @table @kbd
3710 @kindex C-c / p
3711 @item C-c / p
3712 Create a sparse tree based on the value of a property.  This first
3713 prompts for the name of a property, and then for a value.  A sparse tree
3714 is created with all entries that define this property with the given
3715 value.  If you enclose the value into curly braces, it is interpreted as
3716 a regular expression and matched against the property values.
3717 @end table
3719 @node Property inheritance, Column view, Property searches, Properties and Columns
3720 @section Property Inheritance
3721 @cindex properties, inheritance
3722 @cindex inheritance, of properties
3724 The outline structure of Org mode documents lends itself for an
3725 inheritance model of properties: If the parent in a tree has a certain
3726 property, the children can inherit this property.  Org mode does not
3727 turn this on by default, because it can slow down property searches
3728 significantly and is often not needed.  However, if you find inheritance
3729 useful, you can turn it on by setting the variable
3730 @code{org-use-property-inheritance}.  It may be set to @code{t}, to make
3731 all properties inherited from the parent, to a list of properties
3732 that should be inherited, or to a regular expression that matches
3733 inherited properties.
3735 Org mode has a few properties for which inheritance is hard-coded, at
3736 least for the special applications for which they are used:
3738 @table @code
3739 @item COLUMNS
3740 The @code{:COLUMNS:} property defines the format of column view
3741 (@pxref{Column view}).  It is inherited in the sense that the level
3742 where a @code{:COLUMNS:} property is defined is used as the starting
3743 point for a column view table, independently of the location in the
3744 subtree from where columns view is turned on.
3745 @item CATEGORY
3746 For agenda view, a category set through a @code{:CATEGORY:} property
3747 applies to the entire subtree.
3748 @item ARCHIVE
3749 For archiving, the @code{:ARCHIVE:} property may define the archive
3750 location for the entire subtree (@pxref{Moving subtrees}).
3751 @item LOGGING
3752 The LOGGING property may define logging settings for an entry or a
3753 subtree (@pxref{Tracking TODO state changes}).
3754 @end table
3756 @node Column view, Property API, Property inheritance, Properties and Columns
3757 @section Column view
3759 A great way to view and edit properties in an outline tree is
3760 @emph{column view}.  In column view, each outline item is turned into a
3761 table row.  Columns in this table provide access to properties of the
3762 entries.  Org mode implements columns by overlaying a tabular structure
3763 over the headline of each item.  While the headlines have been turned
3764 into a table row, you can still change the visibility of the outline
3765 tree.  For example, you get a compact table by switching to CONTENTS
3766 view (@kbd{S-@key{TAB} S-@key{TAB}}, or simply @kbd{c} while column view
3767 is active), but you can still open, read, and edit the entry below each
3768 headline.  Or, you can switch to column view after executing a sparse
3769 tree command and in this way get a table only for the selected items.
3770 Column view also works in agenda buffers (@pxref{Agenda Views}) where
3771 queries have collected selected items, possibly from a number of files.
3773 @menu
3774 * Defining columns::            The COLUMNS format property
3775 * Using column view::           How to create and use column view
3776 * Capturing column view::       A dynamic block for column view
3777 @end menu
3779 @node Defining columns, Using column view, Column view, Column view
3780 @subsection Defining columns
3781 @cindex column view, for properties
3782 @cindex properties, column view
3784 Setting up a column view first requires defining the columns.  This is
3785 done by defining a column format line.
3787 @menu
3788 * Scope of column definitions::  Where defined, where valid?
3789 * Column attributes::           Appearance and content of a column
3790 @end menu
3792 @node Scope of column definitions, Column attributes, Defining columns, Defining columns
3793 @subsubsection Scope of column definitions
3795 To define a column format for an entire file, use a line like
3797 @example
3798 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
3799 @end example
3801 To specify a format that only applies to a specific tree, add a
3802 @code{:COLUMNS:} property to the top node of that tree, for example:
3804 @example
3805 ** Top node for columns view
3806    :PROPERTIES:
3807    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
3808    :END:
3809 @end example
3811 If a @code{:COLUMNS:} property is present in an entry, it defines columns
3812 for the entry itself, and for the entire subtree below it.  Since the
3813 column definition is part of the hierarchical structure of the document,
3814 you can define columns on level 1 that are general enough for all
3815 sublevels, and more specific columns further down, when you edit a
3816 deeper part of the tree.
3818 @node Column attributes,  , Scope of column definitions, Defining columns
3819 @subsubsection Column attributes
3820 A column definition sets the attributes of a column.  The general
3821 definition looks like this:
3823 @example
3824  %[width]property[(title)][@{summary-type@}]
3825 @end example
3827 @noindent
3828 Except for the percent sign and the property name, all items are
3829 optional.  The individual parts have the following meaning:
3831 @example
3832 width           @r{An integer specifying the width of the column in characters.}
3833                 @r{If omitted, the width will be determined automatically.}
3834 property        @r{The property that should be edited in this column.}
3835 (title)         @r{The header text for the column. If omitted, the}
3836                 @r{property name is used.}
3837 @{summary-type@}  @r{The summary type.  If specified, the column values for}
3838                 @r{parent nodes are computed from the children.}
3839                 @r{Supported summary types are:}
3840                 @{+@}       @r{Sum numbers in this column.}
3841                 @{+;%.1f@}  @r{Like @samp{+}, but format result with @samp{%.1f}.}
3842                 @{$@}       @r{Currency, short for @samp{+;%.2f}.}
3843                 @{:@}       @r{Sum times, HH:MM:SS, plain numbers are hours.}
3844                 @{X@}       @r{Checkbox status, [X] if all children are [X].}
3845                 @{X/@}      @r{Checkbox status, [n/m].}
3846                 @{X%@}      @r{Checkbox status, [n%].}
3847 @end example
3849 @noindent
3850 Here is an example for a complete columns definition, along with allowed
3851 values.
3853 @example
3854 :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.}
3855                    %10Time_Estimate@{:@} %CLOCKSUM
3856 :Owner_ALL:    Tammy Mark Karl Lisa Don
3857 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
3858 :Approved_ALL: "[ ]" "[X]"
3859 @end example
3861 The first column, @samp{%25ITEM}, means the first 25 characters of the
3862 item itself, i.e. of the headline.  You probably always should start the
3863 column definition with the @samp{ITEM} specifier.  The other specifiers
3864 create columns @samp{Owner} with a list of names as allowed values, for
3865 @samp{Status} with four different possible values, and for a checkbox
3866 field @samp{Approved}.  When no width is given after the @samp{%}
3867 character, the column will be exactly as wide as it needs to be in order
3868 to fully display all values.  The @samp{Approved} column does have a
3869 modified title (@samp{Approved?}, with a question mark).  Summaries will
3870 be created for the @samp{Time_Estimate} column by adding time duration
3871 expressions like HH:MM, and for the @samp{Approved} column, by providing
3872 an @samp{[X]} status if all children have been checked.  The
3873 @samp{CLOCKSUM} column is special, it lists the sum of CLOCK intervals
3874 in the subtree.
3876 @node Using column view, Capturing column view, Defining columns, Column view
3877 @subsection Using column view
3879 @table @kbd
3880 @tsubheading{Turning column view on and off}
3881 @kindex C-c C-x C-c
3882 @item C-c C-x C-c
3883 Create the column view for the local environment.  This command searches
3884 the hierarchy, up from point, for a @code{:COLUMNS:} property that defines
3885 a format.  When one is found, the column view table is established for
3886 the entire tree, starting from the entry that contains the @code{:COLUMNS:}
3887 property.  If none is found, the format is taken from the @code{#+COLUMNS}
3888 line or from the variable @code{org-columns-default-format}, and column
3889 view is established for the current entry and its subtree.
3890 @kindex r
3891 @item r
3892 Recreate the column view, to include recent changes made in the buffer.
3893 @kindex g
3894 @item g
3895 Same as @kbd{r}.
3896 @kindex q
3897 @item q
3898 Exit column view.
3899 @tsubheading{Editing values}
3900 @item @key{left} @key{right} @key{up} @key{down}
3901 Move through the column view from field to field.
3902 @kindex S-@key{left}
3903 @kindex S-@key{right}
3904 @item  S-@key{left}/@key{right}
3905 Switch to the next/previous allowed value of the field.  For this, you
3906 have to have specified allowed values for a property.
3907 @kindex n
3908 @kindex p
3909 @itemx  n / p
3910 Same as @kbd{S-@key{left}/@key{right}}
3911 @kindex e
3912 @item e
3913 Edit the property at point.  For the special properties, this will
3914 invoke the same interface that you normally use to change that
3915 property.  For example, when editing a TAGS property, the tag completion
3916 or fast selection interface will pop up.
3917 @kindex C-c C-c
3918 @item C-c C-c
3919 When there is a checkbox at point, toggle it.
3920 @kindex v
3921 @item v
3922 View the full value of this property.  This is useful if the width of
3923 the column is smaller than that of the value.
3924 @kindex a
3925 @item a
3926 Edit the list of allowed values for this property.  If the list is found
3927 in the hierarchy, the modified values is stored there.  If no list is
3928 found, the new value is stored in the first entry that is part of the
3929 current column view.
3930 @tsubheading{Modifying the table structure}
3931 @kindex <
3932 @kindex >
3933 @item < / >
3934 Make the column narrower/wider by one character.
3935 @kindex S-M-@key{right}
3936 @item S-M-@key{right}
3937 Insert a new column, to the right of the current column.
3938 @kindex S-M-@key{left}
3939 @item S-M-@key{left}
3940 Delete the current column.
3941 @end table
3943 @node Capturing column view,  , Using column view, Column view
3944 @subsection Capturing column view
3946 Since column view is just an overlay over a buffer, it cannot be
3947 exported or printed directly.  If you want to capture a column view, use
3948 this @code{columnview} dynamic block (@pxref{Dynamic blocks}).  The frame
3949 of this block looks like this:
3951 @example
3952 * The column view
3953 #+BEGIN: columnview :hlines 1 :id "label"
3955 #+END:
3956 @end example
3958 @noindent This dynamic block has the following parameters:
3960 @table @code
3961 @item :id
3962 This is most important parameter.  Column view is a feature that is
3963 often localized to a certain (sub)tree, and the capture block might be
3964 in a different location in the file.  To identify the tree whose view to
3965 capture, you can use 3 values:
3966 @example
3967 local     @r{use the tree in which the capture block is located}
3968 global    @r{make a global view, including all headings in the file}
3969 "label"   @r{call column view in the tree that has and @code{:ID:}}
3970           @r{property with the value @i{label}}
3971 @end example
3972 @item :hlines
3973 When @code{t}, insert a hline after every line.  When a number N, insert
3974 a hline before each headline with level @code{<= N}.
3975 @item :vlines
3976 When set to @code{t}, enforce column groups to get vertical lines.
3977 @item :maxlevel
3978 When set to a number, don't capture entries below this level.
3979 @item :skip-empty-rows
3980 When set to @code{t}, skip row where the only non-empty specifier of the
3981 column view is @code{ITEM}.
3983 @end table
3985 @noindent
3986 The following commands insert or update the dynamic block:
3988 @table @kbd
3989 @kindex C-c C-x r
3990 @item C-c C-x r
3991 Insert a dynamic block capturing a column view.  You will be prompted
3992 for the scope or id of the view.
3993 @kindex C-c C-c
3994 @item C-c C-c
3995 @kindex C-c C-x C-u
3996 @itemx C-c C-x C-u
3997 Update dynamical block at point.  The cursor needs to be in the
3998 @code{#+BEGIN} line of the dynamic block.
3999 @kindex C-u C-c C-x C-u
4000 @item C-u C-c C-x C-u
4001 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
4002 you have several clock table blocks in a buffer.
4003 @end table
4005 @node Property API,  , Column view, Properties and Columns
4006 @section The Property API
4007 @cindex properties, API
4008 @cindex API, for properties
4010 There is a full API for accessing and changing properties.  This API can
4011 be used by Emacs Lisp programs to work with properties and to implement
4012 features based on them.  For more information see @ref{Using the
4013 property API}.
4015 @node Dates and Times, Remember, Properties and Columns, Top
4016 @chapter Dates and Times
4017 @cindex dates
4018 @cindex times
4019 @cindex time stamps
4020 @cindex date stamps
4022 To assist project planning, TODO items can be labeled with a date and/or
4023 a time.  The specially formatted string carrying the date and time
4024 information is called a @emph{timestamp} in Org mode.  This may be a
4025 little confusing because timestamp is often used as indicating when
4026 something was created or last changed.  However, in Org mode this term
4027 is used in a much wider sense.
4029 @menu
4030 * Timestamps::                  Assigning a time to a tree entry
4031 * Creating timestamps::         Commands which insert timestamps
4032 * Deadlines and scheduling::    Planning your work
4033 * Clocking work time::          Tracking how long you spend on a task
4034 * Effort estimates::            Planning work effort in advance
4035 @end menu
4038 @node Timestamps, Creating timestamps, Dates and Times, Dates and Times
4039 @section Timestamps, deadlines and scheduling
4040 @cindex time stamps
4041 @cindex ranges, time
4042 @cindex date stamps
4043 @cindex deadlines
4044 @cindex scheduling
4046 A time stamp is a specification of a date (possibly with time or a range
4047 of times) in a special format, either @samp{<2003-09-16 Tue>} or
4048 @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16 Tue
4049 12:00-12:30>}@footnote{This is the standard ISO date/time format.  To
4050 use an alternative format, see @ref{Custom time format}.}.  A time stamp
4051 can appear anywhere in the headline or body of an Org tree entry.  Its
4052 presence causes entries to be shown on specific dates in the agenda
4053 (@pxref{Weekly/daily agenda}).  We distinguish:
4055 @table @var
4056 @item Plain time stamp; Event; Appointment
4057 @cindex timestamp
4058 A simple time stamp just assigns a date/time to an item.  This is just
4059 like writing down an appointment or event in a paper agenda.  In the
4060 timeline and agenda displays, the headline of an entry associated with a
4061 plain time stamp will be shown exactly on that date.
4063 @example
4064 * Meet Peter at the movies <2006-11-01 Wed 19:15>
4065 * Discussion on climate change <2006-11-02 Thu 20:00-22:00>
4066 @end example
4068 @item Time stamp with repeater interval
4069 @cindex timestamp, with repeater interval
4070 A time stamp may contain a @emph{repeater interval}, indicating that it
4071 applies not only on the given date, but again and again after a certain
4072 interval of N days (d), weeks (w), months(m), or years(y).  The
4073 following will show up in the agenda every Wednesday:
4075 @example
4076 * Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
4077 @end example
4079 @item Diary-style sexp entries
4080 For more complex date specifications, Org mode supports using the
4081 special sexp diary entries implemented in the Emacs calendar/diary
4082 package.  For example
4084 @example
4085 * The nerd meeting on every 2nd Thursday of the month
4086   <%%(diary-float t 4 2)>
4087 @end example
4089 @item Time/Date range
4090 @cindex timerange
4091 @cindex date range
4092 Two time stamps connected by @samp{--} denote a range.  The headline
4093 will be shown on the first and last day of the range, and on any dates
4094 that are displayed and fall in the range.  Here is an example:
4096 @example
4097 ** Meeting in Amsterdam
4098    <2004-08-23 Mon>--<2004-08-26 Thu>
4099 @end example
4101 @item Inactive time stamp
4102 @cindex timestamp, inactive
4103 @cindex inactive timestamp
4104 Just like a plain time stamp, but with square brackets instead of
4105 angular ones.  These time stamps are inactive in the sense that they do
4106 @emph{not} trigger an entry to show up in the agenda.
4108 @example
4109 * Gillian comes late for the fifth time [2006-11-01 Wed]
4110 @end example
4112 @end table
4114 @node Creating timestamps, Deadlines and scheduling, Timestamps, Dates and Times
4115 @section Creating timestamps
4116 @cindex creating timestamps
4117 @cindex timestamps, creating
4119 For Org mode to recognize time stamps, they need to be in the specific
4120 format.  All commands listed below produce time stamps in the correct
4121 format.
4123 @table @kbd
4124 @kindex C-c .
4125 @item C-c .
4126 Prompt for a date and insert a corresponding time stamp.  When the
4127 cursor is at a previously used time stamp, it is updated to NOW.  When
4128 this command is used twice in succession, a time range is inserted.
4130 @kindex C-u C-c .
4131 @item C-u C-c .
4132 Like @kbd{C-c .}, but use the alternative format which contains date
4133 and time.  The default time can be rounded to multiples of 5 minutes,
4134 see the option @code{org-time-stamp-rounding-minutes}.
4136 @kindex C-c !
4137 @item C-c !
4138 Like @kbd{C-c .}, but insert an inactive time stamp that will not cause
4139 an agenda entry.
4141 @kindex C-c <
4142 @item C-c <
4143 Insert a time stamp corresponding to the cursor date in the Calendar.
4145 @kindex C-c >
4146 @item C-c >
4147 Access the Emacs calendar for the current date.  If there is a
4148 timestamp in the current line, go to the corresponding date
4149 instead.
4151 @kindex C-c C-o
4152 @item C-c C-o
4153 Access the agenda for the date given by the time stamp or -range at
4154 point (@pxref{Weekly/daily agenda}).
4156 @kindex S-@key{left}
4157 @kindex S-@key{right}
4158 @item S-@key{left}
4159 @itemx S-@key{right}
4160 Change date at cursor by one day.  These key bindings conflict with
4161 CUA mode (@pxref{Conflicts}).
4163 @kindex S-@key{up}
4164 @kindex S-@key{down}
4165 @item S-@key{up}
4166 @itemx S-@key{down}
4167 Change the item under the cursor in a timestamp.  The cursor can be on a
4168 year, month, day, hour or minute.  Note that if the cursor is in a
4169 headline and not at a time stamp, these same keys modify the priority of
4170 an item.  (@pxref{Priorities}). The key bindings also conflict with
4171 CUA mode (@pxref{Conflicts}).
4173 @kindex C-c C-y
4174 @cindex evaluate time range
4175 @item C-c C-y
4176 Evaluate a time range by computing the difference between start and end.
4177 With a prefix argument, insert result after the time range (in a table: into
4178 the following column).
4179 @end table
4182 @menu
4183 * The date/time prompt::        How Org mode helps you entering date and time
4184 * Custom time format::          Making dates look different
4185 @end menu
4187 @node The date/time prompt, Custom time format, Creating timestamps, Creating timestamps
4188 @subsection The date/time prompt
4189 @cindex date, reading in minibuffer
4190 @cindex time, reading in minibuffer
4192 When Org mode prompts for a date/time, the default is shown as an ISO
4193 date, and the prompt therefore seems to ask for an ISO date.  But it
4194 will in fact accept any string containing some date and/or time
4195 information, and it is really smart about interpreting your input.  You
4196 can, for example, use @kbd{C-y} to paste a (possibly multi-line) string
4197 copied from an email message.  Org mode will find whatever information
4198 is in there and derive anything you have not specified from the
4199 @emph{default date and time}.  The default is usually the current date
4200 and time, but when modifying an existing time stamp, or when entering
4201 the second stamp of a range, it is taken from the stamp in the buffer.
4202 When filling in information, Org mode assumes that most of the time you
4203 will want to enter a date in the future: If you omit the month/year and
4204 the given day/month is @i{before} today, it will assume that you mean a
4205 future date@footnote{See the variable
4206 @code{org-read-date-prefer-future}.}.
4208 For example, lets assume that today is @b{June 13, 2006}.  Here is how
4209 various inputs will be interpreted, the items filled in by Org mode are
4210 in @b{bold}.
4212 @example
4213 3-2-5         --> 2003-02-05
4214 14            --> @b{2006}-@b{06}-14
4215 12            --> @b{2006}-@b{07}-12
4216 Fri           --> nearest Friday (defaultdate or later)
4217 sep 15        --> @b{2006}-11-15
4218 feb 15        --> @b{2007}-02-15
4219 sep 12 9      --> 2009-09-12
4220 12:45         --> @b{2006}-@b{06}-@b{13} 12:45
4221 22 sept 0:34  --> @b{2006}-09-22 0:34
4222 w4            --> ISO week for of the current year @b{2006}
4223 2012 w4 fri   --> Friday of ISO week 4 in 2012
4224 2012-w04-5    --> Same as above
4225 @end example
4227 Furthermore you can specify a relative date by giving, as the
4228 @emph{first} thing in the input: a plus/minus sign, a number and a
4229 letter [dwmy] to indicate change in days weeks, months, years.  With a
4230 single plus or minus, the date is always relative to today.  With a
4231 double plus or minus, it is relative to the default date.  If instead of
4232 a single letter, you use the abbreviation of day name, the date will be
4233 the nth such day.  E.g.
4235 @example
4236 +0            --> today
4237 .             --> today
4238 +4d           --> four days from today
4239 +4            --> same as above
4240 +2w           --> two weeks from today
4241 ++5           --> five days from default date
4242 +2tue         --> second tuesday from now.
4243 @end example
4245 The function understands English month and weekday abbreviations.  If
4246 you want to use unabbreviated names and/or other languages, configure
4247 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
4249 @cindex calendar, for selecting date
4250 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
4251 you don't need/want the calendar, configure the variable
4252 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
4253 prompt, either by clicking on a date in the calendar, or by pressing
4254 @key{RET}, the date selected in the calendar will be combined with the
4255 information entered at the prompt.  You can control the calendar fully
4256 from the minibuffer:
4258 @kindex <
4259 @kindex >
4260 @kindex mouse-1
4261 @kindex S-@key{right}
4262 @kindex S-@key{left}
4263 @kindex S-@key{down}
4264 @kindex S-@key{up}
4265 @kindex M-S-@key{right}
4266 @kindex M-S-@key{left}
4267 @kindex @key{RET}
4268 @example
4269 > / <          @r{Scroll calendar forward/backward by one month.}
4270 mouse-1        @r{Select date by clicking on it.}
4271 S-@key{right}/@key{left}     @r{One day forward/backward.}
4272 S-@key{down}/@key{up}     @r{One week forward/backward.}
4273 M-S-@key{right}/@key{left}   @r{One month forward/backward.}
4274 @key{RET}           @r{Choose date in calendar.}
4275 @end example
4277 The actions of the date/time prompt may seem complex, but I assure you they
4278 will grow on you, and you will start getting annoyed by pretty much any other
4279 way of entering a date/time out there.  To help you understand what is going
4280 on, the current interpretation of your input will be displayed live in the
4281 minibuffer@footnote{If you find this distracting, turn the display of with
4282 @code{org-read-date-display-live}.}.
4284 @node Custom time format,  , The date/time prompt, Creating timestamps
4285 @subsection Custom time format
4286 @cindex custom date/time format
4287 @cindex time format, custom
4288 @cindex date format, custom
4290 Org mode uses the standard ISO notation for dates and times as it is
4291 defined in ISO 8601.  If you cannot get used to this and require another
4292 representation of date and time to keep you happy, you can get it by
4293 customizing the variables @code{org-display-custom-times} and
4294 @code{org-time-stamp-custom-formats}.
4296 @table @kbd
4297 @kindex C-c C-x C-t
4298 @item C-c C-x C-t
4299 Toggle the display of custom formats for dates and times.
4300 @end table
4302 @noindent
4303 Org mode needs the default format for scanning, so the custom date/time
4304 format does not @emph{replace} the default format - instead it is put
4305 @emph{over} the default format using text properties.  This has the
4306 following consequences:
4307 @itemize @bullet
4308 @item
4309 You cannot place the cursor onto a time stamp anymore, only before or
4310 after.
4311 @item
4312 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
4313 each component of a time stamp.  If the cursor is at the beginning of
4314 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
4315 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
4316 time will be changed by one minute.
4317 @item
4318 If the time stamp contains a range of clock times or a repeater, these
4319 will not be overlayed, but remain in the buffer as they were.
4320 @item
4321 When you delete a time stamp character-by-character, it will only
4322 disappear from the buffer after @emph{all} (invisible) characters
4323 belonging to the ISO timestamp have been removed.
4324 @item
4325 If the custom time stamp format is longer than the default and you are
4326 using dates in tables, table alignment will be messed up.  If the custom
4327 format is shorter, things do work as expected.
4328 @end itemize
4331 @node Deadlines and scheduling, Clocking work time, Creating timestamps, Dates and Times
4332 @section Deadlines and scheduling
4334 A time stamp may be preceded by special keywords to facilitate planning:
4336 @table @var
4337 @item DEADLINE
4338 @cindex DEADLINE keyword
4340 Meaning: the task (most likely a TODO item, though not necessarily) is supposed
4341 to be finished on that date.
4343 On the deadline date, the task will be listed in the agenda.  In
4344 addition, the agenda for @emph{today} will carry a warning about the
4345 approaching or missed deadline, starting
4346 @code{org-deadline-warning-days} before the due date, and continuing
4347 until the entry is marked DONE.  An example:
4349 @example
4350 *** TODO write article about the Earth for the Guide
4351     The editor in charge is [[bbdb:Ford Prefect]]
4352     DEADLINE: <2004-02-29 Sun>
4353 @end example
4355 You can specify a different lead time for warnings for a specific
4356 deadlines using the following syntax.  Here is an example with a warning
4357 period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.
4359 @item SCHEDULED
4360 @cindex SCHEDULED keyword
4362 Meaning: you are planning to start working on that task on the given
4363 date.
4365 The headline will be listed under the given date@footnote{It will still
4366 be listed on that date after it has been marked DONE.  If you don't like
4367 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
4368 addition, a reminder that the scheduled date has passed will be present
4369 in the compilation for @emph{today}, until the entry is marked DONE.
4370 I.e., the task will automatically be forwarded until completed.
4372 @example
4373 *** TODO Call Trillian for a date on New Years Eve.
4374     SCHEDULED: <2004-12-25 Sat>
4375 @end example
4377 @noindent
4378 @b{Important:} Scheduling an item in Org mode should @i{not} be
4379 understood in the same way that we understand @i{scheduling a meeting}.
4380 Setting a date for a meeting is just a simple appointment, you should
4381 mark this entry with a simple plain time stamp, to get this item shown
4382 on the date where it applies.  This is a frequent mis-understanding from
4383 Org-users.  In Org mode, @i{scheduling} means setting a date when you
4384 want to start working on an action item.
4385 @end table
4387 You may use time stamps with repeaters in scheduling and deadline
4388 entries.  Org mode will issue early and late warnings based on the
4389 assumption that the time stamp represents the @i{nearest instance} of
4390 the repeater.  However, the use of diary sexp entries like
4392 @code{<%%(diary-float t 42)>}
4394 in scheduling and deadline timestamps is limited.  Org mode does not
4395 know enough about the internals of each sexp function to issue early and
4396 late warnings.  However, it will show the item on each day where the
4397 sexp entry matches.
4399 @menu
4400 * Inserting deadline/schedule::  Planning items
4401 * Repeated tasks::              Items that show up again and again
4402 @end menu
4404 @node Inserting deadline/schedule, Repeated tasks, Deadlines and scheduling, Deadlines and scheduling
4405 @subsection Inserting deadlines or schedules
4407 The following commands allow to quickly insert a deadline or to schedule
4408 an item:
4410 @table @kbd
4412 @kindex C-c C-d
4413 @item C-c C-d
4414 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will
4415 happen in the line directly following the headline.  When called with a
4416 prefix arg, an existing deadline will be removed from the entry.
4417 @c FIXME Any CLOSED timestamp will be removed.????????
4419 @kindex C-c / d
4420 @cindex sparse tree, for deadlines
4421 @item C-c / d
4422 Create a sparse tree with all deadlines that are either past-due, or
4423 which will become due within @code{org-deadline-warning-days}.
4424 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
4425 prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows
4426 all deadlines due tomorrow.
4428 @kindex C-c C-s
4429 @item C-c C-s
4430 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
4431 happen in the line directly following the headline.  Any CLOSED
4432 timestamp will be removed.  When called with a prefix argument, remove
4433 the scheduling date from the entry.
4434 @end table
4436 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
4437 @subsection Repeated tasks
4439 Some tasks need to be repeated again and again.  Org mode helps to
4440 organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
4441 or plain time stamp.  In the following example
4442 @example
4443 ** TODO Pay the rent
4444    DEADLINE: <2005-10-01 Sat +1m>
4445 @end example
4446 the @code{+1m} is a repeater; the intended interpretation is that the
4447 task has a deadline on <2005-10-01> and repeats itself every (one) month
4448 starting from that time.  If you need both a repeater and a special
4449 warning period in a deadline entry, the repeater comes first and the
4450 warning period last: @code{DEADLINE: <2005-10-01 Sat +1m -3d>}.
4452 Deadlines and scheduled items produce entries in the agenda when they
4453 are over-due, so it is important to be able to mark such an entry as
4454 completed once you have done so.  When you mark a DEADLINE or a SCHEDULE
4455 with the TODO keyword DONE, it will no longer produce entries in the
4456 agenda.  The problem with this is, however, that then also the
4457 @emph{next} instance of the repeated entry will not be active.  Org mode
4458 deals with this in the following way: When you try to mark such an entry
4459 DONE (using @kbd{C-c C-t}), it will shift the base date of the repeating
4460 time stamp by the repeater interval, and immediately set the entry state
4461 back to TODO.  In the example above, setting the state to DONE would
4462 actually switch the date like this:
4464 @example
4465 ** TODO Pay the rent
4466    DEADLINE: <2005-11-01 Tue +1m>
4467 @end example
4469 A timestamp@footnote{You can change this using the option
4470 @code{org-log-repeat}, or the @code{#+STARTUP} options @code{logrepeat},
4471 @code{lognoterepeat}, and @code{nologrepeat}.  With @code{lognoterepeat}, you
4472 will aslo be prompted for a note.} will be added under the deadline, to keep
4473 a record that you actually acted on the previous instance of this deadline.
4475 As a consequence of shifting the base date, this entry will no longer be
4476 visible in the agenda when checking past dates, but all future instances
4477 will be visible.
4479 With the @samp{+1m} cookie, the date shift will always be exactly one
4480 month.  So if you have not payed the rent for three months, marking this
4481 entry DONE will still keep it as an overdue deadline.  Depending on the
4482 task, this may not be the best way to handle it.  For example, if you
4483 forgot to call you father for 3 weeks, it does not make sense to call
4484 him 3 times in a single day to make up for it.  Finally, there are tasks
4485 like changing batteries which should always repeat a certain time
4486 @i{after} the last time you did it.  For these tasks, Org mode has
4487 special repeaters markers with @samp{++} and @samp{.+}.  For example:
4489 @example
4490 ** TODO Call Father
4491    DEADLINE: <2008-02-10 Sun ++1w>
4492    Marking this DONE will shift the date by at least one week,
4493    but also by as many weeks as it takes to get this date into
4494    the future.  However, it stays on a Sunday, even if you called
4495    and marked it done on Saturday.
4496 ** TODO Check the batteries in the smoke detectors
4497    DEADLINE: <2005-11-01 Tue .+1m>
4498    Marking this DONE will shift the date to one month after
4499    today.
4500 @end example
4502 You may have both scheduling and deadline information for a specific
4503 task - just make sure that the repeater intervals on both are the same.
4505 @node Clocking work time, Effort estimates, Deadlines and scheduling, Dates and Times
4506 @section Clocking work time
4508 Org mode allows you to clock the time you spent on specific tasks in a
4509 project.  When you start working on an item, you can start the clock.
4510 When you stop working on that task, or when you mark the task done, the
4511 clock is stopped and the corresponding time interval is recorded.  It
4512 also computes the total time spent on each subtree of a project.
4514 @table @kbd
4515 @kindex C-c C-x C-i
4516 @item C-c C-x C-i
4517 Start the clock on the current item (clock-in).  This inserts the CLOCK
4518 keyword together with a timestamp.  If this is not the first clocking of
4519 this item, the multiple CLOCK lines will be wrapped into a
4520 @code{:CLOCK:} drawer (see also the variable
4521 @code{org-clock-into-drawer}).  When called with a @kbd{C-u} prefix argument,
4522 select the task from a list of recently clocked tasks.  With two @kbd{C-u
4523 C-u} prefixes, clock into the task at point and mark it as the default task.
4524 The default task will always be available when selecting a clocking task,
4525 with letter @kbd{d}.
4526 @kindex C-c C-x C-o
4527 @item C-c C-x C-o
4528 Stop the clock (clock-out).  The inserts another timestamp at the same
4529 location where the clock was last started.  It also directly computes
4530 the resulting time in inserts it after the time range as @samp{=>
4531 HH:MM}.  See the variable @code{org-log-note-clock-out} for the
4532 possibility to record an additional note together with the clock-out
4533 time stamp@footnote{The corresponding in-buffer setting is:
4534 @code{#+STARTUP: lognoteclock-out}}.
4535 @kindex C-c C-y
4536 @item C-c C-y
4537 Recompute the time interval after changing one of the time stamps.  This
4538 is only necessary if you edit the time stamps directly.  If you change
4539 them with @kbd{S-@key{cursor}} keys, the update is automatic.
4540 @kindex C-c C-t
4541 @item C-c C-t
4542 Changing the TODO state of an item to DONE automatically stops the clock
4543 if it is running in this same item.
4544 @kindex C-c C-x C-x
4545 @item C-c C-x C-x
4546 Cancel the current clock.  This is useful if a clock was started by
4547 mistake, or if you ended up working on something else.
4548 @kindex C-c C-x C-j
4549 @item C-c C-x C-j
4550 Jump to the entry that contains the currently running clock.  With a
4551 @kbd{C-u} prefix arg, select the target task from a list of recently clocked
4552 tasks.
4553 @kindex C-c C-x C-d
4554 @item C-c C-x C-d
4555 Display time summaries for each subtree in the current buffer.  This
4556 puts overlays at the end of each headline, showing the total time
4557 recorded under that heading, including the time of any subheadings. You
4558 can use visibility cycling to study the tree, but the overlays disappear
4559 when you change the buffer (see variable
4560 @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
4561 @kindex C-c C-x C-r
4562 @item C-c C-x C-r
4563 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
4564 report as an Org mode table into the current file.  When the cursor is
4565 at an existing clock table, just update it.  When called with a prefix
4566 argument, jump to the first clock report in the current document and
4567 update it.
4568 @example
4569 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
4570 #+END: clocktable
4571 @end example
4572 @noindent
4573 If such a block already exists at point, its content is replaced by the
4574 new table.  The @samp{BEGIN} line can specify options:
4575 @example
4576 :maxlevel    @r{Maximum level depth to which times are listed in the table.}
4577 :emphasize   @r{When @code{t}, emphasize level one and level two items}
4578 :scope       @r{The scope to consider.  This can be any of the following:}
4579              nil        @r{the current buffer or narrowed region}
4580              file       @r{the full current buffer}
4581              subtree    @r{the subtree where the clocktable is located}
4582              treeN      @r{the surrounding level N tree, for example @code{tree3}}
4583              tree       @r{the surrounding level 1 tree}
4584              agenda     @r{all agenda files}
4585              ("file"..) @r{scan these files}
4586              file-with-archives    @r{current file and its archives}
4587              agenda-with-archives  @r{all agenda files, including archives}
4588 :block       @r{The time block to consider.  This block is specified either}
4589              @r{absolute, or relative to the current time and may be any of}
4590              @r{these formats:}
4591              2007-12-31    @r{New year eve 2007}
4592              2007-12       @r{December 2007}
4593              2007-W50      @r{ISO-week 50 in 2007}
4594              2007          @r{the year 2007}
4595              today, yesterday, today-N          @r{a relative day}
4596              thisweek, lastweek, thisweek-N     @r{a relative week}
4597              thismonth, lastmonth, thismonth-N  @r{a relative month}
4598              thisyear, lastyear, thisyear-N     @r{a relative year}
4599              @r{Use @kbd{S-@key{left}/@key{right}} keys to shift the time interval.}
4600 :tstart      @r{A time string specifying when to start considering times}
4601 :tend        @r{A time string specifying when to stop considering times}
4602 :step        @r{@code{week} or @code{day}, to split the table into chunks.}
4603              @r{To use this, @code{:block} or @code{:tstart}, @code{:tend} are needed.}
4604 :link        @r{Link the item headlines in the table to their origins}
4605 @end example
4606 So to get a clock summary of the current level 1 tree, for the current
4607 day, you could write
4608 @example
4609 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1 :link t
4610 #+END: clocktable
4611 @end example
4612 and to use a specific time range you could write@footnote{Note that all
4613 parameters must be specified in a single line - the line is broken here
4614 only to fit it onto the manual.}
4615 @example
4616 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
4617                     :tend "<2006-08-10 Thu 12:00>"
4618 #+END: clocktable
4619 @end example
4620 @kindex C-c C-c
4621 @item C-c C-c
4622 @kindex C-c C-x C-u
4623 @itemx C-c C-x C-u
4624 Update dynamical block at point.  The cursor needs to be in the
4625 @code{#+BEGIN} line of the dynamic block.
4626 @kindex C-u C-c C-x C-u
4627 @item C-u C-c C-x C-u
4628 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
4629 you have several clock table blocks in a buffer.
4630 @kindex S-@key{left}
4631 @kindex S-@key{right}
4632 @item S-@key{left}
4633 @itemx S-@key{right}
4634 Shift the current @code{:block} interval and update the table.  The cursor
4635 needs to be in the @code{#+BEGIN: clocktable} line for this command.  If
4636 @code{:block} is @code{today}, it will be shifted to @code{today-1} etc.
4637 @end table
4639 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
4640 the agenda (@pxref{Weekly/daily agenda}) to show which tasks have been
4641 worked on or closed during a day.
4643 @node Effort estimates,  , Clocking work time, Dates and Times
4644 @section Effort estimates
4645 @cindex Effort estimates
4647 If you want to plan your work in a very detailed way, or if you need to
4648 produce offers with quotations of the estimated work effort, you may want to
4649 assign effort estimates to entries.  If you are also clocking your work, you
4650 may later want to compare the planned effort with the actual working time, a
4651 great way to improve planning estimates.  Effort estimates are stored in a
4652 special property @samp{Effort}@footnote{You may change the property being
4653 used with the variable @code{org-effort-property}.}.  Clearly the best way to
4654 work with effort estimates is through column view (@pxref{Column view}).  You
4655 should start by setting up discrete values for effort estimates, and a
4656 @code{COLUMNS} format that displays these values together with clock sums (if
4657 you want to clock your time).  For a specific buffer you can use
4659 @example
4660 #+PROPERTY: Effort_ALL 0 0:10 0:30 1:00 2:00 3:00 4:00 5:00 6:00 7:00 8:00
4661 #+COLUMNS: %40ITEM(Task) %17Effort(Estimated Effort)@{:@} %CLOCKSUM
4662 @end example
4664 @noindent
4665 or you can set up these values globally by customizing the variables
4666 @code{org-global-properties} and @code{org-columns-default-format}.  In
4667 particular if you want to use this setup also in the agenda, a global setup
4668 may be advised.
4670 The way to assign estimates to individual items is then to switch to column
4671 mode, and to use @kbd{S-@key{right}} and @kbd{S-@key{left}} to change the
4672 value.  The values you enter will immediately be summed up in the hierarchy.
4673 In the column next to it, any clocked time will be displayed.
4675 If you switch to column view in the daily/weekly agenda, the effort column
4676 will summarize the estimated work effort for each day@footnote{Please note
4677 the pitfalls of summing hierarchical data in a flat list (@pxref{Agenda
4678 column view}.}, and you can use this to find space in your schedule.  To get
4679 an overview of the entire part of the day that is committed, you can set the
4680 option @code{org-agenda-columns-add-appointments-to-effort-sum}.  The
4681 appointments on a day that take place over a specified time interval will
4682 then also be added to the load estimate of the day.
4684 @node Remember, Agenda Views, Dates and Times, Top
4685 @chapter Remember
4686 @cindex @file{remember.el}
4688 The @i{Remember} package by John Wiegley lets you store quick notes with
4689 little interruption of your work flow.  See
4690 @uref{http://www.emacswiki.org/cgi-bin/wiki/RememberMode} for more
4691 information.  It is an excellent way to add new notes and tasks to
4692 Org files.  Org significantly expands the possibilities of
4693 @i{remember}: You may define templates for different note types, and
4694 associate target files and headlines with specific templates.  It also
4695 allows you to select the location where a note should be stored
4696 interactively, on the fly.
4698 @menu
4699 * Setting up Remember::         Some code for .emacs to get things going
4700 * Remember templates::          Define the outline of different note types
4701 * Storing notes::               Directly get the note to where it belongs
4702 * Refiling notes::              Moving a note or task to a project
4703 @end menu
4705 @node Setting up Remember, Remember templates, Remember, Remember
4706 @section Setting up Remember
4708 The following customization will tell @i{remember} to use org files as
4709 target, and to create annotations compatible with Org links.
4711 @example
4712 (org-remember-insinuate)
4713 (setq org-directory "~/path/to/my/orgfiles/")
4714 (setq org-default-notes-file (concat org-directory "/notes.org"))
4715 (define-key global-map "\C-cr" 'org-remember)
4716 @end example
4718 The last line binds the command @code{org-remember} to a global
4719 key@footnote{Please select your own key, @kbd{C-c r} is only a
4720 suggestion.}.  @code{org-remember} basically just calls @code{remember},
4721 but it makes a few things easier: If there is an active region, it will
4722 automatically copy the region into the remember buffer.  It also allows
4723 to jump to the buffer and location where remember notes are being
4724 stored: Just call @code{org-remember} with a prefix argument.  If you
4725 use two prefix arguments, Org jumps to the location where the last
4726 remember note was stored.
4728 @node Remember templates, Storing notes, Setting up Remember, Remember
4729 @section Remember templates
4730 @cindex templates, for remember
4732 In combination with Org, you can use templates to generate
4733 different types of @i{remember} notes.  For example, if you would like
4734 to use one template to create general TODO entries, another one for
4735 journal entries, and a third one for collecting random ideas, you could
4736 use:
4738 @example
4739 (setq org-remember-templates
4740  '(("Todo" ?t "* TODO %?\n  %i\n  %a" "~/org/TODO.org" "Tasks")
4741    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org")
4742    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
4743 @end example
4745 @noindent In these entries, the first string is just a name, and the
4746 character specifies how to select the template.  It is useful if the
4747 character is also the first letter of the name.  The next string
4748 specifies the template.  Two more (optional) strings give the file in
4749 which, and the headline under which the new note should be stored.  The
4750 file (if not present or @code{nil}) defaults to
4751 @code{org-default-notes-file}, the heading to
4752 @code{org-remember-default-headline}.  If the file name is not an
4753 absolute path, it will be interpreted relative to @code{org-directory}.
4755 An optional sixth element specifies the contexts in which the user can
4756 select the template.  This element can be either a list of major modes
4757 or a function.  @code{org-remember} will first check whether the function
4758 returns @code{t} or if we are in any of the listed major mode, and select
4759 the template accordingly.
4761 So for example:
4763 @example
4764 (setq org-remember-templates
4765  '(("Bug" ?b "* BUG %?\n  %i\n  %a" "~/org/BUGS.org" "Bugs" (emacs-lisp-mode))
4766    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org" my-check)
4767    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
4768 @end example
4770 The first template will only be available when invoking @code{org-remember}
4771 from an buffer in @code{emacs-lisp-mode}.  The second template will only be
4772 available when the function @code{my-check} returns @code{t}.  The third
4773 template will be proposed in any context.
4775 When you call @kbd{M-x org-remember} (or @kbd{M-x remember}) to remember
4776 something, Org will prompt for a key to select the template (if you have
4777 more than one template) and then prepare the buffer like
4778 @example
4779 * TODO
4780   [[file:link to where you called remember]]
4781 @end example
4783 @noindent
4784 During expansion of the template, special @kbd{%}-escapes allow dynamic
4785 insertion of content:
4786 @example
4787 %^@{prompt@}  @r{prompt the user for a string and replace this sequence with it.}
4788             @r{You may specify a default value and a completion table with}
4789             @r{%^@{prompt|default|completion2|completion3...@}}
4790             @r{The arrow keys access a prompt-specific history.}
4791 %t          @r{time stamp, date only}
4792 %T          @r{time stamp with date and time}
4793 %u, %U      @r{like the above, but inactive time stamps}
4794 %^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
4795             @r{You may define a prompt like @code{%^@{Birthday@}t}}
4796 %n          @r{user name (taken from @code{user-full-name})}
4797 %a          @r{annotation, normally the link created with @code{org-store-link}}
4798 %A          @r{like @code{%a}, but prompt for the description part}
4799 %i          @r{initial content, the region when remember is called with C-u.}
4800             @r{The entire text will be indented like @code{%i} itself.}
4801 %c          @r{Current kill ring head.}
4802 %x          @r{Content of the X clipboard.}
4803 %^C         @r{Interactive selection of which kill or clip to use.}
4804 %^L         @r{Like @code{%^C}, but insert as link.}
4805 %^g         @r{prompt for tags, with completion on tags in target file.}
4806 %^G         @r{prompt for tags, with completion all tags in all agenda files.}
4807 %:keyword   @r{specific information for certain link types, see below}
4808 %[pathname] @r{insert the contents of the file given by @code{pathname}}
4809 %(sexp)     @r{evaluate elisp @code{(sexp)} and replace with the result}
4810 %!          @r{immediately store note after completing the template}
4811             @r{(skipping the @kbd{C-c C-c} that normally triggers storing)}
4812 @end example
4814 @noindent
4815 For specific link types, the following keywords will be
4816 defined@footnote{If you define your own link types (@pxref{Adding
4817 hyperlink types}), any property you store with
4818 @code{org-store-link-props} can be accessed in remember templates in a
4819 similar way.}:
4821 @example
4822 Link type          |  Available keywords
4823 -------------------+----------------------------------------------
4824 bbdb               |  %:name %:company
4825 bbdb               |  %::server %:port %:nick
4826 vm, wl, mh, rmail  |  %:type %:subject %:message-id
4827                    |  %:from %:fromname %:fromaddress
4828                    |  %:to   %:toname   %:toaddress
4829                    |  %: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}.}}
4830 gnus               |  %:group, @r{for messages also all email fields}
4831 w3, w3m            |  %:url
4832 info               |  %:file %:node
4833 calendar           |  %:date"
4834 @end example
4836 @noindent
4837 To place the cursor after template expansion use:
4839 @example
4840 %?          @r{After completing the template, position cursor here.}
4841 @end example
4843 @noindent
4844 If you change your mind about which template to use, call
4845 @code{org-remember} in the remember buffer.  You may then select a new
4846 template that will be filled with the previous context information.
4848 @node Storing notes, Refiling notes, Remember templates, Remember
4849 @section Storing notes
4851 When you are finished preparing a note with @i{remember}, you have to press
4852 @kbd{C-c C-c} to file the note away.  If you have started the clock in the
4853 remember buffer, you will first be asked if you want to clock out
4854 now@footnote{To avoid this query, configure the variable
4855 @code{org-remember-clock-out-on-exit}.}.  If you answer @kbd{n}, the clock
4856 will continue to run after the note is filed away.
4858 The handler will then store the note in the file and under the headline
4859 specified in the template, or it will use the default file and headlines.
4860 The window configuration will be restored, sending you back to the working
4861 context before the call to @code{remember}.  To re-use the location found
4862 during the last call to @code{remember}, exit the remember buffer with
4863 @kbd{C-u C-u C-c C-c}, i.e. specify a double prefix argument to @kbd{C-c
4864 C-c}.
4866 If you want to store the note directly to a different place, use
4867 @kbd{C-u C-c C-c} instead to exit remember@footnote{Configure the
4868 variable @code{org-remember-store-without-prompt} to make this behavior
4869 the default.}.  The handler will then first prompt for a target file -
4870 if you press @key{RET}, the value specified for the template is used.
4871 Then the command offers the headings tree of the selected file, with the
4872 cursor position at the default headline (if you had specified one in the
4873 template).  You can either immediately press @key{RET} to get the note
4874 placed there.  Or you can use the following keys to find a different
4875 location:
4876 @example
4877 @key{TAB}         @r{Cycle visibility.}
4878 @key{down} / @key{up}   @r{Next/previous visible headline.}
4879 n / p        @r{Next/previous visible headline.}
4880 f / b        @r{Next/previous headline same level.}
4881 u            @r{One level up.}
4882 @c 0-9          @r{Digit argument.}
4883 @end example
4884 @noindent
4885 Pressing @key{RET} or @key{left} or @key{right}
4886 then leads to the following result.
4888 @multitable @columnfractions 0.2 0.15 0.65
4889 @item @b{Cursor position} @tab @b{Key} @tab @b{Note gets inserted}
4890 @item on headline     @tab @key{RET}              @tab as sublevel of the heading at cursor, first or last
4891 @item                 @tab                        @tab depending on @code{org-reverse-note-order}.
4892 @item                 @tab @key{left}/@key{right} @tab as same level, before/after current heading
4893 @item buffer-start    @tab @key{RET} @tab as level 2 heading at end of file or level 1 at beginning
4894 @item                 @tab @tab depending on @code{org-reverse-note-order}.
4895 @item not on headline @tab @key{RET}
4896       @tab at cursor position, level taken from context.
4897 @end multitable
4899 Before inserting the text into a tree, the function ensures that the
4900 text has a headline, i.e. a first line that starts with a @samp{*}.  If
4901 not, a headline is constructed from the current date and some additional
4902 data.  If you have indented the text of the note below the headline, the
4903 indentation will be adapted if inserting the note into the tree requires
4904 demotion from level 1.
4906 @node Refiling notes,  , Storing notes, Remember
4907 @section Refiling notes
4908 @cindex refiling notes
4910 Remember is usually used to quickly capture notes and tasks into one or
4911 a few capture lists.  When reviewing the captured data, you may want to
4912 refile some of the entries into a different list, for example into a
4913 project.  Cutting, finding the right location and then pasting the note
4914 is cumbersome.  To simplify this process, you can use the following
4915 special command:
4917 @table @kbd
4918 @kindex C-c C-w
4919 @item C-c C-w
4920 Refile the entry at point.  This command offers possible locations for
4921 refiling the entry and lets you select one with completion.  The item is
4922 filed below the target heading as a subitem.  Depending on
4923 @code{org-reverse-note-order}, it will be either the first of last
4924 subitem.@* By default, all level 1 headlines in the current buffer are
4925 considered to be targets, but you can have more complex definitions
4926 across a number of files.  See the variable @code{org-refile-targets}
4927 for details.
4928 @kindex C-u C-c C-w
4929 @item C-u C-c C-w
4930 Use the refile interface to jump to a heading.
4931 @kindex C-u C-u C-c C-w
4932 @item C-u C-u C-c C-w
4933 Jump to the location where @code{org-refile} last moved a tree to.
4934 @end table
4936 @node Agenda Views, Embedded LaTeX, Remember, Top
4937 @chapter Agenda Views
4938 @cindex agenda views
4940 Due to the way Org works, TODO items, time-stamped items, and
4941 tagged headlines can be scattered throughout a file or even a number of
4942 files.  To get an overview of open action items, or of events that are
4943 important for a particular date, this information must be collected,
4944 sorted and displayed in an organized way.
4946 Org can select items based on various criteria, and display them
4947 in a separate buffer.  Seven different view types are provided:
4949 @itemize @bullet
4950 @item
4951 an @emph{agenda} that is like a calendar and shows information
4952 for specific dates,
4953 @item
4954 a @emph{TODO list} that covers all unfinished
4955 action items,
4956 @item
4957 a @emph{tags view}, showings headlines based on
4958 the tags associated with them,
4959 @item
4960 a @emph{timeline view} that shows all events in a single Org file,
4961 in time-sorted view,
4962 @item
4963 a @emph{keyword search view} that shows all entries from multiple files
4964 that contain specified keywords.
4965 @item
4966 a @emph{stuck projects view} showing projects that currently don't move
4967 along, and
4968 @item
4969 @emph{custom views} that are special tag/keyword searches and
4970 combinations of different views.
4971 @end itemize
4973 @noindent
4974 The extracted information is displayed in a special @emph{agenda
4975 buffer}.  This buffer is read-only, but provides commands to visit the
4976 corresponding locations in the original Org files, and even to
4977 edit these files remotely.
4979 Two variables control how the agenda buffer is displayed and whether the
4980 window configuration is restored when the agenda exits:
4981 @code{org-agenda-window-setup} and
4982 @code{org-agenda-restore-windows-after-quit}.
4984 @menu
4985 * Agenda files::                Files being searched for agenda information
4986 * Agenda dispatcher::           Keyboard access to agenda views
4987 * Built-in agenda views::       What is available out of the box?
4988 * Presentation and sorting::    How agenda items are prepared for display
4989 * Agenda commands::             Remote editing of Org trees
4990 * Custom agenda views::         Defining special searches and views
4991 * Agenda column view::          Using column view for collected entries
4992 @end menu
4994 @node Agenda files, Agenda dispatcher, Agenda Views, Agenda Views
4995 @section Agenda files
4996 @cindex agenda files
4997 @cindex files for agenda
4999 The information to be shown is normally collected from all @emph{agenda
5000 files}, the files listed in the variable
5001 @code{org-agenda-files}@footnote{If the value of that variable is not a
5002 list, but a single file name, then the list of agenda files will be
5003 maintained in that external file.}. If a directory is part of this list,
5004 all files with the extension @file{.org} in this directory will be part
5005 of the list.
5007 Thus even if you only work with a single Org file, this file should
5008 be put into that list@footnote{When using the dispatcher, pressing
5009 @kbd{<} before selecting a command will actually limit the command to
5010 the current file, and ignore @code{org-agenda-files} until the next
5011 dispatcher command.}.  You can customize @code{org-agenda-files}, but
5012 the easiest way to maintain it is through the following commands
5014 @cindex files, adding to agenda list
5015 @table @kbd
5016 @kindex C-c [
5017 @item C-c [
5018 Add current file to the list of agenda files.  The file is added to
5019 the front of the list.  If it was already in the list, it is moved to
5020 the front.  With a prefix argument, file is added/moved to the end.
5021 @kindex C-c ]
5022 @item C-c ]
5023 Remove current file from the list of agenda files.
5024 @kindex C-,
5025 @kindex C-'
5026 @item C-,
5027 @itemx C-'
5028 Cycle through agenda file list, visiting one file after the other.
5029 @kindex M-x org-iswitchb
5030 @item M-x org-iswitchb
5031 Command to use an @code{iswitchb}-like interface to switch to and between Org
5032 buffers.
5033 @end table
5035 @noindent
5036 The Org menu contains the current list of files and can be used
5037 to visit any of them.
5039 If you would like to focus the agenda temporarily onto a file not in
5040 this list, or onto just one file in the list or even only a subtree in a
5041 file, this can be done in different ways.  For a single agenda command,
5042 you may press @kbd{<} once or several times in the dispatcher
5043 (@pxref{Agenda dispatcher}).  To restrict the agenda scope for an
5044 extended period, use the following commands:
5046 @table @kbd
5047 @kindex C-c C-x <
5048 @item C-c C-x <
5049 Permanently restrict the agenda to the current subtree.  When with a
5050 prefix argument, or with the cursor before the first headline in a file,
5051 the agenda scope is set to the entire file.  This restriction remains in
5052 effect until removed with @kbd{C-c C-x >}, or by typing either @kbd{<}
5053 or @kbd{>} in the agenda dispatcher.  If there is a window displaying an
5054 agenda view, the new restriction takes effect immediately.
5055 @kindex C-c C-x <
5056 @item C-c C-x <
5057 Remove the permanent restriction created by @kbd{C-c C-x <}.
5058 @end table
5060 @noindent
5061 When working with @file{Speedbar}, you can use the following commands in
5062 the Speedbar frame:
5063 @table @kbd
5064 @kindex <
5065 @item < @r{in the speedbar frame}
5066 Permanently restrict the agenda to the item at the cursor in the
5067 Speedbar frame, either an Org file or a subtree in such a file.
5068 If there is a window displaying an agenda view, the new restriction takes
5069 effect immediately.
5070 @kindex <
5071 @item > @r{in the speedbar frame}
5072 Lift the restriction again.
5073 @end table
5075 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda Views
5076 @section The agenda dispatcher
5077 @cindex agenda dispatcher
5078 @cindex dispatching agenda commands
5079 The views are created through a dispatcher that should be bound to a
5080 global key, for example @kbd{C-c a} (@pxref{Installation}).  In the
5081 following we will assume that @kbd{C-c a} is indeed how the dispatcher
5082 is accessed and list keyboard access to commands accordingly.  After
5083 pressing @kbd{C-c a}, an additional letter is required to execute a
5084 command.  The dispatcher offers the following default commands:
5085 @table @kbd
5086 @item a
5087 Create the calendar-like agenda (@pxref{Weekly/daily agenda}).
5088 @item t @r{/} T
5089 Create a list of all TODO items (@pxref{Global TODO list}).
5090 @item m @r{/} M
5091 Create a list of headlines matching a TAGS expression (@pxref{Matching
5092 tags and properties}).
5093 @item L
5094 Create the timeline view for the current buffer (@pxref{Timeline}).
5095 @item s
5096 Create a list of entries selected by a boolean expression of keywords
5097 and/or regular expressions that must or must not occur in the entry.
5098 @item /
5099 Search for a regular expression in all agenda files and additionally in
5100 the files listed in @code{org-agenda-multi-occur-extra-files}.  This
5101 uses the Emacs command @code{multi-occur}.  A prefix argument can be
5102 used to specify the number of context lines for each match, default is
5104 @item # @r{/} !
5105 Create a list of stuck projects (@pxref{Stuck projects}).
5106 @item <
5107 Restrict an agenda command to the current buffer@footnote{For backward
5108 compatibility, you can also press @kbd{1} to restrict to the current
5109 buffer.}.  After pressing @kbd{<}, you still need to press the character
5110 selecting the command.
5111 @item < <
5112 If there is an active region, restrict the following agenda command to
5113 the region.  Otherwise, restrict it to the current subtree@footnote{For
5114 backward compatibility, you can also press @kbd{0} to restrict to the
5115 current buffer.}.  After pressing @kbd{< <}, you still need to press the
5116 character selecting the command.
5117 @end table
5119 You can also define custom commands that will be accessible through the
5120 dispatcher, just like the default commands.  This includes the
5121 possibility to create extended agenda buffers that contain several
5122 blocks together, for example the weekly agenda, the global TODO list and
5123 a number of special tags matches.  @xref{Custom agenda views}.
5125 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda Views
5126 @section The built-in agenda views
5128 In this section we describe the built-in views.
5130 @menu
5131 * Weekly/daily agenda::         The calendar page with current tasks
5132 * Global TODO list::            All unfinished action items
5133 * Matching tags and properties::  Structured information with fine-tuned search
5134 * Timeline::                    Time-sorted view for single file
5135 * Keyword search::              Finding entries by keyword
5136 * Stuck projects::              Find projects you need to review
5137 @end menu
5139 @node Weekly/daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
5140 @subsection The weekly/daily agenda
5141 @cindex agenda
5142 @cindex weekly agenda
5143 @cindex daily agenda
5145 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
5146 paper agenda, showing all the tasks for the current week or day.
5148 @table @kbd
5149 @cindex org-agenda, command
5150 @kindex C-c a a
5151 @item C-c a a
5152 Compile an agenda for the current week from a list of org files.  The
5153 agenda shows the entries for each day.  With a numeric
5154 prefix@footnote{For backward compatibility, the universal prefix
5155 @kbd{C-u} causes all TODO entries to be listed before the agenda.  This
5156 feature is deprecated, use the dedicated TODO list, or a block agenda
5157 instead.}  (like @kbd{C-u 2 1 C-c a a}) you may set the number of days
5158 to be displayed (see also the variable @code{org-agenda-ndays})
5159 @end table
5161 Remote editing from the agenda buffer means, for example, that you can
5162 change the dates of deadlines and appointments from the agenda buffer.
5163 The commands available in the Agenda buffer are listed in @ref{Agenda
5164 commands}.
5166 @subsubheading Calendar/Diary integration
5167 @cindex calendar integration
5168 @cindex diary integration
5170 Emacs contains the calendar and diary by Edward M. Reingold.  The
5171 calendar displays a three-month calendar with holidays from different
5172 countries and cultures.  The diary allows you to keep track of
5173 anniversaries, lunar phases, sunrise/set, recurrent appointments
5174 (weekly, monthly) and more.  In this way, it is quite complementary to
5175 Org.  It can be very useful to combine output from Org with
5176 the diary.
5178 In order to include entries from the Emacs diary into Org mode's
5179 agenda, you only need to customize the variable
5181 @lisp
5182 (setq org-agenda-include-diary t)
5183 @end lisp
5185 @noindent After that, everything will happen automatically.  All diary
5186 entries including holidays, anniversaries etc will be included in the
5187 agenda buffer created by Org mode.  @key{SPC}, @key{TAB}, and
5188 @key{RET} can be used from the agenda buffer to jump to the diary
5189 file in order to edit existing diary entries.  The @kbd{i} command to
5190 insert new entries for the current date works in the agenda buffer, as
5191 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
5192 Sunrise/Sunset times, show lunar phases and to convert to other
5193 calendars, respectively.  @kbd{c} can be used to switch back and forth
5194 between calendar and agenda.
5196 If you are using the diary only for sexp entries and holidays, it is
5197 faster to not use the above setting, but instead to copy or even move
5198 the entries into an Org file. Org mode evaluates diary-style sexp
5199 entries, and does it faster because there is no overhead for first
5200 creating the diary display.  Note that the sexp entries must start at
5201 the left margin, no white space is allowed before them.  For example,
5202 the following segment of an Org file will be processed and entries
5203 will be made in the agenda:
5205 @example
5206 * Birthdays and similar stuff
5207 #+CATEGORY: Holiday
5208 %%(org-calendar-holiday)   ; special function for holiday names
5209 #+CATEGORY: Ann
5210 %%(diary-anniversary 14  5 1956) Arthur Dent is %d years old
5211 %%(diary-anniversary  2 10 1869) Mahatma Gandhi would be %d years old
5212 @end example
5214 @subsubheading Appointment reminders
5215 @cindex @file{appt.el}
5216 @cindex appointment reminders
5218 Org can interact with Emacs appointments notification facility.
5220 To add all the appointments of your agenda files, use the command
5221 @code{org-agenda-to-appt}.  This commands also lets you filter through
5222 the list of your appointments and add only those belonging to a specific
5223 category or matching a regular expression. See the docstring for
5224 details.
5226 @node Global TODO list, Matching tags and properties, Weekly/daily agenda, Built-in agenda views
5227 @subsection The global TODO list
5228 @cindex global TODO list
5229 @cindex TODO list, global
5231 The global TODO list contains all unfinished TODO items, formatted and
5232 collected into a single place.
5234 @table @kbd
5235 @kindex C-c a t
5236 @item C-c a t
5237 Show the global TODO list.  This collects the TODO items from all
5238 agenda files (@pxref{Agenda Views}) into a single buffer.  The buffer is in
5239 @code{agenda-mode}, so there are commands to examine and manipulate
5240 the TODO entries directly from that buffer (@pxref{Agenda commands}).
5241 @kindex C-c a T
5242 @item C-c a T
5243 @cindex TODO keyword matching
5244 Like the above, but allows selection of a specific TODO keyword.  You
5245 can also do this by specifying a prefix argument to @kbd{C-c a t}.  With
5246 a @kbd{C-u} prefix you are prompted for a keyword, and you may also
5247 specify several keywords by separating them with @samp{|} as boolean OR
5248 operator.  With a numeric prefix, the Nth keyword in
5249 @code{org-todo-keywords} is selected.
5250 @kindex r
5251 The @kbd{r} key in the agenda buffer regenerates it, and you can give
5252 a prefix argument to this command to change the selected TODO keyword,
5253 for example @kbd{3 r}.  If you often need a search for a specific
5254 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
5255 Matching specific TODO keywords can also be done as part of a tags
5256 search (@pxref{Tag searches}).
5257 @end table
5259 Remote editing of TODO items means that you can change the state of a
5260 TODO entry with a single key press.  The commands available in the
5261 TODO list are described in @ref{Agenda commands}.
5263 @cindex sublevels, inclusion into TODO list
5264 Normally the global TODO list simply shows all headlines with TODO
5265 keywords.  This list can become very long.  There are two ways to keep
5266 it more compact:
5267 @itemize @minus
5268 @item
5269 Some people view a TODO item that has been @emph{scheduled} for
5270 execution (@pxref{Timestamps}) as no longer @emph{open}.  Configure the
5271 variable @code{org-agenda-todo-ignore-scheduled} to exclude scheduled
5272 items from the global TODO list.
5273 @item
5274 TODO items may have sublevels to break up the task into subtasks.  In
5275 such cases it may be enough to list only the highest level TODO headline
5276 and omit the sublevels from the global list.  Configure the variable
5277 @code{org-agenda-todo-list-sublevels} to get this behavior.
5278 @end itemize
5280 @node Matching tags and properties, Timeline, Global TODO list, Built-in agenda views
5281 @subsection Matching tags and properties
5282 @cindex matching, of tags
5283 @cindex matching, of properties
5284 @cindex tags view
5286 If headlines in the agenda files are marked with @emph{tags}
5287 (@pxref{Tags}), you can select headlines based on the tags that apply
5288 to them and collect them into an agenda buffer.
5290 @table @kbd
5291 @kindex C-c a m
5292 @item C-c a m
5293 Produce a list of all headlines that match a given set of tags.  The
5294 command prompts for a selection criterion, which is a boolean logic
5295 expression with tags, like @samp{+work+urgent-withboss} or
5296 @samp{work|home} (@pxref{Tags}).  If you often need a specific search,
5297 define a custom command for it (@pxref{Agenda dispatcher}).
5298 @kindex C-c a M
5299 @item C-c a M
5300 Like @kbd{C-c a m}, but only select headlines that are also TODO items
5301 and force checking subitems (see variable
5302 @code{org-tags-match-list-sublevels}).  Matching specific TODO keywords
5303 together with a tags match is also possible, see @ref{Tag searches}.
5304 @end table
5306 The commands available in the tags list are described in @ref{Agenda
5307 commands}.
5309 @node Timeline, Keyword search, Matching tags and properties, Built-in agenda views
5310 @subsection Timeline for a single file
5311 @cindex timeline, single file
5312 @cindex time-sorted view
5314 The timeline summarizes all time-stamped items from a single Org mode
5315 file in a @emph{time-sorted view}.  The main purpose of this command is
5316 to give an overview over events in a project.
5318 @table @kbd
5319 @kindex C-c a L
5320 @item C-c a L
5321 Show a time-sorted view of the org file, with all time-stamped items.
5322 When called with a @kbd{C-u} prefix, all unfinished TODO entries
5323 (scheduled or not) are also listed under the current date.
5324 @end table
5326 @noindent
5327 The commands available in the timeline buffer are listed in
5328 @ref{Agenda commands}.
5330 @node Keyword search, Stuck projects, Timeline, Built-in agenda views
5331 @subsection Keyword search
5332 @cindex keyword search
5333 @cindex searching, for keywords
5335 This agenda view is a general text search facility for Org mode entries.
5336 It is particularly useful to find notes.
5338 @table @kbd
5339 @kindex C-c a s
5340 @item C-c a s
5341 This is a special search that lets you select entries by keywords or
5342 regular expression, using a boolean logic.  For example, the search
5343 string
5345 @example
5346 +computer +wifi -ethernet -@{8\.11[bg]@}
5347 @end example
5349 @noindent
5350 will search for note entries that contain the keywords @code{computer}
5351 and @code{wifi}, but not the keyword @code{ethernet}, and which are also
5352 not matched by the regular expression @code{8\.11[bg]}, meaning to
5353 exclude both 8.11b and 8.11g.
5355 Note that in addition to the agenda files, this command will also search
5356 the files listed in @code{org-agenda-text-search-extra-files}.
5357 @end table
5359 @node Stuck projects,  , Keyword search, Built-in agenda views
5360 @subsection Stuck projects
5362 If you are following a system like David Allen's GTD to organize your
5363 work, one of the ``duties'' you have is a regular review to make sure
5364 that all projects move along.  A @emph{stuck} project is a project that
5365 has no defined next actions, so it will never show up in the TODO lists
5366 Org mode produces.  During the review, you need to identify such
5367 projects and define next actions for them.
5369 @table @kbd
5370 @kindex C-c a #
5371 @item C-c a #
5372 List projects that are stuck.
5373 @kindex C-c a !
5374 @item C-c a !
5375 Customize the variable @code{org-stuck-projects} to define what a stuck
5376 project is and how to find it.
5377 @end table
5379 You almost certainly will have to configure this view before it will
5380 work for you.  The built-in default assumes that all your projects are
5381 level-2 headlines, and that a project is not stuck if it has at least
5382 one entry marked with a TODO keyword TODO or NEXT or NEXTACTION.
5384 Lets assume that you, in your own way of using Org mode, identify
5385 projects with a tag PROJECT, and that you use a TODO keyword MAYBE to
5386 indicate a project that should not be considered yet.  Lets further
5387 assume that the TODO keyword DONE marks finished projects, and that NEXT
5388 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
5389 is a next action even without the NEXT tag.  Finally, if the project
5390 contains the special word IGNORE anywhere, it should not be listed
5391 either.  In this case you would start by identifying eligible projects
5392 with a tags/todo match @samp{+PROJECT/-MAYBE-DONE}, and then check for
5393 TODO, NEXT, @@SHOP, and IGNORE in the subtree to identify projects that
5394 are not stuck.  The correct customization for this is
5396 @lisp
5397 (setq org-stuck-projects
5398       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
5399                                "\\<IGNORE\\>"))
5400 @end lisp
5403 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda Views
5404 @section Presentation and sorting
5405 @cindex presentation, of agenda items
5407 Before displaying items in an agenda view, Org mode visually prepares
5408 the items and sorts them.  Each item occupies a single line.  The line
5409 starts with a @emph{prefix} that contains the @emph{category}
5410 (@pxref{Categories}) of the item and other important information.  You can
5411 customize the prefix using the option @code{org-agenda-prefix-format}.
5412 The prefix is followed by a cleaned-up version of the outline headline
5413 associated with the item.
5415 @menu
5416 * Categories::                  Not all tasks are equal
5417 * Time-of-day specifications::  How the agenda knows the time
5418 * Sorting of agenda items::     The order of things
5419 @end menu
5421 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
5422 @subsection Categories
5424 @cindex category
5425 The category is a broad label assigned to each agenda item.  By default,
5426 the category is simply derived from the file name, but you can also
5427 specify it with a special line in the buffer, like this@footnote{For
5428 backward compatibility, the following also works: If there are several
5429 such lines in a file, each specifies the category for the text below it.
5430 The first category also applies to any text before the first CATEGORY
5431 line.  However, using this method is @emph{strongly} deprecated as it is
5432 incompatible with the outline structure of the document.  The correct
5433 method for setting multiple categories in a buffer is using a
5434 property.}:
5436 @example
5437 #+CATEGORY: Thesis
5438 @end example
5440 @noindent
5441 If you would like to have a special CATEGORY for a single entry or a
5442 (sub)tree, give the entry a @code{:CATEGORY:} property with the location
5443 as the value (@pxref{Properties and Columns}).
5445 @noindent
5446 The display in the agenda buffer looks best if the category is not
5447 longer than 10 characters.
5449 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
5450 @subsection Time-of-day specifications
5451 @cindex time-of-day specification
5453 Org mode checks each agenda item for a time-of-day specification.  The
5454 time can be part of the time stamp that triggered inclusion into the
5455 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
5456 ranges can be specified with two time stamps, like
5458 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
5460 In the headline of the entry itself, a time(range) may also appear as
5461 plain text (like @samp{12:45} or a @samp{8:30-1pm}.  If the agenda
5462 integrates the Emacs diary (@pxref{Weekly/daily agenda}), time
5463 specifications in diary entries are recognized as well.
5465 For agenda display, Org mode extracts the time and displays it in a
5466 standard 24 hour format as part of the prefix.  The example times in
5467 the previous paragraphs would end up in the agenda like this:
5469 @example
5470     8:30-13:00 Arthur Dent lies in front of the bulldozer
5471    12:45...... Ford Prefect arrives and takes Arthur to the pub
5472    19:00...... The Vogon reads his poem
5473    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
5474 @end example
5476 @cindex time grid
5477 If the agenda is in single-day mode, or for the display of today, the
5478 timed entries are embedded in a time grid, like
5480 @example
5481     8:00...... ------------------
5482     8:30-13:00 Arthur Dent lies in front of the bulldozer
5483    10:00...... ------------------
5484    12:00...... ------------------
5485    12:45...... Ford Prefect arrives and takes Arthur to the pub
5486    14:00...... ------------------
5487    16:00...... ------------------
5488    18:00...... ------------------
5489    19:00...... The Vogon reads his poem
5490    20:00...... ------------------
5491    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
5492 @end example
5494 The time grid can be turned on and off with the variable
5495 @code{org-agenda-use-time-grid}, and can be configured with
5496 @code{org-agenda-time-grid}.
5498 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
5499 @subsection Sorting of agenda items
5500 @cindex sorting, of agenda items
5501 @cindex priorities, of agenda items
5502 Before being inserted into a view, the items are sorted.  How this is
5503 done depends on the type of view.
5504 @itemize @bullet
5505 @item
5506 For the daily/weekly agenda, the items for each day are sorted.  The
5507 default order is to first collect all items containing an explicit
5508 time-of-day specification.  These entries will be shown at the beginning
5509 of the list, as a @emph{schedule} for the day.  After that, items remain
5510 grouped in categories, in the sequence given by @code{org-agenda-files}.
5511 Within each category, items are sorted by priority (@pxref{Priorities}),
5512 which is composed of the base priority (2000 for priority @samp{A}, 1000
5513 for @samp{B}, and 0 for @samp{C}), plus additional increments for
5514 overdue scheduled or deadline items.
5515 @item
5516 For the TODO list, items remain in the order of categories, but within
5517 each category, sorting takes place according to priority
5518 (@pxref{Priorities}).
5519 @item
5520 For tags matches, items are not sorted at all, but just appear in the
5521 sequence in which they are found in the agenda files.
5522 @end itemize
5524 Sorting can be customized using the variable
5525 @code{org-agenda-sorting-strategy}, and may also include criteria based on
5526 the estimated effort of an entry.
5527 @c FIXME: link!!!!!!!!
5530 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda Views
5531 @section Commands in the agenda buffer
5532 @cindex commands, in agenda buffer
5534 Entries in the agenda buffer are linked back to the org file or diary
5535 file where they originate.  You are not allowed to edit the agenda
5536 buffer itself, but commands are provided to show and jump to the
5537 original entry location, and to edit the org-files ``remotely'' from
5538 the agenda buffer.  In this way, all information is stored only once,
5539 removing the risk that your agenda and note files may diverge.
5541 Some commands can be executed with mouse clicks on agenda lines.  For
5542 the other commands, the cursor needs to be in the desired line.
5544 @table @kbd
5545 @tsubheading{Motion}
5546 @cindex motion commands in agenda
5547 @kindex n
5548 @item n
5549 Next line (same as @key{up} and @kbd{C-p}).
5550 @kindex p
5551 @item p
5552 Previous line (same as @key{down} and @kbd{C-n}).
5553 @tsubheading{View/Go to org file}
5554 @kindex mouse-3
5555 @kindex @key{SPC}
5556 @item mouse-3
5557 @itemx @key{SPC}
5558 Display the original location of the item in another window.
5560 @kindex L
5561 @item L
5562 Display original location and recenter that window.
5564 @kindex mouse-2
5565 @kindex mouse-1
5566 @kindex @key{TAB}
5567 @item mouse-2
5568 @itemx mouse-1
5569 @itemx @key{TAB}
5570 Go to the original location of the item in another window.  Under Emacs
5571 22, @kbd{mouse-1} will also works for this.
5573 @kindex @key{RET}
5574 @itemx @key{RET}
5575 Go to the original location of the item and delete other windows.
5577 @kindex f
5578 @item f
5579 Toggle Follow mode.  In Follow mode, as you move the cursor through
5580 the agenda buffer, the other window always shows the corresponding
5581 location in the org file.  The initial setting for this mode in new
5582 agenda buffers can be set with the variable
5583 @code{org-agenda-start-with-follow-mode}.
5585 @kindex b
5586 @item b
5587 Display the entire subtree of the current item in an indirect buffer.  With a
5588 numeric prefix argument N, go up to level N and then take that tree.  If N is
5589 negative, go up that many levels.  With a @kbd{C-u} prefix, do not remove the
5590 previously used indirect buffer.
5592 @kindex l
5593 @item l
5594 Toggle Logbook mode.  In Logbook mode, entries that where marked DONE while
5595 logging was on (variable @code{org-log-done}) are shown in the agenda,
5596 as are entries that have been clocked on that day.
5598 @kindex R
5599 @item R
5600 Toggle Clockreport mode.  In clockreport mode, the daily/weekly agenda will
5601 always show a table with the clocked times for the timespan and file scope
5602 covered by the current agenda view.  The initial setting for this mode in new
5603 agenda buffers can be set with the variable
5604 @code{org-agenda-start-with-clockreport-mode}.
5606 @tsubheading{Change display}
5607 @cindex display changing, in agenda
5608 @kindex o
5609 @item o
5610 Delete other windows.
5612 @kindex d
5613 @kindex w
5614 @kindex m
5615 @kindex y
5616 @item d w m y
5617 Switch to day/week/month/year view.  When switching to day or week view,
5618 this setting becomes the default for subsequent agenda commands.  Since
5619 month and year views are slow to create, they do not become the default.
5620 A numeric prefix argument may be used to jump directly to a specific day
5621 of the year, ISO week, month, or year, respectively.  For example,
5622 @kbd{32 d} jumps to February 1st, @kbd{9 w} to ISO week number 9.  When
5623 setting day, week, or month view, a year may be encoded in the prefix
5624 argument as well.  For example, @kbd{200712 w} will jump to week 12 in
5625 2007.  If such a year specification has only one or two digits, it will
5626 be mapped to the interval 1938-2037.
5628 @kindex D
5629 @item D
5630 Toggle the inclusion of diary entries.  See @ref{Weekly/daily agenda}.
5632 @kindex G
5633 @item G
5634 Toggle the time grid on and off.  See also the variables
5635 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
5637 @kindex r
5638 @item r
5639 Recreate the agenda buffer, for example to reflect the changes
5640 after modification of the time stamps of items with S-@key{left} and
5641 S-@key{right}.  When the buffer is the global TODO list, a prefix
5642 argument is interpreted to create a selective list for a specific TODO
5643 keyword.
5644 @kindex g
5645 @item g
5646 Same as @kbd{r}.
5648 @kindex s
5649 @kindex C-x C-s
5650 @item s
5651 @itemx C-x C-s
5652 Save all Org buffers in the current Emacs session.
5654 @kindex @key{right}
5655 @item @key{right}
5656 Display the following @code{org-agenda-ndays} days.  For example, if
5657 the display covers a week, switch to the following week.  With prefix
5658 arg, go forward that many times @code{org-agenda-ndays} days.
5660 @kindex @key{left}
5661 @item @key{left}
5662 Display the previous dates.
5664 @kindex .
5665 @item .
5666 Go to today.
5668 @kindex C-c C-x C-c
5669 @item C-c C-x C-c
5670 Invoke column view (@pxref{Column view}) in the agenda buffer.  The column
5671 view format is taken from the entry at point, or (if there is no entry at
5672 point), from the first entry in the agenda view.  So whatever the format for
5673 that entry would be in the original buffer (taken from a property, from a
5674 @code{#+COLUMNS} line, or from the default variable
5675 @code{org-columns-default-format}), will be used in the agenda.
5677 @tsubheading{Query editing}
5678 @cindex query editing, in agenda
5680 @kindex [
5681 @kindex ]
5682 @kindex @{
5683 @kindex @}
5684 @item [ ] @{ @}
5685 In the @i{search view} (@pxref{Keyword search}), these keys add new
5686 search words (@kbd{[} and @kbd{]}) or new regular expressions (@kbd{@{}
5687 and @kbd{@}}) to the query string.  The opening bracket/brace will add a
5688 positive search term prefixed by @samp{+}, indicating that this search
5689 term @i{must} occur/match in the entry.  Closing bracket/brace add a
5690 negative search term which @i{must not} occur/match in the entry for it
5691 to be selected.
5694 @tsubheading{Remote editing}
5695 @cindex remote editing, from agenda
5697 @item 0-9
5698 Digit argument.
5700 @cindex undoing remote-editing events
5701 @cindex remote editing, undo
5702 @kindex C-_
5703 @item C-_
5704 Undo a change due to a remote editing command.  The change is undone
5705 both in the agenda buffer and in the remote buffer.
5707 @kindex t
5708 @item t
5709 Change the TODO state of the item, both in the agenda and in the
5710 original org file.
5712 @kindex C-k
5713 @item C-k
5714 Delete the current agenda item along with the entire subtree belonging
5715 to it in the original Org file.  If the text to be deleted remotely
5716 is longer than one line, the kill needs to be confirmed by the user.  See
5717 variable @code{org-agenda-confirm-kill}.
5719 @kindex a
5720 @item a
5721 Toggle the ARCHIVE tag for the current headline.
5723 @kindex A
5724 @item A
5725 Move the subtree corresponding to the current entry to its @emph{Archive
5726 Sibling}.
5728 @kindex $
5729 @item $
5730 Archive the subtree corresponding to the current headline.  This means the
5731 entry will be moved to the configured archive location, most likely a
5732 different file.
5734 @kindex T
5735 @item T
5736 Show all tags associated with the current item.  Because of
5737 inheritance, this may be more than the tags listed in the line itself.
5739 @kindex :
5740 @item :
5741 Set tags for the current headline.  If there is an active region in the
5742 agenda, change a tag for all headings in the region.
5744 @kindex ,
5745 @item ,
5746 Set the priority for the current item.  Org mode prompts for the
5747 priority character. If you reply with @key{SPC}, the priority cookie
5748 is removed from the entry.
5750 @kindex P
5751 @item P
5752 Display weighted priority of current item.
5754 @kindex +
5755 @kindex S-@key{up}
5756 @item +
5757 @itemx S-@key{up}
5758 Increase the priority of the current item.  The priority is changed in
5759 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
5760 key for this.
5762 @kindex -
5763 @kindex S-@key{down}
5764 @item -
5765 @itemx S-@key{down}
5766 Decrease the priority of the current item.
5768 @kindex C-c C-s
5769 @item C-c C-s
5770 Schedule this item
5772 @kindex C-c C-d
5773 @item C-c C-d
5774 Set a deadline for this item.
5776 @kindex S-@key{right}
5777 @item S-@key{right}
5778 Change the time stamp associated with the current line by one day into the
5779 future.  With a numeric prefix argument, change it by that many days.  For
5780 example, @kbd{3 6 5 S-@key{right}} will change it by a year.  The stamp is
5781 changed in the original org file, but the change is not directly reflected in
5782 the agenda buffer.  Use the @kbd{r} key to update the buffer.
5784 @kindex S-@key{left}
5785 @item S-@key{left}
5786 Change the time stamp associated with the current line by one day
5787 into the past.
5789 @kindex >
5790 @item >
5791 Change the time stamp associated with the current line to today.
5792 The key @kbd{>} has been chosen, because it is the same as @kbd{S-.}
5793 on my keyboard.
5795 @kindex I
5796 @item I
5797 Start the clock on the current item.  If a clock is running already, it
5798 is stopped first.
5800 @kindex O
5801 @item O
5802 Stop the previously started clock.
5804 @kindex X
5805 @item X
5806 Cancel the currently running clock.
5808 @kindex J
5809 @item J
5810 Jump to the running clock in another window.
5812 @tsubheading{Calendar commands}
5813 @cindex calendar commands, from agenda
5814 @kindex c
5815 @item c
5816 Open the Emacs calendar and move to the date at the agenda cursor.
5818 @item c
5819 When in the calendar, compute and show the Org mode agenda for the
5820 date at the cursor.
5822 @cindex diary entries, creating from agenda
5823 @kindex i
5824 @item i
5825 Insert a new entry into the diary.  Prompts for the type of entry
5826 (day, weekly, monthly, yearly, anniversary, cyclic) and creates a new
5827 entry in the diary, just as @kbd{i d} etc. would do in the calendar.
5828 The date is taken from the cursor position.
5830 @kindex M
5831 @item M
5832 Show the phases of the moon for the three months around current date.
5834 @kindex S
5835 @item S
5836 Show sunrise and sunset times.  The geographical location must be set
5837 with calendar variables, see documentation of the Emacs calendar.
5839 @kindex C
5840 @item C
5841 Convert the date at cursor into many other cultural and historic
5842 calendars.
5844 @kindex H
5845 @item H
5846 Show holidays for three month around the cursor date.
5848 @item M-x org-export-icalendar-combine-agenda-files
5849 Export a single iCalendar file containing entries from all agenda files.
5850 This is a globally available command, and also available in the agenda menu.
5852 @tsubheading{Exporting to a file}
5853 @kindex C-x C-w
5854 @item C-x C-w
5855 @cindex exporting agenda views
5856 @cindex agenda views, exporting
5857 Write the agenda view to a file.  Depending on the extension of the
5858 selected file name, the view will be exported as HTML (extension
5859 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}), or
5860 plain text (any other extension).  Use the variable
5861 @code{org-agenda-exporter-settings} to set options for @file{ps-print}
5862 and for @file{htmlize} to be used during export.
5864 @tsubheading{Quit and Exit}
5865 @kindex q
5866 @item q
5867 Quit agenda, remove the agenda buffer.
5869 @kindex x
5870 @cindex agenda files, removing buffers
5871 @item x
5872 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
5873 for the compilation of the agenda.  Buffers created by the user to
5874 visit org files will not be removed.
5875 @end table
5878 @node Custom agenda views, Agenda column view, Agenda commands, Agenda Views
5879 @section Custom agenda views
5880 @cindex custom agenda views
5881 @cindex agenda views, custom
5883 Custom agenda commands serve two purposes: to store and quickly access
5884 frequently used TODO and tags searches, and to create special composite
5885 agenda buffers.  Custom agenda commands will be accessible through the
5886 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
5888 @menu
5889 * Storing searches::            Type once, use often
5890 * Block agenda::                All the stuff you need in a single buffer
5891 * Setting Options::             Changing the rules
5892 * Exporting Agenda Views::      Writing agendas to files
5893 * Using the agenda elsewhere::  Using agenda information in other programs
5894 @end menu
5896 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
5897 @subsection Storing searches
5899 The first application of custom searches is the definition of keyboard
5900 shortcuts for frequently used searches, either creating an agenda
5901 buffer, or a sparse tree (the latter covering of course only the current
5902 buffer).
5903 @kindex C-c a C
5904 Custom commands are configured in the variable
5905 @code{org-agenda-custom-commands}.  You can customize this variable, for
5906 example by pressing @kbd{C-c a C}.  You can also directly set it with
5907 Emacs Lisp in @file{.emacs}.  The following example contains all valid
5908 search types:
5910 @lisp
5911 @group
5912 (setq org-agenda-custom-commands
5913       '(("w" todo "WAITING")
5914         ("W" todo-tree "WAITING")
5915         ("u" tags "+boss-urgent")
5916         ("v" tags-todo "+boss-urgent")
5917         ("U" tags-tree "+boss-urgent")
5918         ("f" occur-tree "\\<FIXME\\>")
5919         ("h" . "HOME+Name tags searches") ; description for "h" prefix
5920         ("hl" tags "+home+Lisa")
5921         ("hp" tags "+home+Peter")
5922         ("hk" tags "+home+Kim")))
5923 @end group
5924 @end lisp
5926 @noindent
5927 The initial string in each entry defines the keys you have to press
5928 after the dispatcher command @kbd{C-c a} in order to access the command.
5929 Usually this will be just a single character, but if you have many
5930 similar commands, you can also define two-letter combinations where the
5931 first character is the same in several combinations and serves as a
5932 prefix key@footnote{You can provide a description for a prefix key by
5933 inserting a cons cell with the prefix and the description.}.  The second
5934 parameter is the search type, followed by the string or regular
5935 expression to be used for the matching.  The example above will
5936 therefore define:
5938 @table @kbd
5939 @item C-c a w
5940 as a global search for TODO entries with @samp{WAITING} as the TODO
5941 keyword
5942 @item C-c a W
5943 as the same search, but only in the current buffer and displaying the
5944 results as a sparse tree
5945 @item C-c a u
5946 as a global tags search for headlines marked @samp{:boss:} but not
5947 @samp{:urgent:}
5948 @item C-c a v
5949 as the same search as @kbd{C-c a u}, but limiting the search to
5950 headlines that are also TODO items
5951 @item C-c a U
5952 as the same search as @kbd{C-c a u}, but only in the current buffer and
5953 displaying the result as a sparse tree
5954 @item C-c a f
5955 to create a sparse tree (again: current buffer only) with all entries
5956 containing the word @samp{FIXME}
5957 @item C-c a h
5958 as a prefix command for a HOME tags search where you have to press an
5959 additional key (@kbd{l}, @kbd{p} or @kbd{k}) to select a name (Lisa,
5960 Peter, or Kim) as additional tag to match.
5961 @end table
5963 @node Block agenda, Setting Options, Storing searches, Custom agenda views
5964 @subsection Block agenda
5965 @cindex block agenda
5966 @cindex agenda, with block views
5968 Another possibility is the construction of agenda views that comprise
5969 the results of @emph{several} commands, each of which creates a block in
5970 the agenda buffer.  The available commands include @code{agenda} for the
5971 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
5972 for the global TODO list (as constructed with @kbd{C-c a t}), and the
5973 matching commands discussed above: @code{todo}, @code{tags}, and
5974 @code{tags-todo}.  Here are two examples:
5976 @lisp
5977 @group
5978 (setq org-agenda-custom-commands
5979       '(("h" "Agenda and Home-related tasks"
5980          ((agenda "")
5981           (tags-todo "home")
5982           (tags "garden")))
5983         ("o" "Agenda and Office-related tasks"
5984          ((agenda "")
5985           (tags-todo "work")
5986           (tags "office")))))
5987 @end group
5988 @end lisp
5990 @noindent
5991 This will define @kbd{C-c a h} to create a multi-block view for stuff
5992 you need to attend to at home.  The resulting agenda buffer will contain
5993 your agenda for the current week, all TODO items that carry the tag
5994 @samp{home}, and also all lines tagged with @samp{garden}.  Finally the
5995 command @kbd{C-c a o} provides a similar view for office tasks.
5997 @node Setting Options, Exporting Agenda Views, Block agenda, Custom agenda views
5998 @subsection Setting options for custom commands
5999 @cindex options, for custom agenda views
6001 Org mode contains a number of variables regulating agenda construction
6002 and display.  The global variables define the behavior for all agenda
6003 commands, including the custom commands.  However, if you want to change
6004 some settings just for a single custom view, you can do so.  Setting
6005 options requires inserting a list of variable names and values at the
6006 right spot in @code{org-agenda-custom-commands}.  For example:
6008 @lisp
6009 @group
6010 (setq org-agenda-custom-commands
6011       '(("w" todo "WAITING"
6012          ((org-agenda-sorting-strategy '(priority-down))
6013           (org-agenda-prefix-format "  Mixed: ")))
6014         ("U" tags-tree "+boss-urgent"
6015          ((org-show-following-heading nil)
6016           (org-show-hierarchy-above nil)))
6017         ("N" search ""
6018          ((org-agenda-files '("~org/notes.org"))
6019           (org-agenda-text-search-extra-files nil)))))
6020 @end group
6021 @end lisp
6023 @noindent
6024 Now the @kbd{C-c a w} command will sort the collected entries only by
6025 priority, and the prefix format is modified to just say @samp{  Mixed: }
6026 instead of giving the category of the entry.  The sparse tags tree of
6027 @kbd{C-c a U} will now turn out ultra-compact, because neither the
6028 headline hierarchy above the match, nor the headline following the match
6029 will be shown.  The command @kbd{C-c a N} will do a text search limited
6030 to only a single file.
6032 For command sets creating a block agenda,
6033 @code{org-agenda-custom-commands} has two separate spots for setting
6034 options.  You can add options that should be valid for just a single
6035 command in the set, and options that should be valid for all commands in
6036 the set.  The former are just added to the command entry, the latter
6037 must come after the list of command entries.  Going back to the block
6038 agenda example (@pxref{Block agenda}), let's change the sorting strategy
6039 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
6040 the results for GARDEN tags query in the opposite order,
6041 @code{priority-up}.  This would look like this:
6043 @lisp
6044 @group
6045 (setq org-agenda-custom-commands
6046       '(("h" "Agenda and Home-related tasks"
6047          ((agenda)
6048           (tags-todo "home")
6049           (tags "garden"
6050                 ((org-agenda-sorting-strategy '(priority-up)))))
6051          ((org-agenda-sorting-strategy '(priority-down))))
6052         ("o" "Agenda and Office-related tasks"
6053          ((agenda)
6054           (tags-todo "work")
6055           (tags "office")))))
6056 @end group
6057 @end lisp
6059 As you see, the values and parenthesis setting is a little complex.
6060 When in doubt, use the customize interface to set this variable - it
6061 fully supports its structure.  Just one caveat: When setting options in
6062 this interface, the @emph{values} are just lisp expressions.  So if the
6063 value is a string, you need to add the double quotes around the value
6064 yourself.
6067 @node Exporting Agenda Views, Using the agenda elsewhere, Setting Options, Custom agenda views
6068 @subsection Exporting Agenda Views
6069 @cindex agenda views, exporting
6071 If you are away from your computer, it can be very useful to have a
6072 printed version of some agenda views to carry around.  Org mode can
6073 export custom agenda views as plain text, HTML@footnote{You need to
6074 install Hrvoje Niksic' @file{htmlize.el}.} postscript, and iCalendar
6075 files.  If you want to do this only occasionally, use the command
6077 @table @kbd
6078 @kindex C-x C-w
6079 @item C-x C-w
6080 @cindex exporting agenda views
6081 @cindex agenda views, exporting
6082 Write the agenda view to a file.  Depending on the extension of the
6083 selected file name, the view will be exported as HTML (extension
6084 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}),
6085 iCalendar (extension @file{.ics}), or plain text (any other extension).
6086 Use the variable @code{org-agenda-exporter-settings} to
6087 set options for @file{ps-print} and for @file{htmlize} to be used during
6088 export, for example
6090 @lisp
6091 (setq org-agenda-exporter-settings
6092       '((ps-number-of-columns 2)
6093         (ps-landscape-mode t)
6094         (htmlize-output-type 'css)))
6095 @end lisp
6096 @end table
6098 If you need to export certain agenda views frequently, you can associate
6099 any custom agenda command with a list of output file names
6100 @footnote{If you want to store standard views like the weekly agenda
6101 or the global TODO list as well, you need to define custom commands for
6102 them in order to be able to specify file names.}.  Here is an example
6103 that first does define custom commands for the agenda and the global
6104 todo list, together with a number of files to which to export them.
6105 Then we define two block agenda commands and specify file names for them
6106 as well.  File names can be relative to the current working directory,
6107 or absolute.
6109 @lisp
6110 @group
6111 (setq org-agenda-custom-commands
6112       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
6113         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
6114         ("h" "Agenda and Home-related tasks"
6115          ((agenda "")
6116           (tags-todo "home")
6117           (tags "garden"))
6118          nil
6119          ("~/views/home.html"))
6120         ("o" "Agenda and Office-related tasks"
6121          ((agenda)
6122           (tags-todo "work")
6123           (tags "office"))
6124          nil
6125          ("~/views/office.ps" "~/calendars/office.ics"))))
6126 @end group
6127 @end lisp
6129 The extension of the file name determines the type of export.  If it is
6130 @file{.html}, Org mode will use the @file{htmlize.el} package to convert
6131 the buffer to HTML and save it to this file name.  If the extension is
6132 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
6133 postscript output.  If the extension is @file{.ics}, iCalendar export is
6134 run export over all files that were used to construct the agenda, and
6135 limit the export to entries listed in the agenda now.  Any other
6136 extension produces a plain ASCII file.
6138 The export files are @emph{not} created when you use one of those
6139 commands interactively because this might use too much overhead.
6140 Instead, there is a special command to produce @emph{all} specified
6141 files in one step:
6143 @table @kbd
6144 @kindex C-c a e
6145 @item C-c a e
6146 Export all agenda views that have export file names associated with
6147 them.
6148 @end table
6150 You can use the options section of the custom agenda commands to also
6151 set options for the export commands.  For example:
6153 @lisp
6154 (setq org-agenda-custom-commands
6155       '(("X" agenda ""
6156          ((ps-number-of-columns 2)
6157           (ps-landscape-mode t)
6158           (org-agenda-prefix-format " [ ] ")
6159           (org-agenda-with-colors nil)
6160           (org-agenda-remove-tags t))
6161          ("theagenda.ps"))))
6162 @end lisp
6164 @noindent
6165 This command sets two options for the postscript exporter, to make it
6166 print in two columns in landscape format - the resulting page can be cut
6167 in two and then used in a paper agenda.  The remaining settings modify
6168 the agenda prefix to omit category and scheduling information, and
6169 instead include a checkbox to check off items.  We also remove the tags
6170 to make the lines compact, and we don't want to use colors for the
6171 black-and-white printer.  Settings specified in
6172 @code{org-agenda-exporter-settings} will also apply, but the settings
6173 in @code{org-agenda-custom-commands} take precedence.
6175 @noindent
6176 From the command line you may also use
6177 @example
6178 emacs -f org-batch-store-agenda-views -kill
6179 @end example
6180 @noindent
6181 or, if you need to modify some parameters
6182 @example
6183 emacs -eval '(org-batch-store-agenda-views                      \
6184               org-agenda-ndays 30                               \
6185               org-agenda-start-day "2007-11-01"                 \
6186               org-agenda-include-diary nil                      \
6187               org-agenda-files (quote ("~/org/project.org")))'  \
6188       -kill
6189 @end example
6190 @noindent
6191 which will create the agenda views restricted to the file
6192 @file{~/org/project.org}, without diary entries and with 30 days
6193 extent.
6195 @node Using the agenda elsewhere,  , Exporting Agenda Views, Custom agenda views
6196 @subsection Using agenda information outside of Org
6197 @cindex agenda, pipe
6198 @cindex Scripts, for agenda processing
6200 Org provides commands to access agenda information for the command
6201 line in emacs batch mode.  This extracted information can be sent
6202 directly to a printer, or it can be read by a program that does further
6203 processing of the data.  The first of these commands is the function
6204 @code{org-batch-agenda}, that produces an agenda view and sends it as
6205 ASCII text to STDOUT.  The command takes a single string as parameter.
6206 If the string has length 1, it is used as a key to one of the commands
6207 you have configured in @code{org-agenda-custom-commands}, basically any
6208 key you can use after @kbd{C-c a}.  For example, to directly print the
6209 current TODO list, you could use
6211 @example
6212 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
6213 @end example
6215 If the parameter is a string with 2 or more characters, it is used as a
6216 tags/todo match string.  For example, to print your local shopping list
6217 (all items with the tag @samp{shop}, but excluding the tag
6218 @samp{NewYork}), you could use
6220 @example
6221 emacs -batch -l ~/.emacs                                      \
6222       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
6223 @end example
6225 @noindent
6226 You may also modify parameters on the fly like this:
6228 @example
6229 emacs -batch -l ~/.emacs                                      \
6230    -eval '(org-batch-agenda "a"                               \
6231             org-agenda-ndays 30                               \
6232             org-agenda-include-diary nil                      \
6233             org-agenda-files (quote ("~/org/project.org")))'  \
6234    | lpr
6235 @end example
6237 @noindent
6238 which will produce a 30 day agenda, fully restricted to the Org file
6239 @file{~/org/projects.org}, not even including the diary.
6241 If you want to process the agenda data in more sophisticated ways, you
6242 can use the command @code{org-batch-agenda-csv} to get a comma-separated
6243 list of values for each agenda item.  Each line in the output will
6244 contain a number of fields separated by commas.  The fields in a line
6245 are:
6247 @example
6248 category     @r{The category of the item}
6249 head         @r{The headline, without TODO kwd, TAGS and PRIORITY}
6250 type         @r{The type of the agenda entry, can be}
6251                 todo               @r{selected in TODO match}
6252                 tagsmatch          @r{selected in tags match}
6253                 diary              @r{imported from diary}
6254                 deadline           @r{a deadline}
6255                 scheduled          @r{scheduled}
6256                 timestamp          @r{appointment, selected by timestamp}
6257                 closed             @r{entry was closed on date}
6258                 upcoming-deadline  @r{warning about nearing deadline}
6259                 past-scheduled     @r{forwarded scheduled item}
6260                 block              @r{entry has date block including date}
6261 todo         @r{The TODO keyword, if any}
6262 tags         @r{All tags including inherited ones, separated by colons}
6263 date         @r{The relevant date, like 2007-2-14}
6264 time         @r{The time, like 15:00-16:50}
6265 extra        @r{String with extra planning info}
6266 priority-l   @r{The priority letter if any was given}
6267 priority-n   @r{The computed numerical priority}
6268 @end example
6270 @noindent
6271 Time and date will only be given if a timestamp (or deadline/scheduled)
6272 lead to the selection of the item.
6274 A CSV list like this is very easy to use in a post processing script.
6275 For example, here is a Perl program that gets the TODO list from
6276 Emacs/Org and prints all the items, preceded by a checkbox:
6278 @example
6279 @group
6280 #!/usr/bin/perl
6282 # define the Emacs command to run
6283 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
6285 # run it and capture the output
6286 $agenda = qx@{$cmd 2>/dev/null@};
6288 # loop over all lines
6289 foreach $line (split(/\n/,$agenda)) @{
6291   # get the individual values
6292   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
6293    $priority_l,$priority_n) = split(/,/,$line);
6295   # proccess and print
6296   print "[ ] $head\n";
6298 @end group
6299 @end example
6301 @node Agenda column view,  , Custom agenda views, Agenda Views
6302 @section Using column view in the agenda
6303 @cindex column view, in agenda
6304 @cindex agenda, column view
6306 Column view (@pxref{Column view}) is normally used to view and edit
6307 properties embedded in the hierarchical structure of an Org file.  It can be
6308 quite useful to use column view also from the agenda, where entries are
6309 collected by certain criteria.
6311 @table @kbd
6312 @kindex C-c C-x C-c
6313 @item C-c C-x C-c
6314 Turn on column view in the agenda.
6315 @end table
6317 To understand how to use this properly, it is important to realize that the
6318 entries in the agenda are no longer in their proper outline environment.
6319 This causes the following issues:
6321 @enumerate
6322 @item
6323 Org needs to make a decision which @code{COLUMNS} format to use.  Since the
6324 entries in the agenda are collected from different files, and different files
6325 may have different @code{COLUMNS} formats, this is a non-trivial problem.
6326 Org first checks if the variable @code{org-overriding-columns-format} is
6327 currently set, and if yes takes the format from there.  Otherwise it takes
6328 the format associated with the first item in the agenda, or, if that item
6329 does not have a specific format (defined in a property, or in it's file), it
6330 uses @code{org-columns-default-format}.
6331 @item
6332 If any of the columns has a summary type defined (@pxref{Column attributes}),
6333 turning on column view in the agenda will visit all relevant agenda files and
6334 make sure that the computations of this property are up to date.  This is
6335 also true for the special @code{CLOCKSUM} property.  Org will then sum the
6336 values displayed in the agenda.  In the daily/weekly agenda, the sums will
6337 cover a single day, in all other views they cover the entire block.  It is
6338 vital to realize that the agenda may show the same entry @emph{twice} (for
6339 example as scheduled and as a deadline), and it may show two entries from the
6340 same hierarchy (for example a @emph{parent} and it's @emph{child}).  In these
6341 cases, the summation in the agenda will lead to incorrect results because
6342 some values will count double.
6343 @item
6344 When the column view in the agenda shows the @code{CLOCKSUM}, that is always
6345 the entire clocked time for this item.  So even in the daily/weekly agenda,
6346 the clocksum listed in column view may originate from times outside the
6347 current view.  This has the advantage that you can compare these values with
6348 a column listing the planned total effort for a task - one of the major
6349 applications for column view in the agenda.  If you want information about
6350 clocked time in the displayed period use clock table mode (press @kbd{R} in
6351 the agenda).
6352 @end enumerate
6355 @node Embedded LaTeX, Exporting, Agenda Views, Top
6356 @chapter Embedded LaTeX
6357 @cindex @TeX{} interpretation
6358 @cindex La@TeX{} interpretation
6360 Plain ASCII is normally sufficient for almost all note taking.  One
6361 exception, however, are scientific notes which need to be able to contain
6362 mathematical symbols and the occasional formula.  La@TeX{}@footnote{La@TeX{}
6363 is a macro system based on Donald E. Knuth's @TeX{} system.  Many of the
6364 features described here as ``La@TeX{}'' are really from @TeX{}, but for
6365 simplicity I am blurring this distinction.}  is widely used to typeset
6366 scientific documents. Org mode supports embedding La@TeX{} code into its
6367 files, because many academics are used to reading La@TeX{} source code, and
6368 because it can be readily processed into images for HTML production.
6370 It is not necessary to mark La@TeX{} macros and code in any special way.
6371 If you observe a few conventions, Org mode knows how to find it and what
6372 to do with it.
6374 @menu
6375 * Math symbols::                TeX macros for symbols and Greek letters
6376 * Subscripts and superscripts::  Simple syntax for raising/lowering text
6377 * LaTeX fragments::             Complex formulas made easy
6378 * Processing LaTeX fragments::  Previewing LaTeX processing
6379 * CDLaTeX mode::                Speed up entering of formulas
6380 @end menu
6382 @node Math symbols, Subscripts and superscripts, Embedded LaTeX, Embedded LaTeX
6383 @section Math symbols
6384 @cindex math symbols
6385 @cindex TeX macros
6387 You can use La@TeX{} macros to insert special symbols like @samp{\alpha}
6388 to indicate the Greek letter, or @samp{\to} to indicate an arrow.
6389 Completion for these macros is available, just type @samp{\} and maybe a
6390 few letters, and press @kbd{M-@key{TAB}} to see possible completions.
6391 Unlike La@TeX{} code, Org mode allows these macros to be present
6392 without surrounding math delimiters, for example:
6394 @example
6395 Angles are written as Greek letters \alpha, \beta and \gamma.
6396 @end example
6398 During HTML export (@pxref{HTML export}), these symbols are translated
6399 into the proper syntax for HTML, for the above examples this is
6400 @samp{&alpha;} and @samp{&rarr;}, respectively.
6402 @node Subscripts and superscripts, LaTeX fragments, Math symbols, Embedded LaTeX
6403 @section Subscripts and superscripts
6404 @cindex subscript
6405 @cindex superscript
6407 Just like in La@TeX{}, @samp{^} and @samp{_} are used to indicate super-
6408 and subscripts.  Again, these can be used without embedding them in
6409 math-mode delimiters.  To increase the readability of ASCII text, it is
6410 not necessary (but OK) to surround multi-character sub- and superscripts
6411 with curly braces.  For example
6413 @example
6414 The mass if the sun is M_sun = 1.989 x 10^30 kg.  The radius of
6415 the sun is R_@{sun@} = 6.96 x 10^8 m.
6416 @end example
6418 To avoid interpretation as raised or lowered text, you can quote
6419 @samp{^} and @samp{_} with a backslash: @samp{\_} and @samp{\^}.
6421 During HTML export (@pxref{HTML export}), subscript and superscripts
6422 are surrounded with @code{<sub>} and @code{<sup>} tags, respectively.
6424 @node LaTeX fragments, Processing LaTeX fragments, Subscripts and superscripts, Embedded LaTeX
6425 @section LaTeX fragments
6426 @cindex LaTeX fragments
6428 With symbols, sub- and superscripts, HTML is pretty much at its end when
6429 it comes to representing mathematical formulas@footnote{Yes, there is
6430 MathML, but that is not yet fully supported by many browsers, and there
6431 is no decent converter for turning La@TeX{} or ASCII representations of
6432 formulas into MathML. So for the time being, converting formulas into
6433 images seems the way to go.}. More complex expressions need a dedicated
6434 formula processor. To this end, Org mode can contain arbitrary La@TeX{}
6435 fragments. It provides commands to preview the typeset result of these
6436 fragments, and upon export to HTML, all fragments will be converted to
6437 images and inlined into the HTML document@footnote{The La@TeX{} export
6438 will not use images for displaying La@TeX{} fragments but include these
6439 fragments directly into the La@TeX{} code.}. For this to work you
6440 need to be on a system with a working La@TeX{} installation. You also
6441 need the @file{dvipng} program, available at
6442 @url{http://sourceforge.net/projects/dvipng/}. The La@TeX{} header that
6443 will be used when processing a fragment can be configured with the
6444 variable @code{org-format-latex-header}.
6446 La@TeX{} fragments don't need any special marking at all.  The following
6447 snippets will be identified as La@TeX{} source code:
6448 @itemize @bullet
6449 @item
6450 Environments of any kind.  The only requirement is that the
6451 @code{\begin} statement appears on a new line, preceded by only
6452 whitespace.
6453 @item
6454 Text within the usual La@TeX{} math delimiters.  To avoid conflicts with
6455 currency specifications, single @samp{$} characters are only recognized
6456 as math delimiters if the enclosed text contains at most two line breaks,
6457 is directly attached to the @samp{$} characters with no whitespace in
6458 between, and if the closing @samp{$} is followed by whitespace or
6459 punctuation.  For the other delimiters, there is no such restriction, so
6460 when in doubt, use @samp{\(...\)} as inline math delimiters.
6461 @end itemize
6463 @noindent For example:
6465 @example
6466 \begin@{equation@}                          % arbitrary environments,
6467 x=\sqrt@{b@}                                % even tables, figures
6468 \end@{equation@}                            % etc
6470 If $a^2=b$ and \( b=2 \), then the solution must be
6471 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
6472 @end example
6474 @noindent
6475 If you need any of the delimiter ASCII sequences for other purposes, you
6476 can configure the option @code{org-format-latex-options} to deselect the
6477 ones you do not wish to have interpreted by the La@TeX{} converter.
6479 @node Processing LaTeX fragments, CDLaTeX mode, LaTeX fragments, Embedded LaTeX
6480 @section Processing LaTeX fragments
6481 @cindex LaTeX fragments, preview
6483 La@TeX{} fragments can be processed to produce a preview images of the
6484 typeset expressions:
6486 @table @kbd
6487 @kindex C-c C-x C-l
6488 @item C-c C-x C-l
6489 Produce a preview image of the La@TeX{} fragment at point and overlay it
6490 over the source code.  If there is no fragment at point, process all
6491 fragments in the current entry (between two headlines).  When called
6492 with a prefix argument, process the entire subtree.  When called with
6493 two prefix arguments, or when the cursor is before the first headline,
6494 process the entire buffer.
6495 @kindex C-c C-c
6496 @item C-c C-c
6497 Remove the overlay preview images.
6498 @end table
6500 During HTML export (@pxref{HTML export}), all La@TeX{} fragments are
6501 converted into images and inlined into the document if the following
6502 setting is active:
6504 @lisp
6505 (setq org-export-with-LaTeX-fragments t)
6506 @end lisp
6508 @node CDLaTeX mode,  , Processing LaTeX fragments, Embedded LaTeX
6509 @section Using CDLaTeX to enter math
6510 @cindex CDLaTeX
6512 CDLaTeX mode is a minor mode that is normally used in combination with a
6513 major La@TeX{} mode like AUCTeX in order to speed-up insertion of
6514 environments and math templates.  Inside Org mode, you can make use of
6515 some of the features of CDLaTeX mode.  You need to install
6516 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
6517 AUCTeX) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
6518 Don't use CDLaTeX mode itself under Org mode, but use the light
6519 version @code{org-cdlatex-mode} that comes as part of Org mode.  Turn it
6520 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
6521 Org files with
6523 @lisp
6524 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
6525 @end lisp
6527 When this mode is enabled, the following features are present (for more
6528 details see the documentation of CDLaTeX mode):
6529 @itemize @bullet
6530 @kindex C-c @{
6531 @item
6532 Environment templates can be inserted with @kbd{C-c @{}.
6533 @item
6534 @kindex @key{TAB}
6535 The @key{TAB} key will do template expansion if the cursor is inside a
6536 La@TeX{} fragment@footnote{Org mode has a method to test if the cursor is
6537 inside such a fragment, see the documentation of the function
6538 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
6539 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
6540 correctly inside the first brace.  Another @key{TAB} will get you into
6541 the second brace.  Even outside fragments, @key{TAB} will expand
6542 environment abbreviations at the beginning of a line.  For example, if
6543 you write @samp{equ} at the beginning of a line and press @key{TAB},
6544 this abbreviation will be expanded to an @code{equation} environment.
6545 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
6546 @item
6547 @kindex _
6548 @kindex ^
6549 Pressing @kbd{_} and @kbd{^} inside a La@TeX{} fragment will insert these
6550 characters together with a pair of braces.  If you use @key{TAB} to move
6551 out of the braces, and if the braces surround only a single character or
6552 macro, they are removed again (depending on the variable
6553 @code{cdlatex-simplify-sub-super-scripts}).
6554 @item
6555 @kindex `
6556 Pressing the backquote @kbd{`} followed by a character inserts math
6557 macros, also outside La@TeX{} fragments.  If you wait more than 1.5 seconds
6558 after the backquote, a help window will pop up.
6559 @item
6560 @kindex '
6561 Pressing the normal quote @kbd{'} followed by another character modifies
6562 the symbol before point with an accent or a font.  If you wait more than
6563 1.5 seconds after the backquote, a help window will pop up.  Character
6564 modification will work only inside La@TeX{} fragments, outside the quote
6565 is normal.
6566 @end itemize
6568 @node Exporting, Publishing, Embedded LaTeX, Top
6569 @chapter Exporting
6570 @cindex exporting
6572 Org mode documents can be exported into a variety of other formats.  For
6573 printing and sharing of notes, ASCII export produces a readable and
6574 simple version of an Org file.  HTML export allows you to publish a
6575 notes file on the web, while the XOXO format provides a solid base for
6576 exchange with a broad range of other applications. La@TeX{} export lets
6577 you use Org mode and its structured editing functions to easily create
6578 La@TeX{} files.  To incorporate entries with associated times like
6579 deadlines or appointments into a desktop calendar program like iCal,
6580 Org mode can also produce extracts in the iCalendar format.  Currently
6581 Org mode only supports export, not import of these different formats.
6583 @menu
6584 * Markup rules::                Which structures are recognized?
6585 * Export options::              Per-file export settings
6586 * The export dispatcher::       How to access exporter commands
6587 * ASCII export::                Exporting to plain ASCII
6588 * HTML export::                 Exporting to HTML
6589 * LaTeX export::                Exporting to LaTeX
6590 * XOXO export::                 Exporting to XOXO
6591 * iCalendar export::            Exporting in iCalendar format
6592 @end menu
6594 @node Markup rules, Export options, Exporting, Exporting
6595 @section Markup rules
6597 When exporting Org mode documents,  the exporter tries to reflect the
6598 structure of the document as accurately as possible in the back-end.  Since
6599 export targets like HTML or La@TeX{} allow much richer formatting, Org mode
6600 has rules how to prepare text for rich export.  This section summarizes the
6601 markup rule used in an Org mode buffer.
6603 @menu
6604 * Document title::              How the document title is determined
6605 * Headings and sections::       The main structure of the exported document
6606 * Table of contents::           If, where, how to create a table of contents
6607 * Initial text::                Text before the first headline
6608 * Lists::                       Plain lists are exported
6609 * Paragraphs::                  What determines beginning and ending
6610 * Literal examples::            Source code and other examples
6611 * Tables exported::             Tables are exported richly
6612 * Footnotes::                   Numbers like [1]
6613 * Emphasis and monospace::      To bold or not to bold
6614 * TeX macros and LaTeX fragments::  Create special, rich export.
6615 * Horizontal rules::            A line across the page
6616 * Comment lines::               Some lines will not be exported
6617 @end menu
6619 @node Document title, Headings and sections, Markup rules, Markup rules
6620 @subheading Document title
6622 @noindent
6623 The title of the exported document is taken from the special line
6625 @example
6626 #+TITLE: This is the title of the document
6627 @end example
6629 @noindent
6630 If this line does not exist, the title is derived from the first non-empty,
6631 non-comment line in the buffer.  If no such line exists, or if you have
6632 turned off exporting of the text before the first headline (see below), the
6633 title will be the file name without extension.
6635 If you are exporting only a subtree by marking is as the region, the heading
6636 of the subtree will become the title of the document.
6638 @node Headings and sections, Table of contents, Document title, Markup rules
6639 @subheading Headings and sections
6641 The outline structure of the document as described in @ref{Document
6642 Structure} forms the basis for defining sections of the exported document.
6643 However, since the outline structure is also used for (for example) lists of
6644 tasks, only the first three outline levels will be used as headings.  Deeper
6645 levels will become itemized lists.  You can change the location of this
6646 switch, globally by setting the variable @code{org-headline-levels}, or on a
6647 per file basis with a line
6649 @example
6650 #+OPTIONS: H:4
6651 @end example
6653 @node Table of contents, Initial text, Headings and sections, Markup rules
6654 @subheading Table of contents
6656 The table of contents is normally inserted directly before the first headline
6657 of the file.  If you would like to get it to a different location, insert the
6658 string @code{[TABLE-OF-CONTENTS]} on a line by itself at the desired
6659 location.  The depth of the table of contents is by default the same as the
6660 number of headline levels, but you can choose a smaller number or turn off
6661 the table of contents entirely by configuring the variable
6662 @code{org-export-with-toc}, or on a per-file basis with a line like
6664 @example
6665 #+OPTIONS: toc:2          (only to two levels in TOC)
6666 #+OPTIONS: toc:nil        (no TOC at all)
6667 @end example
6669 @node Initial text, Lists, Table of contents, Markup rules
6670 @subheading Text before the first headline
6672 Org mode normally exports the text before the first headline, and even uses
6673 the first line as the document title.  The text will be fully marked up.  If
6674 you need to include literal HTML or La@TeX{} code, use the special constructs
6675 described below in the sections for the individual exporters.
6677 Some people like to use the space before the first headline for setup and
6678 internal links and therefore would like to control the exported text before
6679 the first headline in a different way.  You can do so by setting the variable
6680 @code{org-export-skip-text-before-1st-heading} to @code{t}.  On a per-file
6681 basis, you can get the same effect with @samp{#+OPTIONS: skip:t}.
6683 @noindent
6684 If you still want to have some text before the first headline, use the
6685 @code{#+TEXT} construct:
6687 @example
6688 #+OPTIONS: skip:t
6689 #+TEXT: This text will go before the *first* headline.
6690 #+TEXT: [TABLE-OF-CONTENTS]
6691 #+TEXT: This goes between the table of contents and the first headline
6692 @end example
6694 @node Lists, Paragraphs, Initial text, Markup rules
6695 @subheading Lists
6697 Plain lists as described in @ref{Plain lists} are translated to the back-ends
6698 syntax for such lists.  Most back-ends support unordered, ordered, and
6699 description lists.
6701 @node Paragraphs, Literal examples, Lists, Markup rules
6702 @subheading Paragraphs, line breaks, and quoting
6704 Paragraphs are separated by at least one empty line.  If you need to enforce
6705 a line break within a paragraph, use @samp{\\} at the end of a line.
6707 When quoting a passage from another document, it is customary to format this
6708 as a paragraph that is indented on both the left and the right margin.  You
6709 can include quotations in Org mode documents like this:
6711 @example
6712 #+begin_quote
6713 Everything should be made as simple as possible,
6714 but not any simpler -- Albert Einstein
6715 #+end_quote
6716 @end example
6718 @node Literal examples, Tables exported, Paragraphs, Markup rules
6719 @subheading Literal examples
6721 You can include literal examples that should not be subjected to
6722 markup.  Such examples will be typeset in monospace, so this is well suited
6723 for source code and similar examples.
6725 @example
6726 #+begin_example
6727 Some example from a text file.
6728 #+end_example
6729 @end example
6731 For simplicity when using small examples, you can also start the example
6732 lines with a colon:
6734 @example
6735 : Some example from a text file.
6736 @end example
6738 If the example is source code from a programming language, or any other text
6739 that can be marked up by font-lock in Emacs, you can ask for the example to
6740 look like the fontified Emacs buffer@footnote{Currently this works only for
6741 the HTML back-end, and requires the @file{htmlize.el} package version 1.34 or
6742 later.}.  This is done with the @samp{src} block, where you also need to
6743 specify the name of the major mode that should be used to fontify the
6744 example:
6746 @example
6747 #+begin_src emacs-lisp
6748 (defun org-xor (a b)
6749    "Exclusive or."
6750    (if a (not b) b))
6751 #+end_src
6752 @end example
6754 @node Tables exported, Footnotes, Literal examples, Markup rules
6755 @subheading Tables
6757 Both the native Org mode tables (@pxref{Tables}) and tables formatted with
6758 the @file{table.el} package will be exported properly.  For Org mode tables,
6759 the lines before the first horizontal separator line will become table header
6760 lines.
6762 @node Footnotes, Emphasis and monospace, Tables exported, Markup rules
6763 @subheading Footnotes
6764 @cindex footnotes
6765 @cindex @file{footnote.el}
6767 @kindex C-c !
6768 Numbers in square brackets are treated as footnote markers, and lines
6769 starting with such a marker are interpreted as the footnote itself.  You can
6770 use the Emacs package @file{footnote.el} to create footnotes@footnote{The
6771 @file{footnote} package uses @kbd{C-c !} to invoke its commands.  This
6772 binding conflicts with the Org mode command for inserting inactive time
6773 stamps.  You could use the variable @code{footnote-prefix} to switch
6774 footnotes commands to another key.  Or, if you are too used to this binding,
6775 you could use @code{org-replace-disputed-keys} and @code{org-disputed-keys}
6776 to change the settings in Org.}.  For example:
6778 @example
6779 The Org homepage[1] now looks a lot better than it used to.
6781 [1] The link is: http://orgmode.org
6782 @end example
6784 @node Emphasis and monospace, TeX macros and LaTeX fragments, Footnotes, Markup rules
6785 @subheading Emphasis and monospace
6787 @cindex underlined text
6788 @cindex bold text
6789 @cindex italic text
6790 @cindex verbatim text
6791 You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
6792 and @code{~verbatim~}, and, if you must, @samp{+strike-through+}.  Text
6793 in the code and verbatim string is not processed for Org mode specific
6794 syntax, it is exported verbatim.
6796 @node TeX macros and LaTeX fragments, Horizontal rules, Emphasis and monospace, Markup rules
6797 @subheading @TeX{} macros and La@TeX{} fragments
6798 @cindex LaTeX fragments, export
6799 @cindex TeX macros, export
6800 @cindex HTML entities
6801 @cindex LaTeX entities
6803 A @TeX{}-like syntax is used to specify special characters.  Where possible,
6804 these will be transformed into the native format of the exporter back-end.
6805 Strings like @code{\alpha} will be exported as @code{&alpha;} in the HTML
6806 output, and as @code{$\alpha$} in the La@TeX{} output.  Similarly,
6807 @code{\nbsp} will become @code{&nbsp;} in HTML and @code{~} in La@TeX{}.
6808 This applies for a large number of entities, with names taken from both HTML
6809 and La@TeX{}, see the variable @code{org-html-entities} for the complete
6810 list.  If you are unsure about a name, use @kbd{M-@key{TAB}} for completion
6811 after having types the backslash and maybe a few characters
6812 (@pxref{Completion}).
6814 La@TeX{} fragments are converted into images for HTML export, and they are
6815 written literally into the La@TeX{} export.  See also @ref{Embedded LaTeX}.
6817 Finally, @samp{\-} is treated as a shy hyphen, and @samp{--}, @samp{---}, and
6818 @samp{...} are all converted into special commands creating hyphens of
6819 different lengths or a compact set of dots.
6821 @node Horizontal rules, Comment lines, TeX macros and LaTeX fragments, Markup rules
6822 @subheading  Horizontal rules
6823 @cindex horizontal rules, in exported files
6824 A line consisting of only dashes, and at least 5 of them, will be
6825 exported as a horizontal line (@samp{<hr/>} in HTML).
6827 @node Comment lines,  , Horizontal rules, Markup rules
6828 @subheading Comment lines
6829 @cindex comment lines
6830 @cindex exporting, not
6832 Lines starting with @samp{#} in column zero are treated as comments
6833 and will never be exported.  Also entire subtrees starting with the
6834 word @samp{COMMENT} will never be exported.
6836 @table @kbd
6837 @kindex C-c ;
6838 @item C-c ;
6839 Toggle the COMMENT keyword at the beginning of an entry.
6840 @end table
6842 @node Export options, The export dispatcher, Markup rules, Exporting
6843 @section Export options
6844 @cindex options, for export
6846 @cindex completion, of option keywords
6847 The exporter recognizes special lines in the buffer which provide
6848 additional information.  These lines may be put anywhere in the file.
6849 The whole set of lines can be inserted into the buffer with @kbd{C-c
6850 C-e t}.  For individual lines, a good way to make sure the keyword is
6851 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
6852 (@pxref{Completion}).
6854 @table @kbd
6855 @kindex C-c C-e t
6856 @item C-c C-e t
6857 Insert template with export options, see example below.
6858 @end table
6860 @example
6861 #+TITLE:     the title to be shown (default is the buffer name)
6862 #+AUTHOR:    the author (default taken from @code{user-full-name})
6863 #+DATE:      A date, fixed, of a format string for @code{format-time-string}
6864 #+EMAIL:     his/her email address (default from @code{user-mail-address})
6865 #+LANGUAGE:  language for HTML, e.g. @samp{en} (@code{org-export-default-language})
6866 #+TEXT:      Some descriptive text to be inserted at the beginning.
6867 #+TEXT:      Several lines may be given.
6868 #+OPTIONS:   H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
6869 @end example
6871 @noindent
6872 The OPTIONS line is a compact@footnote{If you want to configure many options
6873 this way, you can use several OPTIONS lines.} form to specify export settings.  Here
6874 you can:
6875 @cindex headline levels
6876 @cindex section-numbers
6877 @cindex table of contents
6878 @cindex line-break preservation
6879 @cindex quoted HTML tags
6880 @cindex fixed-width sections
6881 @cindex tables
6882 @cindex @TeX{}-like syntax for sub- and superscripts
6883 @cindex footnotes
6884 @cindex special strings
6885 @cindex emphasized text
6886 @cindex @TeX{} macros
6887 @cindex La@TeX{} fragments
6888 @cindex author info, in export
6889 @cindex time info, in export
6890 @example
6891 H:         @r{set the number of headline levels for export}
6892 num:       @r{turn on/off section-numbers}
6893 toc:       @r{turn on/off table of contents, or set level limit (integer)}
6894 \n:        @r{turn on/off line-break-preservation}
6895 @@:         @r{turn on/off quoted HTML tags}
6896 ::         @r{turn on/off fixed-width sections}
6897 |:         @r{turn on/off tables}
6898 ^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
6899            @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
6900            @r{the simple @code{a_b} will be left as it is.}
6901 -:         @r{turn on/off conversion of special strings.}
6902 f:         @r{turn on/off footnotes like this[1].}
6903 *:         @r{turn on/off emphasized text (bold, italic, underlined)}
6904 TeX:       @r{turn on/off simple @TeX{} macros in plain text}
6905 LaTeX:     @r{turn on/off La@TeX{} fragments}
6906 skip:      @r{turn on/off skipping the text before the first heading}
6907 author:    @r{turn on/off inclusion of author name/email into exported file}
6908 timestamp: @r{turn on/off inclusion creation time into exported file}
6909 d:         @r{turn on/off inclusion of drawers}
6910 @end example
6912 These options take effect in both the HTML and La@TeX{} export, except
6913 for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
6914 @code{nil} for the La@TeX{} export.
6917 @node The export dispatcher, ASCII export, Export options, Exporting
6918 @section The export dispatcher
6920 All export commands can be reached using the export dispatcher, which is a
6921 prefix key that prompts for an additional key specifying the command.
6922 Normally the entire file is exported, but if there is an active region that
6923 contains one outline tree, the first heading is used as document title and
6924 the subtrees are exported.
6926 @table @kbd
6927 @kindex C-c C-e
6928 @item C-c C-e
6929 Dispatcher for export and publishing commands.  Displays a help-window
6930 listing the additional key(s) needed to launch an export or publishing
6931 command.  The prefix arg is passed through to the exporter.  If the option
6932 @code{org-export-run-in-background} is set, Org will run the command in the
6933 background if that seems useful for the specific command (i.e. commands that
6934 write to a file).
6935 @kindex C-c C-e v
6936 @item C-c C-e v
6937 Like @kbd{C-c C-e}, but only export the text that is currently visible
6938 (i.e. not hidden by outline visibility).
6939 @kindex C-u C-u C-c C-e
6940 @item C-u C-u C-c C-e
6941 Call an the exporter, but reverse the setting of
6942 @code{org-export-run-in-background}, i.e. request background processing if
6943 not set, or force processing in the current Emacs process if st.
6944 @end table
6946 @node ASCII export, HTML export, The export dispatcher, Exporting
6947 @section ASCII export
6948 @cindex ASCII export
6950 ASCII export produces a simple and very readable version of an Org mode
6951 file.
6953 @cindex region, active
6954 @cindex active region
6955 @cindex Transient mark mode
6956 @table @kbd
6957 @kindex C-c C-e a
6958 @item C-c C-e a
6959 Export as ASCII file.  For an org file @file{myfile.org}, the ASCII file
6960 will be @file{myfile.txt}.  The file will be overwritten without
6961 warning.  If there is an active region, only the region will be
6962 exported. If the selected region is a single tree, the tree head will
6963 become the document title.  If the tree head entry has or inherits an
6964 @code{:EXPORT_FILE_NAME:} property, that name will be used for the
6965 export.
6966 @kindex C-c C-e v a
6967 @item C-c C-e v a
6968 Export only the visible part of the document.
6969 @end table
6971 @cindex headline levels, for exporting
6972 In the exported version, the first 3 outline levels will become
6973 headlines, defining a general document structure.  Additional levels
6974 will be exported as itemized lists.  If you want that transition to occur
6975 at a different level, specify it with a prefix argument.  For example,
6977 @example
6978 @kbd{C-1 C-c C-e a}
6979 @end example
6981 @noindent
6982 creates only top level headlines and does the rest as items.  When
6983 headlines are converted to items, the indentation of the text following
6984 the headline is changed to fit nicely under the item.  This is done with
6985 the assumption that the first body line indicates the base indentation of
6986 the body text.  Any indentation larger than this is adjusted to preserve
6987 the layout relative to the first line.  Should there be lines with less
6988 indentation than the first, these are left alone.
6990 @node HTML export, LaTeX export, ASCII export, Exporting
6991 @section HTML export
6992 @cindex HTML export
6994 Org mode contains an HTML (XHTML 1.0 strict) exporter with extensive
6995 HTML formatting, in ways similar to John Grubers @emph{markdown}
6996 language, but with additional support for tables.
6998 @menu
6999 * HTML Export commands::        How to invoke HTML export
7000 * Quoting HTML tags::           Using direct HTML in Org mode
7001 * Links::                       Transformation of links for HTML
7002 * Images::                      How to include images
7003 * CSS support::                 Changing the appearance of the output
7004 * Javascript support::          Info and Folding in a web browser
7005 @end menu
7007 @node HTML Export commands, Quoting HTML tags, HTML export, HTML export
7008 @subsection HTML export commands
7010 @cindex region, active
7011 @cindex active region
7012 @cindex Transient mark mode
7013 @table @kbd
7014 @kindex C-c C-e h
7015 @item C-c C-e h
7016 Export as HTML file @file{myfile.html}.  For an org file
7017 @file{myfile.org}, the ASCII file will be @file{myfile.html}.  The file
7018 will be overwritten without warning.  If there is an active region, only
7019 the region will be exported. If the selected region is a single tree,
7020 the tree head will become the document title.  If the tree head entry
7021 has or inherits an @code{:EXPORT_FILE_NAME:} property, that name will be
7022 used for the export.
7023 @kindex C-c C-e b
7024 @item C-c C-e b
7025 Export as HTML file and immediately open it with a browser.
7026 @kindex C-c C-e H
7027 @item C-c C-e H
7028 Export to a temporary buffer, do not create a file.
7029 @kindex C-c C-e R
7030 @item C-c C-e R
7031 Export the active region to a temporary buffer.  With a prefix argument, do
7032 not produce the file header and footer, but just the plain HTML section for
7033 the region.  This is good for cut-and-paste operations.
7034 @kindex C-c C-e v h
7035 @kindex C-c C-e v b
7036 @kindex C-c C-e v H
7037 @kindex C-c C-e v R
7038 @item C-c C-e v h
7039 @item C-c C-e v b
7040 @item C-c C-e v H
7041 @item C-c C-e v R
7042 Export only the visible part of the document.
7043 @item M-x org-export-region-as-html
7044 Convert the region to HTML under the assumption that it was Org mode
7045 syntax before.  This is a global command that can be invoked in any
7046 buffer.
7047 @item M-x org-replace-region-by-HTML
7048 Replace the active region (assumed to be in Org mode syntax) by HTML
7049 code.
7050 @end table
7052 @cindex headline levels, for exporting
7053 In the exported version, the first 3 outline levels will become headlines,
7054 defining a general document structure.  Additional levels will be exported as
7055 itemized lists.  If you want that transition to occur at a different level,
7056 specify it with a numeric prefix argument.  For example,
7058 @example
7059 @kbd{C-2 C-c C-e b}
7060 @end example
7062 @noindent
7063 creates two levels of headings and does the rest as items.
7065 @node Quoting HTML tags, Links, HTML Export commands, HTML export
7066 @subsection Quoting HTML tags
7068 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
7069 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
7070 which should be interpreted as such, mark them with @samp{@@} as in
7071 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
7072 simple tags.  For more extensive HTML that should be copied verbatim to
7073 the exported file use either
7075 @example
7076 #+HTML: Literal HTML code for export
7077 @end example
7079 @noindent or
7081 @example
7082 #+BEGIN_HTML
7083 All lines between these markers are exported literally
7084 #+END_HTML
7085 @end example
7088 @node Links, Images, Quoting HTML tags, HTML export
7089 @subsection Links
7091 @cindex links, in HTML export
7092 @cindex internal links, in HTML export
7093 @cindex external links, in HTML export
7094 Internal links (@pxref{Internal links}) will continue to work in HTML
7095 files only if they match a dedicated @samp{<<target>>}.  Automatic links
7096 created by radio targets (@pxref{Radio targets}) will also work in the
7097 HTML file.  Links to external files will still work if the HTML file is
7098 in the same directory as the Org file.  Links to other @file{.org}
7099 files will be translated into HTML links under the assumption that an
7100 HTML version also exists of the linked file.  For information related to
7101 linking files while publishing them to a publishing directory see
7102 @ref{Publishing links}.
7104 @node Images, CSS support, Links, HTML export
7105 @subsection Images
7107 @cindex images, inline in HTML
7108 @cindex inlining images in HTML
7109 HTML export can inline images given as links in the Org file, and
7110 it can make an image the clickable part of a link.  By
7111 default@footnote{but see the variable
7112 @code{org-export-html-inline-images}}, images are inlined if a link does
7113 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
7114 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
7115 @samp{the image} that points to the image.  If the description part
7116 itself is a @code{file:} link or a @code{http:} URL pointing to an
7117 image, this image will be inlined and activated so that clicking on the
7118 image will activate the link.  For example, to include a thumbnail that
7119 will link to a high resolution version of the image, you could use:
7121 @example
7122 [[file:highres.jpg][file:thumb.jpg]]
7123 @end example
7125 @noindent
7126 and you could use @code{http} addresses just as well.
7128 @node CSS support, Javascript support, Images, HTML export
7129 @subsection CSS support
7130 @cindex CSS, for HTML export
7131 @cindex HTML export, CSS
7133 You can also give style information for the exported file.  The HTML
7134 exporter assigns the following CSS classes to appropriate parts of the
7135 document - your style specifications may change these:
7136 @example
7137 .todo           @r{TODO keywords}
7138 .done           @r{the DONE keyword}
7139 .timestamp      @r{time stamp}
7140 .timestamp-kwd  @r{keyword associated with a time stamp, like SCHEDULED}
7141 .tag            @r{tag in a headline}
7142 .target         @r{target for links}
7143 @end example
7145 The default style specification can be configured through the option
7146 @code{org-export-html-style}.  If you want to use a file-local style,
7147 you may use file variables, best wrapped into a COMMENT section at the
7148 end of the outline tree.  For example@footnote{Under Emacs 21, the
7149 continuation lines for a variable value should have no @samp{#} at the
7150 start of the line.}:
7152 @example
7153 * COMMENT html style specifications
7155 # Local Variables:
7156 # org-export-html-style: "   <style type=\"text/css\">
7157 #       p @{font-weight: normal; color: gray; @}
7158 #       h1 @{color: black; @}
7159 #   </style>"
7160 # End:
7161 @end example
7163 Remember to execute @kbd{M-x normal-mode} after changing this to make
7164 the new style visible to Emacs.  This command restarts Org mode for the
7165 current buffer and forces Emacs to re-evaluate the local variables
7166 section in the buffer.
7168 @c FIXME: More about header and footer styles
7169 @c FIXME: Talk about links and targets.
7171 @node Javascript support,  , CSS support, HTML export
7172 @subsection Javascript supported display of web pages
7174 @emph{Sebastian Rose} has written a JavaScript program especially designed to
7175 enhance the web viewing experience of HTML files created with Org.  This
7176 program allows to view large files in two different ways.  The first one is
7177 an @emph{Info}-like mode where each section is displayed separately and
7178 navigation can be done with the @kbd{n} and @kbd{p} keys (and some other keys
7179 as well, press @kbd{?} for an overview of the available keys).  The second
7180 view type is a @emph{folding} view much like Org provides it inside Emacs.
7181 The script is available at @url{http://orgmode.org/org-info.js} and you can
7182 find the documentation for it at @url{http://orgmode.org/org-infojs.html}.
7183 We are serving the script from our site, but if you use it a lot, you might
7184 not want to be dependent on @url{orgmode.org} and prefer to install a local
7185 copy on your own web server.
7187 To use the script, you need to make sure that the @file{org-infojs.el} module
7188 gets loaded.  It should be loaded by default, try @kbd{M-x customize-variable
7189 @key{RET} org-modules @key{RET}} to convince yourself that this is indeed the
7190 case.  All it then takes to make use of the program is adding a single line
7191 to the Org file:
7193 @example
7194 #+INFOSJ_OPT: view:info toc:nil
7195 @end example
7197 @noindent
7198 If this line is found, the HTML header will automatically contain the code
7199 needed to invoke the script.  Using the line above, you can set the following
7200 viewing options:
7202 @example
7203 path:    @r{The path to the script.  The default is to grab the script from}
7204          @r{@url{http://orgmode.org/org-info.js}, but you might want to have}
7205          @r{a local copy and use a path like @samp{../scripts/org-info.js}.}
7206 view:    @r{Initial view when website is first shown.  Possible values are}
7207          info      @r{Info-like interface with one section per page.}
7208          overview  @r{Folding interface, initially showing only top-level.}
7209          content   @r{Folding interface, starting with all headlines visible.}
7210          showall   @r{Folding interface, all headlines and text visible.}
7211 sdepth:  @r{Maximum headline level that will still become an independent}
7212          @r{section for info and folding modes.  The default is taken from}
7213          @r{@code{org-headline-levels} (= the @code{H} switch in @code{#+OPTIONS}).}
7214          @r{If this is smaller than in @code{org-headline-levels}, each}
7215          @r{info/folding section can still contain children headlines.}
7216 toc:     @r{Should the table of content @emph{initially} be visible?}
7217          @r{Even when @code{nil}, you can always get to the toc with @kbd{i}.}
7218 tdepth:  @r{The depth of the table of contents.  The defaults are taken from}
7219          @r{the variables @code{org-headline-levels} and @code{org-export-with-toc}.}
7220 ltoc:    @r{Should there be short contents (children) in each section?}
7221 mouse:   @r{Headings are highlighted when the mouse is over them.  Should be}
7222          @r{@samp{underline} (default) or a background color like @samp{#cccccc}.}
7223 buttons: @r{Should view-toggle buttons be everywhere?  When @code{nil} (the}
7224          @r{default), only one such button will be present.}
7225 @end example
7227 You can choose default values for these options by customizing the variable
7228 @code{org-infojs-options}.  If you always want to apply the script to your
7229 pages, configure the variable @code{org-export-html-use-infojs}.
7231 @node LaTeX export, XOXO export, HTML export, Exporting
7232 @section LaTeX export
7233 @cindex LaTeX export
7235 Org mode contains a La@TeX{} exporter written by Bastien Guerry.
7237 @menu
7238 * LaTeX export commands::       How to invoke LaTeX export
7239 * Quoting LaTeX code::          Incorporating literal LaTeX code
7240 * Sectioning structure::        Changing sectioning in LaTeX output
7241 @end menu
7243 @node LaTeX export commands, Quoting LaTeX code, LaTeX export, LaTeX export
7244 @subsection LaTeX export commands
7246 @table @kbd
7247 @kindex C-c C-e l
7248 @item C-c C-e l
7249 Export as La@TeX{} file @file{myfile.tex}.
7250 @kindex C-c C-e L
7251 @item C-c C-e L
7252 Export to a temporary buffer, do not create a file.
7253 @kindex C-c C-e v l
7254 @kindex C-c C-e v L
7255 @item C-c C-e v l
7256 @item C-c C-e v L
7257 Export only the visible part of the document.
7258 @item M-x org-export-region-as-latex
7259 Convert the region to La@TeX{} under the assumption that it was Org mode
7260 syntax before.  This is a global command that can be invoked in any
7261 buffer.
7262 @item M-x org-replace-region-by-latex
7263 Replace the active region (assumed to be in Org mode syntax) by La@TeX{}
7264 code.
7265 @end table
7267 @cindex headline levels, for exporting
7268 In the exported version, the first 3 outline levels will become
7269 headlines, defining a general document structure.  Additional levels
7270 will be exported as description lists.  The exporter can ignore them or
7271 convert them to a custom string depending on
7272 @code{org-latex-low-levels}.
7274 If you want that transition to occur at a different level, specify it
7275 with a numeric prefix argument. For example,
7277 @example
7278 @kbd{C-2 C-c C-e l}
7279 @end example
7281 @noindent
7282 creates two levels of headings and does the rest as items.
7284 @node Quoting LaTeX code, Sectioning structure, LaTeX export commands, LaTeX export
7285 @subsection Quoting LaTeX code
7287 Embedded La@TeX{} as described in @ref{Embedded LaTeX} will be correctly
7288 inserted into the La@TeX{} file.  Furthermore, you can add special code
7289 that should only be present in La@TeX{} export with the following
7290 constructs:
7292 @example
7293 #+LaTeX: Literal LaTeX code for export
7294 @end example
7296 @noindent or
7298 @example
7299 #+BEGIN_LaTeX
7300 All lines between these markers are exported literally
7301 #+END_LaTeX
7302 @end example
7306 @node   Sectioning structure,  , Quoting LaTeX code, LaTeX export
7307 @subsection Sectioning structure
7308 @cindex LaTeX class
7309 @cindex LaTeX sectioning structure
7311 By default, the La@TeX{} output uses the class @code{article}.
7313 You can change this globally by setting a different value for
7314 @code{org-export-latex-default-class} or locally by adding an option
7315 like @code{#+LaTeX_CLASS: myclass} in your file.  The class should be
7316 listed in @code{org-export-latex-classes}, where you can also define the
7317 sectioning structure for each class.
7320 @node XOXO export, iCalendar export, LaTeX export, Exporting
7321 @section XOXO export
7322 @cindex XOXO export
7324 Org mode contains an exporter that produces XOXO-style output.
7325 Currently, this exporter only handles the general outline structure and
7326 does not interpret any additional Org mode features.
7328 @table @kbd
7329 @kindex C-c C-e x
7330 @item C-c C-e x
7331 Export as XOXO file @file{myfile.html}.
7332 @kindex C-c C-e v
7333 @item C-c C-e v x
7334 Export only the visible part of the document.
7335 @end table
7337 @node iCalendar export,  , XOXO export, Exporting
7338 @section iCalendar export
7339 @cindex iCalendar export
7341 Some people like to use Org mode for keeping track of projects, but
7342 still prefer a standard calendar application for anniversaries and
7343 appointments.  In this case it can be useful to have deadlines and
7344 other time-stamped items in Org files show up in the calendar
7345 application.  Org mode can export calendar information in the standard
7346 iCalendar format.  If you also want to have TODO entries included in the
7347 export, configure the variable @code{org-icalendar-include-todo}.
7349 @table @kbd
7350 @kindex C-c C-e i
7351 @item C-c C-e i
7352 Create iCalendar entries for the current file and store them in the same
7353 directory, using a file extension @file{.ics}.
7354 @kindex C-c C-e I
7355 @item C-c C-e I
7356 Like @kbd{C-c C-e i}, but do this for all files in
7357 @code{org-agenda-files}.  For each of these files, a separate iCalendar
7358 file will be written.
7359 @kindex C-c C-e c
7360 @item C-c C-e c
7361 Create a single large iCalendar file from all files in
7362 @code{org-agenda-files} and write it to the file given by
7363 @code{org-combined-agenda-icalendar-file}.
7364 @end table
7366 The export will honor SUMMARY, DESCRIPTION and LOCATION properties if
7367 the selected entries have them.  If not, the summary will be derived
7368 from the headline, and the description from the body (limited to
7369 @code{org-icalendar-include-body} characters).
7371 How this calendar is best read and updated, depends on the application
7372 you are using.  The FAQ covers this issue.
7374 @node Publishing, Miscellaneous, Exporting, Top
7375 @chapter Publishing
7376 @cindex publishing
7378 Org includes@footnote{@file{org-publish.el} is not distributed with
7379 Emacs 21, if you are still using Emacs 21, you need you need to download
7380 this file separately.} a publishing management system that allows you to
7381 configure automatic HTML conversion of @emph{projects} composed of
7382 interlinked org files.  This system is called @emph{org-publish}.  You can
7383 also configure org-publish to automatically upload your exported HTML
7384 pages and related attachments, such as images and source code files, to
7385 a web server. Org-publish turns Org into a web-site authoring tool.
7387 You can also use Org-publish to convert files into La@TeX{}, or even
7388 combine HTML and La@TeX{} conversion so that files are available in both
7389 formats on the server@footnote{Since La@TeX{} files on a server are not
7390 that helpful, you surely want to perform further conversion on them --
7391 e.g. convert them to @code{PDF} format.}.
7393 Org-publish has been contributed to Org by David O'Toole.
7395 @menu
7396 * Configuration::               Defining projects
7397 * Sample configuration::        Example projects
7398 * Triggering publication::      Publication commands
7399 @end menu
7401 @node Configuration, Sample configuration, Publishing, Publishing
7402 @section Configuration
7404 Publishing needs significant configuration to specify files, destination
7405 and many other properties of a project.
7407 @menu
7408 * Project alist::               The central configuration variable
7409 * Sources and destinations::    From here to there
7410 * Selecting files::             What files are part of the project?
7411 * Publishing action::           Setting the function doing the publishing
7412 * Publishing options::          Tweaking HTML export
7413 * Publishing links::            Which links keep working after publishing?
7414 * Project page index::          Publishing a list of project files
7415 @end menu
7417 @node Project alist, Sources and destinations, Configuration, Configuration
7418 @subsection The variable @code{org-publish-project-alist}
7419 @cindex org-publish-project-alist
7420 @cindex projects, for publishing
7422 Org-publish is configured almost entirely through setting the value of
7423 one variable, called @code{org-publish-project-alist}.
7424 Each element of the list configures one project, and may be in one of
7425 the two following forms:
7427 @lisp
7428 ("project-name" :property value :property value ...)
7430 @r{or}
7432 ("project-name" :components ("project-name" "project-name" ...))
7434 @end lisp
7436 In both cases, projects are configured by specifying property values.
7437 A project defines the set of files that will be published, as well as
7438 the publishing configuration to use when publishing those files.  When
7439 a project takes the second form listed above, the individual members
7440 of the ``components'' property are taken to be components of the
7441 project, which group together files requiring different publishing
7442 options. When you publish such a ``meta-project'' all the components
7443 will also publish.
7445 @node Sources and destinations, Selecting files, Project alist, Configuration
7446 @subsection Sources and destinations for files
7447 @cindex directories, for publishing
7449 Most properties are optional, but some should always be set. In
7450 particular, org-publish needs to know where to look for source files,
7451 and where to put published files.
7453 @multitable @columnfractions 0.3 0.7
7454 @item @code{:base-directory}
7455 @tab Directory containing publishing source files
7456 @item @code{:publishing-directory}
7457 @tab Directory (possibly remote) where output files will be published.
7458 @item @code{:preparation-function}
7459 @tab Function called before starting publishing process, for example to
7460 run @code{make} for updating files to be published.
7461 @end multitable
7462 @noindent
7464 @node Selecting files, Publishing action, Sources and destinations, Configuration
7465 @subsection Selecting files
7466 @cindex files, selecting for publishing
7468 By default, all files with extension @file{.org} in the base directory
7469 are considered part of the project.  This can be modified by setting the
7470 properties
7471 @multitable @columnfractions 0.25 0.75
7472 @item @code{:base-extension}
7473 @tab Extension (without the dot!) of source files.  This actually is a
7474 regular expression.
7476 @item @code{:exclude}
7477 @tab Regular expression to match file names that should not be
7478 published, even though they have been selected on the basis of their
7479 extension.
7481 @item @code{:include}
7482 @tab List of files to be included regardless of @code{:base-extension}
7483 and @code{:exclude}.
7484 @end multitable
7486 @node Publishing action, Publishing options, Selecting files, Configuration
7487 @subsection Publishing action
7488 @cindex action, for publishing
7490 Publishing means that a file is copied to the destination directory and
7491 possibly transformed in the process.  The default transformation is to
7492 export Org files as HTML files, and this is done by the function
7493 @code{org-publish-org-to-html} which calls the HTML exporter
7494 (@pxref{HTML export}). But you also can publish your files in La@TeX{} by
7495 using the function @code{org-publish-org-to-latex} instead. Other files
7496 like images only need to be copied to the publishing destination. For
7497 non-Org files, you need to specify the publishing function.
7500 @multitable @columnfractions 0.3 0.7
7501 @item @code{:publishing-function}
7502 @tab Function executing the publication of a file.  This may also be a
7503 list of functions, which will all be called in turn.
7504 @end multitable
7506 The function must accept two arguments: a property list containing at
7507 least a @code{:publishing-directory} property, and the name of the file
7508 to be published.  It should take the specified file, make the necessary
7509 transformation (if any) and place the result into the destination folder.
7510 You can write your own publishing function, but @code{org-publish}
7511 provides one for attachments (files that only need to be copied):
7512 @code{org-publish-attachment}.
7514 @node Publishing options, Publishing links, Publishing action, Configuration
7515 @subsection Options for the HTML/LaTeX exporters
7516 @cindex options, for publishing
7518 The property list can be used to set many export options for the HTML
7519 and La@TeX{} exporters.  In most cases, these properties correspond to user
7520 variables in Org.  The table below lists these properties along
7521 with the variable they belong to.  See the documentation string for the
7522 respective variable for details.
7524 @multitable @columnfractions 0.3 0.7
7525 @item @code{:language}              @tab @code{org-export-default-language}
7526 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
7527 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
7528 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
7529 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
7530 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
7531 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
7532 @item @code{:special-strings}       @tab @code{org-export-with-special-strings}
7533 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
7534 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
7535 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
7536 @item @code{:timestamps}           .@tab @code{org-export-with-timestamps}
7537 @item @code{:tags}                 .@tab @code{org-export-with-tags}
7538 @item @code{:tables}                @tab @code{org-export-with-tables}
7539 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
7540 @item @code{:style}                 @tab @code{org-export-html-style}
7541 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
7542 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
7543 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
7544 @item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
7545 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
7546 @item @code{:preamble}              @tab @code{org-export-html-preamble}
7547 @item @code{:postamble}             @tab @code{org-export-html-postamble}
7548 @item @code{:auto-preamble}         @tab @code{org-export-html-auto-preamble}
7549 @item @code{:auto-postamble}        @tab @code{org-export-html-auto-postamble}
7550 @item @code{:author}                @tab @code{user-full-name}
7551 @item @code{:email}                 @tab @code{user-mail-address}
7552 @end multitable
7554 If you use several email addresses, separate them by a semi-column.
7556 Most of the @code{org-export-with-*} variables have the same effect in
7557 both HTML and La@TeX{} exporters, except for @code{:TeX-macros} and
7558 @code{:LaTeX-fragments}, respectively @code{nil} and @code{t} in the
7559 La@TeX{} export.
7561 When a property is given a value in @code{org-publish-project-alist},
7562 its setting overrides the value of the corresponding user variable (if
7563 any) during publishing.  Options set within a file (@pxref{Export
7564 options}), however, override everything.
7566 @node Publishing links, Project page index, Publishing options, Configuration
7567 @subsection Links between published files
7568 @cindex links, publishing
7570 To create a link from one Org file to another, you would use
7571 something like @samp{[[file:foo.org][The foo]]} or simply
7572 @samp{file:foo.org.} (@pxref{Hyperlinks}).  Upon publishing this link
7573 becomes a link to @file{foo.html}.  In this way, you can interlink the
7574 pages of your "org web" project and the links will work as expected when
7575 you publish them to HTML.
7577 You may also link to related files, such as images. Provided you are
7578 careful with relative pathnames, and provided you have also configured
7579 @code{org-publish} to upload the related files, these links will work
7580 too. @ref{Complex example} for an example of this usage.
7582 Sometime an Org file to be published may contain links that are
7583 only valid in your production environment, but not in the publishing
7584 location.  In this case, use the property
7586 @multitable @columnfractions 0.4 0.6
7587 @item @code{:link-validation-function}
7588 @tab Function to validate links
7589 @end multitable
7591 @noindent
7592 to define a function for checking link validity.  This function must
7593 accept two arguments, the file name and a directory relative to which
7594 the file name is interpreted in the production environment.  If this
7595 function returns @code{nil}, then the HTML generator will only insert a
7596 description into the HTML file, but no link.  One option for this
7597 function is @code{org-publish-validate-link} which checks if the given
7598 file is part of any project in @code{org-publish-project-alist}.
7600 @node Project page index,  , Publishing links, Configuration
7601 @subsection Project page index
7602 @cindex index, of published pages
7604 The following properties may be used to control publishing of an
7605 index of files or summary page for a given project.
7607 @multitable @columnfractions 0.25 0.75
7608 @item @code{:auto-index}
7609 @tab When non-nil, publish an index during org-publish-current-project or
7610 org-publish-all.
7612 @item @code{:index-filename}
7613 @tab Filename for output of index. Defaults to @file{index.org} (which
7614 becomes @file{index.html}).
7616 @item @code{:index-title}
7617 @tab Title of index page. Defaults to name of file.
7619 @item @code{:index-function}
7620 @tab Plug-in function to use for generation of index.
7621 Defaults to @code{org-publish-org-index}, which generates a plain list
7622 of links to all files in the project.
7623 @end multitable
7625 @node Sample configuration, Triggering publication, Configuration, Publishing
7626 @section Sample configuration
7628 Below we provide two example configurations.  The first one is a simple
7629 project publishing only a set of Org files.  The second example is
7630 more complex, with a multi-component project.
7632 @menu
7633 * Simple example::              One-component publishing
7634 * Complex example::             A multi-component publishing example
7635 @end menu
7637 @node Simple example, Complex example, Sample configuration, Sample configuration
7638 @subsection Example: simple publishing configuration
7640 This example publishes a set of Org files to the @file{public_html}
7641 directory on the local machine.
7643 @lisp
7644 (setq org-publish-project-alist
7645       '(("org"
7646          :base-directory "~/org/"
7647          :publishing-directory "~/public_html"
7648          :section-numbers nil
7649          :table-of-contents nil
7650          :style "<link rel=stylesheet
7651                 href=\"../other/mystyle.css\"
7652                 type=\"text/css\">")))
7653 @end lisp
7655 @node Complex example,  , Simple example, Sample configuration
7656 @subsection Example: complex publishing configuration
7658 This more complicated example publishes an entire website, including
7659 org files converted to HTML, image files, emacs lisp source code, and
7660 style sheets. The publishing-directory is remote and private files are
7661 excluded.
7663 To ensure that links are preserved, care should be taken to replicate
7664 your directory structure on the web server, and to use relative file
7665 paths. For example, if your org files are kept in @file{~/org} and your
7666 publishable images in @file{~/images}, you'd link to an image with
7668 @example
7669 file:../images/myimage.png
7670 @end example
7672 On the web server, the relative path to the image should be the
7673 same. You can accomplish this by setting up an "images" folder in the
7674 right place on the web server, and publishing images to it.
7676 @lisp
7677 (setq org-publish-project-alist
7678       '(("orgfiles"
7679           :base-directory "~/org/"
7680           :base-extension "org"
7681           :publishing-directory "/ssh:user@@host:~/html/notebook/"
7682           :publishing-function org-publish-org-to-html
7683           :exclude "PrivatePage.org"   ;; regexp
7684           :headline-levels 3
7685           :section-numbers nil
7686           :table-of-contents nil
7687           :style "<link rel=stylesheet
7688                   href=\"../other/mystyle.css\" type=\"text/css\">"
7689           :auto-preamble t
7690           :auto-postamble nil)
7692          ("images"
7693           :base-directory "~/images/"
7694           :base-extension "jpg\\|gif\\|png"
7695           :publishing-directory "/ssh:user@@host:~/html/images/"
7696           :publishing-function org-publish-attachment)
7698          ("other"
7699           :base-directory "~/other/"
7700           :base-extension "css\\|el"
7701           :publishing-directory "/ssh:user@@host:~/html/other/"
7702           :publishing-function org-publish-attachment)
7703          ("website" :components ("orgfiles" "images" "other"))))
7704 @end lisp
7706 @node Triggering publication,  , Sample configuration, Publishing
7707 @section Triggering publication
7709 Once org-publish is properly configured, you can publish with the
7710 following functions:
7712 @table @kbd
7713 @item C-c C-e C
7714 Prompt for a specific project and publish all files that belong to it.
7715 @item C-c C-e P
7716 Publish the project containing the current file.
7717 @item C-c C-e F
7718 Publish only the current file.
7719 @item C-c C-e A
7720 Publish all projects.
7721 @end table
7723 Org uses timestamps to track when a file has changed. The above
7724 functions normally only publish changed files. You can override this and
7725 force publishing of all files by giving a prefix argument.
7727 @node Miscellaneous, Extensions and Hacking, Publishing, Top
7728 @chapter Miscellaneous
7730 @menu
7731 * Completion::                  M-TAB knows what you need
7732 * Customization::               Adapting Org to your taste
7733 * In-buffer settings::          Overview of the #+KEYWORDS
7734 * The very busy C-c C-c key::   When in doubt, press C-c C-c
7735 * Clean view::                  Getting rid of leading stars in the outline
7736 * TTY keys::                    Using Org on a tty
7737 * Interaction::                 Other Emacs packages
7738 * Bugs::                        Things which do not work perfectly
7739 @end menu
7741 @node Completion, Customization, Miscellaneous, Miscellaneous
7742 @section Completion
7743 @cindex completion, of @TeX{} symbols
7744 @cindex completion, of TODO keywords
7745 @cindex completion, of dictionary words
7746 @cindex completion, of option keywords
7747 @cindex completion, of tags
7748 @cindex completion, of property keys
7749 @cindex completion, of link abbreviations
7750 @cindex @TeX{} symbol completion
7751 @cindex TODO keywords completion
7752 @cindex dictionary word completion
7753 @cindex option keyword completion
7754 @cindex tag completion
7755 @cindex link abbreviations, completion of
7757 Org supports in-buffer completion.  This type of completion does
7758 not make use of the minibuffer.  You simply type a few letters into
7759 the buffer and use the key to complete text right there.
7761 @table @kbd
7762 @kindex M-@key{TAB}
7763 @item M-@key{TAB}
7764 Complete word at point
7765 @itemize @bullet
7766 @item
7767 At the beginning of a headline, complete TODO keywords.
7768 @item
7769 After @samp{\}, complete @TeX{} symbols supported by the exporter.
7770 @item
7771 After @samp{*}, complete headlines in the current buffer so that they
7772 can be used in search links like @samp{[[*find this headline]]}.
7773 @item
7774 After @samp{:} in a headline, complete tags.  The list of tags is taken
7775 from the variable @code{org-tag-alist} (possibly set through the
7776 @samp{#+TAGS} in-buffer option, @pxref{Setting tags}), or it is created
7777 dynamically from all tags used in the current buffer.
7778 @item
7779 After @samp{:} and not in a headline, complete property keys.  The list
7780 of keys is constructed dynamically from all keys used in the current
7781 buffer.
7782 @item
7783 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
7784 @item
7785 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
7786 @samp{OPTIONS} which set file-specific options for Org mode.  When the
7787 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
7788 will insert example settings for this keyword.
7789 @item
7790 In the line after @samp{#+STARTUP: }, complete startup keywords,
7791 i.e. valid keys for this line.
7792 @item
7793 Elsewhere, complete dictionary words using Ispell.
7794 @end itemize
7795 @end table
7797 @node Customization, In-buffer settings, Completion, Miscellaneous
7798 @section Customization
7799 @cindex customization
7800 @cindex options, for customization
7801 @cindex variables, for customization
7803 There are more than 180 variables that can be used to customize
7804 Org.  For the sake of compactness of the manual, I am not
7805 describing the variables here.  A structured overview of customization
7806 variables is available with @kbd{M-x org-customize}.  Or select
7807 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
7808 settings can also be activated on a per-file basis, by putting special
7809 lines into the buffer (@pxref{In-buffer settings}).
7811 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
7812 @section Summary of in-buffer settings
7813 @cindex in-buffer settings
7814 @cindex special keywords
7816 Org mode uses special lines in the buffer to define settings on a
7817 per-file basis.  These lines start with a @samp{#+} followed by a
7818 keyword, a colon, and then individual words defining a setting.  Several
7819 setting words can be in the same line, but you can also have multiple
7820 lines for the keyword.  While these settings are described throughout
7821 the manual, here is a summary.  After changing any of those lines in the
7822 buffer, press @kbd{C-c C-c} with the cursor still in the line to
7823 activate the changes immediately.  Otherwise they become effective only
7824 when the file is visited again in a new Emacs session.
7826 @table @kbd
7827 @item #+ARCHIVE: %s_done::
7828 This line sets the archive location for the agenda file.  It applies for
7829 all subsequent lines until the next @samp{#+ARCHIVE} line, or the end
7830 of the file.  The first such line also applies to any entries before it.
7831 The corresponding variable is @code{org-archive-location}.
7832 @item #+CATEGORY:
7833 This line sets the category for the agenda file.  The category applies
7834 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
7835 end of the file.  The first such line also applies to any entries before it.
7836 @item #+COLUMNS: %25ITEM .....
7837 Set the default format for columns view.  This format applies when
7838 columns view is invoked in location where no @code{COLUMNS} property
7839 applies.
7840 @item #+CONSTANTS: name1=value1 ...
7841 Set file-local values for constants to be used in table formulas.  This
7842 line set the local variable @code{org-table-formula-constants-local}.
7843 The global version of this variable is
7844 @code{org-table-formula-constants}.
7845 @item #+DRAWERS: NAME1 .....
7846 Set the file-local set of drawers.  The corresponding global variable is
7847 @code{org-drawers}.
7848 @item #+LINK:  linkword replace
7849 These lines (several are allowed) specify link abbreviations.
7850 @xref{Link abbreviations}.  The corresponding variable is
7851 @code{org-link-abbrev-alist}.
7852 @item #+PRIORITIES: highest lowest default
7853 This line sets the limits and the default for the priorities.  All three
7854 must be either letters A-Z or numbers 0-9.  The highest priority must
7855 have a lower ASCII number that the lowest priority.
7856 @item #+PROPERTY: Property_Name Value
7857 This line sets a default inheritance value for entries in the current
7858 buffer, most useful for specifying the allowed values of a property.
7859 @item #+STARTUP:
7860 This line sets options to be used at startup of Org mode, when an
7861 Org file is being visited.  The first set of options deals with the
7862 initial visibility of the outline tree.  The corresponding variable for
7863 global default settings is @code{org-startup-folded}, with a default
7864 value @code{t}, which means @code{overview}.
7865 @cindex @code{overview}, STARTUP keyword
7866 @cindex @code{content}, STARTUP keyword
7867 @cindex @code{showall}, STARTUP keyword
7868 @example
7869 overview   @r{top-level headlines only}
7870 content    @r{all headlines}
7871 showall    @r{no folding at all, show everything}
7872 @end example
7873 Then there are options for aligning tables upon visiting a file.  This
7874 is useful in files containing narrowed table columns.  The corresponding
7875 variable is @code{org-startup-align-all-tables}, with a default value
7876 @code{nil}.
7877 @cindex @code{align}, STARTUP keyword
7878 @cindex @code{noalign}, STARTUP keyword
7879 @example
7880 align      @r{align all tables}
7881 noalign    @r{don't align tables on startup}
7882 @end example
7883 Logging closing and reinstating TODO items, and clock intervals
7884 (variables @code{org-log-done}, @code{org-log-note-clock-out}, and
7885 @code{org-log-repeat}) can be configured using these options.
7886 @cindex @code{logdone}, STARTUP keyword
7887 @cindex @code{lognotedone}, STARTUP keyword
7888 @cindex @code{nologdone}, STARTUP keyword
7889 @cindex @code{lognoteclock-out}, STARTUP keyword
7890 @cindex @code{nolognoteclock-out}, STARTUP keyword
7891 @cindex @code{logrepeat}, STARTUP keyword
7892 @cindex @code{lognoterepeat}, STARTUP keyword
7893 @cindex @code{nologrepeat}, STARTUP keyword
7894 @example
7895 logdone            @r{record a timestamp when an item is marked DONE}
7896 lognotedone        @r{record timestamp and a note when DONE}
7897 nologdone          @r{don't record when items are marked DONE}
7898 logrepeat          @r{record a time when reinstating a repeating item}
7899 lognoterepeat      @r{record a note when reinstating a repeating item}
7900 nologrepeat        @r{do not record when reinstating repeating item}
7901 lognoteclock-out   @r{record a note when clocking out}
7902 nolognoteclock-out @r{don't record a note when clocking out}
7903 @end example
7904 Here are the options for hiding leading stars in outline headings.  The
7905 corresponding variables are @code{org-hide-leading-stars} and
7906 @code{org-odd-levels-only}, both with a default setting @code{nil}
7907 (meaning @code{showstars} and @code{oddeven}).
7908 @cindex @code{hidestars}, STARTUP keyword
7909 @cindex @code{showstars}, STARTUP keyword
7910 @cindex @code{odd}, STARTUP keyword
7911 @cindex @code{even}, STARTUP keyword
7912 @example
7913 hidestars  @r{make all but one of the stars starting a headline invisible.}
7914 showstars  @r{show all stars starting a headline}
7915 odd        @r{allow only odd outline levels (1,3,...)}
7916 oddeven    @r{allow all outline levels}
7917 @end example
7918 To turn on custom format overlays over time stamps (variables
7919 @code{org-put-time-stamp-overlays} and
7920 @code{org-time-stamp-overlay-formats}), use
7921 @cindex @code{customtime}, STARTUP keyword
7922 @example
7923 customtime @r{overlay custom time format}
7924 @end example
7925 The following options influence the table spreadsheet (variable
7926 @code{constants-unit-system}).
7927 @cindex @code{constcgs}, STARTUP keyword
7928 @cindex @code{constSI}, STARTUP keyword
7929 @example
7930 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
7931 constSI    @r{@file{constants.el} should use the SI unit system}
7932 @end example
7933 @item #+TAGS:  TAG1(c1) TAG2(c2)
7934 These lines (several such lines are allowed) specify the valid tags in
7935 this file, and (potentially) the corresponding @emph{fast tag selection}
7936 keys.  The corresponding variable is @code{org-tag-alist}.
7937 @item #+TBLFM:
7938 This line contains the formulas for the table directly above the line.
7939 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+OPTIONS, #+DATE:
7940 These lines provide settings for exporting files.  For more details see
7941 @ref{Export options}.
7942 @item #+SEQ_TODO:   #+TYP_TODO:
7943 These lines set the TODO keywords and their interpretation in the
7944 current file.  The corresponding variables are @code{org-todo-keywords}
7945 and @code{org-todo-interpretation}.
7946 @end table
7948 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
7949 @section The very busy C-c C-c key
7950 @kindex C-c C-c
7951 @cindex C-c C-c, overview
7953 The key @kbd{C-c C-c} has many purposes in Org, which are all
7954 mentioned scattered throughout this manual.  One specific function of
7955 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
7956 other circumstances it means something like @emph{Hey Org, look
7957 here and update according to what you see here}.  Here is a summary of
7958 what this means in different contexts.
7960 @itemize @minus
7961 @item
7962 If there are highlights in the buffer from the creation of a sparse
7963 tree, or from clock display, remove these highlights.
7964 @item
7965 If the cursor is in one of the special @code{#+KEYWORD} lines, this
7966 triggers scanning the buffer for these lines and updating the
7967 information.
7968 @item
7969 If the cursor is inside a table, realign the table.  This command
7970 works even if the automatic table editor has been turned off.
7971 @item
7972 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
7973 the entire table.
7974 @item
7975 If the cursor is inside a table created by the @file{table.el} package,
7976 activate that table.
7977 @item
7978 If the current buffer is a remember buffer, close the note and file it.
7979 With a prefix argument, file it, without further interaction, to the
7980 default location.
7981 @item
7982 If the cursor is on a @code{<<<target>>>}, update radio targets and
7983 corresponding links in this buffer.
7984 @item
7985 If the cursor is in a property line or at the start or end of a property
7986 drawer, offer property commands.
7987 @item
7988 If the cursor is in a plain list item with a checkbox, toggle the status
7989 of the checkbox.
7990 @item
7991 If the cursor is on a numbered item in a plain list, renumber the
7992 ordered list.
7993 @item
7994 If the cursor is on the @code{#+BEGIN} line of a dynamical block, the
7995 block is updated.
7996 @end itemize
7998 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
7999 @section A cleaner outline view
8000 @cindex hiding leading stars
8001 @cindex clean outline view
8003 Some people find it noisy and distracting that the Org headlines
8004 are starting with a potentially large number of stars.  For example
8005 the tree from @ref{Headlines}:
8007 @example
8008 * Top level headline
8009 ** Second level
8010 *** 3rd level
8011     some text
8012 *** 3rd level
8013     more text
8014 * Another top level headline
8015 @end example
8017 @noindent
8018 Unfortunately this is deeply ingrained into the code of Org and
8019 cannot be easily changed.  You can, however, modify the display in such
8020 a way that all leading stars become invisible and the outline more easy
8021 to read.  To do this, customize the variable
8022 @code{org-hide-leading-stars} like this:
8024 @lisp
8025 (setq org-hide-leading-stars t)
8026 @end lisp
8028 @noindent
8029 or change this on a per-file basis with one of the lines (anywhere in
8030 the buffer)
8032 @example
8033 #+STARTUP: showstars
8034 #+STARTUP: hidestars
8035 @end example
8037 @noindent
8038 Press @kbd{C-c C-c} with the cursor in a @samp{STARTUP} line to activate
8039 the modifications.
8041 With stars hidden, the tree becomes:
8043 @example
8044 * Top level headline
8045  * Second level
8046   * 3rd level
8047     some text
8048   * 3rd level
8049     more text
8050 * Another top level headline
8051 @end example
8053 @noindent
8054 Note that the leading stars are not truly replaced by whitespace, they
8055 are only fontified with the face @code{org-hide} that uses the
8056 background color as font color.  If you are not using either white or
8057 black background, you may have to customize this face to get the wanted
8058 effect.  Another possibility is to set this font such that the extra
8059 stars are @i{almost} invisible, for example using the color
8060 @code{grey90} on a white background.
8062 Things become cleaner still if you skip all the even levels and use only
8063 odd levels 1, 3, 5..., effectively adding two stars to go from one
8064 outline level to the next:
8066 @example
8067 * Top level headline
8068   * Second level
8069     * 3rd level
8070       some text
8071     * 3rd level
8072       more text
8073 * Another top level headline
8074 @end example
8076 @noindent
8077 In order to make the structure editing and export commands handle this
8078 convention correctly, use
8080 @lisp
8081 (setq org-odd-levels-only t)
8082 @end lisp
8084 @noindent
8085 or set this on a per-file basis with one of the following lines (don't
8086 forget to press @kbd{C-c C-c} with the cursor in the startup line to
8087 activate changes immediately).
8089 @example
8090 #+STARTUP: odd
8091 #+STARTUP: oddeven
8092 @end example
8094 You can convert an Org file from single-star-per-level to the
8095 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
8096 RET} in that file.  The reverse operation is @kbd{M-x
8097 org-convert-to-oddeven-levels}.
8099 @node TTY keys, Interaction, Clean view, Miscellaneous
8100 @section Using Org on a tty
8101 @cindex tty key bindings
8103 Because Org contains a large number of commands, by default much of
8104 Org's core commands are bound to keys that are generally not
8105 accessible on a tty, such as the cursor keys (@key{left}, @key{right},
8106 @key{up}, @key{down}), @key{TAB} and @key{RET}, in particular when used
8107 together with modifiers like @key{Meta} and/or @key{Shift}.  To access
8108 these commands on a tty when special keys are unavailable, the following
8109 alternative bindings can be used.  The tty bindings below will likely be
8110 more cumbersome; you may find for some of the bindings below that a
8111 customized work-around suits you better.  For example, changing a time
8112 stamp is really only fun with @kbd{S-@key{cursor}} keys, whereas on a
8113 tty you would rather use @kbd{C-c .} to re-insert the timestamp.
8115 @multitable @columnfractions 0.15 0.2 0.2
8116 @item @b{Default} @tab @b{Alternative 1} @tab @b{Alternative 2}
8117 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab
8118 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{@key{Esc} @key{left}}
8119 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab
8120 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{@key{Esc} @key{right}}
8121 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab
8122 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{@key{Esc} @key{up}}
8123 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab
8124 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{@key{Esc} @key{down}}
8125 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab
8126 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab
8127 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{@key{Esc} @key{RET}}
8128 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab
8129 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab
8130 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab
8131 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab
8132 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab
8133 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab
8134 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab
8135 @end multitable
8137 @node Interaction, Bugs, TTY keys, Miscellaneous
8138 @section Interaction with other packages
8139 @cindex packages, interaction with other
8140 Org lives in the world of GNU Emacs and interacts in various ways
8141 with other code out there.
8143 @menu
8144 * Cooperation::                 Packages Org cooperates with
8145 * Conflicts::                   Packages that lead to conflicts
8146 @end menu
8148 @node Cooperation, Conflicts, Interaction, Interaction
8149 @subsection Packages that Org cooperates with
8151 @table @asis
8152 @cindex @file{calc.el}
8153 @item @file{calc.el} by Dave Gillespie
8154 Org uses the Calc package for implementing spreadsheet
8155 functionality in its tables (@pxref{The spreadsheet}).  Org
8156 checks for the availability of Calc by looking for the function
8157 @code{calc-eval} which should be autoloaded in your setup if Calc has
8158 been installed properly.  As of Emacs 22, Calc is part of the Emacs
8159 distribution.  Another possibility for interaction between the two
8160 packages is using Calc for embedded calculations. @xref{Embedded Mode,
8161 , Embedded Mode, Calc, GNU Emacs Calc Manual}.
8162 @cindex @file{constants.el}
8163 @item @file{constants.el} by Carsten Dominik
8164 In a table formula (@pxref{The spreadsheet}), it is possible to use
8165 names for natural constants or units.  Instead of defining your own
8166 constants in the variable @code{org-table-formula-constants}, install
8167 the @file{constants} package which defines a large number of constants
8168 and units, and lets you use unit prefixes like @samp{M} for
8169 @samp{Mega} etc.  You will need version 2.0 of this package, available
8170 at @url{http://www.astro.uva.nl/~dominik/Tools}. Org checks for
8171 the function @code{constants-get}, which has to be autoloaded in your
8172 setup.  See the installation instructions in the file
8173 @file{constants.el}.
8174 @item @file{cdlatex.el} by Carsten Dominik
8175 @cindex @file{cdlatex.el}
8176 Org mode can make use of the CDLaTeX package to efficiently enter
8177 La@TeX{} fragments into Org files. See @ref{CDLaTeX mode}.
8178 @item @file{imenu.el} by Ake Stenhoff and Lars Lindberg
8179 @cindex @file{imenu.el}
8180 Imenu allows menu access to an index of items in a file.  Org mode
8181 supports Imenu - all you need to do to get the index is the following:
8182 @lisp
8183 (add-hook 'org-mode-hook
8184           (lambda () (imenu-add-to-menubar "Imenu")))
8185 @end lisp
8186 By default the index is two levels deep - you can modify the depth using
8187 the option @code{org-imenu-depth}.
8188 @item @file{remember.el} by John Wiegley
8189 @cindex @file{remember.el}
8190 Org cooperates with remember, see @ref{Remember}.
8191 @file{Remember.el} is not part of Emacs, find it on the web.
8192 @item @file{speedbar.el} by Eric M. Ludlam
8193 @cindex @file{speedbar.el}
8194 Speedbar is a package that creates a special frame displaying files and
8195 index items in files.  Org mode supports Speedbar and allows you to
8196 drill into Org files directly from the Speedbar.  It also allows to
8197 restrict the scope of agenda commands to a file or a subtree by using
8198 the command @kbd{<} in the Speedbar frame.
8199 @cindex @file{table.el}
8200 @item @file{table.el} by Takaaki Ota
8201 @kindex C-c C-c
8202 @cindex table editor, @file{table.el}
8203 @cindex @file{table.el}
8205 Complex ASCII tables with automatic line wrapping, column- and
8206 row-spanning, and alignment can be created using the Emacs table
8207 package by Takaaki Ota (@uref{http://sourceforge.net/projects/table},
8208 and also part of Emacs 22).
8209 When @key{TAB} or @kbd{C-c C-c} is pressed in such a table, Org mode
8210 will call @command{table-recognize-table} and move the cursor into the
8211 table.  Inside a table, the keymap of Org mode is inactive.  In order
8212 to execute Org mode-related commands, leave the table.
8214 @table @kbd
8215 @kindex C-c C-c
8216 @item C-c C-c
8217 Recognize @file{table.el} table.  Works when the cursor is in a
8218 table.el table.
8220 @kindex C-c ~
8221 @item C-c ~
8222 Insert a table.el table.  If there is already a table at point, this
8223 command converts it between the table.el format and the Org mode
8224 format.  See the documentation string of the command
8225 @code{org-convert-table} for the restrictions under which this is
8226 possible.
8227 @end table
8228 @file{table.el} is part of Emacs 22.
8229 @cindex @file{footnote.el}
8230 @item @file{footnote.el} by Steven L. Baur
8231 Org mode recognizes numerical footnotes as provided by this package
8232 (@pxref{Footnotes}).
8233 @end table
8235 @node Conflicts,  , Cooperation, Interaction
8236 @subsection Packages that lead to conflicts with Org mode
8238 @table @asis
8240 @cindex @file{allout.el}
8241 @item @file{allout.el} by Ken Manheimer
8242 Startup of Org may fail with the error message
8243 @code{(wrong-type-argument keymapp nil)} when there is an outdated
8244 version @file{allout.el} on the load path, for example the version
8245 distributed with Emacs 21.x.  Upgrade to Emacs 22 and this problem will
8246 disappear.  If for some reason you cannot do this, make sure that org.el
8247 is loaded @emph{before} @file{allout.el}, for example by putting
8248 @code{(require 'org)} early enough into your @file{.emacs} file.
8250 @cindex @file{CUA.el}
8251 @item @file{CUA.el} by Kim. F. Storm
8252 Key bindings in Org conflict with the @kbd{S-<cursor>} keys used by
8253 CUA mode (as well as pc-select-mode and s-region-mode) to select and
8254 extend the region.  If you want to use one of these packages along with
8255 Org, configure the variable @code{org-replace-disputed-keys}.  When
8256 set, Org will move the following key bindings in Org files, and
8257 in the agenda buffer (but not during date selection).
8259 @example
8260 S-UP    -> M-p             S-DOWN  -> M-n
8261 S-LEFT  -> M--             S-RIGHT -> M-+
8262 @end example
8264 Yes, these are unfortunately more difficult to remember.  If you want
8265 to have other replacement keys, look at the variable
8266 @code{org-disputed-keys}.
8267 @item @file{windmove.el} by Hovav Shacham
8268 @cindex @file{windmove.el}
8269 Also this package uses the @kbd{S-<cursor>} keys, so everything written
8270 in the paragraph above about CUA mode also applies here.
8272 @cindex @file{footnote.el}
8273 @item @file{footnote.el} by Steven L. Baur
8274 Org supports the syntax of the footnote package, but only the
8275 numerical footnote markers.  Also, the default key for footnote
8276 commands, @kbd{C-c !} is already used by Org.  You could use the
8277 variable @code{footnote-prefix} to switch footnotes commands to another
8278 key.  Or, you could use @code{org-replace-disputed-keys} and
8279 @code{org-disputed-keys} to change the settings in Org.
8281 @end table
8284 @node Bugs,  , Interaction, Miscellaneous
8285 @section Bugs
8286 @cindex bugs
8288 Here is a list of things that should work differently, but which I
8289 have found too hard to fix.
8291 @itemize @bullet
8292 @item
8293 If a table field starts with a link, and if the corresponding table
8294 column is narrowed (@pxref{Narrow columns}) to a width too small to
8295 display the link, the field would look entirely empty even though it is
8296 not.  To prevent this, Org throws an error.  The work-around is to
8297 make the column wide enough to fit the link, or to add some text (at
8298 least 2 characters) before the link in the same field.
8299 @item
8300 Narrowing table columns does not work on XEmacs, because the
8301 @code{format} function does not transport text properties.
8302 @item
8303 Text in an entry protected with the @samp{QUOTE} keyword should not
8304 autowrap.
8305 @item
8306 When the application called by @kbd{C-c C-o} to open a file link fails
8307 (for example because the application does not exist or refuses to open
8308 the file), it does so silently.  No error message is displayed.
8309 @item
8310 Recalculating a table line applies the formulas from left to right.
8311 If a formula uses @emph{calculated} fields further down the row,
8312 multiple recalculation may be needed to get all fields consistent.  You
8313 may use the command @code{org-table-iterate} (@kbd{C-u C-c *}) to
8314 recalculate until convergence.
8315 @item
8316 A single letter cannot be made bold, for example @samp{*a*}.
8317 @item
8318 The exporters work well, but could be made more efficient.
8319 @end itemize
8322 @node Extensions and Hacking, History and Acknowledgments, Miscellaneous, Top
8323 @appendix Extensions, Hooks and Hacking
8325 This appendix lists extensions for Org written by other authors.
8326 It also covers some aspects where users can extend the functionality of
8327 Org.
8329 @menu
8330 * Extensions::                  Existing 3rd-party extensions
8331 * Adding hyperlink types::      New custom link types
8332 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
8333 * Dynamic blocks::              Automatically filled blocks
8334 * Special agenda views::        Customized views
8335 * Using the property API::      Writing programs that use entry properties
8336 @end menu
8338 @node Extensions, Adding hyperlink types, Extensions and Hacking, Extensions and Hacking
8339 @section Third-party extensions for Org
8340 @cindex extension, third-party
8342 There are lots of extensions that have been written by other people.  Most of
8343 them have either been integrated into Org by now, or they can be found in the
8344 Org distribution, in the @file{contrib} directory.  The list has gotten too
8345 long to cover in any detail here, but there is a seaparate manual for these
8346 extensions.
8348 @node Adding hyperlink types, Tables in arbitrary syntax, Extensions, Extensions and Hacking
8349 @section Adding hyperlink types
8350 @cindex hyperlinks, adding new types
8352 Org has a large number of hyperlink types built-in
8353 (@pxref{Hyperlinks}).  If you would like to add new link types, it
8354 provides an interface for doing so.  Lets look at an example file
8355 @file{org-man.el} that will add support for creating links like
8356 @samp{[[man:printf][The printf manpage]]} to show Unix manual pages inside
8357 emacs:
8359 @lisp
8360 ;;; org-man.el - Support for links to manpages in Org
8362 (require 'org)
8364 (org-add-link-type "man" 'org-man-open)
8365 (add-hook 'org-store-link-functions 'org-man-store-link)
8367 (defcustom org-man-command 'man
8368   "The Emacs command to be used to display a man page."
8369   :group 'org-link
8370   :type '(choice (const man) (const woman)))
8372 (defun org-man-open (path)
8373   "Visit the manpage on PATH.
8374 PATH should be a topic that can be thrown at the man command."
8375   (funcall org-man-command path))
8377 (defun org-man-store-link ()
8378   "Store a link to a manpage."
8379   (when (memq major-mode '(Man-mode woman-mode))
8380     ;; This is a man page, we do make this link
8381     (let* ((page (org-man-get-page-name))
8382            (link (concat "man:" page))
8383            (description (format "Manpage for %s" page)))
8384       (org-store-link-props
8385        :type "man"
8386        :link link
8387        :description description))))
8389 (defun org-man-get-page-name ()
8390   "Extract the page name from the buffer name."
8391   ;; This works for both `Man-mode' and `woman-mode'.
8392   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
8393       (match-string 1 (buffer-name))
8394     (error "Cannot create link to this man page")))
8396 (provide 'org-man)
8398 ;;; org-man.el ends here
8399 @end lisp
8401 @noindent
8402 You would activate this new link type in @file{.emacs} with
8404 @lisp
8405 (require 'org-man)
8406 @end lisp
8408 @noindent
8409 Lets go through the file and see what it does.
8410 @enumerate
8411 @item
8412 It does @code{(require 'org)} to make sure that @file{org.el} has been
8413 loaded.
8414 @item
8415 The next line calls @code{org-add-link-type} to define a new link type
8416 with prefix @samp{man}.  The call also contains the name of a function
8417 that will be called to follow such a link.
8418 @item
8419 The next line adds a function to @code{org-store-link-functions}, in
8420 order to allow the command @kbd{C-c l} to record a useful link in a
8421 buffer displaying a man page.
8422 @end enumerate
8424 The rest of the file defines the necessary variables and functions.
8425 First there is a customization variable that determines which emacs
8426 command should be used to display man pages.  There are two options,
8427 @code{man} and @code{woman}.  Then the function to follow a link is
8428 defined.  It gets the link path as an argument - in this case the link
8429 path is just a topic for the manual command.  The function calls the
8430 value of @code{org-man-command} to display the man page.
8432 Finally the function @code{org-man-store-link} is defined.  When you try
8433 to store a link with @kbd{C-c l}, also this function will be called to
8434 try to make a link.  The function must first decide if it is supposed to
8435 create the link for this buffer type, we do this by checking the value
8436 of the variable @code{major-mode}.  If not, the function must exit and
8437 return the value @code{nil}.  If yes, the link is created by getting the
8438 manual topic from the buffer name and prefixing it with the string
8439 @samp{man:}.  Then it must call the command @code{org-store-link-props}
8440 and set the @code{:type} and @code{:link} properties.  Optionally you
8441 can also set the @code{:description} property to provide a default for
8442 the link description when the link is later inserted into an Org
8443 buffer with @kbd{C-c C-l}.
8445 @node Tables in arbitrary syntax, Dynamic blocks, Adding hyperlink types, Extensions and Hacking
8446 @section Tables and lists in arbitrary syntax
8447 @cindex tables, in other modes
8448 @cindex lists, in other modes
8449 @cindex Orgtbl mode
8451 Since Orgtbl mode can be used as a minor mode in arbitrary buffers, a
8452 frequent feature request has been to make it work with native tables in
8453 specific languages, for example La@TeX{}.  However, this is extremely
8454 hard to do in a general way, would lead to a customization nightmare,
8455 and would take away much of the simplicity of the Orgtbl mode table
8456 editor.
8459 This appendix describes a different approach.  We keep the Orgtbl mode
8460 table in its native format (the @i{source table}), and use a custom
8461 function to @i{translate} the table to the correct syntax, and to
8462 @i{install} it in the right location (the @i{target table}).  This puts
8463 the burden of writing conversion functions on the user, but it allows
8464 for a very flexible system.
8466 Bastien added the ability to do the same with lists.  You can use Org's
8467 facilities to edit and structure lists by turning @code{orgstruct-mode}
8468 on, then locally exporting such lists in another format (HTML, La@TeX{}
8469 or Texinfo.)
8472 @menu
8473 * Radio tables::                Sending and receiving
8474 * A LaTeX example::             Step by step, almost a tutorial
8475 * Translator functions::        Copy and modify
8476 * Radio lists::                 Doing the same for lists
8477 @end menu
8479 @node Radio tables, A LaTeX example, Tables in arbitrary syntax, Tables in arbitrary syntax
8480 @subsection Radio tables
8481 @cindex radio tables
8483 To define the location of the target table, you first need to create two
8484 lines that are comments in the current mode, but contain magic words for
8485 Orgtbl mode to find.  Orgtbl mode will insert the translated table
8486 between these lines, replacing whatever was there before.  For example:
8488 @example
8489 /* BEGIN RECEIVE ORGTBL table_name */
8490 /* END RECEIVE ORGTBL table_name */
8491 @end example
8493 @noindent
8494 Just above the source table, we put a special line that tells
8495 Orgtbl mode how to translate this table and where to install it.  For
8496 example:
8497 @example
8498 #+ORGTBL: SEND table_name translation_function arguments....
8499 @end example
8501 @noindent
8502 @code{table_name} is the reference name for the table that is also used
8503 in the receiver lines. @code{translation_function} is the Lisp function
8504 that does the translation.  Furthermore, the line can contain a list of
8505 arguments (alternating key and value) at the end.  The arguments will be
8506 passed as a property list to the translation function for
8507 interpretation.  A few standard parameters are already recognized and
8508 acted upon before the translation function is called:
8510 @table @code
8511 @item :skip N
8512 Skip the first N lines of the table. Hlines do count!
8513 @item :skipcols (n1 n2 ...)
8514 List of columns that should be skipped.  If the table has a column with
8515 calculation marks, that column is automatically discarded as well.
8516 Please note that the translator function sees the table @emph{after} the
8517 removal of these columns, the function never knows that there have been
8518 additional columns.
8519 @end table
8521 @noindent
8522 The one problem remaining is how to keep the source table in the buffer
8523 without disturbing the normal workings of the file, for example during
8524 compilation of a C file or processing of a La@TeX{} file.  There are a
8525 number of different solutions:
8527 @itemize @bullet
8528 @item
8529 The table could be placed in a block comment if that is supported by the
8530 language.  For example, in C mode you could wrap the table between
8531 @samp{/*} and @samp{*/} lines.
8532 @item
8533 Sometimes it is possible to put the table after some kind of @i{END}
8534 statement, for example @samp{\bye} in TeX and @samp{\end@{document@}}
8535 in La@TeX{}.
8536 @item
8537 You can just comment the table line by line whenever you want to process
8538 the file, and uncomment it whenever you need to edit the table.  This
8539 only sounds tedious - the command @kbd{M-x orgtbl-toggle-comment} does
8540 make this comment-toggling very easy, in particular if you bind it to a
8541 key.
8542 @end itemize
8544 @node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
8545 @subsection A LaTeX example of radio tables
8546 @cindex LaTeX, and Orgtbl mode
8548 The best way to wrap the source table in La@TeX{} is to use the
8549 @code{comment} environment provided by @file{comment.sty}.  It has to be
8550 activated by placing @code{\usepackage@{comment@}} into the document
8551 header.  Orgtbl mode can insert a radio table skeleton@footnote{By
8552 default this works only for La@TeX{}, HTML, and Texinfo.  Configure the
8553 variable @code{orgtbl-radio-tables} to install templates for other
8554 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
8555 be prompted for a table name, lets say we use @samp{salesfigures}.  You
8556 will then get the following template:
8558 @example
8559 % BEGIN RECEIVE ORGTBL salesfigures
8560 % END RECEIVE ORGTBL salesfigures
8561 \begin@{comment@}
8562 #+ORGTBL: SEND salesfigures orgtbl-to-latex
8563 | | |
8564 \end@{comment@}
8565 @end example
8567 @noindent
8568 The @code{#+ORGTBL: SEND} line tells Orgtbl mode to use the function
8569 @code{orgtbl-to-latex} to convert the table into La@TeX{} and to put it
8570 into the receiver location with name @code{salesfigures}.  You may now
8571 fill in the table, feel free to use the spreadsheet features@footnote{If
8572 the @samp{#+TBLFM} line contains an odd number of dollar characters,
8573 this may cause problems with font-lock in LaTeX mode.  As shown in the
8574 example you can fix this by adding an extra line inside the
8575 @code{comment} environment that is used to balance the dollar
8576 expressions.  If you are using AUCTeX with the font-latex library, a
8577 much better solution is to add the @code{comment} environment to the
8578 variable @code{LaTeX-verbatim-environments}.}:
8580 @example
8581 % BEGIN RECEIVE ORGTBL salesfigures
8582 % END RECEIVE ORGTBL salesfigures
8583 \begin@{comment@}
8584 #+ORGTBL: SEND salesfigures orgtbl-to-latex
8585 | Month | Days | Nr sold | per day |
8586 |-------+------+---------+---------|
8587 | Jan   |   23 |      55 |     2.4 |
8588 | Feb   |   21 |      16 |     0.8 |
8589 | March |   22 |     278 |    12.6 |
8590 #+TBLFM: $4=$3/$2;%.1f
8591 % $ (optional extra dollar to keep font-lock happy, see footnote)
8592 \end@{comment@}
8593 @end example
8595 @noindent
8596 When you are done, press @kbd{C-c C-c} in the table to get the converted
8597 table inserted between the two marker lines.
8599 Now lets assume you want to make the table header by hand, because you
8600 want to control how columns are aligned etc.  In this case we make sure
8601 that the table translator does skip the first 2 lines of the source
8602 table, and tell the command to work as a @i{splice}, i.e. to not produce
8603 header and footer commands of the target table:
8605 @example
8606 \begin@{tabular@}@{lrrr@}
8607 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
8608 % BEGIN RECEIVE ORGTBL salesfigures
8609 % END RECEIVE ORGTBL salesfigures
8610 \end@{tabular@}
8612 \begin@{comment@}
8613 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
8614 | Month | Days | Nr sold | per day |
8615 |-------+------+---------+---------|
8616 | Jan   |   23 |      55 |     2.4 |
8617 | Feb   |   21 |      16 |     0.8 |
8618 | March |   22 |     278 |    12.6 |
8619 #+TBLFM: $4=$3/$2;%.1f
8620 \end@{comment@}
8621 @end example
8623 The La@TeX{} translator function @code{orgtbl-to-latex} is already part of
8624 Orgtbl mode.  It uses a @code{tabular} environment to typeset the table
8625 and marks horizontal lines with @code{\hline}.  Furthermore, it
8626 interprets the following parameters:
8628 @table @code
8629 @item :splice nil/t
8630 When set to t, return only table body lines, don't wrap them into a
8631 tabular environment.  Default is nil.
8633 @item :fmt fmt
8634 A format to be used to wrap each field, should contain @code{%s} for the
8635 original field value.  For example, to wrap each field value in dollars,
8636 you could use @code{:fmt "$%s$"}.  This may also be a property list with
8637 column numbers and formats. for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
8638 A function of one argument can be used in place of the strings; the
8639 function must return a formatted string.
8641 @item :efmt efmt
8642 Use this format to print numbers with exponentials.  The format should
8643 have @code{%s} twice for inserting mantissa and exponent, for example
8644 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
8645 may also be a property list with column numbers and formats, for example
8646 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
8647 @code{efmt} has been applied to a value, @code{fmt} will also be
8648 applied.  Similar to @code{fmt}, functions of two arguments can be
8649 supplied instead of strings.
8650 @end table
8652 @node Translator functions, Radio lists, A LaTeX example, Tables in arbitrary syntax
8653 @subsection Translator functions
8654 @cindex HTML, and Orgtbl mode
8655 @cindex translator function
8657 Orgtbl mode has several translator functions built-in:
8658 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and
8659 @code{orgtbl-to-texinfo}.  Except for @code{orgtbl-to-html}@footnote{The
8660 HTML translator uses the same code that produces tables during HTML
8661 export.}, these all use a generic translator, @code{orgtbl-to-generic}.
8662 For example, @code{orgtbl-to-latex} itself is a very short function that
8663 computes the column definitions for the @code{tabular} environment,
8664 defines a few field and line separators and then hands over to the
8665 generic translator.  Here is the entire code:
8667 @lisp
8668 @group
8669 (defun orgtbl-to-latex (table params)
8670   "Convert the Orgtbl mode TABLE to LaTeX."
8671   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
8672                                org-table-last-alignment ""))
8673          (params2
8674           (list
8675            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
8676            :tend "\\end@{tabular@}"
8677            :lstart "" :lend " \\\\" :sep " & "
8678            :efmt "%s\\,(%s)" :hline "\\hline")))
8679     (orgtbl-to-generic table (org-combine-plists params2 params))))
8680 @end group
8681 @end lisp
8683 As you can see, the properties passed into the function (variable
8684 @var{PARAMS}) are combined with the ones newly defined in the function
8685 (variable @var{PARAMS2}).  The ones passed into the function (i.e. the
8686 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
8687 would like to use the La@TeX{} translator, but wanted the line endings to
8688 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
8689 overrule the default with
8691 @example
8692 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
8693 @end example
8695 For a new language, you can either write your own converter function in
8696 analogy with the La@TeX{} translator, or you can use the generic function
8697 directly.  For example, if you have a language where a table is started
8698 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
8699 started with @samp{!BL!}, ended with @samp{!EL!} and where the field
8700 separator is a TAB, you could call the generic translator like this (on
8701 a single line!):
8703 @example
8704 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
8705                               :lstart "!BL! " :lend " !EL!" :sep "\t"
8706 @end example
8708 @noindent
8709 Please check the documentation string of the function
8710 @code{orgtbl-to-generic} for a full list of parameters understood by
8711 that function and remember that you can pass each of them into
8712 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
8713 using the generic function.
8715 Of course you can also write a completely new function doing complicated
8716 things the generic translator cannot do.  A translator function takes
8717 two arguments.  The first argument is the table, a list of lines, each
8718 line either the symbol @code{hline} or a list of fields.  The second
8719 argument is the property list containing all parameters specified in the
8720 @samp{#+ORGTBL: SEND} line.  The function must return a single string
8721 containing the formatted table.  If you write a generally useful
8722 translator, please post it on @code{emacs-orgmode@@gnu.org} so that
8723 others can benefit from your work.
8725 @node  Radio lists,  , Translator functions, Tables in arbitrary syntax
8726 @subsection Radio lists
8727 @cindex radio lists
8728 @cindex org-list-insert-radio-list
8730 Sending and receiving radio lists works exactly the same way than
8731 sending and receiving radio tables (@pxref{Radio tables}) @footnote{You
8732 need to load the @code{org-export-latex.el} package to use radio lists
8733 since the relevant code is there for now.}.  As for radio tables, you
8734 can insert radio lists templates in HTML, La@TeX{} and Texinfo modes by
8735 calling @code{org-list-insert-radio-list}.
8737 Here are the differences with radio tables:
8739 @itemize @minus
8740 @item
8741 Use @code{ORGLST} instead of @code{ORGTBL}.
8742 @item
8743 The available translation functions for radio lists don't take
8744 parameters.
8745 @item
8746 `C-c C-c' will work when pressed on the first item of the list.
8747 @end itemize
8749 Here is a La@TeX{} example.  Let's say that you have this in your
8750 La@TeX{} file:
8752 @example
8753 % BEGIN RECEIVE ORGLST to-buy
8754 % END RECEIVE ORGLST to-buy
8755 \begin@{comment@}
8756 #+ORGLIST: SEND to-buy orgtbl-to-latex
8757 - a new house
8758 - a new computer
8759   + a new keyboard
8760   + a new mouse
8761 - a new life
8762 \end@{comment@}
8763 @end example
8765 Pressing `C-c C-c' on @code{a new house} and will insert the converted
8766 La@TeX{} list between the two marker lines.
8768 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Extensions and Hacking
8769 @section Dynamic blocks
8770 @cindex dynamic blocks
8772 Org documents can contain @emph{dynamic blocks}.  These are
8773 specially marked regions that are updated by some user-written function.
8774 A good example for such a block is the clock table inserted by the
8775 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
8777 Dynamic block are enclosed by a BEGIN-END structure that assigns a name
8778 to the block and can also specify parameters for the function producing
8779 the content of the block.
8781 @example
8782 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
8784 #+END:
8785 @end example
8787 Dynamic blocks are updated with the following commands
8789 @table @kbd
8790 @kindex C-c C-x C-u
8791 @item C-c C-x C-u
8792 Update dynamic block at point.
8793 @kindex C-u C-c C-x C-u
8794 @item C-u C-c C-x C-u
8795 Update all dynamic blocks in the current file.
8796 @end table
8798 Updating a dynamic block means to remove all the text between BEGIN and
8799 END, parse the BEGIN line for parameters and then call the specific
8800 writer function for this block to insert the new content.  If you want
8801 to use the original content in the writer function, you can use the
8802 extra parameter @code{:content}.
8804 For a block with name @code{myblock}, the writer function is
8805 @code{org-dblock-write:myblock} with as only parameter a property list
8806 with the parameters given in the begin line.  Here is a trivial example
8807 of a block that keeps track of when the block update function was last
8808 run:
8810 @example
8811 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
8813 #+END:
8814 @end example
8816 @noindent
8817 The corresponding block writer function could look like this:
8819 @lisp
8820 (defun org-dblock-write:block-update-time (params)
8821    (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
8822      (insert "Last block update at: "
8823              (format-time-string fmt (current-time)))))
8824 @end lisp
8826 If you want to make sure that all dynamic blocks are always up-to-date,
8827 you could add the function @code{org-update-all-dblocks} to a hook, for
8828 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
8829 written in a way that is does nothing in buffers that are not in
8830 @code{org-mode}.
8832 @node Special agenda views, Using the property API, Dynamic blocks, Extensions and Hacking
8833 @section Special agenda views
8834 @cindex agenda views, user-defined
8836 Org provides a special hook that can be used to narrow down the
8837 selection made by any of the agenda views.  You may specify a function
8838 that is used at each match to verify if the match should indeed be part
8839 of the agenda view, and if not, how much should be skipped.
8841 Let's say you want to produce a list of projects that contain a WAITING
8842 tag anywhere in the project tree.  Let's further assume that you have
8843 marked all tree headings that define a project with the TODO keyword
8844 PROJECT.  In this case you would run a TODO search for the keyword
8845 PROJECT, but skip the match unless there is a WAITING tag anywhere in
8846 the subtree belonging to the project line.
8848 To achieve this, you must write a function that searches the subtree for
8849 the tag.  If the tag is found, the function must return @code{nil} to
8850 indicate that this match should not be skipped.  If there is no such
8851 tag, return the location of the end of the subtree, to indicate that
8852 search should continue from there.
8854 @lisp
8855 (defun my-skip-unless-waiting ()
8856   "Skip trees that are not waiting"
8857   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
8858     (if (re-search-forward ":waiting:" subtree-end t)
8859         nil          ; tag found, do not skip
8860       subtree-end))) ; tag not found, continue after end of subtree
8861 @end lisp
8863 Now you may use this function in an agenda custom command, for example
8864 like this:
8866 @lisp
8867 (org-add-agenda-custom-command
8868  '("b" todo "PROJECT"
8869    ((org-agenda-skip-function 'my-org-waiting-projects)
8870     (org-agenda-overriding-header "Projects waiting for something: "))))
8871 @end lisp
8873 Note that this also binds @code{org-agenda-overriding-header} to get a
8874 meaningful header in the agenda view.
8876 A general way to create custom searches is to base them on a search for
8877 entries with a certain level limit.  If you want to study all entries with
8878 your custom search function, simply do a search for @samp{LEVEL>0}, and then
8879 use @code{org-agenda-skip-function} to select the entries you really want to
8880 have.
8882 You may also put a Lisp form into @code{org-agenda-skip-function}.  In
8883 particular, you may use the functions @code{org-agenda-skip-entry-if}
8884 and @code{org-agenda-skip-subtree-if} in this form, for example:
8886 @table @code
8887 @item '(org-agenda-skip-entry-if 'scheduled)
8888 Skip current entry if it has been scheduled.
8889 @item '(org-agenda-skip-entry-if 'notscheduled)
8890 Skip current entry if it has not been scheduled.
8891 @item '(org-agenda-skip-entry-if 'deadline)
8892 Skip current entry if it has a deadline.
8893 @item '(org-agenda-skip-entry-if 'scheduled 'deadline)
8894 Skip current entry if it has a deadline, or if it is scheduled.
8895 @item '(org-agenda-skip-entry 'regexp "regular expression")
8896 Skip current entry if the regular expression matches in the entry.
8897 @item '(org-agenda-skip-entry 'notregexp "regular expression")
8898 Skip current entry unless the regular expression matches.
8899 @item '(org-agenda-skip-subtree-if 'regexp "regular expression")
8900 Same as above, but check and skip the entire subtree.
8901 @end table
8903 Therefore we could also have written the search for WAITING projects
8904 like this, even without defining a special function:
8906 @lisp
8907 (org-add-agenda-custom-command
8908  '("b" todo "PROJECT"
8909    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
8910                                 'regexp ":waiting:"))
8911     (org-agenda-overriding-header "Projects waiting for something: "))))
8912 @end lisp
8914 @node Using the property API,  , Special agenda views, Extensions and Hacking
8915 @section Using the property API
8916 @cindex API, for properties
8917 @cindex properties, API
8919 Here is a description of the functions that can be used to work with
8920 properties.
8922 @defun org-entry-properties &optional pom which
8923 Get all properties of the entry at point-or-marker POM.
8924 This includes the TODO keyword, the tags, time strings for deadline,
8925 scheduled, and clocking, and any additional properties defined in the
8926 entry.  The return value is an alist, keys may occur multiple times
8927 if the property key was used several times.
8928 POM may also be nil, in which case the current entry is used.
8929 If WHICH is nil or `all', get all properties.  If WHICH is
8930 `special' or `standard', only get that subclass.
8931 @end defun
8932 @defun org-entry-get pom property &optional inherit
8933 Get value of PROPERTY for entry at point-or-marker POM.  By default,
8934 this only looks at properties defined locally in the entry.  If INHERIT
8935 is non-nil and the entry does not have the property, then also check
8936 higher levels of the hierarchy.  If INHERIT is the symbol
8937 @code{selective}, use inheritance if and only if the setting of
8938 @code{org-use-property-inheritance} selects PROPERTY for inheritance.
8939 @end defun
8941 @defun org-entry-delete pom property
8942 Delete the property PROPERTY from entry at point-or-marker POM.
8943 @end defun
8945 @defun org-entry-put pom property value
8946 Set PROPERTY to VALUE for entry at point-or-marker POM.
8947 @end defun
8949 @defun org-buffer-property-keys &optional include-specials
8950 Get all property keys in the current buffer.
8951 @end defun
8953 @defun org-insert-property-drawer
8954 Insert a property drawer at point.
8955 @end defun
8957 @defun org-entry-add-to-multivalued-property pom property value
8958 Treat the value of the property PROPERTY as a whitespace-separated list of
8959 values and make sure that VALUE is in this list.
8960 @end defun
8962 @defun org-entry-remove-from-multivalued-property pom property value
8963 Treat the value of the property PROPERTY as a whitespace-separated list of
8964 values and make sure that VALUE is @emph{not} in this list.
8965 @end defun
8967 @defun org-entry-member-in-multivalued-property pom property value
8968 Treat the value of the property PROPERTY as a whitespace-separated list of
8969 values and check if VALUE is in this list.
8970 @end defun
8972 @node History and Acknowledgments, Main Index, Extensions and Hacking, Top
8973 @appendix History and Acknowledgments
8974 @cindex acknowledgments
8975 @cindex history
8976 @cindex thanks
8978 Org was borne in 2003, out of frustration over the user interface
8979 of the Emacs Outline mode.  I was trying to organize my notes and
8980 projects, and using Emacs seemed to be the natural way to go.  However,
8981 having to remember eleven different commands with two or three keys per
8982 command, only to hide and show parts of the outline tree, that seemed
8983 entirely unacceptable to me.  Also, when using outlines to take notes, I
8984 constantly want to restructure the tree, organizing it parallel to my
8985 thoughts and plans.  @emph{Visibility cycling} and @emph{structure
8986 editing} were originally implemented in the package
8987 @file{outline-magic.el}, but quickly moved to the more general
8988 @file{org.el}.  As this environment became comfortable for project
8989 planning, the next step was adding @emph{TODO entries}, basic @emph{time
8990 stamps}, and @emph{table support}.  These areas highlight the two main
8991 goals that Org still has today: To create a new, outline-based,
8992 plain text mode with innovative and intuitive editing features, and to
8993 incorporate project planning functionality directly into a notes file.
8995 A special thanks goes to @i{Bastien Guerry} who has not only writen a large
8996 number of extensions to Org (most of them integrated into the core by now),
8997 but has also helped the development and maintenance of Org so much that he
8998 should be considered co-author of this package.
9000 Since the first release, literally thousands of emails to me or on
9001 @code{emacs-orgmode@@gnu.org} have provided a constant stream of bug
9002 reports, feedback, new ideas, and sometimes patches and add-on code.
9003 Many thanks to everyone who has helped to improve this package.  I am
9004 trying to keep here a list of the people who had significant influence
9005 in shaping one or more aspects of Org.  The list may not be
9006 complete, if I have forgotten someone, please accept my apologies and
9007 let me know.
9009 @itemize @bullet
9011 @item
9012 @i{Russel Adams} came up with the idea for drawers.
9013 @item
9014 @i{Thomas Baumann} wrote @file{org-bbdb.el} and @file{org-mhe.el}.
9015 @item
9016 @i{Alex Bochannek} provided a patch for rounding time stamps.
9017 @item
9018 @i{Charles Cave}'s suggestion sparked the implementation of templates
9019 for Remember.
9020 @item
9021 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
9022 specified time.
9023 @item
9024 @i{Gregory Chernov} patched support for lisp forms into table
9025 calculations and improved XEmacs compatibility, in particular by porting
9026 @file{nouline.el} to XEmacs.
9027 @item
9028 @i{Sacha Chua} suggested to copy some linking code from Planner.
9029 @item
9030 @i{Eddward DeVilla} proposed and tested checkbox statistics.  He also
9031 came up with the idea of properties, and that there should be an API for
9032 them.
9033 @item
9034 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
9035 inspired some of the early development, including HTML export.  He also
9036 asked for a way to narrow wide table columns.
9037 @item
9038 @i{Christian Egli} converted the documentation into Texinfo format,
9039 patched CSS formatting into the HTML exporter, and inspired the agenda.
9040 @item
9041 @i{David Emery} provided a patch for custom CSS support in exported
9042 HTML agendas.
9043 @item
9044 @i{Nic Ferrier} contributed mailcap and XOXO support.
9045 @item
9046 @i{Miguel A. Figueroa-Villanueva} implemented hierarchical checkboxes.
9047 @item
9048 @i{John Foerch} figured out how to make incremental search show context
9049 around a match in a hidden outline tree.
9050 @item
9051 @i{Niels Giesen} had the idea to automatically archive DONE trees.
9052 @item
9053 @i{Bastien Guerry} wrote the La@TeX{} exporter and @file{org-bibtex.el}, and
9054 has been prolific with patches, ideas, and bug reports.
9055 @item
9056 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
9057 @item
9058 @i{Bernt Hansen} has driven much of the support for auto-repeating tasks,
9059 task state change logging, and the clocktable.  His clear explanations have
9060 been critical when we started to adopt the GIT version control system.
9061 @item
9062 @i{Phil Jackson} wrote @file{org-irc.el}.
9063 @item
9064 @i{Scott Jaderholm} proposed footnotes, control over whitespace between
9065 folded entries, and column view for properties.
9066 @item
9067 @i{Tokuya Kameshima} wrote @file{org-wl.el} and @file{org-mew.el}.
9068 @item
9069 @i{Shidai Liu} ("Leo") asked for embedded La@TeX{} and tested it.  He also
9070 provided frequent feedback and some patches.
9071 @item
9072 @i{Jason F. McBrayer} suggested agenda export to CSV format.
9073 @item
9074 @i{Max Mikhanosha} came up with the idea of refiling.
9075 @item
9076 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
9077 basis.
9078 @item
9079 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
9080 happy.
9081 @item
9082 @i{Rick Moynihan} proposed to allow multiple TODO sequences in a file
9083 and to be able to quickly restrict the agenda to a subtree.
9084 @item
9085 @i{Todd Neal} provided patches for links to Info files and elisp forms.
9086 @item
9087 @i{Tim O'Callaghan} suggested in-file links, search options for general
9088 file links, and TAGS.
9089 @item
9090 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
9091 into Japanese.
9092 @item
9093 @i{Oliver Oppitz} suggested multi-state TODO items.
9094 @item
9095 @i{Scott Otterson} sparked the introduction of descriptive text for
9096 links, among other things.
9097 @item
9098 @i{Pete Phillips} helped during the development of the TAGS feature, and
9099 provided frequent feedback.
9100 @item
9101 @i{T.V. Raman} reported bugs and suggested improvements.
9102 @item
9103 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
9104 control.
9105 @item
9106 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
9107 @item
9108 @i{Sebastian Rose} wrote @file{org-info.js}, a Java script for displaying
9109 webpages derived from Org using an Info-like, or a folding interface with
9110 single key navigation.
9111 @item
9112 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
9113 conflict with @file{allout.el}.
9114 @item
9115 @i{Jason Riedy} generalized the send-receive mechanism for orgtbl tables with
9116 extensive patches.
9117 @item
9118 @i{Philip Rooke} created the Org reference card, provided lots
9119 of feedback, developed and applied standards to the Org documentation and
9120 wrote the manual for the contributed packages.
9121 @item
9122 @i{Christian Schlauer} proposed angular brackets around links, among
9123 other things.
9124 @item
9125 Linking to VM/BBDB/Gnus was first inspired by @i{Tom Shannon}'s
9126 @file{organizer-mode.el}.
9127 @item
9128 @i{Ilya Shlyakhter} proposed the Archive Sibling.
9129 @item
9130 @i{Daniel Sinder} came up with the idea of internal archiving by locking
9131 subtrees.
9132 @item
9133 @i{Dale Smith} proposed link abbreviations.
9134 @item
9135 @i{Adam Spiers} asked for global linking commands and inspired the link
9136 extension system.  support mairix.
9137 @item
9138 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
9139 chapter about publishing.
9140 @item
9141 @i{J@"urgen Vollmer} contributed code generating the table of contents
9142 in HTML output.
9143 @item
9144 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
9145 keyword.
9146 @item
9147 @i{David Wainberg} suggested archiving, and improvements to the linking
9148 system.
9149 @item
9150 @i{John Wiegley} wrote @file{emacs-wiki.el}, @file{planner.el}, and
9151 @file{muse.el}, which have similar goals as Org.  Initially the development
9152 of Org was fully independent because I was not aware of the existence of
9153 these packages.  But with time I have accasionally looked at John's code and
9154 learned a lot from it.  John has also contributed a number of great ideas and
9155 patches directly to Org, including the file @code{org-mac-message.el}'
9156 @item
9157 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
9158 linking to Gnus.
9159 @item
9160 @i{Roland Winkler} requested additional key bindings to make Org
9161 work on a tty.
9162 @item
9163 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
9164 and contributed various ideas and code snippets.
9165 @end itemize
9168 @node Main Index, Key Index, History and Acknowledgments, Top
9169 @unnumbered The Main Index
9171 @printindex cp
9173 @node Key Index,  , Main Index, Top
9174 @unnumbered Key Index
9176 @printindex ky
9178 @bye
9180 @ignore
9181         arch-tag: 7893d1Fe-cc57-4d13-b5e5-f494a1CBC7ac
9182 @end ignore
9184 @c Local variables:
9185 @c ispell-local-dictionary: "en_US-w_accents"
9186 @c ispell-local-pdict: "./.aspell.org.pws"
9187 @c fill-column: 77
9188 @c End: