Fixes to standardise references to prefix arguments.
[org-mode.git] / doc / org.texi
bloba21ad2c5821ffece662ff84e90bf89153b58722c
1 \input texinfo
2 @c %**start of header
3 @setfilename ../../info/org
4 @settitle Org Mode Manual
6 @set VERSION 6.00pre-1
7 @set DATE March 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-mode (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 Org Mode 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-mode 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-mode came into being
94 * Main Index::
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-mode does
103 * Installation::                How to install a downloaded version of Org-mode
104 * Activation::                  How to activate Org-mode for certain buffers.
105 * Feedback::                    Bug reports, ideas, patches etc.
106 * Conventions::                 Type-setting conventions in the manual
108 Document Structure
110 * Outlines::                    Org-mode 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-mode
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-mode 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-mode::  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 * Time stamps::                 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::
216 Creating timestamps
218 * The date/time prompt::        How org-mode helps you entering date and time
219 * Custom time format::          Making dates look differently
221 Deadlines and Scheduling
223 * Inserting deadline/schedule::  Planning items
224 * Repeated tasks::              Items that show up again and again
226 Remember
228 * Setting up remember::         Some code for .emacs to get things going
229 * Remember templates::          Define the outline of different note types
230 * Storing notes::               Directly get the note to where it belongs
231 * Refiling notes::              Moving a note or task to a project
233 Agenda Views
235 * Agenda files::                Files being searched for agenda information
236 * Agenda dispatcher::           Keyboard access to agenda views
237 * Built-in agenda views::       What is available out of the box?
238 * Presentation and sorting::    How agenda items are prepared for display
239 * Agenda commands::             Remote editing of org trees
240 * Custom agenda views::         Defining special searches and views
242 The built-in agenda views
244 * Weekly/Daily agenda::         The calendar page with current tasks
245 * Global TODO list::            All unfinished action items
246 * Matching tags and properties::  Structured information with fine-tuned search
247 * Timeline::                    Time-sorted view for single file
248 * Keyword search::              Finding entries by keyword
249 * Stuck projects::              Find projects you need to review
251 Presentation and sorting
253 * Categories::                  Not all tasks are equal
254 * Time-of-day specifications::  How the agenda knows the time
255 * Sorting of agenda items::     The order of things
257 Custom agenda views
259 * Storing searches::            Type once, use often
260 * Block agenda::                All the stuff you need in a single buffer
261 * Setting Options::             Changing the rules
262 * Exporting Agenda Views::      Writing agendas to files.
263 * Extracting Agenda Information for other programs::
265 Embedded LaTeX
267 * Math symbols::                TeX macros for symbols and Greek letters
268 * Subscripts and Superscripts::  Simple syntax for raising/lowering text
269 * LaTeX fragments::             Complex formulas made easy
270 * Processing LaTeX fragments::  Previewing LaTeX processing
271 * CDLaTeX mode::                Speed up entering of formulas
273 Exporting
275 * ASCII export::                Exporting to plain ASCII
276 * HTML export::                 Exporting to HTML
277 * LaTeX export::                Exporting to LaTeX
278 * XOXO export::                 Exporting to XOXO
279 * iCalendar export::            Exporting in iCalendar format
280 * Text interpretation::         How the exporter looks at the file
282 HTML export
284 * HTML Export commands::        How to invoke LaTeX export
285 * Quoting HTML tags::           Using direct HTML in Org-mode
286 * Links::                       Transformation of links for HTML
287 * Images::                      How to include images
288 * CSS support::                 Changing the appearance of the output
290 LaTeX export
292 * LaTeX export commands::       How to invoke LaTeX export
293 * Quoting LaTeX code::          Incorporating literal LaTeX code
294 * Sectioning structure::
296 Text interpretation by the exporter
298 * Comment lines::               Some lines will not be exported
299 * Initial text::                Text before the first headline
300 * Footnotes::                   Numbers like [1]
301 * Quoted examples::             Inserting quoted chunks of text
302 * Enhancing text::              Subscripts, symbols and more
303 * Export options::              How to influence the export settings
305 Publishing
307 * Configuration::               Defining projects
308 * Sample configuration::        Example projects
309 * Triggering publication::      Publication commands
311 Configuration
313 * Project alist::               The central configuration variable
314 * Sources and destinations::    From here to there
315 * Selecting files::             What files are part of the project?
316 * Publishing action::           Setting the function doing the publishing
317 * Publishing options::          Tweaking HTML export
318 * Publishing links::            Which links keep working after publishing?
319 * Project page index::          Publishing a list of project files
321 Sample configuration
323 * Simple example::              One-component publishing
324 * Complex example::             A multi-component publishing example
326 Miscellaneous
328 * Completion::                  M-TAB knows what you need
329 * Customization::               Adapting Org-mode to your taste
330 * In-buffer settings::          Overview of the #+KEYWORDS
331 * The very busy C-c C-c key::   When in doubt, press C-c C-c
332 * Clean view::                  Getting rid of leading stars in the outline
333 * TTY keys::                    Using Org-mode on a tty
334 * Interaction::                 Other Emacs packages
335 * Bugs::                        Things which do not work perfectly
337 Interaction with other packages
339 * Cooperation::                 Packages Org-mode cooperates with
340 * Conflicts::                   Packages that lead to conflicts
342 Extensions, Hooks and Hacking
344 * Extensions::                  Existing 3rd-part extensions
345 * Adding hyperlink types::      New custom link types
346 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
347 * Dynamic blocks::              Automatically filled blocks
348 * Special agenda views::        Customized views
349 * Using the property API::      Writing programs that use entry properties
351 Tables and Lists in arbitrary syntax
353 * Radio tables::                Sending and receiving
354 * A LaTeX example::             Step by step, almost a tutorial
355 * Translator functions::        Copy and modify
356 * Radio lists::                 Doing the same for lists.
358 @end detailmenu
359 @end menu
361 @node Introduction, Document structure, Top, Top
362 @chapter Introduction
363 @cindex introduction
365 @menu
366 * Summary::                     Brief summary of what Org-mode does
367 * Installation::                How to install a downloaded version of Org-mode
368 * Activation::                  How to activate Org-mode for certain buffers.
369 * Feedback::                    Bug reports, ideas, patches etc.
370 * Conventions::                 Type-setting conventions in the manual
371 @end menu
373 @node Summary, Installation, Introduction, Introduction
374 @section Summary
375 @cindex summary
377 Org-mode is a mode for keeping notes, maintaining TODO lists, and doing
378 project planning with a fast and effective plain-text system.
380 Org-mode develops organizational tasks around NOTES files that contain
381 lists or information about projects as plain text.  Org-mode is
382 implemented on top of outline-mode, which makes it possible to keep the
383 content of large files well structured.  Visibility cycling and
384 structure editing help to work with the tree.  Tables are easily created
385 with a built-in table editor.  Org-mode supports TODO items, deadlines,
386 time stamps, and scheduling.  It dynamically compiles entries into an
387 agenda that utilizes and smoothly integrates much of the Emacs calendar
388 and diary.  Plain text URL-like links connect to websites, emails,
389 Usenet messages, BBDB entries, and any files related to the projects.
390 For printing and sharing of notes, an Org-mode file can be exported as a
391 structured ASCII file, as HTML, or (TODO and agenda items only) as an
392 iCalendar file.  It can also serve as a publishing tool for a set of
393 linked web pages.
395 An important design aspect that distinguishes Org-mode from for example
396 Planner/Muse is that it encourages to store every piece of information
397 only once.  In Planner, you have project pages, day pages and possibly
398 other files, duplicating some information such as tasks.  In Org-mode,
399 you only have notes files.  In your notes you mark entries as tasks,
400 label them with tags and timestamps.  All necessary lists like a
401 schedule for the day, the agenda for a meeting, tasks lists selected by
402 tags etc are created dynamically when you need them.
404 Org-mode keeps simple things simple.  When first fired up, it should
405 feel like a straightforward, easy to use outliner.  Complexity is not
406 imposed, but a large amount of functionality is available when you need
407 it.  Org-mode is a toolbox and can be used in different ways, for
408 example as:
410 @example
411 @r{@bullet{} outline extension with visibility cycling and structure editing}
412 @r{@bullet{} ASCII system and table editor for taking structured notes}
413 @r{@bullet{} ASCII table editor with spreadsheet-like capabilities}
414 @r{@bullet{} TODO list editor}
415 @r{@bullet{} full agenda and planner with deadlines and work scheduling}
416 @r{@bullet{} environment to implement David Allen's GTD system}
417 @r{@bullet{} a basic database application}
418 @r{@bullet{} simple hypertext system, with HTML and LaTeX export}
419 @r{@bullet{} publishing tool to create a set of interlinked webpages}
420 @end example
422 Org-mode's automatic, context sensitive table editor with spreadsheet
423 capabilities can be integrated into any major mode by activating the
424 minor Orgtbl-mode.  Using a translation step, it can be used to maintain
425 tables in arbitrary file types, for example in La@TeX{}.  The structure
426 editing and list creation capabilities can be used outside Org-mode with
427 the minor Orgstruct-mode.
429 @cindex FAQ
430 There is a website for Org-mode which provides links to the newest
431 version of Org-mode, as well as additional information, frequently asked
432 questions (FAQ), links to tutorials etc.  This page is located at
433 @uref{http://orgmode.org}.
435 @page
438 @node Installation, Activation, Summary, Introduction
439 @section Installation
440 @cindex installation
441 @cindex XEmacs
443 @b{Important:} @i{If Org-mode is part of the Emacs distribution or an
444 XEmacs package, please skip this section and go directly to
445 @ref{Activation}.}
447 If you have downloaded Org-mode from the Web, you must take the
448 following steps to install it: Go into the Org-mode distribution
449 directory and edit the top section of the file @file{Makefile}.  You
450 must set the name of the Emacs binary (likely either @file{emacs} or
451 @file{xemacs}), and the paths to the directories where local Lisp and
452 Info files are kept.  If you don't have access to the system-wide
453 directories, create your own two directories for these files, enter them
454 into the Makefile, and make sure Emacs finds the Lisp files by adding
455 the following line to @file{.emacs}:
457 @example
458 (setq load-path (cons "~/path/to/lispdir" load-path))
459 @end example
461 @b{XEmacs users now need to install the file @file{noutline.el} from
462 the @file{xemacs} sub-directory of the Org-mode distribution.  Use the
463 command:}
465 @example
466 @b{make install-noutline}
467 @end example
469 @noindent Now byte-compile and install the Lisp files with the shell
470 commands:
472 @example
473 make
474 make install
475 @end example
477 @noindent If you want to install the info documentation, use this command:
479 @example
480 make install-info
481 @end example
483 @noindent Then add to @file{.emacs}:
485 @lisp
486 ;; This line only if org-mode is not part of the X/Emacs distribution.
487 (require 'org-install)
488 @end lisp
490 @node Activation, Feedback, Installation, Introduction
491 @section Activation
492 @cindex activation
493 @cindex autoload
494 @cindex global key bindings
495 @cindex key bindings, global
497 @iftex
498 @b{Important:} @i{If you use copy-and-paste to copy lisp code from the
499 PDF documentation as viewed by Acrobat reader to your .emacs file, the
500 single quote character comes out incorrectly and the code will not work.
501 You need to fix the single quotes by hand, or copy from Info
502 documentation.}
503 @end iftex
505 Add the following lines to your @file{.emacs} file.  The last two lines
506 define @emph{global} keys for the commands @command{org-store-link} and
507 @command{org-agenda} - please choose suitable keys yourself.
509 @lisp
510 ;; The following lines are always needed.  Choose your own keys.
511 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
512 (global-set-key "\C-cl" 'org-store-link)
513 (global-set-key "\C-ca" 'org-agenda)
514 @end lisp
516 Furthermore, you must activate @code{font-lock-mode} in org-mode
517 buffers, because significant functionality depends on font-locking being
518 active.  You can do this with either one of the following two lines
519 (XEmacs user must use the second option):
520 @lisp
521 (global-font-lock-mode 1)                     ; for all buffers
522 (add-hook 'org-mode-hook 'turn-on-font-lock)  ; org-mode buffers only
523 @end lisp
525 @cindex org-mode, turning on
526 With this setup, all files with extension @samp{.org} will be put
527 into Org-mode.  As an alternative, make the first line of a file look
528 like this:
530 @example
531 MY PROJECTS    -*- mode: org; -*-
532 @end example
534 @noindent which will select Org-mode for this buffer no matter what
535 the file's name is.  See also the variable
536 @code{org-insert-mode-line-in-empty-file}.
538 @node Feedback, Conventions, Activation, Introduction
539 @section Feedback
540 @cindex feedback
541 @cindex bug reports
542 @cindex maintainer
543 @cindex author
545 If you find problems with Org-mode, or if you have questions, remarks,
546 or ideas about it, please contact the maintainer @value{MAINTAINER} at
547 @value{MAINTAINEREMAIL}.
549 For bug reports, please provide as much information as possible,
550 including the version information of Emacs (@kbd{C-h v emacs-version
551 @key{RET}}) and Org-mode (@kbd{C-h v org-version @key{RET}}), as well as
552 the Org-mode related setup in @file{.emacs}.  If an error occurs, a
553 backtrace can be very useful (see below on how to create one).  Often a
554 small example file helps, along with clear information about:
556 @enumerate
557 @item What exactly did you do?
558 @item What did you expect to happen?
559 @item What happened instead?
560 @end enumerate
561 @noindent Thank you for helping to improve this mode.
563 @subsubheading How to create a useful backtrace
565 @cindex backtrace of an error
566 If working with Org-mode produces an error with a message you don't
567 understand, you may have hit a bug.  The best way to report this is by
568 providing, in addition to what was mentioned above, a @emph{Backtrace}.
569 This is information from the built-in debugger about where and how the
570 error occurred.  Here is how to produce a useful backtrace:
572 @enumerate
573 @item
574 Start a fresh Emacs or XEmacs, and make sure that it will load the
575 original Lisp code in @file{org.el} instead of the compiled version in
576 @file{org.elc}.  The backtrace contains much more information if it is
577 produced with uncompiled code.  To do this, either rename @file{org.elc}
578 to something else before starting Emacs, or ask Emacs explicitly to load
579 @file{org.el} by using the command line
580 @example
581 emacs -l /path/to/org.el
582 @end example
583 @item
584 Go to the @code{Options} menu and select @code{Enter Debugger on Error}
585 (XEmacs has this option in the @code{Troubleshooting} sub-menu).
586 @item
587 Do whatever you have to do to hit the error.  Don't forget to
588 document the steps you take.
589 @item
590 When you hit the error, a @file{*Backtrace*} buffer will appear on the
591 screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
592 attach it to your bug report.
593 @end enumerate
595 @node Conventions,  , Feedback, Introduction
596 @section Typesetting conventions used in this manual
598 Org-mode uses three types of keywords: TODO keywords, tags, and property
599 names.  In this manual we use the following conventions:
601 @table @code
602 @item TODO
603 @itemx WAITING
604 TODO keywords are written with all capitals, even if they are
605 user-defined.
606 @item boss
607 @itemx ARCHIVE
608 User-defined tags are written in lowercase; built-in tags with special
609 meaning are written with all capitals.
610 @item Release
611 @itemx PRIORITY
612 User-defined properties are capitalized; built-in properties with
613 special meaning are written with all capitals.
614 @end table
616 @node Document structure, Tables, Introduction, Top
617 @chapter Document Structure
618 @cindex document structure
619 @cindex structure of document
621 Org-mode is based on outline mode and provides flexible commands to
622 edit the structure of the document.
624 @menu
625 * Outlines::                    Org-mode is based on outline-mode
626 * Headlines::                   How to typeset org-tree headlines
627 * Visibility cycling::          Show and hide, much simplified
628 * Motion::                      Jumping to other headlines
629 * Structure editing::           Changing sequence and level of headlines
630 * Archiving::                   Move done task trees to a different place
631 * Sparse trees::                Matches embedded in context
632 * Plain lists::                 Additional structure within an entry
633 * Drawers::                     Tucking stuff away
634 * Orgstruct-mode::              Structure editing outside Org-mode
635 @end menu
637 @node Outlines, Headlines, Document structure, Document structure
638 @section Outlines
639 @cindex outlines
640 @cindex outline-mode
642 Org-mode is implemented on top of outline-mode.  Outlines allow a
643 document to be organized in a hierarchical structure, which (at least
644 for me) is the best representation of notes and thoughts.  An overview
645 of this structure is achieved by folding (hiding) large parts of the
646 document to show only the general document structure and the parts
647 currently being worked on.  Org-mode greatly simplifies the use of
648 outlines by compressing the entire show/hide functionality into a single
649 command @command{org-cycle}, which is bound to the @key{TAB} key.
651 @node Headlines, Visibility cycling, Outlines, Document structure
652 @section Headlines
653 @cindex headlines
654 @cindex outline tree
656 Headlines define the structure of an outline tree.  The headlines in
657 Org-mode start with one or more stars, on the left margin@footnote{See
658 the variable @code{org-special-ctrl-a/e} to configure special behavior
659 of @kbd{C-a} and @kbd{C-e} in headlines.}.  For example:
661 @example
662 * Top level headline
663 ** Second level
664 *** 3rd level
665     some text
666 *** 3rd level
667     more text
669 * Another top level headline
670 @end example
672 @noindent Some people find the many stars too noisy and would prefer an
673 outline that has whitespace followed by a single star as headline
674 starters.  @ref{Clean view} describes a setup to realize this.
676 An empty line after the end of a subtree is considered part of it and
677 will be hidden when the subtree is folded.  However, if you leave at
678 least two empty lines, one empty line will remain visible after folding
679 the subtree, in order to structure the collapsed view.  See the
680 variable @code{org-cycle-separator-lines} to modify this behavior.
682 @node Visibility cycling, Motion, Headlines, Document structure
683 @section Visibility cycling
684 @cindex cycling, visibility
685 @cindex visibility cycling
686 @cindex trees, visibility
687 @cindex show hidden text
688 @cindex hide text
690 Outlines make it possible to hide parts of the text in the buffer.
691 Org-mode uses just two commands, bound to @key{TAB} and
692 @kbd{S-@key{TAB}} to change the visibility in the buffer.
694 @cindex subtree visibility states
695 @cindex subtree cycling
696 @cindex folded, subtree visibility state
697 @cindex children, subtree visibility state
698 @cindex subtree, subtree visibility state
699 @table @kbd
700 @kindex @key{TAB}
701 @item @key{TAB}
702 @emph{Subtree cycling}: Rotate current subtree among the states
704 @example
705 ,-> FOLDED -> CHILDREN -> SUBTREE --.
706 '-----------------------------------'
707 @end example
709 The cursor must be on a headline for this to work@footnote{see, however,
710 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
711 beginning of the buffer and the first line is not a headline, then
712 @key{TAB} actually runs global cycling (see below)@footnote{see the
713 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
714 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
716 @cindex global visibility states
717 @cindex global cycling
718 @cindex overview, global visibility state
719 @cindex contents, global visibility state
720 @cindex show all, global visibility state
721 @kindex S-@key{TAB}
722 @item S-@key{TAB}
723 @itemx C-u @key{TAB}
724 @emph{Global cycling}: Rotate the entire buffer among the states
726 @example
727 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
728 '--------------------------------------'
729 @end example
731 When @kbd{S-@key{TAB}} is called with a numeric prefix argument N, the
732 CONTENTS view up to headlines of level N will be shown.  Note that inside
733 tables, @kbd{S-@key{TAB}} jumps to the previous field.
735 @cindex show all, command
736 @kindex C-c C-a
737 @item C-c C-a
738 Show all.
739 @kindex C-c C-r
740 @item C-c C-r
741 Reveal context around point, showing the current entry, the following heading
742 and the hierarchy above.  Useful for working near a location that has been
743 exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda command
744 (@pxref{Agenda commands}).  With a prefix argument show, on each
745 level, all sibling headings.
746 @kindex C-c C-x b
747 @item C-c C-x b
748 Show the current subtree in an indirect buffer@footnote{The indirect
749 buffer
750 @ifinfo
751 (@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
752 @end ifinfo
753 @ifnotinfo
754 (see the Emacs manual for more information about indirect buffers)
755 @end ifnotinfo
756 will contain the entire buffer, but will be narrowed to the current
757 tree.  Editing the indirect buffer will also change the original buffer,
758 but without affecting visibility in that buffer.}.  With a numeric
759 prefix argument N, go up to level N and then take that tree.  If N is
760 negative then go up that many levels.  With a @kbd{C-u} prefix, do not remove
761 the previously used indirect buffer.
762 @end table
764 When Emacs first visits an Org-mode file, the global state is set to
765 OVERVIEW, i.e. only the top level headlines are visible.  This can be
766 configured through the variable @code{org-startup-folded}, or on a
767 per-file basis by adding one of the following lines anywhere in the
768 buffer:
770 @example
771 #+STARTUP: overview
772 #+STARTUP: content
773 #+STARTUP: showall
774 @end example
776 @node Motion, Structure editing, Visibility cycling, Document structure
777 @section Motion
778 @cindex motion, between headlines
779 @cindex jumping, to headlines
780 @cindex headline navigation
781 The following commands jump to other headlines in the buffer.
783 @table @kbd
784 @kindex C-c C-n
785 @item C-c C-n
786 Next heading.
787 @kindex C-c C-p
788 @item C-c C-p
789 Previous heading.
790 @kindex C-c C-f
791 @item C-c C-f
792 Next heading same level.
793 @kindex C-c C-b
794 @item C-c C-b
795 Previous heading same level.
796 @kindex C-c C-u
797 @item C-c C-u
798 Backward to higher level heading.
799 @kindex C-c C-j
800 @item C-c C-j
801 Jump to a different place without changing the current outline
802 visibility.  Shows the document structure in a temporary buffer, where
803 you can use the following keys to find your destination:
804 @example
805 @key{TAB}         @r{Cycle visibility.}
806 @key{down} / @key{up}   @r{Next/previous visible headline.}
807 n / p        @r{Next/previous visible headline.}
808 f / b        @r{Next/previous headline same level.}
809 u            @r{One level up.}
810 0-9          @r{Digit argument.}
811 @key{RET}         @r{Select this location.}
812 @end example
813 @end table
815 @node Structure editing, Archiving, Motion, Document structure
816 @section Structure editing
817 @cindex structure editing
818 @cindex headline, promotion and demotion
819 @cindex promotion, of subtrees
820 @cindex demotion, of subtrees
821 @cindex subtree, cut and paste
822 @cindex pasting, of subtrees
823 @cindex cutting, of subtrees
824 @cindex copying, of subtrees
825 @cindex subtrees, cut and paste
827 @table @kbd
828 @kindex M-@key{RET}
829 @item M-@key{RET}
830 Insert new heading with same level as current.  If the cursor is in a
831 plain list item, a new item is created (@pxref{Plain lists}).  To force
832 creation of a new headline, use a prefix argument, or first press @key{RET}
833 to get to the beginning of the next line.  When this command is used in
834 the middle of a line, the line is split and the rest of the line becomes
835 the new headline@footnote{If you do not want the line to be split,
836 customize the variable @code{org-M-RET-may-split-line}.}.  If the
837 command is used at the beginning of a headline, the new headline is
838 created before the current line.  If at the beginning of any other line,
839 the content of that line is made the new heading.  If the command is
840 used at the end of a folded subtree (i.e. behind the ellipses at the end
841 of a headline), then a headline like the current one will be inserted
842 after the end of the subtree.
843 @kindex C-@key{RET}
844 @item C-@key{RET}
845 Insert a new heading after the current subtree, same level as the
846 current headline.  This command works from anywhere in the entry.
847 @kindex M-S-@key{RET}
848 @item M-S-@key{RET}
849 Insert new TODO entry with same level as current heading.
850 @kindex M-@key{left}
851 @item M-@key{left}
852 Promote current heading by one level.
853 @kindex M-@key{right}
854 @item M-@key{right}
855 Demote current heading by one level.
856 @kindex M-S-@key{left}
857 @item M-S-@key{left}
858 Promote the current subtree by one level.
859 @kindex M-S-@key{right}
860 @item M-S-@key{right}
861 Demote the current subtree by one level.
862 @kindex M-S-@key{up}
863 @item M-S-@key{up}
864 Move subtree up (swap with previous subtree of same
865 level).
866 @kindex M-S-@key{down}
867 @item M-S-@key{down}
868 Move subtree down (swap with next subtree of same level).
869 @kindex C-c C-x C-w
870 @kindex C-c C-x C-k
871 @item C-c C-x C-w
872 @itemx C-c C-x C-k
873 Kill subtree, i.e. remove it from buffer but save in kill ring.
874 With a numeric prefix argument N, kill N sequential subtrees.
875 @kindex C-c C-x M-w
876 @item C-c C-x M-w
877 Copy subtree to kill ring.  With a numeric prefix argument N, copy the N
878 sequential subtrees.
879 @kindex C-c C-x C-y
880 @item C-c C-x C-y
881 Yank subtree from kill ring.  This does modify the level of the subtree to
882 make sure the tree fits in nicely at the yank position.  The yank level can
883 also be specified with a numeric prefix argument, or by yanking after a
884 headline marker like @samp{****}.
885 @kindex C-c C-w
886 @item C-c C-w
887 Refile entry to a different location.  @xref{Refiling notes}.
888 @kindex C-c ^
889 @item C-c ^
890 Sort same-level entries.  When there is an active region, all entries in
891 the region will be sorted.  Otherwise the children of the current
892 headline are sorted.  The command prompts for the sorting method, which
893 can be alphabetically, numerically, by time (using the first time stamp
894 in each entry), by priority, and each of these in reverse order.  You
895 can also supply your own function to extract the sorting key.  With a
896 @kbd{C-u} prefix, sorting will be case-sensitive.  With two @kbd{C-u
897 C-u} prefixes, duplicate entries will also be removed.
898 @kindex C-c *
899 @item C-c *
900 Turn a normal line or plain list item into a headline (so that it
901 becomes a subheading at its location).  Also turn a headline into a
902 normal line by removing the stars.  If there is an active region, turn
903 all lines in the region into headlines.  Or, if the first line is a
904 headline, remove the stars from all headlines in the region.
905 @end table
907 @cindex region, active
908 @cindex active region
909 @cindex transient-mark-mode
910 When there is an active region (transient-mark-mode), promotion and
911 demotion work on all headlines in the region.  To select a region of
912 headlines, it is best to place both point and mark at the beginning of a
913 line, mark at the beginning of the first headline, and point at the line
914 just after the last headline to change.  Note that when the cursor is
915 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
916 functionality.
918 @node Archiving, Sparse trees, Structure editing, Document structure
919 @section Archiving
920 @cindex archiving
922 When a project represented by a (sub)tree is finished, you may want
923 to move the tree out of the way and to stop it from contributing to the
924 agenda.  Org-mode knows two ways of archiving.  You can mark a tree with
925 the ARCHIVE tag, or you can move an entire (sub)tree to a different
926 location.
928 @menu
929 * ARCHIVE tag::                 Marking a tree as inactive
930 * Moving subtrees::             Moving a tree to an archive file
931 @end menu
933 @node ARCHIVE tag, Moving subtrees, Archiving, Archiving
934 @subsection The ARCHIVE tag
935 @cindex internal archiving
937 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
938 its location in the outline tree, but behaves in the following way:
939 @itemize @minus
940 @item
941 It does not open when you attempt to do so with a visibility cycling
942 command (@pxref{Visibility cycling}).  You can force cycling archived
943 subtrees with @kbd{C-@key{TAB}}, or by setting the option
944 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
945 @code{show-all} will open archived subtrees.
946 @item
947 During sparse tree construction (@pxref{Sparse trees}), matches in
948 archived subtrees are not exposed, unless you configure the option
949 @code{org-sparse-tree-open-archived-trees}.
950 @item
951 During agenda view construction (@pxref{Agenda views}), the content of
952 archived trees is ignored unless you configure the option
953 @code{org-agenda-skip-archived-trees}.
954 @item
955 Archived trees are not exported (@pxref{Exporting}), only the headline
956 is.  Configure the details using the variable
957 @code{org-export-with-archived-trees}.
958 @end itemize
960 The following commands help managing the ARCHIVE tag:
962 @table @kbd
963 @kindex C-c C-x C-a
964 @item C-c C-x C-a
965 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
966 the headline changes to a shadowed face, and the subtree below it is
967 hidden.
968 @kindex C-u C-c C-x C-a
969 @item C-u C-c C-x C-a
970 Check if any direct children of the current headline should be archived.
971 To do this, each subtree is checked for open TODO entries.  If none are
972 found, the command offers to set the ARCHIVE tag for the child.  If the
973 cursor is @emph{not} on a headline when this command is invoked, the
974 level 1 trees will be checked.
975 @kindex C-@kbd{TAB}
976 @item C-@kbd{TAB}
977 Cycle a tree even if it is tagged with ARCHIVE.
978 @end table
980 @node Moving subtrees,  , ARCHIVE tag, Archiving
981 @subsection Moving subtrees
982 @cindex external archiving
984 Once an entire project is finished, you may want to move it to a
985 different location, either in the current file, or even in a different
986 file, the archive file.
988 @table @kbd
989 @kindex C-c C-x C-s
990 @item C-c C-x C-s
991 Archive the subtree starting at the cursor position to the location
992 given by @code{org-archive-location}.  Context information that could be
993 lost like the file name, the category, inherited tags, and the TODO
994 state will be store as properties in the entry.
995 @kindex C-u C-c C-x C-s
996 @item C-u C-c C-x C-s
997 Check if any direct children of the current headline could be moved to
998 the archive.  To do this, each subtree is checked for open TODO entries.
999 If none are found, the command offers to move it to the archive
1000 location.  If the cursor is @emph{not} on a headline when this command
1001 is invoked, the level 1 trees will be checked.
1002 @end table
1004 @cindex archive locations
1005 The default archive location is a file in the same directory as the
1006 current file, with the name derived by appending @file{_archive} to the
1007 current file name.  For information and examples on how to change this,
1008 see the documentation string of the variable
1009 @code{org-archive-location}.  There is also an in-buffer option for
1010 setting this variable, for example@footnote{For backward compatibility,
1011 the following also works: If there are several such lines in a file,
1012 each specifies the archive location for the text below it.  The first
1013 such line also applies to any text before its definition.  However,
1014 using this method is @emph{strongly} deprecated as it is incompatible
1015 with the outline structure of the document.  The correct method for
1016 setting multiple archive locations in a buffer is using a property.}:
1018 @example
1019 #+ARCHIVE: %s_done::
1020 @end example
1022 @noindent
1023 If you would like to have a special ARCHIVE location for a single entry
1024 or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
1025 location as the value (@pxref{Properties and columns}).
1027 When a subtree is moved, it receives a number of special properties that
1028 record context information like the file from where the entry came, it's
1029 outline path the archiving time etc.  Configure the variable
1030 @code{org-archive-save-context-info} to adjust the amount of information
1031 added.
1033 @node Sparse trees, Plain lists, Archiving, Document structure
1034 @section Sparse trees
1035 @cindex sparse trees
1036 @cindex trees, sparse
1037 @cindex folding, sparse trees
1038 @cindex occur, command
1040 An important feature of Org-mode is the ability to construct
1041 @emph{sparse trees} for selected information in an outline tree, so that
1042 the entire document is folded as much as possible, but the selected
1043 information is made visible along with the headline structure above
1044 it@footnote{See also the variables @code{org-show-hierarchy-above},
1045 @code{org-show-following-heading}, and @code{org-show-siblings} for
1046 detailed control on how much context is shown around each match.}.  Just
1047 try it out and you will see immediately how it works.
1049 Org-mode contains several commands creating such trees, all these
1050 commands can be accessed through a dispatcher:
1052 @table @kbd
1053 @kindex C-c /
1054 @item C-c /
1055 This prompts for an extra key to select a sparse-tree creating command.
1056 @kindex C-c / r
1057 @item C-c / r
1058 Occur.  Prompts for a regexp and shows a sparse tree with all matches.
1059 If the match is in a headline, the headline is made visible.  If the
1060 match is in the body of an entry, headline and body are made visible.
1061 In order to provide minimal context, also the full hierarchy of
1062 headlines above the match is shown, as well as the headline following
1063 the match.  Each match is also highlighted; the highlights disappear
1064 when the buffer is changed by an editing command, or by pressing
1065 @kbd{C-c C-c}.  When called with a @kbd{C-u} prefix argument, previous
1066 highlights are kept, so several calls to this command can be stacked.
1067 @end table
1069 @noindent
1070 For frequently used sparse trees of specific search strings, you can
1071 use the variable @code{org-agenda-custom-commands} to define fast
1072 keyboard access to specific sparse trees.  These commands will then be
1073 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
1074 For example:
1076 @lisp
1077 (setq org-agenda-custom-commands
1078       '(("f" occur-tree "FIXME")))
1079 @end lisp
1081 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
1082 a sparse tree matching the string @samp{FIXME}.
1084 The other sparse tree commands select headings based on TODO keywords,
1085 tags, or properties and will be discussed later in this manual.
1087 @kindex C-c C-e v
1088 @cindex printing sparse trees
1089 @cindex visible text, printing
1090 To print a sparse tree, you can use the Emacs command
1091 @code{ps-print-buffer-with-faces} which does not print invisible parts
1092 of the document @footnote{This does not work under XEmacs, because
1093 XEmacs uses selective display for outlining, not text properties.}.
1094 Or you can use the command @kbd{C-c C-e v} to export only the visible
1095 part of the document and print the resulting file.
1097 @node Plain lists, Drawers, Sparse trees, Document structure
1098 @section Plain lists
1099 @cindex plain lists
1100 @cindex lists, plain
1101 @cindex lists, ordered
1102 @cindex ordered lists
1104 Within an entry of the outline tree, hand-formatted lists can provide
1105 additional structure.  They also provide a way to create lists of
1106 checkboxes (@pxref{Checkboxes}).  Org-mode supports editing such lists,
1107 and the HTML exporter (@pxref{Exporting}) parses and formats them.
1109 Org-mode knows ordered and unordered lists.  Unordered list items start
1110 with @samp{-}, @samp{+}, or @samp{*}@footnote{When using @samp{*} as a
1111 bullet, lines must be indented or they will be seen as top-level
1112 headlines.  Also, when you are hiding leading stars to get a clean
1113 outline view, plain list items starting with a star are visually
1114 indistinguishable from true headlines.  In short: even though @samp{*}
1115 is supported, it may be better to not use it for plain list items.} as
1116 bullets.  Ordered list items start with a numeral followed by either a
1117 period or a right parenthesis, such as @samp{1.} or @samp{1)}.  Items
1118 belonging to the same list must have the same indentation on the first
1119 line.  In particular, if an ordered list reaches number @samp{10.}, then
1120 the 2--digit numbers must be written left-aligned with the other numbers
1121 in the list.  Indentation also determines the end of a list item.  It
1122 ends before the next line that is indented like the bullet/number, or
1123 less.  Empty lines are part of the previous item, so you can have
1124 several paragraphs in one item.  If you would like an empty line to
1125 terminate all currently open plain lists, configure the variable
1126 @code{org-empty-line-terminates-plain-lists}.  Here is an example:
1128 @example
1129 @group
1130 ** Lord of the Rings
1131    My favorite scenes are (in this order)
1132    1. The attack of the Rohirrim
1133    2. Eowyns fight with the witch king
1134       + this was already my favorite scene in the book
1135       + I really like Miranda Otto.
1136    3. Peter Jackson being shot by Legolas
1137        - on DVD only
1138       He makes a really funny face when it happens.
1139    But in the end, not individual scenes matter but the film as a whole.
1140 @end group
1141 @end example
1143 Org-mode supports these lists by tuning filling and wrapping commands to
1144 deal with them correctly@footnote{Org-mode only changes the filling
1145 settings for Emacs.  For XEmacs, you should use Kyle E. Jones'
1146 @file{filladapt.el}.  To turn this on,  put into @file{.emacs}:
1147 @code{(require 'filladapt)}}.
1149 The following commands act on items when the cursor is in the first line
1150 of an item (the line with the bullet or number).
1152 @table @kbd
1153 @kindex @key{TAB}
1154 @item @key{TAB}
1155 Items can be folded just like headline levels if you set the variable
1156 @code{org-cycle-include-plain-lists}.  The level of an item is then
1157 given by the indentation of the bullet/number.  Items are always
1158 subordinate to real headlines, however; the hierarchies remain
1159 completely separated.
1161 If @code{org-cycle-include-plain-lists} has not been set, @key{TAB}
1162 fixes the indentation of the current line in a heuristic way.
1163 @kindex M-@key{RET}
1164 @item M-@key{RET}
1165 Insert new item at current level.  With a prefix argument, force a new
1166 heading (@pxref{Structure editing}).  If this command is used in the middle
1167 of a line, the line is @emph{split} and the rest of the line becomes the new
1168 item@footnote{If you do not want the line to be split, customize the variable
1169 @code{org-M-RET-may-split-line}.}.  If this command is executed in the
1170 @emph{whitespace before a bullet or number}, the new item is created
1171 @emph{before} the current item.  If the command is executed in the white
1172 space before the text that is part of an item but does not contain the
1173 bullet, a bullet is added to the current line.
1174 @kindex M-S-@key{RET}
1175 @item M-S-@key{RET}
1176 Insert a new item with a checkbox (@pxref{Checkboxes}).
1177 @kindex S-@key{up}
1178 @kindex S-@key{down}
1179 @item S-@key{up}
1180 @itemx S-@key{down}
1181 Jump to the previous/next item in the current list.
1182 @kindex M-S-@key{up}
1183 @kindex M-S-@key{down}
1184 @item M-S-@key{up}
1185 @itemx M-S-@key{down}
1186 Move the item including subitems up/down (swap with previous/next item
1187 of same indentation).  If the list is ordered, renumbering is
1188 automatic.
1189 @kindex M-S-@key{left}
1190 @kindex M-S-@key{right}
1191 @item M-S-@key{left}
1192 @itemx M-S-@key{right}
1193 Decrease/increase the indentation of the item, including subitems.
1194 Initially, the item tree is selected based on current indentation.
1195 When these commands are executed several times in direct succession,
1196 the initially selected region is used, even if the new indentation
1197 would imply a different hierarchy.  To use the new hierarchy, break
1198 the command chain with a cursor motion or so.
1199 @kindex C-c C-c
1200 @item C-c C-c
1201 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1202 state of the checkbox.  If not, this command makes sure that all the
1203 items on this list level use the same bullet.  Furthermore, if this is
1204 an ordered list, make sure the numbering is OK.
1205 @kindex C-c -
1206 @item C-c -
1207 Cycle the entire list level through the different itemize/enumerate bullets
1208 (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}).  With a numeric prefix
1209 argument N, select the Nth bullet from this list.  If there is an active
1210 region when calling this, all lines will be converted to list items.  If the
1211 first line already was a list item, any item markers will be removed from the
1212 list.  Finally, even without an active region, a normal line will be
1213 converted into a list item.
1214 @end table
1216 @node Drawers, Orgstruct-mode, Plain lists, Document structure
1217 @section Drawers
1218 @cindex drawers
1219 @cindex visibility cycling, drawers
1221 Sometimes you want to keep information associated with an entry, but you
1222 normally don't want to see it.  For this, Org-mode has @emph{drawers}.
1223 Drawers need to be configured with the variable
1224 @code{org-drawers}@footnote{You can define drawers on a per-file basis
1225 with a line like @code{#+DRAWERS: HIDDEN PROPERTIES STATE}}.  Drawers
1226 look like this:
1228 @example
1229 ** This is a headline
1230    Still outside the drawer
1231    :DRAWERNAME:
1232       This is inside the drawer.
1233    :END:
1234    After the drawer.
1235 @end example
1237 Visibility cycling (@pxref{Visibility cycling}) on the headline will
1238 hide and show the entry, but keep the drawer collapsed to a single line.
1239 In order to look inside the drawer, you need to move the cursor to the
1240 drawer line and press @key{TAB} there.  Org-mode uses a drawer for
1241 storing properties (@pxref{Properties and columns}).
1243 @node Orgstruct-mode,  , Drawers, Document structure
1244 @section The Orgstruct minor mode
1245 @cindex Orgstruct-mode
1246 @cindex minor mode for structure editing
1248 If you like the intuitive way the Org-mode structure editing and list
1249 formatting works, you might want to use these commands in other modes
1250 like text-mode or mail-mode as well.  The minor mode Orgstruct-mode
1251 makes this possible.  You can always toggle the mode with @kbd{M-x
1252 orgstruct-mode}.  To turn it on by default, for example in mail mode,
1255 @lisp
1256 (add-hook 'mail-mode-hook 'turn-on-orgstruct)
1257 @end lisp
1259 When this mode is active and the cursor is on a line that looks to
1260 Org-mode like a headline of the first line of a list item, most
1261 structure editing commands will work, even if the same keys normally
1262 have different functionality in the major mode you are using.  If the
1263 cursor is not in one of those special lines, Orgstruct-mode lurks
1264 silently in the shadow.
1266 @node Tables, Hyperlinks, Document structure, Top
1267 @chapter Tables
1268 @cindex tables
1269 @cindex editing tables
1271 Org-mode comes with a fast and intuitive table editor.  Spreadsheet-like
1272 calculations are supported in connection with the Emacs @file{calc}
1273 package
1274 @ifinfo
1275 (@pxref{Top,Calc,,calc,Gnu Emacs Calculator Manual}).
1276 @end ifinfo
1277 @ifnotinfo
1278 (see the Emacs Calculator manual for more information about the Emacs
1279 calculator).
1280 @end ifnotinfo
1282 @menu
1283 * Built-in table editor::       Simple tables
1284 * Narrow columns::              Stop wasting space in tables
1285 * Column groups::               Grouping to trigger vertical lines
1286 * Orgtbl-mode::                 The table editor as minor mode
1287 * The spreadsheet::             The table editor has spreadsheet capabilities.
1288 @end menu
1290 @node Built-in table editor, Narrow columns, Tables, Tables
1291 @section The built-in table editor
1292 @cindex table editor, built-in
1294 Org-mode makes it easy to format tables in plain ASCII.  Any line with
1295 @samp{|} as the first non-whitespace character is considered part of a
1296 table.  @samp{|} is also the column separator.  A table might look like
1297 this:
1299 @example
1300 | Name  | Phone | Age |
1301 |-------+-------+-----|
1302 | Peter |  1234 |  17 |
1303 | Anna  |  4321 |  25 |
1304 @end example
1306 A table is re-aligned automatically each time you press @key{TAB} or
1307 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
1308 the next field (@key{RET} to the next row) and creates new table rows
1309 at the end of the table or before horizontal lines.  The indentation
1310 of the table is set by the first line.  Any line starting with
1311 @samp{|-} is considered as a horizontal separator line and will be
1312 expanded on the next re-align to span the whole table width.  So, to
1313 create the above table, you would only type
1315 @example
1316 |Name|Phone|Age|
1318 @end example
1320 @noindent and then press @key{TAB} to align the table and start filling in
1321 fields.
1323 When typing text into a field, Org-mode treats @key{DEL},
1324 @key{Backspace}, and all character keys in a special way, so that
1325 inserting and deleting avoids shifting other fields.  Also, when
1326 typing @emph{immediately after the cursor was moved into a new field
1327 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
1328 field is automatically made blank.  If this behavior is too
1329 unpredictable for you, configure the variables
1330 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
1332 @table @kbd
1333 @tsubheading{Creation and conversion}
1334 @kindex C-c |
1335 @item C-c |
1336 Convert the active region to table. If every line contains at least one
1337 TAB character, the function assumes that the material is tab separated.
1338 If every line contains a comma, comma-separated values (CSV) are assumed.
1339 If not, lines are split at whitespace into fields.  You can use a prefix
1340 argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
1341 C-u} forces TAB, and a numeric argument N indicates that at least N
1342 consecutive spaces, or alternatively a TAB will be the separator.
1344 If there is no active region, this command creates an empty Org-mode
1345 table.  But it's easier just to start typing, like
1346 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
1348 @tsubheading{Re-aligning and field motion}
1349 @kindex C-c C-c
1350 @item C-c C-c
1351 Re-align the table without moving the cursor.
1353 @kindex @key{TAB}
1354 @item @key{TAB}
1355 Re-align the table, move to the next field.  Creates a new row if
1356 necessary.
1358 @kindex S-@key{TAB}
1359 @item S-@key{TAB}
1360 Re-align, move to previous field.
1362 @kindex @key{RET}
1363 @item @key{RET}
1364 Re-align the table and move down to next row.  Creates a new row if
1365 necessary.  At the beginning or end of a line, @key{RET} still does
1366 NEWLINE, so it can be used to split a table.
1368 @tsubheading{Column and row editing}
1369 @kindex M-@key{left}
1370 @kindex M-@key{right}
1371 @item M-@key{left}
1372 @itemx M-@key{right}
1373 Move the current column left/right.
1375 @kindex M-S-@key{left}
1376 @item M-S-@key{left}
1377 Kill the current column.
1379 @kindex M-S-@key{right}
1380 @item M-S-@key{right}
1381 Insert a new column to the left of the cursor position.
1383 @kindex M-@key{up}
1384 @kindex M-@key{down}
1385 @item M-@key{up}
1386 @itemx M-@key{down}
1387 Move the current row up/down.
1389 @kindex M-S-@key{up}
1390 @item M-S-@key{up}
1391 Kill the current row or horizontal line.
1393 @kindex M-S-@key{down}
1394 @item M-S-@key{down}
1395 Insert a new row above the current row.  With a prefix argument, the line is
1396 created below the current one.
1398 @kindex C-c -
1399 @item C-c -
1400 Insert a horizontal line below current row. With a prefix argument, the line
1401 is created above the current line.
1403 @kindex C-c ^
1404 @item C-c ^
1405 Sort the table lines in the region.  The position of point indicates the
1406 column to be used for sorting, and the range of lines is the range
1407 between the nearest horizontal separator lines, or the entire table.  If
1408 point is before the first column, you will be prompted for the sorting
1409 column.  If there is an active region, the mark specifies the first line
1410 and the sorting column, while point should be in the last line to be
1411 included into the sorting.  The command prompts for the sorting type
1412 (alphabetically, numerically, or by time).  When called with a prefix
1413 argument, alphabetic sorting will be case-sensitive.
1415 @tsubheading{Regions}
1416 @kindex C-c C-x M-w
1417 @item C-c C-x M-w
1418 Copy a rectangular region from a table to a special clipboard.  Point
1419 and mark determine edge fields of the rectangle.  The process ignores
1420 horizontal separator lines.
1422 @kindex C-c C-x C-w
1423 @item C-c C-x C-w
1424 Copy a rectangular region from a table to a special clipboard, and
1425 blank all fields in the rectangle.  So this is the ``cut'' operation.
1427 @kindex C-c C-x C-y
1428 @item C-c C-x C-y
1429 Paste a rectangular region into a table.
1430 The upper right corner ends up in the current field.  All involved fields
1431 will be overwritten.  If the rectangle does not fit into the present table,
1432 the table is enlarged as needed.  The process ignores horizontal separator
1433 lines.
1435 @kindex C-c C-q
1436 @kindex M-@key{RET}
1437 @item C-c C-q
1438 @itemx M-@kbd{RET}
1439 Wrap several fields in a column like a paragraph.  If there is an active
1440 region, and both point and mark are in the same column, the text in the
1441 column is wrapped to minimum width for the given number of lines.  A numeric
1442 prefix argument may be used to change the number of desired lines.  If there
1443 is no region, the current field is split at the cursor position and the text
1444 fragment to the right of the cursor is prepended to the field one line
1445 down. If there is no region, but you specify a prefix argument, the current
1446 field is made blank, and the content is appended to the field above.
1448 @tsubheading{Calculations}
1449 @cindex formula, in tables
1450 @cindex calculations, in tables
1451 @cindex region, active
1452 @cindex active region
1453 @cindex transient-mark-mode
1454 @kindex C-c +
1455 @item C-c +
1456 Sum the numbers in the current column, or in the rectangle defined by
1457 the active region.  The result is shown in the echo area and can
1458 be inserted with @kbd{C-y}.
1460 @kindex S-@key{RET}
1461 @item S-@key{RET}
1462 When current field is empty, copy from first non-empty field above.
1463 When not empty, copy current field down to next row and move cursor
1464 along with it.  Depending on the variable
1465 @code{org-table-copy-increment}, integer field values will be
1466 incremented during copy.  This key is also used by CUA-mode
1467 (@pxref{Cooperation}).
1469 @tsubheading{Miscellaneous}
1470 @kindex C-c `
1471 @item C-c `
1472 Edit the current field in a separate window.  This is useful for fields
1473 that are not fully visible (@pxref{Narrow columns}).  When called with a
1474 @kbd{C-u} prefix, just make the full field visible, so that it can be
1475 edited in place.
1477 @item M-x org-table-import
1478 Import a file as a table.  The table should be TAB- or whitespace
1479 separated.  Useful, for example, to import a spreadsheet table or data
1480 from a database, because these programs generally can write
1481 TAB-separated text files.  This command works by inserting the file into
1482 the buffer and then converting the region to a table.  Any prefix
1483 argument is passed on to the converter, which uses it to determine the
1484 separator.
1485 @item C-c |
1486 Tables can also be imported by pasting tabular text into the org-mode
1487 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
1488 @kbd{C-c |} command (see above under @i{Creation and conversion}.
1490 @item M-x org-table-export
1491 Export the table as a TAB-separated file.  Useful for data exchange with,
1492 for example, spreadsheet or database programs.
1493 @end table
1495 If you don't like the automatic table editor because it gets in your
1496 way on lines which you would like to start with @samp{|}, you can turn
1497 it off with
1499 @lisp
1500 (setq org-enable-table-editor nil)
1501 @end lisp
1503 @noindent Then the only table command that still works is
1504 @kbd{C-c C-c} to do a manual re-align.
1506 @node Narrow columns, Column groups, Built-in table editor, Tables
1507 @section Narrow columns
1508 @cindex narrow columns in tables
1510 The width of columns is automatically determined by the table editor.
1511 Sometimes a single field or a few fields need to carry more text,
1512 leading to inconveniently wide columns.  To limit@footnote{This feature
1513 does not work on XEmacs.} the width of a column, one field anywhere in
1514 the column may contain just the string @samp{<N>} where @samp{N} is an
1515 integer specifying the width of the column in characters.  The next
1516 re-align will then set the width of this column to no more than this
1517 value.
1519 @example
1520 @group
1521 |---+------------------------------|               |---+--------|
1522 |   |                              |               |   | <6>    |
1523 | 1 | one                          |               | 1 | one    |
1524 | 2 | two                          |     ----\     | 2 | two    |
1525 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
1526 | 4 | four                         |               | 4 | four   |
1527 |---+------------------------------|               |---+--------|
1528 @end group
1529 @end example
1531 @noindent
1532 Fields that are wider become clipped and end in the string @samp{=>}.
1533 Note that the full text is still in the buffer, it is only invisible.
1534 To see the full text, hold the mouse over the field - a tool-tip window
1535 will show the full content.  To edit such a field, use the command
1536 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
1537 open a new window with the full field.  Edit it and finish with @kbd{C-c
1538 C-c}.
1540 When visiting a file containing a table with narrowed columns, the
1541 necessary character hiding has not yet happened, and the table needs to
1542 be aligned before it looks nice.  Setting the option
1543 @code{org-startup-align-all-tables} will realign all tables in a file
1544 upon visiting, but also slow down startup.  You can also set this option
1545 on a per-file basis with:
1547 @example
1548 #+STARTUP: align
1549 #+STARTUP: noalign
1550 @end example
1552 @node Column groups, Orgtbl-mode, Narrow columns, Tables
1553 @section Column groups
1554 @cindex grouping columns in tables
1556 When Org-mode exports tables, it does so by default without vertical
1557 lines because that is visually more satisfying in general.  Occasionally
1558 however, vertical lines can be useful to structure a table into groups
1559 of columns, much like horizontal lines can do for groups of rows.  In
1560 order to specify column groups, you can use a special row where the
1561 first field contains only @samp{/}.  The further fields can either
1562 contain @samp{<} to indicate that this column should start a group,
1563 @samp{>} to indicate the end of a column, or @samp{<>} to make a column
1564 a group of its own.  Boundaries between column groups will upon export be
1565 marked with vertical lines.  Here is an example:
1567 @example
1568 |   |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1569 |---+----+-----+-----+-----+---------+------------|
1570 | / | <> |   < |     |   > |       < |          > |
1571 | # |  1 |   1 |   1 |   1 |       1 |          1 |
1572 | # |  2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
1573 | # |  3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
1574 |---+----+-----+-----+-----+---------+------------|
1575 #+TBLFM: $3=$2^2::$4=$2^3::$5=$2^4::$6=sqrt($2)::$7=sqrt(sqrt(($2))
1576 @end example
1578 It is also sufficient to just insert the column group starters after
1579 every vertical line you'd like to have:
1581 @example
1582 |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1583 |----+-----+-----+-----+---------+------------|
1584 | /  | <   |     |     | <       |            |
1585 @end example
1587 @node Orgtbl-mode, The spreadsheet, Column groups, Tables
1588 @section The Orgtbl minor mode
1589 @cindex Orgtbl-mode
1590 @cindex minor mode for tables
1592 If you like the intuitive way the Org-mode table editor works, you
1593 might also want to use it in other modes like text-mode or mail-mode.
1594 The minor mode Orgtbl-mode makes this possible.  You can always toggle
1595 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
1596 example in mail mode, use
1598 @lisp
1599 (add-hook 'mail-mode-hook 'turn-on-orgtbl)
1600 @end lisp
1602 Furthermore, with some special setup, it is possible to maintain tables
1603 in arbitrary syntax with Orgtbl-mode.  For example, it is possible to
1604 construct La@TeX{} tables with the underlying ease and power of
1605 Orgtbl-mode, including spreadsheet capabilities.  For details, see
1606 @ref{Tables in arbitrary syntax}.
1608 @node The spreadsheet,  , Orgtbl-mode, Tables
1609 @section The spreadsheet
1610 @cindex calculations, in tables
1611 @cindex spreadsheet capabilities
1612 @cindex @file{calc} package
1614 The table editor makes use of the Emacs @file{calc} package to implement
1615 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
1616 derive fields from other fields.  While fully featured, Org-mode's
1617 implementation is not identical to other spreadsheets.  For example,
1618 Org-mode knows the concept of a @emph{column formula} that will be
1619 applied to all non-header fields in a column without having to copy the
1620 formula to each relevant field.
1622 @menu
1623 * References::                  How to refer to another field or range
1624 * Formula syntax for Calc::     Using Calc to compute stuff
1625 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
1626 * Field formulas::              Formulas valid for a single field
1627 * Column formulas::             Formulas valid for an entire column
1628 * Editing and debugging formulas::  Fixing formulas
1629 * Updating the table::          Recomputing all dependent fields
1630 * Advanced features::           Field names, parameters and automatic recalc
1631 @end menu
1633 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
1634 @subsection References
1635 @cindex references
1637 To compute fields in the table from other fields, formulas must
1638 reference other fields or ranges.  In Org-mode, fields can be referenced
1639 by name, by absolute coordinates, and by relative coordinates.  To find
1640 out what the coordinates of a field are, press @kbd{C-c ?} in that
1641 field, or press @kbd{C-c @}} to toggle the display of a grid.
1643 @subsubheading Field references
1644 @cindex field references
1645 @cindex references, to fields
1647 Formulas can reference the value of another field in two ways.  Like in
1648 any other spreadsheet, you may reference fields with a letter/number
1649 combination like @code{B3}, meaning the 2nd field in the 3rd row.
1650 @c Such references are always fixed to that field, they don't change
1651 @c when you copy and paste a formula to a different field.  So
1652 @c Org-mode's @code{B3} behaves like @code{$B$3} in other spreadsheets.
1654 @noindent
1655 Org-mode also uses another, more general operator that looks like this:
1656 @example
1657 @@row$column
1658 @end example
1660 @noindent
1661 Column references can be absolute like @samp{1}, @samp{2},...@samp{N},
1662 or relative to the current column like @samp{+1} or @samp{-2}.
1664 The row specification only counts data lines and ignores horizontal
1665 separator lines (hlines).  You can use absolute row numbers
1666 @samp{1}...@samp{N}, and row numbers relative to the current row like
1667 @samp{+3} or @samp{-1}.  Or specify the row relative to one of the
1668 hlines: @samp{I} refers to the first hline@footnote{Note that only
1669 hlines are counted that @emph{separate} table lines.  If the table
1670 starts with a hline above the header, it does not count.}, @samp{II} to
1671 the second etc.  @samp{-I} refers to the first such line above the
1672 current line, @samp{+I} to the first such line below the current line.
1673 You can also write @samp{III+2} which is the second data line after the
1674 third hline in the table.  Relative row numbers like @samp{-3} will not
1675 cross hlines if the current line is too close to the hline.  Instead,
1676 the value directly at the hline is used.
1678 @samp{0} refers to the current row and column.  Also, if you omit
1679 either the column or the row part of the reference, the current
1680 row/column is implied.
1682 Org-mode's references with @emph{unsigned} numbers are fixed references
1683 in the sense that if you use the same reference in the formula for two
1684 different fields, the same field will be referenced each time.
1685 Org-mode's references with @emph{signed} numbers are floating
1686 references because the same reference operator can reference different
1687 fields depending on the field being calculated by the formula.
1689 Here are a few examples:
1691 @example
1692 @@2$3      @r{2nd row, 3rd column}
1693 C2        @r{same as previous}
1694 $5        @r{column 5 in the current row}
1695 E&        @r{same as previous}
1696 @@2        @r{current column, row 2}
1697 @@-1$-3    @r{the field one row up, three columns to the left}
1698 @@-I$2     @r{field just under hline above current row, column 2}
1699 @end example
1701 @subsubheading Range references
1702 @cindex range references
1703 @cindex references, to ranges
1705 You may reference a rectangular range of fields by specifying two field
1706 references connected by two dots @samp{..}.  If both fields are in the
1707 current row, you may simply use @samp{$2..$7}, but if at least one field
1708 is in a different row, you need to use the general @code{@@row$column}
1709 format at least for the first field (i.e the reference must start with
1710 @samp{@@} in order to be interpreted correctly).  Examples:
1712 @example
1713 $1..$3        @r{First three fields in the current row.}
1714 $P..$Q        @r{Range, using column names (see under Advanced)}
1715 @@2$1..@@4$3    @r{6 fields between these two fields.}
1716 A2..C4        @r{Same as above.}
1717 @@-1$-2..@@-1   @r{3 numbers from the column to the left, 2 up to current row}
1718 @end example
1720 @noindent Range references return a vector of values that can be fed
1721 into Calc vector functions.  Empty fields in ranges are normally
1722 suppressed, so that the vector contains only the non-empty fields (but
1723 see the @samp{E} mode switch below).  If there are no non-empty fields,
1724 @samp{[0]} is returned to avoid syntax errors in formulas.
1726 @subsubheading Named references
1727 @cindex named references
1728 @cindex references, named
1729 @cindex name, of column or field
1730 @cindex constants, in calculations
1732 @samp{$name} is interpreted as the name of a column, parameter or
1733 constant.  Constants are defined globally through the variable
1734 @code{org-table-formula-constants}, and locally (for the file) through a
1735 line like
1737 @example
1738 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
1739 @end example
1741 @noindent
1742 Also properties (@pxref{Properties and columns}) can be used as
1743 constants in table formulas: For a property @samp{:Xyz:} use the name
1744 @samp{$PROP_Xyz}, and the property will be searched in the current
1745 outline entry and in the hierarchy above it.  If you have the
1746 @file{constants.el} package, it will also be used to resolve constants,
1747 including natural constants like @samp{$h} for Planck's constant, and
1748 units like @samp{$km} for kilometers@footnote{@file{Constant.el} can
1749 supply the values of constants in two different unit systems, @code{SI}
1750 and @code{cgs}.  Which one is used depends on the value of the variable
1751 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
1752 @code{constSI} and @code{constcgs} to set this value for the current
1753 buffer.}.  Column names and parameters can be specified in special table
1754 lines.  These are described below, see @ref{Advanced features}.  All
1755 names must start with a letter, and further consist of letters and
1756 numbers.
1758 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
1759 @subsection Formula syntax for Calc
1760 @cindex formula syntax, Calc
1761 @cindex syntax, of formulas
1763 A formula can be any algebraic expression understood by the Emacs
1764 @file{Calc} package.  @b{Note that @file{calc} has the
1765 non-standard convention that @samp{/} has lower precedence than
1766 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
1767 evaluation by @code{calc-eval} (@pxref{Calling Calc from
1768 Your Programs,calc-eval,Calling calc from Your Lisp Programs,calc,GNU
1769 Emacs Calc Manual}),
1770 @c FIXME:  The link to the calc manual in HTML does not work.
1771 variable substitution takes place according to the rules described above.
1772 @cindex vectors, in table calculations
1773 The range vectors can be directly fed into the calc vector functions
1774 like @samp{vmean} and @samp{vsum}.
1776 @cindex format specifier
1777 @cindex mode, for @file{calc}
1778 A formula can contain an optional mode string after a semicolon.  This
1779 string consists of flags to influence Calc and other modes during
1780 execution.  By default, Org-mode uses the standard calc modes (precision
1781 12, angular units degrees, fraction and symbolic modes off.  The display
1782 format, however, has been changed to @code{(float 5)} to keep tables
1783 compact.  The default settings can be configured using the variable
1784 @code{org-calc-default-modes}.
1786 @example
1787 p20           @r{switch the internal precision to 20 digits}
1788 n3 s3 e2 f4   @r{normal, scientific, engineering, or fixed display format}
1789 D R           @r{angle modes: degrees, radians}
1790 F S           @r{fraction and symbolic modes}
1791 N             @r{interpret all fields as numbers, use 0 for non-numbers}
1792 T             @r{force text interpretation}
1793 E             @r{keep empty fields in ranges}
1794 @end example
1796 @noindent
1797 In addition, you may provide a @code{printf} format specifier to
1798 reformat the final result.  A few examples:
1800 @example
1801 $1+$2                @r{Sum of first and second field}
1802 $1+$2;%.2f           @r{Same, format result to two decimals}
1803 exp($2)+exp($1)      @r{Math functions can be used}
1804 $0;%.1f              @r{Reformat current cell to 1 decimal}
1805 ($3-32)*5/9          @r{Degrees F -> C conversion}
1806 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
1807 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
1808 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
1809 vmean($2..$7)        @r{Compute column range mean, using vector function}
1810 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
1811 taylor($3,x=7,2)     @r{taylor series of $3, at x=7, second degree}
1812 @end example
1814 Calc also contains a complete set of logical operations.  For example
1816 @example
1817 if($1<20,teen,string(""))  @r{``teen'' if age $1 less than 20, else empty}
1818 @end example
1820 @node Formula syntax for Lisp, Field formulas, Formula syntax for Calc, The spreadsheet
1821 @subsection Emacs Lisp forms as formulas
1822 @cindex Lisp forms, as table formulas
1824 It is also possible to write a formula in Emacs Lisp; this can be useful
1825 for string manipulation and control structures, if the Calc's
1826 functionality is not enough.  If a formula starts with a single quote
1827 followed by an opening parenthesis, then it is evaluated as a lisp form.
1828 The evaluation should return either a string or a number.  Just as with
1829 @file{calc} formulas, you can specify modes and a printf format after a
1830 semicolon.  With Emacs Lisp forms, you need to be conscious about the way
1831 field references are interpolated into the form.  By default, a
1832 reference will be interpolated as a Lisp string (in double quotes)
1833 containing the field.  If you provide the @samp{N} mode switch, all
1834 referenced elements will be numbers (non-number fields will be zero) and
1835 interpolated as Lisp numbers, without quotes.  If you provide the
1836 @samp{L} flag, all fields will be interpolated literally, without quotes.
1837 I.e., if you want a reference to be interpreted as a string by the Lisp
1838 form, enclose the reference operator itself in double quotes, like
1839 @code{"$3"}.  Ranges are inserted as space-separated fields, so you can
1840 embed them in list or vector syntax.  A few examples, note how the
1841 @samp{N} mode is used when we do computations in lisp.
1843 @example
1844 @r{Swap the first two characters of the content of column 1}
1845   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
1846 @r{Add columns 1 and 2, equivalent to the Calc's @code{$1+$2}}
1847   '(+ $1 $2);N
1848 @r{Compute the sum of columns 1-4, like Calc's @code{vsum($1..$4)}}
1849   '(apply '+ '($1..$4));N
1850 @end example
1852 @node Field formulas, Column formulas, Formula syntax for Lisp, The spreadsheet
1853 @subsection Field formulas
1854 @cindex field formula
1855 @cindex formula, for individual table field
1857 To assign a formula to a particular field, type it directly into the
1858 field, preceded by @samp{:=}, for example @samp{:=$1+$2}.  When you
1859 press @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in
1860 the field, the formula will be stored as the formula for this field,
1861 evaluated, and the current field replaced with the result.
1863 Formulas are stored in a special line starting with @samp{#+TBLFM:}
1864 directly below the table.  If you typed the equation in the 4th field of
1865 the 3rd data line in the table, the formula will look like
1866 @samp{@@3$4=$1+$2}.  When inserting/deleting/swapping column and rows
1867 with the appropriate commands, @i{absolute references} (but not relative
1868 ones) in stored formulas are modified in order to still reference the
1869 same field.  Of cause this is not true if you edit the table structure
1870 with normal editing commands - then you must fix the equations yourself.
1872 Instead of typing an equation into the field, you may also use the
1873 following command
1875 @table @kbd
1876 @kindex C-u C-c =
1877 @item C-u C-c =
1878 Install a new formula for the current field.  The command prompts for a
1879 formula, with default taken from the @samp{#+TBLFM:} line, applies
1880 it to the current field and stores it.
1881 @end table
1883 @node Column formulas, Editing and debugging formulas, Field formulas, The spreadsheet
1884 @subsection Column formulas
1885 @cindex column formula
1886 @cindex formula, for table column
1888 Often in a table, the same formula should be used for all fields in a
1889 particular column.  Instead of having to copy the formula to all fields
1890 in that column, org-mode allows to assign a single formula to an entire
1891 column.  If the table contains horizontal separator hlines, everything
1892 before the first such line is considered part of the table @emph{header}
1893 and will not be modified by column formulas.
1895 To assign a formula to a column, type it directly into any field in the
1896 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
1897 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the
1898 field, the formula will be stored as the formula for the current column,
1899 evaluated and the current field replaced with the result.  If the field
1900 contains only @samp{=}, the previously stored formula for this column is
1901 used.  For each column, Org-mode will only remember the most recently
1902 used formula.  In the @samp{TBLFM:} line, column formulas will look like
1903 @samp{$4=$1+$2}.
1905 Instead of typing an equation into the field, you may also use the
1906 following command:
1908 @table @kbd
1909 @kindex C-c =
1910 @item C-c =
1911 Install a new formula for the current column and replace current field with
1912 the result of the formula.  The command prompts for a formula, with default
1913 taken from the @samp{#+TBLFM} line, applies it to the current field and
1914 stores it.  With a numeric prefix argument(e.g. @kbd{C-5 C-c =}) the command
1915 will apply it to that many consecutive fields in the current column.
1916 @end table
1918 @node Editing and debugging formulas, Updating the table, Column formulas, The spreadsheet
1919 @subsection Editing and Debugging formulas
1920 @cindex formula editing
1921 @cindex editing, of table formulas
1923 You can edit individual formulas in the minibuffer or directly in the
1924 field.  Org-mode can also prepare a special buffer with all active
1925 formulas of a table.  When offering a formula for editing, Org-mode
1926 converts references to the standard format (like @code{B3} or @code{D&})
1927 if possible.  If you prefer to only work with the internal format (like
1928 @code{@@3$2} or @code{$4}), configure the variable
1929 @code{org-table-use-standard-references}.
1931 @table @kbd
1932 @kindex C-c =
1933 @kindex C-u C-c =
1934 @item C-c =
1935 @itemx C-u C-c =
1936 Edit the formula associated with the current column/field in the
1937 minibuffer.  See @ref{Column formulas} and @ref{Field formulas}.
1938 @kindex C-u C-u C-c =
1939 @item C-u C-u C-c =
1940 Re-insert the active formula (either a
1941 field formula, or a column formula) into the current field, so that you
1942 can edit it directly in the field.  The advantage over editing in the
1943 minibuffer is that you can use the command @kbd{C-c ?}.
1944 @kindex C-c ?
1945 @item C-c ?
1946 While editing a formula in a table field, highlight the field(s)
1947 referenced by the reference at the cursor position in the formula.
1948 @kindex C-c @}
1949 @item C-c @}
1950 Toggle the display of row and column numbers for a table, using
1951 overlays.  These are updated each time the table is aligned, you can
1952 force it with @kbd{C-c C-c}.
1953 @kindex C-c @{
1954 @item C-c @{
1955 Toggle the formula debugger on and off.  See below.
1956 @kindex C-c '
1957 @item C-c '
1958 Edit all formulas for the current table in a special buffer, where the
1959 formulas will be displayed one per line.  If the current field has an
1960 active formula, the cursor in the formula editor will mark it.
1961 While inside the special buffer, Org-mode will automatically highlight
1962 any field or range reference at the cursor position.  You may edit,
1963 remove and add formulas, and use the following commands:
1964 @table @kbd
1965 @kindex C-c C-c
1966 @kindex C-x C-s
1967 @item C-c C-c
1968 @itemx C-x C-s
1969 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
1970 prefix, also apply the new formulas to the entire table.
1971 @kindex C-c C-q
1972 @item C-c C-q
1973 Exit the formula editor without installing changes.
1974 @kindex C-c C-r
1975 @item C-c C-r
1976 Toggle all references in the formula editor between standard (like
1977 @code{B3}) and internal (like @code{@@3$2}).
1978 @kindex @key{TAB}
1979 @item @key{TAB}
1980 Pretty-print or indent lisp formula at point.  When in a line containing
1981 a lisp formula, format the formula according to Emacs Lisp rules.
1982 Another @key{TAB} collapses the formula back again.  In the open
1983 formula, @key{TAB} re-indents just like in Emacs-lisp-mode.
1984 @kindex M-@key{TAB}
1985 @item M-@key{TAB}
1986 Complete Lisp symbols, just like in Emacs-lisp-mode.
1987 @kindex S-@key{up}
1988 @kindex S-@key{down}
1989 @kindex S-@key{left}
1990 @kindex S-@key{right}
1991 @item S-@key{up}/@key{down}/@key{left}/@key{right}
1992 Shift the reference at point.  For example, if the reference is
1993 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
1994 This also works for relative references, and for hline references.
1995 @kindex M-S-@key{up}
1996 @kindex M-S-@key{down}
1997 @item M-S-@key{up}/@key{down}
1998 Move the test line for column formulas in the Org-mode buffer up and
1999 down.
2000 @kindex M-@key{up}
2001 @kindex M-@key{down}
2002 @item M-@key{up}/@key{down}
2003 Scroll the window displaying the table.
2004 @kindex C-c @}
2005 @item C-c @}
2006 Turn the coordinate grid in the table on and off.
2007 @end table
2008 @end table
2010 Making a table field blank does not remove the formula associated with
2011 the field, because that is stored in a different line (the @samp{TBLFM}
2012 line) - during the next recalculation the field will be filled again.
2013 To remove a formula from a field, you have to give an empty reply when
2014 prompted for the formula, or to edit the @samp{#+TBLFM} line.
2016 @kindex C-c C-c
2017 You may edit the @samp{#+TBLFM} directly and re-apply the changed
2018 equations with @kbd{C-c C-c} in that line, or with the normal
2019 recalculation commands in the table.
2021 @subsubheading Debugging formulas
2022 @cindex formula debugging
2023 @cindex debugging, of table formulas
2024 When the evaluation of a formula leads to an error, the field content
2025 becomes the string @samp{#ERROR}.  If you would like see what is going
2026 on during variable substitution and calculation in order to find a bug,
2027 turn on formula debugging in the @code{Tbl} menu and repeat the
2028 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
2029 field.  Detailed information will be displayed.
2031 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
2032 @subsection Updating the Table
2033 @cindex recomputing table fields
2034 @cindex updating, table
2036 Recalculation of a table is normally not automatic, but needs to be
2037 triggered by a command.  See @ref{Advanced features} for a way to make
2038 recalculation at least semi-automatically.
2040 In order to recalculate a line of a table or the entire table, use the
2041 following commands:
2043 @table @kbd
2044 @kindex C-c *
2045 @item C-c *
2046 Recalculate the current row by first applying the stored column formulas
2047 from left to right, and all field formulas in the current row.
2049 @kindex C-u C-c *
2050 @item C-u C-c *
2051 @kindex C-u C-c C-c
2052 @itemx C-u C-c C-c
2053 Recompute the entire table, line by line.  Any lines before the first
2054 hline are left alone, assuming that these are part of the table header.
2056 @kindex C-u C-u C-c *
2057 @kindex C-u C-u C-c C-c
2058 @item C-u C-u C-c *
2059 @itemx C-u C-u C-c C-c
2060 Iterate the table by recomputing it until no further changes occur.
2061 This may be necessary if some computed fields use the value of other
2062 fields that are computed @i{later} in the calculation sequence.
2063 @end table
2065 @node Advanced features,  , Updating the table, The spreadsheet
2066 @subsection Advanced features
2068 If you want the recalculation of fields to happen automatically, or if
2069 you want to be able to assign @i{names} to fields and columns, you need
2070 to reserve the first column of the table for special marking characters.
2071 @table @kbd
2072 @kindex C-#
2073 @item C-#
2074 Rotate the calculation mark in first column through the states @samp{},
2075 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  The meaning of these characters
2076 is discussed below.  When there is an active region, change all marks in
2077 the region.
2078 @end table
2080 Here is an example of a table that collects exam results of students and
2081 makes use of these features:
2083 @example
2084 @group
2085 |---+---------+--------+--------+--------+-------+------|
2086 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2087 |---+---------+--------+--------+--------+-------+------|
2088 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2089 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2090 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2091 |---+---------+--------+--------+--------+-------+------|
2092 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
2093 | # | Sara    |      6 |     14 |     19 |    39 |  7.8 |
2094 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
2095 |---+---------+--------+--------+--------+-------+------|
2096 |   | Average |        |        |        |  29.7 |      |
2097 | ^ |         |        |        |        |    at |      |
2098 | $ | max=50  |        |        |        |       |      |
2099 |---+---------+--------+--------+--------+-------+------|
2100 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
2101 @end group
2102 @end example
2104 @noindent @b{Important}: Please note that for these special tables,
2105 recalculating the table with @kbd{C-u C-c *} will only affect rows that
2106 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
2107 to the field itself.  The column formulas are not applied in rows with
2108 empty first field.
2110 @cindex marking characters, tables
2111 The marking characters have the following meaning:
2112 @table @samp
2113 @item !
2114 The fields in this line define names for the columns, so that you may
2115 refer to a column as @samp{$Tot} instead of @samp{$6}.
2116 @item ^
2117 This row defines names for the fields @emph{above} the row.  With such
2118 a definition, any formula in the table may use @samp{$m1} to refer to
2119 the value @samp{10}.  Also, if you assign a formula to a names field, it
2120 will be stored as @samp{$name=...}.
2121 @item _
2122 Similar to @samp{^}, but defines names for the fields in the row
2123 @emph{below}.
2124 @item $
2125 Fields in this row can define @emph{parameters} for formulas.  For
2126 example, if a field in a @samp{$} row contains @samp{max=50}, then
2127 formulas in this table can refer to the value 50 using @samp{$max}.
2128 Parameters work exactly like constants, only that they can be defined on
2129 a per-table basis.
2130 @item #
2131 Fields in this row are automatically recalculated when pressing
2132 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
2133 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
2134 lines will be left alone by this command.
2135 @item *
2136 Selects this line for global recalculation with @kbd{C-u C-c *}, but
2137 not for automatic recalculation.  Use this when automatic
2138 recalculation slows down editing too much.
2139 @item
2140 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
2141 All lines that should be recalculated should be marked with @samp{#}
2142 or @samp{*}.
2143 @item /
2144 Do not export this line.  Useful for lines that contain the narrowing
2145 @samp{<N>} markers.
2146 @end table
2148 Finally, just to whet your appetite on what can be done with the
2149 fantastic @file{calc} package, here is a table that computes the Taylor
2150 series of degree @code{n} at location @code{x} for a couple of
2151 functions.
2153 @example
2154 @group
2155 |---+-------------+---+-----+--------------------------------------|
2156 |   | Func        | n | x   | Result                               |
2157 |---+-------------+---+-----+--------------------------------------|
2158 | # | exp(x)      | 1 | x   | 1 + x                                |
2159 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
2160 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
2161 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
2162 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
2163 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
2164 |---+-------------+---+-----+--------------------------------------|
2165 #+TBLFM: $5=taylor($2,$4,$3);n3
2166 @end group
2167 @end example
2169 @node Hyperlinks, TODO items, Tables, Top
2170 @chapter Hyperlinks
2171 @cindex hyperlinks
2173 Like HTML, Org-mode provides links inside a file, external links to
2174 other files, Usenet articles, emails, and much more.
2176 @menu
2177 * Link format::                 How links in Org-mode are formatted
2178 * Internal links::              Links to other places in the current file
2179 * External links::              URL-like links to the world
2180 * Handling links::              Creating, inserting and following
2181 * Using links outside Org-mode::  Linking from my C source code?
2182 * Link abbreviations::          Shortcuts for writing complex links
2183 * Search options::              Linking to a specific location
2184 * Custom searches::             When the default search is not enough
2185 @end menu
2187 @node Link format, Internal links, Hyperlinks, Hyperlinks
2188 @section Link format
2189 @cindex link format
2190 @cindex format, of links
2192 Org-mode will recognize plain URL-like links and activate them as
2193 clickable links.  The general link format, however, looks like this:
2195 @example
2196 [[link][description]]       @r{or alternatively}           [[link]]
2197 @end example
2199 Once a link in the buffer is complete (all brackets present), Org-mode
2200 will change the display so that @samp{description} is displayed instead
2201 of @samp{[[link][description]]} and @samp{link} is displayed instead of
2202 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
2203 which by default is an underlined face.  You can directly edit the
2204 visible part of a link.  Note that this can be either the @samp{link}
2205 part (if there is no description) or the @samp{description} part.  To
2206 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
2207 cursor on the link.
2209 If you place the cursor at the beginning or just behind the end of the
2210 displayed text and press @key{BACKSPACE}, you will remove the
2211 (invisible) bracket at that location.  This makes the link incomplete
2212 and the internals are again displayed as plain text.  Inserting the
2213 missing bracket hides the link internals again.  To show the
2214 internal structure of all links, use the menu entry
2215 @code{Org->Hyperlinks->Literal links}.
2217 @node Internal links, External links, Link format, Hyperlinks
2218 @section Internal links
2219 @cindex internal links
2220 @cindex links, internal
2221 @cindex targets, for links
2223 If the link does not look like a URL, it is considered to be internal in
2224 the current file.  Links such as @samp{[[My Target]]} or @samp{[[My
2225 Target][Find my target]]} lead to a text search in the current file.
2226 The link can be followed with @kbd{C-c C-o} when the cursor is on the
2227 link, or with a mouse click (@pxref{Handling links}).  The preferred
2228 match for such a link is a dedicated target: the same string in double
2229 angular brackets.  Targets may be located anywhere; sometimes it is
2230 convenient to put them into a comment line. For example
2232 @example
2233 # <<My Target>>
2234 @end example
2236 @noindent In HTML export (@pxref{HTML export}), such targets will become
2237 named anchors for direct access through @samp{http} links@footnote{Note
2238 that text before the first headline is usually not exported, so the
2239 first such target should be after the first headline.}.
2241 If no dedicated target exists, Org-mode will search for the words in the
2242 link.  In the above example the search would be for @samp{my target}.
2243 Links starting with a star like @samp{*My Target} restrict the search to
2244 headlines.  When searching, Org-mode will first try an exact match, but
2245 then move on to more and more lenient searches.  For example, the link
2246 @samp{[[*My Targets]]} will find any of the following:
2248 @example
2249 ** My targets
2250 ** TODO my targets are bright
2251 ** my 20 targets are
2252 @end example
2254 To insert a link targeting a headline, in-buffer completion can be used.
2255 Just type a star followed by a few optional letters into the buffer and
2256 press @kbd{M-@key{TAB}}.  All headlines in the current buffer will be
2257 offered as completions.  @xref{Handling links}, for more commands
2258 creating links.
2260 Following a link pushes a mark onto Org-mode's own mark ring.  You can
2261 return to the previous position with @kbd{C-c &}.  Using this command
2262 several times in direct succession goes back to positions recorded
2263 earlier.
2265 @menu
2266 * Radio targets::               Make targets trigger links in plain text.
2267 @end menu
2269 @node Radio targets,  , Internal links, Internal links
2270 @subsection Radio targets
2271 @cindex radio targets
2272 @cindex targets, radio
2273 @cindex links, radio targets
2275 Org-mode can automatically turn any occurrences of certain target names
2276 in normal text into a link.  So without explicitly creating a link, the
2277 text connects to the target radioing its position.  Radio targets are
2278 enclosed by triple angular brackets.  For example, a target @samp{<<<My
2279 Target>>>} causes each occurrence of @samp{my target} in normal text to
2280 become activated as a link.  The Org-mode file is scanned automatically
2281 for radio targets only when the file is first loaded into Emacs.  To
2282 update the target list during editing, press @kbd{C-c C-c} with the
2283 cursor on or at a target.
2285 @node External links, Handling links, Internal links, Hyperlinks
2286 @section External links
2287 @cindex links, external
2288 @cindex external links
2289 @cindex links, external
2290 @cindex Gnus links
2291 @cindex BBDB links
2292 @cindex IRC links
2293 @cindex URL links
2294 @cindex file links
2295 @cindex VM links
2296 @cindex RMAIL links
2297 @cindex WANDERLUST links
2298 @cindex MH-E links
2299 @cindex USENET links
2300 @cindex SHELL links
2301 @cindex Info links
2302 @cindex elisp links
2304 Org-mode supports links to files, websites, Usenet and email messages,
2305 BBDB database entries and links to both IRC conversations and their
2306 logs.  External links are URL-like locators.  They start with a short
2307 identifying string followed by a colon.  There can be no space after
2308 the colon.  The following list shows examples for each link type.
2310 @example
2311 http://www.astro.uva.nl/~dominik          @r{on the web}
2312 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
2313 file:papers/last.pdf                      @r{file, relative path}
2314 news:comp.emacs                           @r{Usenet link}
2315 mailto:adent@@galaxy.net                  @r{Mail link}
2316 vm:folder                                 @r{VM folder link}
2317 vm:folder#id                              @r{VM message link}
2318 vm://myself@@some.where.org/folder#id     @r{VM on remote machine}
2319 wl:folder                                 @r{WANDERLUST folder link}
2320 wl:folder#id                              @r{WANDERLUST message link}
2321 mhe:folder                                @r{MH-E folder link}
2322 mhe:folder#id                             @r{MH-E message link}
2323 rmail:folder                              @r{RMAIL folder link}
2324 rmail:folder#id                           @r{RMAIL message link}
2325 gnus:group                                @r{Gnus group link}
2326 gnus:group#id                             @r{Gnus article link}
2327 bbdb:Richard Stallman                     @r{BBDB link}
2328 irc:/irc.com/#emacs/bob                   @r{IRC link}
2329 shell:ls *.org                            @r{A shell command}
2330 elisp:(find-file-other-frame "Elisp.org") @r{An elisp form to evaluate}
2331 @end example
2333 A link should be enclosed in double brackets and may contain a
2334 descriptive text to be displayed instead of the URL (@pxref{Link
2335 format}), for example:
2337 @example
2338 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
2339 @end example
2341 @noindent
2342 If the description is a file name or URL that points to an image, HTML
2343 export (@pxref{HTML export}) will inline the image as a clickable
2344 button.  If there is no description at all and the link points to an
2345 image,
2346 that image will be inlined into the exported HTML file.
2348 @cindex angular brackets, around links
2349 @cindex plain text external links
2350 Org-mode also finds external links in the normal text and activates them
2351 as links.  If spaces must be part of the link (for example in
2352 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
2353 about the end of the link, enclose them in angular brackets.
2355 @node Handling links, Using links outside Org-mode, External links, Hyperlinks
2356 @section Handling links
2357 @cindex links, handling
2359 Org-mode provides methods to create a link in the correct syntax, to
2360 insert it into an org-mode file, and to follow the link.
2362 @table @kbd
2363 @kindex C-c l
2364 @cindex storing links
2365 @item C-c l
2366 Store a link to the current location.  This is a @emph{global} command
2367 which can be used in any buffer to create a link.  The link will be
2368 stored for later insertion into an Org-mode buffer (see below).  For
2369 Org-mode files, if there is a @samp{<<target>>} at the cursor, the
2370 link points to the target.  Otherwise it points to the current
2371 headline.  For VM, Rmail, Wanderlust, MH-E, Gnus and BBDB buffers, the
2372 link will indicate the current article/entry.  For W3 and W3M buffers,
2373 the link goes to the current URL.  For IRC links, if you set the
2374 variable @code{org-irc-link-to-logs} to non-nil then @kbd{C-c l} will
2375 store a @samp{file:/} style link to the relevant point in the logs for
2376 the current conversation. Otherwise an @samp{irc:/} style link to the
2377 user/channel/server under the point will be stored.  For any other
2378 files, the link will point to the file, with a search string
2379 (@pxref{Search options}) pointing to the contents of the current line.
2380 If there is an active region, the selected words will form the basis
2381 of the search string.  If the automatically created link is not
2382 working correctly or accurately enough, you can write custom functions
2383 to select the search string and to do the search for particular file
2384 types - see @ref{Custom searches}.  The key binding @kbd{C-c l} is
2385 only a suggestion - see @ref{Installation}.
2387 @kindex C-c C-l
2388 @cindex link completion
2389 @cindex completion, of links
2390 @cindex inserting links
2391 @item C-c C-l
2392 Insert a link.  This prompts for a link to be inserted into the buffer.  You
2393 can just type a link, using text for an internal link, or one of the link
2394 type prefixes mentioned in the examples above.  All links stored during the
2395 current session are part of the history for this prompt, so you can access
2396 them with @key{up} and @key{down} (or @kbd{M-p/n}).  Completion, on the other
2397 hand, will help you to insert valid link prefixes like @samp{http:} or
2398 @samp{ftp:}, including the prefixes defined through link abbreviations
2399 (@pxref{Link abbreviations}).  The link will be inserted into the
2400 buffer@footnote{After insertion of a stored link, the link will be removed
2401 from the list of stored links.  To keep it in the list later use, use a
2402 triple @kbd{C-u} prefix argument to @kbd{C-c C-l}, or configure the option
2403 @code{org-keep-stored-link-after-insertion}.}, along with a descriptive text.
2404 If some text was selected when this command is called, the selected text
2405 becomes the default description.@* Note that you don't have to use this
2406 command to insert a link.  Links in Org-mode are plain text, and you can type
2407 or paste them straight into the buffer.  By using this command, the links are
2408 automatically enclosed in double brackets, and you will be asked for the
2409 optional descriptive text.
2411 @c  If the link is a @samp{file:} link and
2412 @c the linked file is located in the same directory as the current file or
2413 @c a subdirectory of it, the path of the file will be inserted relative to
2414 @c the current directory.
2416 @kindex C-u C-c C-l
2417 @cindex file name completion
2418 @cindex completion, of file names
2419 @item C-u C-c C-l
2420 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
2421 a file will be inserted and you may use file name completion to select
2422 the name of the file.  The path to the file is inserted relative to the
2423 directory of the current org file, if the linked file is in the current
2424 directory or in a sub-directory of it, or if the path is written relative
2425 to the current directory using @samp{../}.  Otherwise an absolute path
2426 is used, if possible with @samp{~/} for your home directory.  You can
2427 force an absolute path with two @kbd{C-u} prefixes.
2429 @item C-c C-l @r{(with cursor on existing link)}
2430 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
2431 link and description parts of the link.
2433 @cindex following links
2434 @kindex C-c C-o
2435 @item C-c C-o
2436 Open link at point.  This will launch a web browser for URLs (using
2437 @command{browse-url-at-point}), run VM/MH-E/Wanderlust/Rmail/Gnus/BBDB
2438 for the corresponding links, and execute the command in a shell link.
2439 When the cursor is on an internal link, this commands runs the
2440 corresponding search.  When the cursor is on a TAG list in a headline,
2441 it creates the corresponding TAGS view.  If the cursor is on a time
2442 stamp, it compiles the agenda for that date.  Furthermore, it will visit
2443 text and remote files in @samp{file:} links with Emacs and select a
2444 suitable application for local non-text files.  Classification of files
2445 is based on file extension only.  See option @code{org-file-apps}.  If
2446 you want to override the default application and visit the file with
2447 Emacs, use a @kbd{C-u} prefix.
2449 @kindex mouse-2
2450 @kindex mouse-1
2451 @item mouse-2
2452 @itemx mouse-1
2453 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
2454 would.  Under Emacs 22, also @kbd{mouse-1} will follow a link.
2456 @kindex mouse-3
2457 @item mouse-3
2458 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
2459 internal links to be displayed in another window@footnote{See the
2460 variable @code{org-display-internal-link-with-indirect-buffer}}.
2462 @cindex mark ring
2463 @kindex C-c %
2464 @item C-c %
2465 Push the current position onto the mark ring, to be able to return
2466 easily. Commands following an internal link do this automatically.
2468 @cindex links, returning to
2469 @kindex C-c &
2470 @item C-c &
2471 Jump back to a recorded position.  A position is recorded by the
2472 commands following internal links, and by @kbd{C-c %}.  Using this
2473 command several times in direct succession moves through a ring of
2474 previously recorded positions.
2476 @kindex C-c C-x C-n
2477 @kindex C-c C-x C-p
2478 @cindex links, finding next/previous
2479 @item C-c C-x C-n
2480 @itemx C-c C-x C-p
2481 Move forward/backward to the next link in the buffer.  At the limit of
2482 the buffer, the search fails once, and then wraps around.  The key
2483 bindings for this are really too long, you might want to bind this also
2484 to @kbd{C-n} and @kbd{C-p}
2485 @lisp
2486 (add-hook 'org-load-hook
2487   (lambda ()
2488     (define-key 'org-mode-map "\C-n" 'org-next-link)
2489     (define-key 'org-mode-map "\C-p" 'org-previous-link)))
2490 @end lisp
2491 @end table
2493 @node Using links outside Org-mode, Link abbreviations, Handling links, Hyperlinks
2494 @section Using links outside Org-mode
2496 You can insert and follow links that have Org-mode syntax not only in
2497 Org-mode, but in any Emacs buffer.  For this, you should create two
2498 global commands, like this (please select suitable global keys
2499 yourself):
2501 @lisp
2502 (global-set-key "\C-c L" 'org-insert-link-global)
2503 (global-set-key "\C-c o" 'org-open-at-point-global)
2504 @end lisp
2506 @node Link abbreviations, Search options, Using links outside Org-mode, Hyperlinks
2507 @section Link abbreviations
2508 @cindex link abbreviations
2509 @cindex abbreviation, links
2511 Long URLs can be cumbersome to type, and often many similar links are
2512 needed in a document.  For this you can use link abbreviations.  An
2513 abbreviated link looks like this
2515 @example
2516 [[linkword:tag][description]]
2517 @end example
2519 @noindent
2520 where the tag is optional.  Such abbreviations are resolved according to
2521 the information in the variable @code{org-link-abbrev-alist} that
2522 relates the linkwords to replacement text.  Here is an example:
2524 @lisp
2525 @group
2526 (setq org-link-abbrev-alist
2527   '(("bugzilla" . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
2528     ("google"   . "http://www.google.com/search?q=")
2529     ("ads"      . "http://adsabs.harvard.edu/cgi-bin/
2530                    nph-abs_connect?author=%s&db_key=AST")))
2531 @end group
2532 @end lisp
2534 If the replacement text contains the string @samp{%s}, it will be
2535 replaced with the tag.  Otherwise the tag will be appended to the string
2536 in order to create the link.  You may also specify a function that will
2537 be called with the tag as the only argument to create the link.
2539 With the above setting, you could link to a specific bug with
2540 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
2541 @code{[[google:OrgMode]]} and find out what the Org-mode author is
2542 doing besides Emacs hacking with @code{[[ads:Dominik,C]]}.
2544 If you need special abbreviations just for a single Org-mode buffer, you
2545 can define them in the file with
2547 @example
2548 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
2549 #+LINK: google    http://www.google.com/search?q=%s
2550 @end example
2552 @noindent
2553 In-buffer completion @pxref{Completion} can be used after @samp{[} to
2554 complete link abbreviations.
2556 @node Search options, Custom searches, Link abbreviations, Hyperlinks
2557 @section Search options in file links
2558 @cindex search option in file links
2559 @cindex file links, searching
2561 File links can contain additional information to make Emacs jump to a
2562 particular location in the file when following a link.  This can be a
2563 line number or a search option after a double@footnote{For backward
2564 compatibility, line numbers can also follow a single colon.} colon. For
2565 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
2566 links}) to a file, it encodes the words in the current line as a search
2567 string that can be used to find this line back later when following the
2568 link with @kbd{C-c C-o}.
2570 Here is the syntax of the different ways to attach a search to a file
2571 link, together with an explanation:
2573 @example
2574 [[file:~/code/main.c::255]]
2575 [[file:~/xx.org::My Target]]
2576 [[file:~/xx.org::*My Target]]
2577 [[file:~/xx.org::/regexp/]]
2578 @end example
2580 @table @code
2581 @item 255
2582 Jump to line 255.
2583 @item My Target
2584 Search for a link target @samp{<<My Target>>}, or do a text search for
2585 @samp{my target}, similar to the search in internal links, see
2586 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
2587 link will become an HTML reference to the corresponding named anchor in
2588 the linked file.
2589 @item *My Target
2590 In an Org-mode file, restrict search to headlines.
2591 @item /regexp/
2592 Do a regular expression search for @code{regexp}.  This uses the Emacs
2593 command @code{occur} to list all matches in a separate window.  If the
2594 target file is in Org-mode, @code{org-occur} is used to create a
2595 sparse tree with the matches.
2596 @c If the target file is a directory,
2597 @c @code{grep} will be used to search all files in the directory.
2598 @end table
2600 As a degenerate case, a file link with an empty file name can be used
2601 to search the current file.  For example, @code{[[file:::find me]]} does
2602 a search for @samp{find me} in the current file, just as
2603 @samp{[[find me]]} would.
2605 @node Custom searches,  , Search options, Hyperlinks
2606 @section Custom Searches
2607 @cindex custom search strings
2608 @cindex search strings, custom
2610 The default mechanism for creating search strings and for doing the
2611 actual search related to a file link may not work correctly in all
2612 cases.  For example, BibTeX database files have many entries like
2613 @samp{year="1993"} which would not result in good search strings,
2614 because the only unique identification for a BibTeX entry is the
2615 citation key.
2617 If you come across such a problem, you can write custom functions to set
2618 the right search string for a particular file type, and to do the search
2619 for the string in the file.  Using @code{add-hook}, these functions need
2620 to be added to the hook variables
2621 @code{org-create-file-search-functions} and
2622 @code{org-execute-file-search-functions}.  See the docstring for these
2623 variables for more information.  Org-mode actually uses this mechanism
2624 for Bib@TeX{} database files, and you can use the corresponding code as
2625 an implementation example.  Search for @samp{BibTeX links} in the source
2626 file.
2630 @node TODO items, Tags, Hyperlinks, Top
2631 @chapter TODO items
2632 @cindex TODO items
2634 Org-mode does not maintain TODO lists as separate documents.  Instead,
2635 TODO items are an integral part of the notes file, because TODO items
2636 usually come up while taking notes!  With Org-mode, simply mark any
2637 entry in a tree as being a TODO item.  In this way, information is not
2638 duplicated, and the entire context from which the TODO item emerged is
2639 always present.
2641 Of course, this technique for managing TODO items scatters them
2642 throughout your notes file.  Org-mode compensates for this by providing
2643 methods to give you an overview of all the things that you have to do.
2645 @menu
2646 * TODO basics::                 Marking and displaying TODO entries
2647 * TODO extensions::             Workflow and assignments
2648 * Progress logging::            Dates and notes for progress
2649 * Priorities::                  Some things are more important than others
2650 * Breaking down tasks::         Splitting a task into manageable pieces
2651 * Checkboxes::                  Tick-off lists
2652 @end menu
2654 @node TODO basics, TODO extensions, TODO items, TODO items
2655 @section Basic TODO functionality
2657 Any headline becomes a TODO item when it starts with the word
2658 @samp{TODO}, for example:
2660 @example
2661 *** TODO Write letter to Sam Fortune
2662 @end example
2664 @noindent
2665 The most important commands to work with TODO entries are:
2667 @table @kbd
2668 @kindex C-c C-t
2669 @cindex cycling, of TODO states
2670 @item C-c C-t
2671 Rotate the TODO state of the current item among
2673 @example
2674 ,-> (unmarked) -> TODO -> DONE --.
2675 '--------------------------------'
2676 @end example
2678 The same rotation can also be done ``remotely'' from the timeline and
2679 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
2681 @kindex C-u C-c C-t
2682 @item C-u C-c C-t
2683 Select a specific keyword using completion or (if it has been set up)
2684 the fast selection interface.  For the latter, you need to assign keys
2685 to TODO states, see @ref{Per-file keywords} and @ref{Setting tags} for
2686 more information.
2688 @kindex S-@key{right}
2689 @kindex S-@key{left}
2690 @item S-@key{right}
2691 @itemx S-@key{left}
2692 Select the following/preceding TODO state, similar to cycling.  Useful
2693 mostly if more than two TODO states are possible (@pxref{TODO
2694 extensions}).
2695 @kindex C-c C-v
2696 @kindex C-c / t
2697 @cindex sparse tree, for TODO
2698 @item C-c C-v
2699 @itemx C-c / t
2700 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds
2701 the entire buffer, but shows all TODO items and the headings hierarchy
2702 above them.  With a prefix argument, search for a specific TODO.  You will be
2703 prompted for the keyword, and you can also give a list of keywords like
2704 @code{KWD1|KWD2|...}.  With numeric prefix argument N, show the tree for the
2705 Nth keyword in the variable @code{org-todo-keywords}.  With two prefix
2706 arguments, find all TODO and DONE entries.
2707 @kindex C-c a t
2708 @item C-c a t
2709 Show the global TODO list.  Collects the TODO items from all agenda
2710 files (@pxref{Agenda views}) into a single buffer.  The new buffer will
2711 be in @code{agenda-mode}, which provides commands to examine and
2712 manipulate the TODO entries from the new buffer (@pxref{Agenda
2713 commands}).  @xref{Global TODO list}, for more information.
2714 @kindex S-M-@key{RET}
2715 @item S-M-@key{RET}
2716 Insert a new TODO entry below the current one.
2717 @end table
2719 @node TODO extensions, Progress logging, TODO basics, TODO items
2720 @section Extended use of TODO keywords
2721 @cindex extended TODO keywords
2723 By default, marked TODO entries have one of only two states: TODO and
2724 DONE.  Org-mode allows you to classify TODO items in more complex ways
2725 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With
2726 special setup, the TODO keyword system can work differently in different
2727 files.
2729 Note that @i{tags} are another way to classify headlines in general and
2730 TODO items in particular (@pxref{Tags}).
2732 @menu
2733 * Workflow states::             From TODO to DONE in steps
2734 * TODO types::                  I do this, Fred does the rest
2735 * Multiple sets in one file::   Mixing it all, and still finding your way
2736 * Fast access to TODO states::  Single letter selection of a state
2737 * Per-file keywords::           Different files, different requirements
2738 * Faces for TODO keywords::     Highlighting states
2739 @end menu
2741 @node Workflow states, TODO types, TODO extensions, TODO extensions
2742 @subsection TODO keywords as workflow states
2743 @cindex TODO workflow
2744 @cindex workflow states as TODO keywords
2746 You can use TODO keywords to indicate different @emph{sequential} states
2747 in the process of working on an item, for example@footnote{Changing
2748 this variable only becomes effective after restarting Org-mode in a
2749 buffer.}:
2751 @lisp
2752 (setq org-todo-keywords
2753   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
2754 @end lisp
2756 The vertical bar separates the TODO keywords (states that @emph{need
2757 action}) from the DONE states (which need @emph{no further action}.  If
2758 you don't provide the separator bar, the last state is used as the DONE
2759 state.
2760 @cindex completion, of TODO keywords
2761 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
2762 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED.  You may
2763 also use a numeric prefix argument to quickly select a specific state.  For
2764 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY.
2765 Or you can use @kbd{S-left} to go backward through the sequence.  If you
2766 define many keywords, you can use in-buffer completion
2767 (@pxref{Completion}) or even a special one-key selection scheme
2768 (@pxref{Fast access to TODO states}) to insert these words into the
2769 buffer.  Changing a TODO state can be logged with a timestamp, see
2770 @ref{Tracking TODO state changes} for more information.
2772 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
2773 @subsection TODO keywords as types
2774 @cindex TODO types
2775 @cindex names as TODO keywords
2776 @cindex types as TODO keywords
2778 The second possibility is to use TODO keywords to indicate different
2779 @emph{types} of action items.  For example, you might want to indicate
2780 that items are for ``work'' or ``home''.  Or, when you work with several
2781 people on a single project, you might want to assign action items
2782 directly to persons, by using their names as TODO keywords.  This would
2783 be set up like this:
2785 @lisp
2786 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
2787 @end lisp
2789 In this case, different keywords do not indicate a sequence, but rather
2790 different types.  So the normal work flow would be to assign a task to a
2791 person, and later to mark it DONE.  Org-mode supports this style by adapting
2792 the workings of the command @kbd{C-c C-t}@footnote{This is also true for the
2793 @kbd{t} command in the timeline and agenda buffers.}.  When used several
2794 times in succession, it will still cycle through all names, in order to first
2795 select the right type for a task.  But when you return to the item after some
2796 time and execute @kbd{C-c C-t} again, it will switch from any name directly
2797 to DONE.  Use prefix arguments or completion to quickly select a specific
2798 name.  You can also review the items of a specific TODO type in a sparse tree
2799 by using a numeric prefix to @kbd{C-c C-v}.  For example, to see all things
2800 Lucy has to do, you would use @kbd{C-3 C-c C-v}.  To collect Lucy's items
2801 from all agenda files into a single buffer, you would use the numeric prefix
2802 argument as well when creating the global TODO list: @kbd{C-3 C-c t}.
2804 @node Multiple sets in one file, Fast access to TODO states, TODO types, TODO extensions
2805 @subsection Multiple keyword sets in one file
2806 @cindex TODO keyword sets
2808 Sometimes you may want to use different sets of TODO keywords in
2809 parallel.  For example, you may want to have the basic
2810 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
2811 separate state indicating that an item has been canceled (so it is not
2812 DONE, but also does not require action).  Your setup would then look
2813 like this:
2815 @lisp
2816 (setq org-todo-keywords
2817       '((sequence "TODO" "|" "DONE")
2818         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
2819         (sequence "|" "CANCELED")))
2820 @end lisp
2822 The keywords should all be different, this helps Org-mode to keep track
2823 of which subsequence should be used for a given entry.  In this setup,
2824 @kbd{C-c C-t} only operates within a subsequence, so it switches from
2825 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
2826 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
2827 select the correct sequence.  Besides the obvious ways like typing a
2828 keyword or using completion, you may also apply the following commands:
2830 @table @kbd
2831 @kindex C-S-@key{right}
2832 @kindex C-S-@key{left}
2833 @item C-S-@key{right}
2834 @itemx C-S-@key{left}
2835 These keys jump from one TODO subset to the next.  In the above example,
2836 @kbd{C-S-@key{right}} would jump from @code{TODO} or @code{DONE} to
2837 @code{REPORT}, and any of the words in the second row to @code{CANCELED}.
2838 @kindex S-@key{right}
2839 @kindex S-@key{left}
2840 @item S-@key{right}
2841 @itemx S-@key{left}
2842 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through
2843 @emph{all} keywords from all sets, so for example @kbd{S-@key{<right>}}
2844 would switch from @code{DONE} to @code{REPORT} in the example above.
2845 @end table
2847 @node Fast access to TODO states, Per-file keywords, Multiple sets in one file, TODO extensions
2848 @subsection Fast access to TODO states
2850 If you would like to quickly change an entry to an arbitrary TODO state
2851 instead of cycling through the states, you can set up keys for
2852 single-letter access to the states.  This is done by adding the section
2853 key after each keyword, in parenthesis.  For example:
2855 @lisp
2856 (setq org-todo-keywords
2857       '((sequence "TODO(t)" "|" "DONE(d)")
2858         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
2859         (sequence "|" "CANCELED(c)")))
2860 @end lisp
2862 If you then press @code{C-u C-c C-t} followed by the selection key, the
2863 entry will be switched to this state.  @key{SPC} can be used to remove
2864 any TODO keyword from an entry.  Should you like this way of selecting
2865 TODO states a lot, you might want to set the variable
2866 @code{org-use-fast-todo-selection} to @code{t} and make this behavior
2867 the default.  Check also the variable
2868 @code{org-fast-tag-selection-include-todo}, it allows to change the TODO
2869 state through the tags interface (@pxref{Setting tags}), in case you
2870 like to mingle the two concepts.
2872 @node Per-file keywords, Faces for TODO keywords, Fast access to TODO states, TODO extensions
2873 @subsection Setting up keywords for individual files
2874 @cindex keyword options
2875 @cindex per-file keywords
2877 It can be very useful to use different aspects of the TODO mechanism in
2878 different files.  For file-local settings, you need to add special lines
2879 to the file which set the keywords and interpretation for that file
2880 only.  For example, to set one of the two examples discussed above, you
2881 need one of the following lines, starting in column zero anywhere in the
2882 file:
2884 @example
2885 #+SEQ_TODO: TODO FEEDBACK VERIFY | DONE CANCELED
2886 @end example
2888 @example
2889 #+TYP_TODO: Fred Sara Lucy Mike | DONE
2890 @end example
2892 A setup for using several sets in parallel would be:
2894 @example
2895 #+SEQ_TODO: TODO | DONE
2896 #+SEQ_TODO: REPORT BUG KNOWNCAUSE | FIXED
2897 #+SEQ_TODO: | CANCELED
2898 @end example
2900 @cindex completion, of option keywords
2901 @kindex M-@key{TAB}
2902 @noindent To make sure you are using the correct keyword, type
2903 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
2905 @cindex DONE, final TODO keyword
2906 Remember that the keywords after the vertical bar (or the last keyword
2907 if no bar is there) must always mean that the item is DONE (although you
2908 may use a different word).  After changing one of these lines, use
2909 @kbd{C-c C-c} with the cursor still in the line to make the changes
2910 known to Org-mode@footnote{Org-mode parses these lines only when
2911 Org-mode is activated after visiting a file.  @kbd{C-c C-c} with the
2912 cursor in a line starting with @samp{#+} is simply restarting Org-mode
2913 for the current buffer.}.
2915 @node Faces for TODO keywords,  , Per-file keywords, TODO extensions
2916 @subsection Faces for TODO keywords
2917 @cindex faces, for TODO keywords
2919 Org-mode highlights TODO keywords with special faces: @code{org-todo}
2920 for keywords indicating that an item still has to be acted upon, and
2921 @code{org-done} for keywords indicating that an item is finished.  If
2922 you are using more than 2 different states, you might want to use
2923 special faces for some of them.  This can be done using the variable
2924 @code{org-todo-keyword-faces}.  For example:
2926 @lisp
2927 (setq org-todo-keyword-faces
2928       '(("TODO"      . org-warning)
2929         ("DEFERRED"  . shadow)
2930         ("CANCELED"  . (:foreground "blue" :weight bold))))
2931 @end lisp
2933 While using a list with face properties as shown for CANCELED
2934 @emph{should} work, this does not aways seem to be the case.  If
2935 necessary, define a special face and use that.
2937 @page
2938 @node Progress logging, Priorities, TODO extensions, TODO items
2939 @section Progress Logging
2940 @cindex progress logging
2941 @cindex logging, of progress
2943 Org-mode can automatically record a time stamp and possibly a note when
2944 you mark a TODO item as DONE, or even each time you change the state of
2945 a TODO item.  This system is highly configurable, settings can be on a
2946 per-keyword basis and can be localized to a file or even a subtree.  For
2947 information on how to clock working time for a task, see @ref{Clocking
2948 work time}.
2950 @menu
2951 * Closing items::               When was this entry marked DONE?
2952 * Tracking TODO state changes::  When did the status change?
2953 @end menu
2955 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
2956 @subsection Closing items
2958 The most basic logging is to keep track of @emph{when} a certain TODO
2959 item was finished.  This is achieved with@footnote{The corresponding
2960 in-buffer setting is: @code{#+STARTUP: logdone}}.
2962 @lisp
2963 (setq org-log-done 'time)
2964 @end lisp
2966 @noindent
2967 Then each time you turn an entry from a TODO (not-done) state into any
2968 of the DONE states, a line @samp{CLOSED: [timestamp]} will be inserted
2969 just after the headline.  If you turn the entry back into a TODO item
2970 through further state cycling, that line will be removed again.  If you
2971 want to record a note along with the timestamp, use@footnote{The
2972 corresponding in-buffer setting is: @code{#+STARTUP: lognotedone}}
2974 @lisp
2975 (setq org-log-done 'note)
2976 @end lisp
2978 @noindent
2979 You will then be prompted for a note, and that note will be stored below
2980 the entry with a @samp{Closing Note} heading.
2982 In the timeline (@pxref{Timeline}) and in the agenda
2983 (@pxref{Weekly/Daily agenda}), you can then use the @kbd{l} key to
2984 display the TODO items with a @samp{CLOSED} timestamp on each day,
2985 giving you an overview of what has been done.
2987 @node Tracking TODO state changes,  , Closing items, Progress logging
2988 @subsection Tracking TODO state changes
2990 When TODO keywords are used as workflow states (@pxref{Workflow
2991 states}), you might want to keep track of when a state change occurred
2992 and maybe take a note about this change.  Since it is normally too much
2993 to record a note for every state, Org-mode expects configuration on a
2994 per-keyword basis for this.  This is achieved by adding special markers
2995 @samp{!} (for a time stamp) and @samp{@@} (for a note) in parenthesis
2996 after each keyword.  For example, with the setting
2998 @lisp
2999 (setq org-todo-keywords
3000   '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
3001 @end lisp
3003 @noindent
3004 you not only define global TODO keywords and fast access keys, but also
3005 request that a time is recorded when the entry is turned into
3006 DONE@footnote{It is possible that Org-mode will record two time stamps
3007 when you are using both @code{org-log-done} and state change logging.
3008 However, it will never prompt for two notes - if you have configured
3009 both, the state change recording note will take precedence and cancel
3010 the @samp{Closing Note}.}, and that a note is recorded when switching to
3011 WAIT or CANCELED.  The setting for WAIT is even more special: The
3012 @samp{!} after the slash means that in addition to the note taken when
3013 entering the state, a time stamp should be recorded when @i{leaving} the
3014 WAIT state, if and only if the @i{target} state does not configure
3015 logging for entering it.  So it has no effect when switching from WAIT
3016 to DONE, because DONE is configured to record a timestamp only.  But
3017 when switching from WAIT back to TODO, the @samp{/!} in the WAIT
3018 setting now triggers a timestamp even though TODO has no logging
3019 configured.
3021 You can use the exact same syntax for setting logging preferences local
3022 to a buffer:
3023 @example
3024 #+SEQ_TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
3025 @end example
3027 In order to define logging settings that are local to a subtree or a
3028 single item, define a LOGGING property in this entry.  Any non-empty
3029 LOGGING property resets all logging settings to nil.  You may then turn
3030 on logging for this specific tree using STARTUP keywords like
3031 @code{lognotedone} or @code{logrepeat}, as well as adding state specific
3032 settings like @code{TODO(!)}.  For example
3034 @example
3035 * TODO Log each state with only a time
3036   :PROPERTIES:
3037   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
3038   :END:
3039 * TODO Only log when switching to WAIT, and when repeating
3040   :PROPERTIES:
3041   :LOGGING: WAIT(@@) logrepeat
3042   :END:
3043 * TODO No logging at all
3044   :PROPERTIES:
3045   :LOGGING: nil
3046   :END:
3047 @end example
3050 @node Priorities, Breaking down tasks, Progress logging, TODO items
3051 @section Priorities
3052 @cindex priorities
3054 If you use Org-mode extensively, you may end up enough TODO items that
3055 it starts to make sense to prioritize them.  Prioritizing can be done by
3056 placing a @emph{priority cookie} into the headline of a TODO item, like
3057 this
3059 @example
3060 *** TODO [#A] Write letter to Sam Fortune
3061 @end example
3063 @noindent
3064 By default, Org-mode supports three priorities: @samp{A}, @samp{B}, and
3065 @samp{C}.  @samp{A} is the highest priority.  An entry without a cookie
3066 is treated as priority @samp{B}.  Priorities make a difference only in
3067 the agenda (@pxref{Weekly/Daily agenda}); outside the agenda, they have
3068 no inherent meaning to Org-mode.
3070 Priorities can be attached to any outline tree entries; they do not need
3071 to be TODO items.
3073 @table @kbd
3074 @kindex @kbd{C-c ,}
3075 @item @kbd{C-c ,}
3076 Set the priority of the current headline.  The command prompts for a
3077 priority character @samp{A}, @samp{B} or @samp{C}.  When you press
3078 @key{SPC} instead, the priority cookie is removed from the headline.
3079 The priorities can also be changed ``remotely'' from the timeline and
3080 agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
3082 @kindex S-@key{up}
3083 @kindex S-@key{down}
3084 @item S-@key{up}
3085 @itemx S-@key{down}
3086 Increase/decrease priority of current headline@footnote{See also the
3087 option @code{org-priority-start-cycle-with-default'}.}.  Note that these
3088 keys are also used to modify time stamps (@pxref{Creating timestamps}).
3089 Furthermore, these keys are also used by CUA-mode (@pxref{Conflicts}).
3090 @end table
3092 You can change the range of allowed priorities by setting the variables
3093 @code{org-highest-priority}, @code{org-lowest-priority}, and
3094 @code{org-default-priority}.  For an individual buffer, you may set
3095 these values (highest, lowest, default) like this (please make sure that
3096 the highest priority is earlier in the alphabet than the lowest
3097 priority):
3099 @example
3100 #+PRIORITIES: A C B
3101 @end example
3103 @node Breaking down tasks, Checkboxes, Priorities, TODO items
3104 @section Breaking tasks down into subtasks
3105 @cindex tasks, breaking down
3107 It is often advisable to break down large tasks into smaller, manageable
3108 subtasks.  You can do this by creating an outline tree below a TODO
3109 item, with detailed subtasks on the tree@footnote{To keep subtasks out
3110 of the global TODO list, see the
3111 @code{org-agenda-todo-list-sublevels}.}.  Another possibility is the use
3112 of checkboxes to identify (a hierarchy of) a large number of subtasks
3113 (@pxref{Checkboxes}).
3116 @node Checkboxes,  , Breaking down tasks, TODO items
3117 @section Checkboxes
3118 @cindex checkboxes
3120 Every item in a plain list (@pxref{Plain lists}) can be made into a
3121 checkbox by starting it with the string @samp{[ ]}.  This feature is
3122 similar to TODO items (@pxref{TODO items}), but is more lightweight.
3123 Checkboxes are not included into the global TODO list, so they are often
3124 great to split a task into a number of simple steps.  Or you can use
3125 them in a shopping list.  To toggle a checkbox, use @kbd{C-c C-c}, or
3126 use the mouse (thanks to Piotr Zielinski's @file{org-mouse.el}).
3128 Here is an example of a checkbox list.
3130 @example
3131 * TODO Organize party [2/4]
3132   - [-] call people [1/3]
3133     - [ ] Peter
3134     - [X] Sarah
3135     - [ ] Sam
3136   - [X] order food
3137   - [ ] think about what music to play
3138   - [X] talk to the neighbors
3139 @end example
3141 Checkboxes work hierarchically, so if a checkbox item has children that
3142 are checkboxes, toggling one of the children checkboxes will make the
3143 parent checkbox reflect if none, some, or all of the children are
3144 checked.
3146 @cindex statistics, for checkboxes
3147 @cindex checkbox statistics
3148 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are
3149 cookies indicating how many checkboxes present in this entry have been
3150 checked off, and the total number of checkboxes are present.  This can
3151 give you an idea on how many checkboxes remain, even without opening a
3152 folded entry.  The cookies can be placed into a headline or into (the
3153 first line of) a plain list item. Each cookie covers all checkboxes
3154 structurally below the headline/item on which the cookie appear.  You
3155 have to insert the cookie yourself by typing either @samp{[/]} or
3156 @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m} result, as in
3157 the examples above.  With @samp{[%]} you get information about the
3158 percentage of checkboxes checked (in the above example, this would be
3159 @samp{[50%]} and @samp{[33%]}, respectively).
3161 @noindent The following commands work with checkboxes:
3163 @table @kbd
3164 @kindex C-c C-c
3165 @item C-c C-c
3166 Toggle checkbox at point.  With a prefix argument, set it to @samp{[-]},
3167 which is considered to be an intermediate state.
3168 @kindex C-c C-x C-b
3169 @item C-c C-x C-b
3170 Toggle checkbox at point.
3171 @itemize @minus
3172 @item
3173 If there is an active region, toggle the first checkbox in the region
3174 and set all remaining boxes to the same status as the first.  If you
3175 want to toggle all boxes in the region independently, use a prefix
3176 argument.
3177 @item
3178 If the cursor is in a headline, toggle checkboxes in the region between
3179 this headline and the next (so @emph{not} the entire subtree).
3180 @item
3181 If there is no active region, just toggle the checkbox at point.
3182 @end itemize
3183 @kindex M-S-@key{RET}
3184 @item M-S-@key{RET}
3185 Insert a new item with a checkbox.
3186 This works only if the cursor is already in a plain list item
3187 (@pxref{Plain lists}).
3188 @kindex C-c #
3189 @item C-c #
3190 Update the checkbox statistics in the current outline entry.  When
3191 called with a @kbd{C-u} prefix, update the entire file.  Checkbox
3192 statistic cookies are updated automatically if you toggle checkboxes
3193 with @kbd{C-c C-c} and make new ones with @kbd{M-S-@key{RET}}.  If you
3194 delete boxes or add/change them by hand, use this command to get things
3195 back into synch.  Or simply toggle any checkbox twice with @kbd{C-c C-c}.
3196 @end table
3198 @node Tags, Properties and columns, TODO items, Top
3199 @chapter Tags
3200 @cindex tags
3201 @cindex headline tagging
3202 @cindex matching, tags
3203 @cindex sparse tree, tag based
3205 An excellent way to implement labels and contexts for cross-correlating
3206 information is to assign @i{tags} to headlines.  Org-mode has extensive
3207 support for tags.
3209 Every headline can contain a list of tags; they occur at the end of the
3210 headline.  Tags are normal words containing letters, numbers, @samp{_},
3211 and @samp{@@}.  Tags must be preceded and followed by a single colon,
3212 e.g., @samp{:WORK:}.  Several tags can be specified, as in
3213 @samp{:work:URGENT:}.
3215 @menu
3216 * Tag inheritance::             Tags use the tree structure of the outline
3217 * Setting tags::                How to assign tags to a headline
3218 * Tag searches::                Searching for combinations of tags
3219 @end menu
3221 @node Tag inheritance, Setting tags, Tags, Tags
3222 @section Tag inheritance
3223 @cindex tag inheritance
3224 @cindex inheritance, of tags
3225 @cindex sublevels, inclusion into tags match
3227 @i{Tags} make use of the hierarchical structure of outline trees.  If a
3228 heading has a certain tag, all subheadings will inherit the tag as
3229 well.  For example, in the list
3231 @example
3232 * Meeting with the French group      :work:
3233 ** Summary by Frank                  :boss:notes:
3234 *** TODO Prepare slides for him      :action:
3235 @end example
3237 @noindent
3238 the final heading will have the tags @samp{:work:}, @samp{:boss:},
3239 @samp{:notes:}, and @samp{:action:} even though the final heading is not
3240 explicitly marked with those tags.  When executing tag searches and
3241 Org-mode finds that a certain headline matches the search criterion, it
3242 will not check any sublevel headline, assuming that these also match and
3243 that the list of matches could become very long because of that.  If you
3244 do want the sublevels be tested and listed as well, you may set the
3245 variable @code{org-tags-match-list-sublevels}.  To limit tag inheritance
3246 to specific tags, or to turn it off entirely, use the variable
3247 @code{org-use-tag-inheritance}.
3249 @node Setting tags, Tag searches, Tag inheritance, Tags
3250 @section Setting tags
3251 @cindex setting tags
3252 @cindex tags, setting
3254 @kindex M-@key{TAB}
3255 Tags can simply be typed into the buffer at the end of a headline.
3256 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
3257 also a special command for inserting tags:
3259 @table @kbd
3260 @kindex C-c C-c
3261 @item C-c C-c
3262 @cindex completion, of tags
3263 Enter new tags for the current headline.  Org-mode will either offer
3264 completion or a special single-key interface for setting tags, see
3265 below.  After pressing @key{RET}, the tags will be inserted and aligned
3266 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
3267 tags in the current buffer will be aligned to that column, just to make
3268 things look nice.  TAGS are automatically realigned after promotion,
3269 demotion, and TODO state changes (@pxref{TODO basics}).
3270 @end table
3272 Org will support tag insertion based on a @emph{list of tags}.  By
3273 default this list is constructed dynamically, containing all tags
3274 currently used in the buffer.  You may also globally specify a hard list
3275 of tags with the variable @code{org-tag-alist}.  Finally you can set
3276 the default tags for a given file with lines like
3278 @example
3279 #+TAGS: @@work @@home @@tennisclub
3280 #+TAGS: laptop car pc sailboat
3281 @end example
3283 If you have globally defined your preferred set of tags using the
3284 variable @code{org-tag-alist}, but would like to use a dynamic tag list
3285 in a specific file, add an empty TAGS option line to that file:
3287 @example
3288 #+TAGS:
3289 @end example
3291 The default support method for entering tags is minibuffer completion.
3292 However, Org-mode also implements a much better method: @emph{fast tag
3293 selection}.  This method allows to select and deselect tags with a
3294 single key per tag.  To function efficiently, you should assign unique
3295 keys to most tags.  This can be done globally with
3297 @lisp
3298 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
3299 @end lisp
3301 @noindent or on a per-file basis with
3303 @example
3304 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
3305 @end example
3307 @noindent
3308 You can also group together tags that are mutually exclusive.  With
3309 curly braces@footnote{In @code{org-mode-alist} use
3310 @code{'(:startgroup)} and @code{'(:endgroup)}, respectively.  Several
3311 groups are allowed.}
3313 @example
3314 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
3315 @end example
3317 @noindent you indicate that at most one of @samp{@@work}, @samp{@@home},
3318 and @samp{@@tennisclub} should be selected.
3320 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
3321 these lines to activate any changes.
3323 If at least one tag has a selection key, pressing @kbd{C-c C-c} will
3324 automatically present you with a special interface, listing inherited
3325 tags, the tags of the current headline, and a list of all valid tags
3326 with corresponding keys@footnote{Keys will automatically be assigned to
3327 tags which have no configured keys.}.  In this interface, you can use
3328 the following keys:
3330 @table @kbd
3331 @item a-z...
3332 Pressing keys assigned to tags will add or remove them from the list of
3333 tags in the current line.  Selecting a tag in a group of mutually
3334 exclusive tags will turn off any other tags from that group.
3335 @kindex @key{TAB}
3336 @item @key{TAB}
3337 Enter a tag in the minibuffer, even if the tag is not in the predefined
3338 list.  You will be able to complete on all tags present in the buffer.
3339 @kindex @key{SPC}
3340 @item @key{SPC}
3341 Clear all tags for this line.
3342 @kindex @key{RET}
3343 @item @key{RET}
3344 Accept the modified set.
3345 @item C-g
3346 Abort without installing changes.
3347 @item q
3348 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
3349 @item !
3350 Turn off groups of mutually exclusive tags.  Use this to (as an
3351 exception) assign several tags from such a group.
3352 @item C-c
3353 Toggle auto-exit after the next change (see below).
3354 If you are using expert mode, the first @kbd{C-c} will display the
3355 selection window.
3356 @end table
3358 @noindent
3359 This method lets you assign tags to a headline with very few keys.  With
3360 the above setup, you could clear the current tags and set @samp{@@home},
3361 @samp{laptop} and @samp{pc} tags with just the following keys: @kbd{C-c
3362 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to
3363 @samp{@@work} would be done with @kbd{C-c C-c w @key{RET}} or
3364 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
3365 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
3366 @key{RET} @key{RET}}.
3368 If you find that most of the time, you need only a single key press to
3369 modify your list of tags, set the variable
3370 @code{org-fast-tag-selection-single-key}.  Then you no longer have to
3371 press @key{RET} to exit fast tag selection - it will immediately exit
3372 after the first change.  If you then occasionally need more keys, press
3373 @kbd{C-c} to turn off auto-exit for the current tag selection process
3374 (in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
3375 C-c}).  If you set the variable to the value @code{expert}, the special
3376 window is not even shown for single-key tag selection, it comes up only
3377 when you press an extra @kbd{C-c}.
3379 @node Tag searches,  , Setting tags, Tags
3380 @section Tag searches
3381 @cindex tag searches
3382 @cindex searching for tags
3384 Once a system of tags has been set up, it can be used to collect related
3385 information into special lists.
3387 @table @kbd
3388 @kindex C-c \
3389 @kindex C-c / T
3390 @item C-c \
3391 @itemx C-c / T
3392 Create a sparse tree with all headlines matching a tags search.  With a
3393 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
3394 @kindex C-c a m
3395 @item C-c a m
3396 Create a global list of tag matches from all agenda files.
3397 @xref{Matching tags and properties}.
3398 @kindex C-c a M
3399 @item C-c a M
3400 Create a global list of tag matches from all agenda files, but check
3401 only TODO items and force checking subitems (see variable
3402 @code{org-tags-match-list-sublevels}).
3403 @end table
3405 @cindex Boolean logic, for tag searches
3406 A @i{tags} search string can use Boolean operators @samp{&} for AND and
3407 @samp{|} for OR.  @samp{&} binds more strongly than @samp{|}.
3408 Parenthesis are currently not implemented.  A tag may also be preceded
3409 by @samp{-}, to select against it, and @samp{+} is syntactic sugar for
3410 positive selection.  The AND operator @samp{&} is optional when @samp{+}
3411 or @samp{-} is present.  Examples:
3413 @table @samp
3414 @item +work-boss
3415 Select headlines tagged @samp{:work:}, but discard those also tagged
3416 @samp{:boss:}.
3417 @item work|laptop
3418 Selects lines tagged @samp{:work:} or @samp{:laptop:}.
3419 @item work|laptop&night
3420 Like before, but require the @samp{:laptop:} lines to be tagged also
3421 @samp{:night:}.
3422 @end table
3424 @cindex TODO keyword matching, with tags search
3425 If you are using multi-state TODO keywords (@pxref{TODO extensions}), it
3426 can be useful to also match on the TODO keyword.  This can be done by
3427 adding a condition after a slash to a tags match.  The syntax is similar
3428 to the tag matches, but should be applied with consideration: For
3429 example, a positive selection on several TODO keywords can not
3430 meaningfully be combined with boolean AND.  However, @emph{negative
3431 selection} combined with AND can be meaningful.  To make sure that only
3432 lines are checked that actually have any TODO keyword, use @kbd{C-c a
3433 M}, or equivalently start the TODO part after the slash with @samp{!}.
3434 Examples:
3436 @table @samp
3437 @item work/WAITING
3438 Select @samp{:work:}-tagged TODO lines with the specific TODO
3439 keyword @samp{WAITING}.
3440 @item work/!-WAITING-NEXT
3441 Select @samp{:work:}-tagged TODO lines that are neither @samp{WAITING}
3442 nor @samp{NEXT}
3443 @item work/+WAITING|+NEXT
3444 Select @samp{:work:}-tagged TODO lines that are either @samp{WAITING} or
3445 @samp{NEXT}.
3446 @end table
3448 @cindex regular expressions, with tags search
3449 Any element of the tag/todo match can be a regular expression - in this
3450 case it must be enclosed in curly braces.  For example,
3451 @samp{work+@{^boss.*@}} matches headlines that contain the tag
3452 @samp{:work:} and any tag @i{starting} with @samp{boss}.
3454 @cindex level, require for tags/property match
3455 @cindex category, require for tags/property match
3456 You can also require a headline to be of a certain level or category, by
3457 writing instead of any TAG an expression like @samp{LEVEL=3} or
3458 @samp{CATEGORY="work"}, respectively.  For example, a search
3459 @samp{+LEVEL=3+boss/-DONE} lists all level three headlines that have the
3460 tag @samp{boss} and are @emph{not} marked with the TODO keyword DONE.
3462 @node Properties and columns, Dates and times, Tags, Top
3463 @chapter Properties and Columns
3464 @cindex properties
3466 Properties are a set of key-value pairs associated with an entry.  There
3467 are two main applications for properties in Org-mode.  First, properties
3468 are like tags, but with a value.  Second, you can use properties to
3469 implement (very basic) database capabilities in an Org-mode buffer.  For
3470 an example of the first application, imagine maintaining a file where
3471 you document bugs and plan releases of a piece of software.  Instead of
3472 using tags like @code{:release_1:}, @code{:release_2:}, one can use a
3473 property, say @code{:Release:}, that in different subtrees has different
3474 values, such as @code{1.0} or @code{2.0}.  For an example of the second
3475 application of properties, imagine keeping track of your music CD's,
3476 where properties could be things such as the album artist, date of
3477 release, number of tracks, and so on.
3479 Properties can be conveniently edited and viewed in column view
3480 (@pxref{Column view}).
3482 Properties are like tags, but with a value.  For example, in a file
3483 where you document bugs and plan releases of a piece of software,
3484 instead of using tags like @code{:release_1:}, @code{:release_2:}, it
3485 can be more efficient to use a property @code{:Release:} with a value
3486 @code{1.0} or @code{2.0}.  Second, you can use properties to implement
3487 (very basic) database capabilities in an Org-mode buffer, for example to
3488 create a list of Music CD's you own.  You can edit and view properties
3489 conveniently in column view (@pxref{Column view}).
3491 @menu
3492 * Property syntax::             How properties are spelled out
3493 * Special properties::          Access to other Org-mode features
3494 * Property searches::           Matching property values
3495 * Property inheritance::        Passing values down the tree
3496 * Column view::                 Tabular viewing and editing
3497 * Property API::                Properties for Lisp programmers
3498 @end menu
3500 @node Property syntax, Special properties, Properties and columns, Properties and columns
3501 @section Property Syntax
3502 @cindex property syntax
3503 @cindex drawer, for properties
3505 Properties are key-value pairs.  They need to be inserted into a special
3506 drawer (@pxref{Drawers}) with the name @code{PROPERTIES}.  Each property
3507 is specified on a single line, with the key (surrounded by colons)
3508 first, and the value after it.  Here is an example:
3510 @example
3511 * CD collection
3512 ** Classic
3513 *** Goldberg Variations
3514     :PROPERTIES:
3515     :Title:     Goldberg Variations
3516     :Composer:  J.S. Bach
3517     :Artist:    Glen Gould
3518     :Publisher: Deutsche Grammphon
3519     :NDisks:    1
3520     :END:
3521 @end example
3523 You may define the allowed values for a particular property @samp{:Xyz:}
3524 by setting a property @samp{:Xyz_ALL:}.  This special property is
3525 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
3526 the entire tree.  When allowed values are defined, setting the
3527 corresponding property becomes easier and is less prone to typing
3528 errors.  For the example with the CD collection, we can predefine
3529 publishers and the number of disks in a box like this:
3531 @example
3532 * CD collection
3533   :PROPERTIES:
3534   :NDisks_ALL:  1 2 3 4
3535   :Publisher_ALL: "Deutsche Grammophon" Phillips EMI
3536   :END:
3537 @end example
3539 If you want to set properties that can be inherited by any entry in a
3540 file, use a line like
3542 @example
3543 #+PROPERTY: NDisks_ALL 1 2 3 4
3544 @end example
3546 Property values set with the global variable
3547 @code{org-global-properties} can be inherited by all entries in all
3548 Org-mode files.
3550 @noindent
3551 The following commands help to work with properties:
3553 @table @kbd
3554 @kindex M-@key{TAB}
3555 @item M-@key{TAB}
3556 After an initial colon in a line, complete property keys.  All keys used
3557 in the current file will be offered as possible completions.
3558 @kindex C-c C-x p
3559 @item C-c C-x p
3560 Set a property.  This prompts for a property name and a value.  If
3561 necessary, the property drawer is created as well.
3562 @item M-x org-insert-property-drawer
3563 Insert a property drawer into the current entry.  The drawer will be
3564 inserted early in the entry, but after the lines with planning
3565 information like deadlines.
3566 @kindex C-c C-c
3567 @item C-c C-c
3568 With the cursor in a property drawer, this executes property commands.
3569 @item C-c C-c s
3570 Set a property in the current entry.  Both the property and the value
3571 can be inserted using completion.
3572 @kindex S-@key{right}
3573 @kindex S-@key{left}
3574 @item S-@key{left}/@key{right}
3575 Switch property at point to the next/previous allowed value.
3576 @item C-c C-c d
3577 Remove a property from the current entry.
3578 @item C-c C-c D
3579 Globally remove a property, from all entries in the current file.
3580 @item C-c C-c c
3581 Compute the property at point, using the operator and scope from the
3582 nearest column format definition.
3583 @end table
3585 @node Special properties, Property searches, Property syntax, Properties and columns
3586 @section Special Properties
3587 @cindex properties, special
3589 Special properties provide alternative access method to Org-mode
3590 features discussed in the previous chapters, like the TODO state or the
3591 priority of an entry.  This interface exists so that you can include
3592 these states into columns view (@pxref{Column view}), or to use them in
3593 queries.  The following property names are special and should not be
3594 used as keys in the properties drawer:
3596 @example
3597 TODO         @r{The TODO keyword of the entry.}
3598 TAGS         @r{The tags defined directly in the headline.}
3599 ALLTAGS      @r{All tags, including inherited ones.}
3600 PRIORITY     @r{The priority of the entry, a string with a single letter.}
3601 DEADLINE     @r{The deadline time string, without the angular brackets.}
3602 SCHEDULED    @r{The scheduling time stamp, without the angular brackets.}
3603 TIMESTAMP    @r{The first keyword-less time stamp in the entry.}
3604 TIMESTAMP_IA @r{The first inactive time stamp in the entry.}
3605 CLOCKSUM     @r{The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}}
3606              @r{must be run first to compute the values.}
3607 @end example
3609 @node Property searches, Property inheritance, Special properties, Properties and columns
3610 @section Property searches
3611 @cindex properties, searching
3612 @cindex searching, of properties
3614 To create sparse trees and special lists with selection based on
3615 properties, the same commands are used as for tag searches (@pxref{Tag
3616 searches}), and the same logic applies.  For example, a search string
3618 @example
3619 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort=""+With=@{Sarah\|Denny@}
3620 @end example
3622 @noindent
3623 finds entries tagged @samp{:work:} but not @samp{:boss:}, which
3624 also have a priority value @samp{A}, a @samp{:Coffee:} property with the
3625 value @samp{unlimited}, an @samp{Effort} property that is undefined or
3626 empty, and a @samp{:With:} property that is matched by
3627 the regular expression @samp{Sarah\|Denny}.
3629 You can configure Org-mode to use property inheritance during a search,
3630 see @ref{Property inheritance} for details.
3632 There is also a special command for creating sparse trees based on a
3633 single property:
3635 @table @kbd
3636 @kindex C-c / p
3637 @item C-c / p
3638 Create a sparse tree based on the value of a property.  This first
3639 prompts for the name of a property, and then for a value.  A sparse tree
3640 is created with all entries that define this property with the given
3641 value.  If you enclose the value into curly braces, it is interpreted as
3642 a regular expression and matched against the property values.
3643 @end table
3645 @node Property inheritance, Column view, Property searches, Properties and columns
3646 @section Property Inheritance
3647 @cindex properties, inheritance
3648 @cindex inheritance, of properties
3650 The outline structure of Org-mode documents lends itself for an
3651 inheritance model of properties: If the parent in a tree has a certain
3652 property, the children can inherit this property.  Org-mode does not
3653 turn this on by default, because it can slow down property searches
3654 significantly and is often not needed.  However, if you find inheritance
3655 useful, you can turn it on by setting the variable
3656 @code{org-use-property-inheritance}.  It may be set to @code{t}, to make
3657 all properties inherited from the parent, to a list of properties
3658 that should be inherited, or to a regular expression that matches
3659 inherited properties.
3661 Org-mode has a few properties for which inheritance is hard-coded, at
3662 least for the special applications for which they are used:
3664 @table @code
3665 @item COLUMNS
3666 The @code{:COLUMNS:} property defines the format of column view
3667 (@pxref{Column view}).  It is inherited in the sense that the level
3668 where a @code{:COLUMNS:} property is defined is used as the starting
3669 point for a column view table, independently of the location in the
3670 subtree from where columns view is turned on.
3671 @item CATEGORY
3672 For agenda view, a category set through a @code{:CATEGORY:} property
3673 applies to the entire subtree.
3674 @item ARCHIVE
3675 For archiving, the @code{:ARCHIVE:} property may define the archive
3676 location for the entire subtree (@pxref{Moving subtrees}).
3677 @item LOGGING
3678 The LOGGING property may define logging settings for an entry or a
3679 subtree (@pxref{Tracking TODO state changes}).
3680 @end table
3682 @node Column view, Property API, Property inheritance, Properties and columns
3683 @section Column View
3685 A great way to view and edit properties in an outline tree is
3686 @emph{column view}.  In column view, each outline item is turned into a
3687 table row.  Columns in this table provide access to properties of the
3688 entries.  Org-mode implements columns by overlaying a tabular structure
3689 over the headline of each item.  While the headlines have been turned
3690 into a table row, you can still change the visibility of the outline
3691 tree.  For example, you get a compact table by switching to CONTENTS
3692 view (@kbd{S-@key{TAB} S-@key{TAB}}, or simply @kbd{c} while column view
3693 is active), but you can still open, read, and edit the entry below each
3694 headline.  Or, you can switch to column view after executing a sparse
3695 tree command and in this way get a table only for the selected items.
3696 Column view also works in agenda buffers (@pxref{Agenda views}) where
3697 queries have collected selected items, possibly from a number of files.
3699 @menu
3700 * Defining columns::            The COLUMNS format property
3701 * Using column view::           How to create and use column view
3702 * Capturing Column View::       A dynamic block for column view
3703 @end menu
3705 @node Defining columns, Using column view, Column view, Column view
3706 @subsection Defining Columns
3707 @cindex column view, for properties
3708 @cindex properties, column view
3710 Setting up a column view first requires defining the columns.  This is
3711 done by defining a column format line.
3713 @menu
3714 * Scope of column definitions::  Where defined, where valid?
3715 * Column attributes::           Appearance and content of a column
3716 @end menu
3718 @node Scope of column definitions, Column attributes, Defining columns, Defining columns
3719 @subsubsection Scope of column definitions
3721 To define a column format for an entire file, use a line like
3723 @example
3724 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
3725 @end example
3727 To specify a format that only applies to a specific tree, add a
3728 @code{:COLUMNS:} property to the top node of that tree, for example:
3730 @example
3731 ** Top node for columns view
3732    :PROPERTIES:
3733    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
3734    :END:
3735 @end example
3737 If a @code{:COLUMNS:} property is present in an entry, it defines columns
3738 for the entry itself, and for the entire subtree below it.  Since the
3739 column definition is part of the hierarchical structure of the document,
3740 you can define columns on level 1 that are general enough for all
3741 sublevels, and more specific columns further down, when you edit a
3742 deeper part of the tree.
3744 @node Column attributes,  , Scope of column definitions, Defining columns
3745 @subsubsection Column attributes
3746 A column definition sets the attributes of a column.  The general
3747 definition looks like this:
3749 @example
3750  %[width]property[(title)][@{summary-type@}]
3751 @end example
3753 @noindent
3754 Except for the percent sign and the property name, all items are
3755 optional.  The individual parts have the following meaning:
3757 @example
3758 width           @r{An integer specifying the width of the column in characters.}
3759                 @r{If omitted, the width will be determined automatically.}
3760 property        @r{The property that should be edited in this column.}
3761 (title)         @r{The header text for the column. If omitted, the}
3762                 @r{property name is used.}
3763 @{summary-type@}  @r{The summary type.  If specified, the column values for}
3764                 @r{parent nodes are computed from the children.}
3765                 @r{Supported summary types are:}
3766                 @{+@}       @r{Sum numbers in this column.}
3767                 @{+;%.1f@}  @r{Like @samp{+}, but format result with @samp{%.1f}.}
3768                 @{$@}       @r{Currency, short for @samp{+;%.2f}.}
3769                 @{:@}       @r{Sum times, HH:MM:SS, plain numbers are hours.}
3770                 @{X@}       @r{Checkbox status, [X] if all children are [X].}
3771                 @{X/@}      @r{Checkbox status, [n/m].}
3772                 @{X%@}      @r{Checkbox status, [n%].}
3773 @end example
3775 @noindent
3776 Here is an example for a complete columns definition, along with allowed
3777 values.
3779 @example
3780 :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.}
3781                    %10Time_Estimate@{:@} %CLOCKSUM
3782 :Owner_ALL:    Tammy Mark Karl Lisa Don
3783 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
3784 :Approved_ALL: "[ ]" "[X]"
3785 @end example
3787 The first column, @samp{%25ITEM}, means the first 25 characters of the
3788 item itself, i.e. of the headline.  You probably always should start the
3789 column definition with the @samp{ITEM} specifier.  The other specifiers
3790 create columns @samp{Owner} with a list of names as allowed values, for
3791 @samp{Status} with four different possible values, and for a checkbox
3792 field @samp{Approved}.  When no width is given after the @samp{%}
3793 character, the column will be exactly as wide as it needs to be in order
3794 to fully display all values.  The @samp{Approved} column does have a
3795 modified title (@samp{Approved?}, with a question mark).  Summaries will
3796 be created for the @samp{Time_Estimate} column by adding time duration
3797 expressions like HH:MM, and for the @samp{Approved} column, by providing
3798 an @samp{[X]} status if all children have been checked.  The
3799 @samp{CLOCKSUM} column is special, it lists the sum of CLOCK intervals
3800 in the subtree.
3802 @node Using column view, Capturing Column View, Defining columns, Column view
3803 @subsection Using Column View
3805 @table @kbd
3806 @tsubheading{Turning column view on and off}
3807 @kindex C-c C-x C-c
3808 @item C-c C-x C-c
3809 Create the column view for the local environment.  This command searches
3810 the hierarchy, up from point, for a @code{:COLUMNS:} property that defines
3811 a format.  When one is found, the column view table is established for
3812 the entire tree, starting from the entry that contains the @code{:COLUMNS:}
3813 property.  If none is found, the format is taken from the @code{#+COLUMNS}
3814 line or from the variable @code{org-columns-default-format}, and column
3815 view is established for the current entry and its subtree.
3816 @kindex r
3817 @item r
3818 Recreate the column view, to include recent changes made in the buffer.
3819 @kindex g
3820 @item g
3821 Same as @kbd{r}.
3822 @kindex q
3823 @item q
3824 Exit column view.
3825 @tsubheading{Editing values}
3826 @item @key{left} @key{right} @key{up} @key{down}
3827 Move through the column view from field to field.
3828 @kindex S-@key{left}
3829 @kindex S-@key{right}
3830 @item  S-@key{left}/@key{right}
3831 Switch to the next/previous allowed value of the field.  For this, you
3832 have to have specified allowed values for a property.
3833 @kindex n
3834 @kindex p
3835 @itemx  n / p
3836 Same as @kbd{S-@key{left}/@key{right}}
3837 @kindex e
3838 @item e
3839 Edit the property at point.  For the special properties, this will
3840 invoke the same interface that you normally use to change that
3841 property.  For example, when editing a TAGS property, the tag completion
3842 or fast selection interface will pop up.
3843 @kindex C-c C-c
3844 @item C-c C-c
3845 When there is a checkbox at point, toggle it.
3846 @kindex v
3847 @item v
3848 View the full value of this property.  This is useful if the width of
3849 the column is smaller than that of the value.
3850 @kindex a
3851 @item a
3852 Edit the list of allowed values for this property.  If the list is found
3853 in the hierarchy, the modified values is stored there.  If no list is
3854 found, the new value is stored in the first entry that is part of the
3855 current column view.
3856 @tsubheading{Modifying the table structure}
3857 @kindex <
3858 @kindex >
3859 @item < / >
3860 Make the column narrower/wider by one character.
3861 @kindex S-M-@key{right}
3862 @item S-M-@key{right}
3863 Insert a new column, to the right of the current column.
3864 @kindex S-M-@key{left}
3865 @item S-M-@key{left}
3866 Delete the current column.
3867 @end table
3869 @node Capturing Column View,  , Using column view, Column view
3870 @subsection Capturing Column View
3872 Since column view is just an overlay over a buffer, it cannot be
3873 exported or printed directly.  If you want to capture a column view, use
3874 this @code{columnview} dynamic block (@pxref{Dynamic blocks}).  The frame
3875 of this block looks like this:
3877 @example
3878 * The column view
3879 #+BEGIN: columnview :hlines 1 :id "label"
3881 #+END:
3882 @end example
3884 @noindent This dynamic block has the following parameters:
3886 @table @code
3887 @item :id
3888 This is most important parameter.  Column view is a feature that is
3889 often localized to a certain (sub)tree, and the capture block might be
3890 in a different location in the file.  To identify the tree whose view to
3891 capture, you can use 3 values:
3892 @example
3893 local     @r{use the tree in which the capture block is located}
3894 global    @r{make a global view, including all headings in the file}
3895 "label"   @r{call column view in the tree that has and @code{:ID:}}
3896           @r{property with the value @i{label}}
3897 @end example
3898 @item :hlines
3899 When @code{t}, insert a hline after every line.  When a number N, insert
3900 a hline before each headline with level @code{<= N}.
3901 @item :vlines
3902 When set to @code{t}, enforce column groups to get vertical lines.
3903 @item :maxlevel
3904 When set to a number, don't capture entries below this level.
3905 @item :skip-empty-rows
3906 When set to @code{t}, skip row where the only non-empty specifier of the
3907 column view is @code{ITEM}.
3909 @end table
3911 @noindent
3912 The following commands insert or update the dynamic block:
3914 @table @kbd
3915 @kindex C-c C-x r
3916 @item C-c C-x r
3917 Insert a dynamic block capturing a column view.  You will be prompted
3918 for the scope or id of the view.
3919 @kindex C-c C-c
3920 @item C-c C-c
3921 @kindex C-c C-x C-u
3922 @itemx C-c C-x C-u
3923 Update dynamical block at point.  The cursor needs to be in the
3924 @code{#+BEGIN} line of the dynamic block.
3925 @kindex C-u C-c C-x C-u
3926 @item C-u C-c C-x C-u
3927 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
3928 you have several clock table blocks in a buffer.
3929 @end table
3931 @node Property API,  , Column view, Properties and columns
3932 @section The Property API
3933 @cindex properties, API
3934 @cindex API, for properties
3936 There is a full API for accessing and changing properties.  This API can
3937 be used by Emacs Lisp programs to work with properties and to implement
3938 features based on them.  For more information see @ref{Using the
3939 property API}.
3941 @node Dates and times, Remember, Properties and columns, Top
3942 @chapter Dates and Times
3943 @cindex dates
3944 @cindex times
3945 @cindex time stamps
3946 @cindex date stamps
3948 To assist project planning, TODO items can be labeled with a date and/or
3949 a time.  The specially formatted string carrying the date and time
3950 information is called a @emph{timestamp} in Org-mode.  This may be a
3951 little confusing because timestamp is often used as indicating when
3952 something was created or last changed.  However, in Org-mode this term
3953 is used in a much wider sense.
3955 @menu
3956 * Time stamps::                 Assigning a time to a tree entry
3957 * Creating timestamps::         Commands which insert timestamps
3958 * Deadlines and scheduling::    Planning your work
3959 * Clocking work time::
3960 @end menu
3963 @node Time stamps, Creating timestamps, Dates and times, Dates and times
3964 @section Time stamps, deadlines and scheduling
3965 @cindex time stamps
3966 @cindex ranges, time
3967 @cindex date stamps
3968 @cindex deadlines
3969 @cindex scheduling
3971 A time stamp is a specification of a date (possibly with time or a range
3972 of times) in a special format, either @samp{<2003-09-16 Tue>} or
3973 @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16 Tue
3974 12:00-12:30>}@footnote{This is the standard ISO date/time format.  To
3975 use an alternative format, see @ref{Custom time format}.}.  A time stamp
3976 can appear anywhere in the headline or body of an org-tree entry.  Its
3977 presence causes entries to be shown on specific dates in the agenda
3978 (@pxref{Weekly/Daily agenda}).  We distinguish:
3980 @table @var
3981 @item Plain time stamp; Event; Appointment
3982 @cindex timestamp
3983 A simple time stamp just assigns a date/time to an item.  This is just
3984 like writing down an appointment or event in a paper agenda.  In the
3985 timeline and agenda displays, the headline of an entry associated with a
3986 plain time stamp will be shown exactly on that date.
3988 @example
3989 * Meet Peter at the movies <2006-11-01 Wed 19:15>
3990 * Discussion on climate change <2006-11-02 Thu 20:00-22:00>
3991 @end example
3993 @item Time stamp with repeater interval
3994 @cindex timestamp, with repeater interval
3995 A time stamp may contain a @emph{repeater interval}, indicating that it
3996 applies not only on the given date, but again and again after a certain
3997 interval of N days (d), weeks (w), months(m), or years(y).  The
3998 following will show up in the agenda every Wednesday:
4000 @example
4001 * Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
4002 @end example
4004 @item Diary-style sexp entries
4005 For more complex date specifications, Org-mode supports using the
4006 special sexp diary entries implemented in the Emacs calendar/diary
4007 package.  For example
4009 @example
4010 * The nerd meeting on every 2nd Thursday of the month
4011   <%%(diary-float t 4 2)>
4012 @end example
4014 @item Time/Date range
4015 @cindex timerange
4016 @cindex date range
4017 Two time stamps connected by @samp{--} denote a range.  The headline
4018 will be shown on the first and last day of the range, and on any dates
4019 that are displayed and fall in the range.  Here is an example:
4021 @example
4022 ** Meeting in Amsterdam
4023    <2004-08-23 Mon>--<2004-08-26 Thu>
4024 @end example
4026 @item Inactive time stamp
4027 @cindex timestamp, inactive
4028 @cindex inactive timestamp
4029 Just like a plain time stamp, but with square brackets instead of
4030 angular ones.  These time stamps are inactive in the sense that they do
4031 @emph{not} trigger an entry to show up in the agenda.
4033 @example
4034 * Gillian comes late for the fifth time [2006-11-01 Wed]
4035 @end example
4037 @end table
4039 @node Creating timestamps, Deadlines and scheduling, Time stamps, Dates and times
4040 @section Creating timestamps
4041 @cindex creating timestamps
4042 @cindex timestamps, creating
4044 For Org-mode to recognize time stamps, they need to be in the specific
4045 format.  All commands listed below produce time stamps in the correct
4046 format.
4048 @table @kbd
4049 @kindex C-c .
4050 @item C-c .
4051 Prompt for a date and insert a corresponding time stamp.  When the
4052 cursor is at a previously used time stamp, it is updated to NOW.  When
4053 this command is used twice in succession, a time range is inserted.
4055 @kindex C-u C-c .
4056 @item C-u C-c .
4057 Like @kbd{C-c .}, but use the alternative format which contains date
4058 and time.  The default time can be rounded to multiples of 5 minutes,
4059 see the option @code{org-time-stamp-rounding-minutes}.
4061 @kindex C-c !
4062 @item C-c !
4063 Like @kbd{C-c .}, but insert an inactive time stamp that will not cause
4064 an agenda entry.
4066 @kindex C-c <
4067 @item C-c <
4068 Insert a time stamp corresponding to the cursor date in the Calendar.
4070 @kindex C-c >
4071 @item C-c >
4072 Access the Emacs calendar for the current date.  If there is a
4073 timestamp in the current line, go to the corresponding date
4074 instead.
4076 @kindex C-c C-o
4077 @item C-c C-o
4078 Access the agenda for the date given by the time stamp or -range at
4079 point (@pxref{Weekly/Daily agenda}).
4081 @kindex S-@key{left}
4082 @kindex S-@key{right}
4083 @item S-@key{left}
4084 @itemx S-@key{right}
4085 Change date at cursor by one day.  These key bindings conflict with
4086 CUA-mode (@pxref{Conflicts}).
4088 @kindex S-@key{up}
4089 @kindex S-@key{down}
4090 @item S-@key{up}
4091 @itemx S-@key{down}
4092 Change the item under the cursor in a timestamp.  The cursor can be on a
4093 year, month, day, hour or minute.  Note that if the cursor is in a
4094 headline and not at a time stamp, these same keys modify the priority of
4095 an item.  (@pxref{Priorities}). The key bindings also conflict with
4096 CUA-mode (@pxref{Conflicts}).
4098 @kindex C-c C-y
4099 @cindex evaluate time range
4100 @item C-c C-y
4101 Evaluate a time range by computing the difference between start and end.
4102 With a prefix argument, insert result after the time range (in a table: into
4103 the following column).
4104 @end table
4107 @menu
4108 * The date/time prompt::        How org-mode helps you entering date and time
4109 * Custom time format::          Making dates look differently
4110 @end menu
4112 @node The date/time prompt, Custom time format, Creating timestamps, Creating timestamps
4113 @subsection The date/time prompt
4114 @cindex date, reading in minibuffer
4115 @cindex time, reading in minibuffer
4117 When Org-mode prompts for a date/time, the default is shown as an ISO
4118 date, and the prompt therefore seems to ask for an ISO date.  But it
4119 will in fact accept any string containing some date and/or time
4120 information, and it is really smart about interpreting your input.  You
4121 can, for example, use @kbd{C-y} to paste a (possibly multi-line) string
4122 copied from an email message.  Org-mode will find whatever information
4123 is in there and derive anything you have not specified from the
4124 @emph{default date and time}.  The default is usually the current date
4125 and time, but when modifying an existing time stamp, or when entering
4126 the second stamp of a range, it is taken from the stamp in the buffer.
4127 When filling in information, Org-mode assumes that most of the time you
4128 will want to enter a date in the future: If you omit the month/year and
4129 the given day/month is @i{before} today, it will assume that you mean a
4130 future date@footnote{See the variable
4131 @code{org-read-date-prefer-future}.}.
4133 For example, lets assume that today is @b{June 13, 2006}.  Here is how
4134 various inputs will be interpreted, the items filled in by Org-mode are
4135 in @b{bold}.
4137 @example
4138 3-2-5         --> 2003-02-05
4139 14            --> @b{2006}-@b{06}-14
4140 12            --> @b{2006}-@b{07}-12
4141 Fri           --> nearest Friday (defaultdate or later)
4142 sep 15        --> @b{2006}-11-15
4143 feb 15        --> @b{2007}-02-15
4144 sep 12 9      --> 2009-09-12
4145 12:45         --> @b{2006}-@b{06}-@b{13} 12:45
4146 22 sept 0:34  --> @b{2006}-09-22 0:34
4147 @end example
4149 Furthermore you can specify a relative date by giving, as the
4150 @emph{first} thing in the input: a plus/minus sign, a number and a
4151 letter [dwmy] to indicate change in days weeks, months, years.  With a
4152 single plus or minus, the date is always relative to today.  With a
4153 double plus or minus, it is relative to the default date.  If instead of
4154 a single letter, you use the abbreviation of day name, the date will be
4155 the nth such day.  E.g.
4157 @example
4158 +4d           --> four days from today
4159 +4            --> same as above
4160 +2w           --> two weeks from today
4161 ++5           --> five days from default date
4162 +2tue         --> second tuesday from now.
4163 @end example
4165 The function understands English month and weekday abbreviations.  If
4166 you want to use unabbreviated names and/or other languages, configure
4167 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
4169 @cindex calendar, for selecting date
4170 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
4171 you don't need/want the calendar, configure the variable
4172 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
4173 prompt, either by clicking on a date in the calendar, or by pressing
4174 @key{RET}, the date selected in the calendar will be combined with the
4175 information entered at the prompt.  You can control the calendar fully
4176 from the minibuffer:
4178 @kindex <
4179 @kindex >
4180 @kindex mouse-1
4181 @kindex S-@key{right}
4182 @kindex S-@key{left}
4183 @kindex S-@key{down}
4184 @kindex S-@key{up}
4185 @kindex M-S-@key{right}
4186 @kindex M-S-@key{left}
4187 @kindex @key{RET}
4188 @example
4189 > / <          @r{Scroll calendar forward/backward by one month.}
4190 mouse-1        @r{Select date by clicking on it.}
4191 S-@key{right}/@key{left}     @r{One day forward/backward.}
4192 S-@key{down}/@key{up}     @r{One week forward/backward.}
4193 M-S-@key{right}/@key{left}   @r{One month forward/backward.}
4194 @key{RET}           @r{Choose date in calendar.}
4195 @end example
4197 The actions of the date/time prompt may seem complex, but I assure you
4198 they will grow on you.  To help you understand what is going on, the
4199 current interpretation of your input will be displayed live in the
4200 minibuffer@footnote{If you find this distracting, turn the display of
4201 with @code{org-read-date-display-live}.}.
4203 @node Custom time format,  , The date/time prompt, Creating timestamps
4204 @subsection Custom time format
4205 @cindex custom date/time format
4206 @cindex time format, custom
4207 @cindex date format, custom
4209 Org-mode uses the standard ISO notation for dates and times as it is
4210 defined in ISO 8601.  If you cannot get used to this and require another
4211 representation of date and time to keep you happy, you can get it by
4212 customizing the variables @code{org-display-custom-times} and
4213 @code{org-time-stamp-custom-formats}.
4215 @table @kbd
4216 @kindex C-c C-x C-t
4217 @item C-c C-x C-t
4218 Toggle the display of custom formats for dates and times.
4219 @end table
4221 @noindent
4222 Org-mode needs the default format for scanning, so the custom date/time
4223 format does not @emph{replace} the default format - instead it is put
4224 @emph{over} the default format using text properties.  This has the
4225 following consequences:
4226 @itemize @bullet
4227 @item
4228 You cannot place the cursor onto a time stamp anymore, only before or
4229 after.
4230 @item
4231 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
4232 each component of a time stamp.  If the cursor is at the beginning of
4233 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
4234 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
4235 time will be changed by one minute.
4236 @item
4237 If the time stamp contains a range of clock times or a repeater, these
4238 will not be overlayed, but remain in the buffer as they were.
4239 @item
4240 When you delete a time stamp character-by-character, it will only
4241 disappear from the buffer after @emph{all} (invisible) characters
4242 belonging to the ISO timestamp have been removed.
4243 @item
4244 If the custom time stamp format is longer than the default and you are
4245 using dates in tables, table alignment will be messed up.  If the custom
4246 format is shorter, things do work as expected.
4247 @end itemize
4250 @node Deadlines and scheduling, Clocking work time, Creating timestamps, Dates and times
4251 @section Deadlines and Scheduling
4253 A time stamp may be preceded by special keywords to facilitate planning:
4255 @table @var
4256 @item DEADLINE
4257 @cindex DEADLINE keyword
4259 Meaning: the task (most likely a TODO item, though not necessarily) is supposed
4260 to be finished on that date.
4262 On the deadline date, the task will be listed in the agenda.  In
4263 addition, the agenda for @emph{today} will carry a warning about the
4264 approaching or missed deadline, starting
4265 @code{org-deadline-warning-days} before the due date, and continuing
4266 until the entry is marked DONE.  An example:
4268 @example
4269 *** TODO write article about the Earth for the Guide
4270     The editor in charge is [[bbdb:Ford Prefect]]
4271     DEADLINE: <2004-02-29 Sun>
4272 @end example
4274 You can specify a different lead time for warnings for a specific
4275 deadlines using the following syntax.  Here is an example with a warning
4276 period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.
4278 @item SCHEDULED
4279 @cindex SCHEDULED keyword
4281 Meaning: you are planning to start working on that task on the given
4282 date.
4284 The headline will be listed under the given date@footnote{It will still
4285 be listed on that date after it has been marked DONE.  If you don't like
4286 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
4287 addition, a reminder that the scheduled date has passed will be present
4288 in the compilation for @emph{today}, until the entry is marked DONE.
4289 I.e., the task will automatically be forwarded until completed.
4291 @example
4292 *** TODO Call Trillian for a date on New Years Eve.
4293     SCHEDULED: <2004-12-25 Sat>
4294 @end example
4296 @noindent
4297 @b{Important:} Scheduling an item in Org-mode should @i{not} be
4298 understood in the same way that we understand @i{scheduling a meeting}.
4299 Setting a date for a meeting is just a simple appointment, you should
4300 mark this entry with a simple plain time stamp, to get this item shown
4301 on the date where it applies.  This is a frequent mis-understanding from
4302 Org-users.  In Org-mode, @i{scheduling} means setting a date when you
4303 want to start working on an action item.
4304 @end table
4306 You may use time stamps with repeaters in scheduling and deadline
4307 entries.  Org-mode will issue early and late warnings based on the
4308 assumption that the time stamp represents the @i{nearest instance} of
4309 the repeater.  However, the use of diary sexp entries like
4311 @code{<%%(diary-float t 42)>}
4313 in scheduling and deadline timestamps is limited.  Org-mode does not
4314 know enough about the internals of each sexp function to issue early and
4315 late warnings.  However, it will show the item on each day where the
4316 sexp entry matches.
4318 @menu
4319 * Inserting deadline/schedule::  Planning items
4320 * Repeated tasks::              Items that show up again and again
4321 @end menu
4323 @node Inserting deadline/schedule, Repeated tasks, Deadlines and scheduling, Deadlines and scheduling
4324 @subsection Inserting deadline/schedule
4326 The following commands allow to quickly insert a deadline or to schedule
4327 an item:
4329 @table @kbd
4331 @kindex C-c C-d
4332 @item C-c C-d
4333 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will
4334 happen in the line directly following the headline.  When called with a
4335 prefix arg, an existing deadline will be removed from the entry.
4336 @c FIXME Any CLOSED timestamp will be removed.????????
4338 @kindex C-c / d
4339 @cindex sparse tree, for deadlines
4340 @item C-c / d
4341 Create a sparse tree with all deadlines that are either past-due, or
4342 which will become due within @code{org-deadline-warning-days}.
4343 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
4344 prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows
4345 all deadlines due tomorrow.
4347 @kindex C-c C-s
4348 @item C-c C-s
4349 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
4350 happen in the line directly following the headline.  Any CLOSED
4351 timestamp will be removed.  When called with a prefix argument, remove
4352 the scheduling date from the entry.
4353 @end table
4355 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
4356 @subsection Repeated Tasks
4358 Some tasks need to be repeated again and again.  Org-mode helps to
4359 organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
4360 or plain time stamp.  In the following example
4361 @example
4362 ** TODO Pay the rent
4363    DEADLINE: <2005-10-01 Sat +1m>
4364 @end example
4365 the @code{+1m} is a repeater; the intended interpretation is that the
4366 task has a deadline on <2005-10-01> and repeats itself every (one) month
4367 starting from that time.  If you need both a repeater and a special
4368 warning period in a deadline entry, the repeater comes first and the
4369 warning period last: @code{DEADLINE: <2005-10-01 Sat +1m -3d>}.
4371 Deadlines and scheduled items produce entries in the agenda when they
4372 are over-due, so it is important to be able to mark such an entry as
4373 completed once you have done so.  When you mark a DEADLINE or a SCHEDULE
4374 with the TODO keyword DONE, it will no longer produce entries in the
4375 agenda.  The problem with this is, however, that then also the
4376 @emph{next} instance of the repeated entry will not be active.  Org-mode
4377 deals with this in the following way: When you try to mark such an entry
4378 DONE (using @kbd{C-c C-t}), it will shift the base date of the repeating
4379 time stamp by the repeater interval, and immediately set the entry state
4380 back to TODO.  In the example above, setting the state to DONE would
4381 actually switch the date like this:
4383 @example
4384 ** TODO Pay the rent
4385    DEADLINE: <2005-11-01 Tue +1m>
4386 @end example
4388 You will also be prompted for a note@footnote{You can change this using
4389 the option @code{org-log-repeat}, or the @code{#+STARTUP} options
4390 @code{logrepeat}, @code{lognoterepeat}, and @code{nologrepeat}.} that
4391 will be put under the DEADLINE line to keep a record that you actually
4392 acted on the previous instance of this deadline.
4394 As a consequence of shifting the base date, this entry will no longer be
4395 visible in the agenda when checking past dates, but all future instances
4396 will be visible.
4398 With the @samp{+1m} cookie, the date shift will always be exactly one
4399 month.  So if you have not payed the rent for three months, marking this
4400 entry DONE will still keep it as an overdue deadline.  Depending on the
4401 task, this may not be the best way to handle it.  For example, if you
4402 forgot to call you father for 3 weeks, it does not make sense to call
4403 her 3 times in a single day to make up for it.  Finally, there are tasks
4404 like changing batteries which should always repeat a certain time
4405 @i{after} the last time you did it.  For these tasks, Org-mode has
4406 special repeaters markers with @samp{++} and @samp{.+}.  For example:
4408 @example
4409 ** TODO Call Father
4410    DEADLINE: <2008-02-10 Sun ++1w>
4411    Marking this DONE will shift the date by at least one week,
4412    but also by as many weeks as it takes to get this date into
4413    the future.  However, it stays on a Sunday, even if you called
4414    and marked it done on Saturday.
4415 ** TODO Check the batteries in the smoke detectors
4416    DEADLINE: <2005-11-01 Tue .+1m>
4417    Marking this DONE will shift the date to one month after
4418    today.
4419 @end example
4421 You may have both scheduling and deadline information for a specific
4422 task - just make sure that the repeater intervals on both are the same.
4424 @node Clocking work time,  , Deadlines and scheduling, Dates and times
4425 @section Clocking work time
4427 Org-mode allows you to clock the time you spent on specific tasks in a
4428 project.  When you start working on an item, you can start the clock.
4429 When you stop working on that task, or when you mark the task done, the
4430 clock is stopped and the corresponding time interval is recorded.  It
4431 also computes the total time spent on each subtree of a project.
4433 @table @kbd
4434 @kindex C-c C-x C-i
4435 @item C-c C-x C-i
4436 Start the clock on the current item (clock-in).  This inserts the CLOCK
4437 keyword together with a timestamp.  If this is not the first clocking of
4438 this item, the multiple CLOCK lines will be wrapped into a
4439 @code{:CLOCK:} drawer (see also the variable
4440 @code{org-clock-into-drawer}).
4441 @kindex C-c C-x C-o
4442 @item C-c C-x C-o
4443 Stop the clock (clock-out).  The inserts another timestamp at the same
4444 location where the clock was last started.  It also directly computes
4445 the resulting time in inserts it after the time range as @samp{=>
4446 HH:MM}.  See the variable @code{org-log-note-clock-out} for the
4447 possibility to record an additional note together with the clock-out
4448 time stamp@footnote{The corresponding in-buffer setting is:
4449 @code{#+STARTUP: lognoteclock-out}}.
4450 @kindex C-c C-y
4451 @item C-c C-y
4452 Recompute the time interval after changing one of the time stamps.  This
4453 is only necessary if you edit the time stamps directly.  If you change
4454 them with @kbd{S-@key{cursor}} keys, the update is automatic.
4455 @kindex C-c C-t
4456 @item C-c C-t
4457 Changing the TODO state of an item to DONE automatically stops the clock
4458 if it is running in this same item.
4459 @kindex C-c C-x C-x
4460 @item C-c C-x C-x
4461 Cancel the current clock.  This is useful if a clock was started by
4462 mistake, or if you ended up working on something else.
4463 @kindex C-c C-x C-j
4464 @item C-c C-x C-j
4465 Jump to the entry that contains the currently running clock, an another
4466 window.
4467 @kindex C-c C-x C-d
4468 @item C-c C-x C-d
4469 Display time summaries for each subtree in the current buffer.  This
4470 puts overlays at the end of each headline, showing the total time
4471 recorded under that heading, including the time of any subheadings. You
4472 can use visibility cycling to study the tree, but the overlays disappear
4473 when you change the buffer (see variable
4474 @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
4475 @kindex C-c C-x C-r
4476 @item C-c C-x C-r
4477 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
4478 report as an org-mode table into the current file.  When the cursor is
4479 at an existing clock table, just update it.  When called with a prefix
4480 argument, jump to the first clock report in the current document and
4481 update it.
4482 @example
4483 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
4485 #+END: clocktable
4486 @end example
4487 @noindent
4488 If such a block already exists at point, its content is replaced by the
4489 new table.  The @samp{BEGIN} line can specify options:
4490 @example
4491 :maxlevel    @r{Maximum level depth to which times are listed in the table.}
4492 :emphasize   @r{When @code{t}, emphasize level one and level two items}
4493 :scope       @r{The scope to consider.  This can be any of the following:}
4494              nil        @r{the current buffer or narrowed region}
4495              file       @r{the full current buffer}
4496              subtree    @r{the subtree where the clocktable is located}
4497              treeN      @r{the surrounding level N tree, for example @code{tree3}}
4498              tree       @r{the surrounding level 1 tree}
4499              agenda     @r{all agenda files}
4500              ("file"..) @r{scan these files}
4501 :block       @r{The time block to consider.  This block is specified relative}
4502              @r{to the current time and may be any of these keywords:}
4503              @r{@code{today}, @code{yesterday}, @code{thisweek}, @code{lastweek},}
4504              @r{@code{thismonth}, @code{lastmonth}, @code{thisyear}, or @code{lastyear}}.
4505 :tstart      @r{A time string specifying when to start considering times}
4506 :tend        @r{A time string specifying when to stop considering times}
4507 :step        @r{@code{week} or @code{day}, to split the table into chunks}
4508 :link        @r{Link the item headlines in the table to their origins}
4509 @end example
4510 So to get a clock summary of the current level 1 tree, for the current
4511 day, you could write
4512 @example
4513 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1
4515 #+END: clocktable
4516 @end example
4517 and to use a specific time range you could write@footnote{Note that all
4518 parameters must be specified in a single line - the line is broken here
4519 only to fit it onto the manual.}
4520 @example
4521 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>"
4522                     :tend "<2006-08-10 Thu 12:00>"
4524 #+END: clocktable
4525 @end example
4526 @kindex C-c C-c
4527 @item C-c C-c
4528 @kindex C-c C-x C-u
4529 @itemx C-c C-x C-u
4530 Update dynamical block at point.  The cursor needs to be in the
4531 @code{#+BEGIN} line of the dynamic block.
4532 @kindex C-u C-c C-x C-u
4533 @item C-u C-c C-x C-u
4534 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
4535 you have several clock table blocks in a buffer.
4536 @end table
4538 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
4539 the agenda (@pxref{Weekly/Daily agenda}) to show which tasks have been
4540 worked on or closed during a day.
4542 @node Remember, Agenda views, Dates and times, Top
4543 @chapter Remember
4544 @cindex @file{remember.el}
4546 The @i{Remember} package by John Wiegley lets you store quick notes with
4547 little interruption of your work flow.  See
4548 @uref{http://www.emacswiki.org/cgi-bin/wiki/RememberMode} for more
4549 information.  It is an excellent way to add new notes and tasks to
4550 Org-mode files.  Org-mode significantly expands the possibilities of
4551 @i{remember}: You may define templates for different note types, and
4552 associate target files and headlines with specific templates.  It also
4553 allows you to select the location where a note should be stored
4554 interactively, on the fly.
4556 @menu
4557 * Setting up remember::         Some code for .emacs to get things going
4558 * Remember templates::          Define the outline of different note types
4559 * Storing notes::               Directly get the note to where it belongs
4560 * Refiling notes::              Moving a note or task to a project
4561 @end menu
4563 @node Setting up remember, Remember templates, Remember, Remember
4564 @section Setting up remember
4566 The following customization will tell @i{remember} to use org files as
4567 target, and to create annotations compatible with Org-mode links.
4569 @example
4570 (org-remember-insinuate)
4571 (setq org-directory "~/path/to/my/orgfiles/")
4572 (setq org-default-notes-file (concat org-directory "/notes.org"))
4573 (define-key global-map "\C-cr" 'org-remember)
4574 @end example
4576 The last line binds the command @code{org-remember} to a global
4577 key@footnote{Please select your own key, @kbd{C-c r} is only a
4578 suggestion.}.  @code{org-remember} basically just calls @code{remember},
4579 but it makes a few things easier: If there is an active region, it will
4580 automatically copy the region into the remember buffer.  It also allows
4581 to jump to the buffer and location where remember notes are being
4582 stored: Just call @code{org-remember} with a prefix argument.  If you
4583 use two prefix arguments, Org-mode jumps to the location where the last
4584 remember note was stored.
4586 @node Remember templates, Storing notes, Setting up remember, Remember
4587 @section Remember templates
4588 @cindex templates, for remember
4590 In combination with Org-mode, you can use templates to generate
4591 different types of @i{remember} notes.  For example, if you would like
4592 to use one template to create general TODO entries, another one for
4593 journal entries, and a third one for collecting random ideas, you could
4594 use:
4596 @example
4597 (setq org-remember-templates
4598  '(("Todo" ?t "* TODO %?\n  %i\n  %a" "~/org/TODO.org" "Tasks")
4599    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org")
4600    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
4601 @end example
4603 @noindent In these entries, the first string is just a name, and the
4604 character specifies how to select the template.  It is useful if the
4605 character is also the first letter of the name.  The next string
4606 specifies the template.  Two more (optional) strings give the file in
4607 which, and the headline under which the new note should be stored.  The
4608 file (if not present or @code{nil}) defaults to
4609 @code{org-default-notes-file}, the heading to
4610 @code{org-remember-default-headline}.  If the file name is not an
4611 absolute path, it will be interpreted relative to @code{org-directory}.
4613 An optional sixth element specifies the contexts in which the user can
4614 select the template.  This element can be either a list of major modes
4615 or a function.  @code{org-remember} will first check whether the function
4616 returns @code{t} or if we are in any of the listed major mode, and select 
4617 the template accordingly.
4619 So for example:
4621 @example
4622 (setq org-remember-templates
4623  '(("Bug" ?b "* BUG %?\n  %i\n  %a" "~/org/BUGS.org" "Bugs" (emacs-lisp-mode))
4624    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org" my-check)
4625    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
4626 @end example
4628 The first template will only be available when invoking @code{org-remember}
4629 from an buffer in @code{emacs-lisp-mode}.  The second template will only be
4630 available when the function @code{my-check} returns @code{t}.  The third
4631 template will be proposed in any context.
4633 When you call @kbd{M-x remember} (or @kbd{M-x org-remember}) to remember
4634 something, org will prompt for a key to select the template (if you have
4635 more than one template) and then prepare the buffer like
4636 @example
4637 * TODO
4638   [[file:link to where you called remember]]
4639 @end example
4641 @noindent
4642 During expansion of the template, special @kbd{%}-escapes allow dynamic
4643 insertion of content:
4644 @example
4645 %^@{prompt@}  @r{prompt the user for a string and replace this sequence with it.}
4646             @r{You may specify a default value and a completion table with}
4647             @r{%^@{prompt|default|completion2|completion3...@}}
4648             @r{The arrow keys access a prompt-specific history.}
4649 %t          @r{time stamp, date only}
4650 %T          @r{time stamp with date and time}
4651 %u, %U      @r{like the above, but inactive time stamps}
4652 %^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
4653             @r{You may define a prompt like @code{%^@{Birthday@}t}}
4654 %n          @r{user name (taken from @code{user-full-name})}
4655 %a          @r{annotation, normally the link created with @code{org-store-link}}
4656 %A          @r{like @code{%a}, but prompt for the description part}
4657 %i          @r{initial content, the region when remember is called with C-u.}
4658             @r{The entire text will be indented like @code{%i} itself.}
4659 %c          @r{Content of the clipboard, or current kill ring head.}
4660 %^g         @r{prompt for tags, with completion on tags in target file.}
4661 %^G         @r{prompt for tags, with completion all tags in all agenda files.}
4662 %:keyword   @r{specific information for certain link types, see below}
4663 %[pathname] @r{insert the contents of the file given by @code{pathname}}
4664 %(sexp)     @r{evaluate elisp @code{(sexp)} and replace with the result}
4665 %!          @r{immediately store note after completing the template}
4666             @r{(skipping the @kbd{C-c C-c} that normally triggers storing)}
4667 @end example
4669 @noindent
4670 For specific link types, the following keywords will be
4671 defined@footnote{If you define your own link types (@pxref{Adding
4672 hyperlink types}), any property you store with
4673 @code{org-store-link-props} can be accessed in remember templates in a
4674 similar way.}:
4676 @example
4677 Link type          |  Available keywords
4678 -------------------+----------------------------------------------
4679 bbdb               |  %:name %:company
4680 bbdb               |  %::server %:port %:nick
4681 vm, wl, mh, rmail  |  %:type %:subject %:message-id
4682                    |  %:from %:fromname %:fromaddress
4683                    |  %:to   %:toname   %:toaddress
4684                    |  %: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}.}}
4685 gnus               |  %:group, @r{for messages also all email fields}
4686 w3, w3m            |  %:url
4687 info               |  %:file %:node
4688 calendar           |  %:date"
4689 @end example
4691 @noindent
4692 To place the cursor after template expansion use:
4694 @example
4695 %?          @r{After completing the template, position cursor here.}
4696 @end example
4698 @noindent
4699 If you change your mind about which template to use, call
4700 @code{org-remember} in the remember buffer.  You may then select a new
4701 template that will be filled with the previous context information.
4703 @node Storing notes, Refiling notes, Remember templates, Remember
4704 @section Storing notes
4706 When you are finished preparing a note with @i{remember}, you have to
4707 press @kbd{C-c C-c} to file the note away.  The handler will store the
4708 note in the file and under the headline specified in the template, or it
4709 will use the default file and headlines.  The window configuration will
4710 be restored, sending you back to the working context before the call to
4711 @code{remember}.  To re-use the location found during the last call to
4712 @code{remember}, exit the remember buffer with @kbd{C-u C-u C-c C-c},
4713 i.e. specify a double prefix argument to @kbd{C-c C-c}.
4715 If you want to store the note directly to a different place, use
4716 @kbd{C-u C-c C-c} instead to exit remember@footnote{Configure the
4717 variable @code{org-remember-store-without-prompt} to make this behavior
4718 the default.}.  The handler will then first prompt for a target file -
4719 if you press @key{RET}, the value specified for the template is used.
4720 Then the command offers the headings tree of the selected file, with the
4721 cursor position at the default headline (if you had specified one in the
4722 template).  You can either immediately press @key{RET} to get the note
4723 placed there.  Or you can use the following keys to find a different
4724 location:
4725 @example
4726 @key{TAB}         @r{Cycle visibility.}
4727 @key{down} / @key{up}   @r{Next/previous visible headline.}
4728 n / p        @r{Next/previous visible headline.}
4729 f / b        @r{Next/previous headline same level.}
4730 u            @r{One level up.}
4731 @c 0-9          @r{Digit argument.}
4732 @end example
4733 @noindent
4734 Pressing @key{RET} or @key{left} or @key{right}
4735 then leads to the following result.
4737 @multitable @columnfractions 0.2 0.15 0.65
4738 @item @b{Cursor position} @tab @b{Key} @tab @b{Note gets inserted}
4739 @item on headline     @tab @key{RET}              @tab as sublevel of the heading at cursor, first or last
4740 @item                 @tab                        @tab depending on @code{org-reverse-note-order}.
4741 @item                 @tab @key{left}/@key{right} @tab as same level, before/after current heading
4742 @item buffer-start    @tab @key{RET} @tab as level 2 heading at end of file or level 1 at beginning
4743 @item                 @tab @tab depending on @code{org-reverse-note-order}.
4744 @item not on headline @tab @key{RET}
4745       @tab at cursor position, level taken from context.
4746 @end multitable
4748 Before inserting the text into a tree, the function ensures that the
4749 text has a headline, i.e. a first line that starts with a @samp{*}.  If
4750 not, a headline is constructed from the current date and some additional
4751 data.  If you have indented the text of the note below the headline, the
4752 indentation will be adapted if inserting the note into the tree requires
4753 demotion from level 1.
4755 @node Refiling notes,  , Storing notes, Remember
4756 @section Refiling notes
4757 @cindex refiling notes
4759 Remember is usually used to quickly capture notes and tasks into one or
4760 a few capture lists.  When reviewing the captured data, you may want to
4761 refile some of the entries into a different list, for example into a
4762 project.  Cutting, finding the right location and then pasting the note
4763 is cumbersome.  To simplify this process, you can use the following
4764 special command:
4766 @table @kbd
4767 @kindex C-c C-w
4768 @item C-c C-w
4769 Refile the entry at point.  This command offers possible locations for
4770 refiling the entry and lets you select one with completion.  The item is
4771 filed below the target heading as a subitem.  Depending on
4772 @code{org-reverse-note-order}, it will be either the first of last
4773 subitem.@* By default, all level 1 headlines in the current buffer are
4774 considered to be targets, but you can have more complex definitions
4775 across a number of files.  See the variable @code{org-refile-targets}
4776 for details.
4777 @kindex C-u C-c C-w
4778 @item C-u C-c C-w
4779 Use the refile interface to jump to a heading.
4780 @kindex C-u C-u C-c C-w
4781 @item C- C-u C-c C-w
4782 Jump to the location where @code{org-refile} last moved a tree to.
4783 @end table
4785 @node Agenda views, Embedded LaTeX, Remember, Top
4786 @chapter Agenda Views
4787 @cindex agenda views
4789 Due to the way Org-mode works, TODO items, time-stamped items, and
4790 tagged headlines can be scattered throughout a file or even a number of
4791 files.  To get an overview of open action items, or of events that are
4792 important for a particular date, this information must be collected,
4793 sorted and displayed in an organized way.
4795 Org-mode can select items based on various criteria, and display them
4796 in a separate buffer.  Seven different view types are provided:
4798 @itemize @bullet
4799 @item
4800 an @emph{agenda} that is like a calendar and shows information
4801 for specific dates,
4802 @item
4803 a @emph{TODO list} that covers all unfinished
4804 action items,
4805 @item
4806 a @emph{tags view}, showings headlines based on
4807 the tags associated with them,
4808 @item
4809 a @emph{timeline view} that shows all events in a single Org-mode file,
4810 in time-sorted view,
4811 @item
4812 a @emph{keyword search view} that shows all entries from multiple files
4813 that contain specified keywords.
4814 @item
4815 a @emph{stuck projects view} showing projects that currently don't move
4816 along, and
4817 @item
4818 @emph{custom views} that are special tag/keyword searches and
4819 combinations of different views.
4820 @end itemize
4822 @noindent
4823 The extracted information is displayed in a special @emph{agenda
4824 buffer}.  This buffer is read-only, but provides commands to visit the
4825 corresponding locations in the original Org-mode files, and even to
4826 edit these files remotely.
4828 Two variables control how the agenda buffer is displayed and whether the
4829 window configuration is restored when the agenda exits:
4830 @code{org-agenda-window-setup} and
4831 @code{org-agenda-restore-windows-after-quit}.
4833 @menu
4834 * Agenda files::                Files being searched for agenda information
4835 * Agenda dispatcher::           Keyboard access to agenda views
4836 * Built-in agenda views::       What is available out of the box?
4837 * Presentation and sorting::    How agenda items are prepared for display
4838 * Agenda commands::             Remote editing of org trees
4839 * Custom agenda views::         Defining special searches and views
4840 @end menu
4842 @node Agenda files, Agenda dispatcher, Agenda views, Agenda views
4843 @section Agenda files
4844 @cindex agenda files
4845 @cindex files for agenda
4847 The information to be shown is normally collected from all @emph{agenda
4848 files}, the files listed in the variable
4849 @code{org-agenda-files}@footnote{If the value of that variable is not a
4850 list, but a single file name, then the list of agenda files will be
4851 maintained in that external file.}. If a directory is part of this list,
4852 all files with the extension @file{.org} in this directory will be part
4853 of the list.
4855 Thus even if you only work with a single Org-mode file, this file should
4856 be put into that list@footnote{When using the dispatcher, pressing
4857 @kbd{<} before selecting a command will actually limit the command to
4858 the current file, and ignore @code{org-agenda-files} until the next
4859 dispatcher command.}.  You can customize @code{org-agenda-files}, but
4860 the easiest way to maintain it is through the following commands
4862 @cindex files, adding to agenda list
4863 @table @kbd
4864 @kindex C-c [
4865 @item C-c [
4866 Add current file to the list of agenda files.  The file is added to
4867 the front of the list.  If it was already in the list, it is moved to
4868 the front.  With a prefix argument, file is added/moved to the end.
4869 @kindex C-c ]
4870 @item C-c ]
4871 Remove current file from the list of agenda files.
4872 @kindex C-,
4873 @kindex C-'
4874 @item C-,
4875 @itemx C-'
4876 Cycle through agenda file list, visiting one file after the other.
4877 @end table
4879 @noindent
4880 The Org menu contains the current list of files and can be used
4881 to visit any of them.
4883 If you would like to focus the agenda temporarily onto a file not in
4884 this list, or onto just one file in the list or even only a subtree in a
4885 file, this can be done in different ways.  For a single agenda command,
4886 you may press @kbd{<} once or several times in the dispatcher
4887 (@pxref{Agenda dispatcher}).  To restrict the agenda scope for an
4888 extended period, use the following commands:
4890 @table @kbd
4891 @kindex C-c C-x <
4892 @item C-c C-x <
4893 Permanently restrict the agenda to the current subtree.  When with a
4894 prefix argument, or with the cursor before the first headline in a file,
4895 the agenda scope is set to the entire file.  This restriction remains in
4896 effect until removed with @kbd{C-c C-x >}, or by typing either @kbd{<}
4897 or @kbd{>} in the agenda dispatcher.  If there is a window displaying an
4898 agenda view, the new restriction takes effect immediately.
4899 @kindex C-c C-x <
4900 @item C-c C-x <
4901 Remove the permanent restriction created by @kbd{C-c C-x <}.
4902 @end table
4904 @noindent
4905 When working with @file{Speedbar}, you can use the following commands in
4906 the Speedbar frame:
4907 @table @kbd
4908 @kindex <
4909 @item < @r{in the speedbar frame}
4910 Permanently restrict the agenda to the item at the cursor in the
4911 Speedbar frame, either an Org-mode file or a subtree in such a file.
4912 If there is a window displaying an agenda view, the new restriction takes
4913 effect immediately.
4914 @kindex <
4915 @item > @r{in the speedbar frame}
4916 Lift the restriction again.
4917 @end table
4919 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda views
4920 @section The agenda dispatcher
4921 @cindex agenda dispatcher
4922 @cindex dispatching agenda commands
4923 The views are created through a dispatcher that should be bound to a
4924 global key, for example @kbd{C-c a} (@pxref{Installation}).  In the
4925 following we will assume that @kbd{C-c a} is indeed how the dispatcher
4926 is accessed and list keyboard access to commands accordingly.  After
4927 pressing @kbd{C-c a}, an additional letter is required to execute a
4928 command.  The dispatcher offers the following default commands:
4929 @table @kbd
4930 @item a
4931 Create the calendar-like agenda (@pxref{Weekly/Daily agenda}).
4932 @item t @r{/} T
4933 Create a list of all TODO items (@pxref{Global TODO list}).
4934 @item m @r{/} M
4935 Create a list of headlines matching a TAGS expression (@pxref{Matching
4936 tags and properties}).
4937 @item L
4938 Create the timeline view for the current buffer (@pxref{Timeline}).
4939 @item s
4940 Create a list of entries selected by a boolean expression of keywords
4941 and/or regular expressions that must or must not occur in the entry.
4942 @item /
4943 Search for a regular expression in all agenda files and additionally in
4944 the files listed in @code{org-agenda-multi-occur-extra-files}.  This
4945 uses the Emacs command @code{multi-occur}.  A prefix argument can be
4946 used to specify the number of context lines for each match, default is
4948 @item # @r{/} !
4949 Create a list of stuck projects (@pxref{Stuck projects}).
4950 @item <
4951 Restrict an agenda command to the current buffer@footnote{For backward
4952 compatibility, you can also press @kbd{1} to restrict to the current
4953 buffer.}.  After pressing @kbd{<}, you still need to press the character
4954 selecting the command.
4955 @item < <
4956 If there is an active region, restrict the following agenda command to
4957 the region.  Otherwise, restrict it to the current subtree@footnote{For
4958 backward compatibility, you can also press @kbd{0} to restrict to the
4959 current buffer.}.  After pressing @kbd{< <}, you still need to press the
4960 character selecting the command.
4961 @end table
4963 You can also define custom commands that will be accessible through the
4964 dispatcher, just like the default commands.  This includes the
4965 possibility to create extended agenda buffers that contain several
4966 blocks together, for example the weekly agenda, the global TODO list and
4967 a number of special tags matches.  @xref{Custom agenda views}.
4969 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda views
4970 @section The built-in agenda views
4972 In this section we describe the built-in views.
4974 @menu
4975 * Weekly/Daily agenda::         The calendar page with current tasks
4976 * Global TODO list::            All unfinished action items
4977 * Matching tags and properties::  Structured information with fine-tuned search
4978 * Timeline::                    Time-sorted view for single file
4979 * Keyword search::              Finding entries by keyword
4980 * Stuck projects::              Find projects you need to review
4981 @end menu
4983 @node Weekly/Daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
4984 @subsection The weekly/daily agenda
4985 @cindex agenda
4986 @cindex weekly agenda
4987 @cindex daily agenda
4989 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
4990 paper agenda, showing all the tasks for the current week or day.
4992 @table @kbd
4993 @cindex org-agenda, command
4994 @kindex C-c a a
4995 @item C-c a a
4996 Compile an agenda for the current week from a list of org files.  The
4997 agenda shows the entries for each day.  With a numeric
4998 prefix@footnote{For backward compatibility, the universal prefix
4999 @kbd{C-u} causes all TODO entries to be listed before the agenda.  This
5000 feature is deprecated, use the dedicated TODO list, or a block agenda
5001 instead.}  (like @kbd{C-u 2 1 C-c a a}) you may set the number of days
5002 to be displayed (see also the variable @code{org-agenda-ndays})
5003 @end table
5005 Remote editing from the agenda buffer means, for example, that you can
5006 change the dates of deadlines and appointments from the agenda buffer.
5007 The commands available in the Agenda buffer are listed in @ref{Agenda
5008 commands}.
5010 @subsubheading Calendar/Diary integration
5011 @cindex calendar integration
5012 @cindex diary integration
5014 Emacs contains the calendar and diary by Edward M. Reingold.  The
5015 calendar displays a three-month calendar with holidays from different
5016 countries and cultures.  The diary allows you to keep track of
5017 anniversaries, lunar phases, sunrise/set, recurrent appointments
5018 (weekly, monthly) and more.  In this way, it is quite complementary to
5019 Org-mode.  It can be very useful to combine output from Org-mode with
5020 the diary.
5022 In order to include entries from the Emacs diary into Org-mode's
5023 agenda, you only need to customize the variable
5025 @lisp
5026 (setq org-agenda-include-diary t)
5027 @end lisp
5029 @noindent After that, everything will happen automatically.  All diary
5030 entries including holidays, anniversaries etc will be included in the
5031 agenda buffer created by Org-mode.  @key{SPC}, @key{TAB}, and
5032 @key{RET} can be used from the agenda buffer to jump to the diary
5033 file in order to edit existing diary entries.  The @kbd{i} command to
5034 insert new entries for the current date works in the agenda buffer, as
5035 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
5036 Sunrise/Sunset times, show lunar phases and to convert to other
5037 calendars, respectively.  @kbd{c} can be used to switch back and forth
5038 between calendar and agenda.
5040 If you are using the diary only for sexp entries and holidays, it is
5041 faster to not use the above setting, but instead to copy or even move
5042 the entries into an Org-mode file. Org-mode evaluates diary-style sexp
5043 entries, and does it faster because there is no overhead for first
5044 creating the diary display.  Note that the sexp entries must start at
5045 the left margin, no white space is allowed before them.  For example,
5046 the following segment of an Org-mode file will be processed and entries
5047 will be made in the agenda:
5049 @example
5050 * Birthdays and similar stuff
5051 #+CATEGORY: Holiday
5052 %%(org-calendar-holiday)   ; special function for holiday names
5053 #+CATEGORY: Ann
5054 %%(diary-anniversary 14  5 1956) Arthur Dent is %d years old
5055 %%(diary-anniversary  2 10 1869) Mahatma Gandhi would be %d years old
5056 @end example
5058 @subsubheading Appointment reminders
5059 @cindex @file{appt.el}
5060 @cindex appointment reminders
5062 Org can interact with Emacs appointments notification facility.
5064 To add all the appointments of your agenda files, use the command
5065 @code{org-agenda-to-appt}.  This commands also lets you filter through
5066 the list of your appointments and add only those belonging to a specific
5067 category or matching a regular expression. See the docstring for
5068 details.
5070 @node Global TODO list, Matching tags and properties, Weekly/Daily agenda, Built-in agenda views
5071 @subsection The global TODO list
5072 @cindex global TODO list
5073 @cindex TODO list, global
5075 The global TODO list contains all unfinished TODO items, formatted and
5076 collected into a single place.
5078 @table @kbd
5079 @kindex C-c a t
5080 @item C-c a t
5081 Show the global TODO list.  This collects the TODO items from all
5082 agenda files (@pxref{Agenda views}) into a single buffer.  The buffer is in
5083 @code{agenda-mode}, so there are commands to examine and manipulate
5084 the TODO entries directly from that buffer (@pxref{Agenda commands}).
5085 @kindex C-c a T
5086 @item C-c a T
5087 @cindex TODO keyword matching
5088 Like the above, but allows selection of a specific TODO keyword.  You
5089 can also do this by specifying a prefix argument to @kbd{C-c a t}.  With
5090 a @kbd{C-u} prefix you are prompted for a keyword, and you may also
5091 specify several keywords by separating them with @samp{|} as boolean OR
5092 operator.  With a numeric prefix, the Nth keyword in
5093 @code{org-todo-keywords} is selected.
5094 @kindex r
5095 The @kbd{r} key in the agenda buffer regenerates it, and you can give
5096 a prefix argument to this command to change the selected TODO keyword,
5097 for example @kbd{3 r}.  If you often need a search for a specific
5098 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
5099 Matching specific TODO keywords can also be done as part of a tags
5100 search (@pxref{Tag searches}).
5101 @end table
5103 Remote editing of TODO items means that you can change the state of a
5104 TODO entry with a single key press.  The commands available in the
5105 TODO list are described in @ref{Agenda commands}.
5107 @cindex sublevels, inclusion into TODO list
5108 Normally the global TODO list simply shows all headlines with TODO
5109 keywords.  This list can become very long.  There are two ways to keep
5110 it more compact:
5111 @itemize @minus
5112 @item
5113 Some people view a TODO item that has been @emph{scheduled} for
5114 execution (@pxref{Time stamps}) as no longer @emph{open}.  Configure the
5115 variable @code{org-agenda-todo-ignore-scheduled} to exclude scheduled
5116 items from the global TODO list.
5117 @item
5118 TODO items may have sublevels to break up the task into subtasks.  In
5119 such cases it may be enough to list only the highest level TODO headline
5120 and omit the sublevels from the global list.  Configure the variable
5121 @code{org-agenda-todo-list-sublevels} to get this behavior.
5122 @end itemize
5124 @node Matching tags and properties, Timeline, Global TODO list, Built-in agenda views
5125 @subsection Matching Tags and Properties
5126 @cindex matching, of tags
5127 @cindex matching, of properties
5128 @cindex tags view
5130 If headlines in the agenda files are marked with @emph{tags}
5131 (@pxref{Tags}), you can select headlines based on the tags that apply
5132 to them and collect them into an agenda buffer.
5134 @table @kbd
5135 @kindex C-c a m
5136 @item C-c a m
5137 Produce a list of all headlines that match a given set of tags.  The
5138 command prompts for a selection criterion, which is a boolean logic
5139 expression with tags, like @samp{+work+urgent-withboss} or
5140 @samp{work|home} (@pxref{Tags}).  If you often need a specific search,
5141 define a custom command for it (@pxref{Agenda dispatcher}).
5142 @kindex C-c a M
5143 @item C-c a M
5144 Like @kbd{C-c a m}, but only select headlines that are also TODO items
5145 and force checking subitems (see variable
5146 @code{org-tags-match-list-sublevels}).  Matching specific TODO keywords
5147 together with a tags match is also possible, see @ref{Tag searches}.
5148 @end table
5150 The commands available in the tags list are described in @ref{Agenda
5151 commands}.
5153 @node Timeline, Keyword search, Matching tags and properties, Built-in agenda views
5154 @subsection Timeline for a single file
5155 @cindex timeline, single file
5156 @cindex time-sorted view
5158 The timeline summarizes all time-stamped items from a single Org-mode
5159 file in a @emph{time-sorted view}.  The main purpose of this command is
5160 to give an overview over events in a project.
5162 @table @kbd
5163 @kindex C-c a L
5164 @item C-c a L
5165 Show a time-sorted view of the org file, with all time-stamped items.
5166 When called with a @kbd{C-u} prefix, all unfinished TODO entries
5167 (scheduled or not) are also listed under the current date.
5168 @end table
5170 @noindent
5171 The commands available in the timeline buffer are listed in
5172 @ref{Agenda commands}.
5174 @node Keyword search, Stuck projects, Timeline, Built-in agenda views
5175 @subsection Keyword search
5176 @cindex keyword search
5177 @cindex searching, for keywords
5179 This agenda view is a general text search facility for Org-mode entries.
5180 It is particularly useful to find notes.
5182 @table @kbd
5183 @kindex C-c a s
5184 @item C-c a s
5185 This is a special search that lets you select entries by keywords or
5186 regular expression, using a boolean logic.  For example, the search
5187 string
5189 @example
5190 +computer +wifi -ethernet -@{8\.11[bg]@}
5191 @end example
5193 @noindent
5194 will search for note entries that contain the keywords @code{computer}
5195 and @code{wifi}, but not the keyword @code{ethernet}, and which are also
5196 not matched by the regular expression @code{8\.11[bg]}, meaning to
5197 exclude both 8.11b and 8.11g.
5199 Note that in addition to the agenda files, this command will also search
5200 the files listed in @code{org-agenda-text-search-extra-files}.
5201 @end table
5203 @node Stuck projects,  , Keyword search, Built-in agenda views
5204 @subsection Stuck projects
5206 If you are following a system like David Allen's GTD to organize your
5207 work, one of the ``duties'' you have is a regular review to make sure
5208 that all projects move along.  A @emph{stuck} project is a project that
5209 has no defined next actions, so it will never show up in the TODO lists
5210 Org-mode produces.  During the review, you need to identify such
5211 projects and define next actions for them.
5213 @table @kbd
5214 @kindex C-c a #
5215 @item C-c a #
5216 List projects that are stuck.
5217 @kindex C-c a !
5218 @item C-c a !
5219 Customize the variable @code{org-stuck-projects} to define what a stuck
5220 project is and how to find it.
5221 @end table
5223 You almost certainly will have to configure this view before it will
5224 work for you.  The built-in default assumes that all your projects are
5225 level-2 headlines, and that a project is not stuck if it has at least
5226 one entry marked with a TODO keyword TODO or NEXT or NEXTACTION.
5228 Lets assume that you, in your own way of using Org-mode, identify
5229 projects with a tag PROJECT, and that you use a TODO keyword MAYBE to
5230 indicate a project that should not be considered yet.  Lets further
5231 assume that the TODO keyword DONE marks finished projects, and that NEXT
5232 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
5233 is a next action even without the NEXT tag.  Finally, if the project
5234 contains the special word IGNORE anywhere, it should not be listed
5235 either.  In this case you would start by identifying eligible projects
5236 with a tags/todo match @samp{+PROJECT/-MAYBE-DONE}, and then check for
5237 TODO, NEXT, @@SHOP, and IGNORE in the subtree to identify projects that
5238 are not stuck.  The correct customization for this is
5240 @lisp
5241 (setq org-stuck-projects
5242       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
5243                                "\\<IGNORE\\>"))
5244 @end lisp
5247 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda views
5248 @section Presentation and sorting
5249 @cindex presentation, of agenda items
5251 Before displaying items in an agenda view, Org-mode visually prepares
5252 the items and sorts them.  Each item occupies a single line.  The line
5253 starts with a @emph{prefix} that contains the @emph{category}
5254 (@pxref{Categories}) of the item and other important information.  You can
5255 customize the prefix using the option @code{org-agenda-prefix-format}.
5256 The prefix is followed by a cleaned-up version of the outline headline
5257 associated with the item.
5259 @menu
5260 * Categories::                  Not all tasks are equal
5261 * Time-of-day specifications::  How the agenda knows the time
5262 * Sorting of agenda items::     The order of things
5263 @end menu
5265 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
5266 @subsection Categories
5268 @cindex category
5269 The category is a broad label assigned to each agenda item.  By default,
5270 the category is simply derived from the file name, but you can also
5271 specify it with a special line in the buffer, like this@footnote{For
5272 backward compatibility, the following also works: If there are several
5273 such lines in a file, each specifies the category for the text below it.
5274 The first category also applies to any text before the first CATEGORY
5275 line.  However, using this method is @emph{strongly} deprecated as it is
5276 incompatible with the outline structure of the document.  The correct
5277 method for setting multiple categories in a buffer is using a
5278 property.}:
5280 @example
5281 #+CATEGORY: Thesis
5282 @end example
5284 @noindent
5285 If you would like to have a special CATEGORY for a single entry or a
5286 (sub)tree, give the entry a @code{:CATEGORY:} property with the location
5287 as the value (@pxref{Properties and columns}).
5289 @noindent
5290 The display in the agenda buffer looks best if the category is not
5291 longer than 10 characters.
5293 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
5294 @subsection Time-of-Day Specifications
5295 @cindex time-of-day specification
5297 Org-mode checks each agenda item for a time-of-day specification.  The
5298 time can be part of the time stamp that triggered inclusion into the
5299 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
5300 ranges can be specified with two time stamps, like
5302 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
5304 In the headline of the entry itself, a time(range) may also appear as
5305 plain text (like @samp{12:45} or a @samp{8:30-1pm}.  If the agenda
5306 integrates the Emacs diary (@pxref{Weekly/Daily agenda}), time
5307 specifications in diary entries are recognized as well.
5309 For agenda display, Org-mode extracts the time and displays it in a
5310 standard 24 hour format as part of the prefix.  The example times in
5311 the previous paragraphs would end up in the agenda like this:
5313 @example
5314     8:30-13:00 Arthur Dent lies in front of the bulldozer
5315    12:45...... Ford Prefect arrives and takes Arthur to the pub
5316    19:00...... The Vogon reads his poem
5317    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
5318 @end example
5320 @cindex time grid
5321 If the agenda is in single-day mode, or for the display of today, the
5322 timed entries are embedded in a time grid, like
5324 @example
5325     8:00...... ------------------
5326     8:30-13:00 Arthur Dent lies in front of the bulldozer
5327    10:00...... ------------------
5328    12:00...... ------------------
5329    12:45...... Ford Prefect arrives and takes Arthur to the pub
5330    14:00...... ------------------
5331    16:00...... ------------------
5332    18:00...... ------------------
5333    19:00...... The Vogon reads his poem
5334    20:00...... ------------------
5335    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
5336 @end example
5338 The time grid can be turned on and off with the variable
5339 @code{org-agenda-use-time-grid}, and can be configured with
5340 @code{org-agenda-time-grid}.
5342 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
5343 @subsection Sorting of agenda items
5344 @cindex sorting, of agenda items
5345 @cindex priorities, of agenda items
5346 Before being inserted into a view, the items are sorted.  How this is
5347 done depends on the type of view.
5348 @itemize @bullet
5349 @item
5350 For the daily/weekly agenda, the items for each day are sorted.  The
5351 default order is to first collect all items containing an explicit
5352 time-of-day specification.  These entries will be shown at the beginning
5353 of the list, as a @emph{schedule} for the day.  After that, items remain
5354 grouped in categories, in the sequence given by @code{org-agenda-files}.
5355 Within each category, items are sorted by priority (@pxref{Priorities}),
5356 which is composed of the base priority (2000 for priority @samp{A}, 1000
5357 for @samp{B}, and 0 for @samp{C}), plus additional increments for
5358 overdue scheduled or deadline items.
5359 @item
5360 For the TODO list, items remain in the order of categories, but within
5361 each category, sorting takes place according to priority
5362 (@pxref{Priorities}).
5363 @item
5364 For tags matches, items are not sorted at all, but just appear in the
5365 sequence in which they are found in the agenda files.
5366 @end itemize
5368 Sorting can be customized using the variable
5369 @code{org-agenda-sorting-strategy}.
5372 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda views
5373 @section Commands in the agenda buffer
5374 @cindex commands, in agenda buffer
5376 Entries in the agenda buffer are linked back to the org file or diary
5377 file where they originate.  You are not allowed to edit the agenda
5378 buffer itself, but commands are provided to show and jump to the
5379 original entry location, and to edit the org-files ``remotely'' from
5380 the agenda buffer.  In this way, all information is stored only once,
5381 removing the risk that your agenda and note files may diverge.
5383 Some commands can be executed with mouse clicks on agenda lines.  For
5384 the other commands, the cursor needs to be in the desired line.
5386 @table @kbd
5387 @tsubheading{Motion}
5388 @cindex motion commands in agenda
5389 @kindex n
5390 @item n
5391 Next line (same as @key{up} and @kbd{C-p}).
5392 @kindex p
5393 @item p
5394 Previous line (same as @key{down} and @kbd{C-n}).
5395 @tsubheading{View/Go to org file}
5396 @kindex mouse-3
5397 @kindex @key{SPC}
5398 @item mouse-3
5399 @itemx @key{SPC}
5400 Display the original location of the item in another window.
5402 @kindex L
5403 @item L
5404 Display original location and recenter that window.
5406 @kindex mouse-2
5407 @kindex mouse-1
5408 @kindex @key{TAB}
5409 @item mouse-2
5410 @itemx mouse-1
5411 @itemx @key{TAB}
5412 Go to the original location of the item in another window.  Under Emacs
5413 22, @kbd{mouse-1} will also works for this.
5415 @kindex @key{RET}
5416 @itemx @key{RET}
5417 Go to the original location of the item and delete other windows.
5419 @kindex f
5420 @item f
5421 Toggle Follow mode.  In Follow mode, as you move the cursor through
5422 the agenda buffer, the other window always shows the corresponding
5423 location in the org file.  The initial setting for this mode in new
5424 agenda buffers can be set with the variable
5425 @code{org-agenda-start-with-follow-mode}.
5427 @kindex b
5428 @item b
5429 Display the entire subtree of the current item in an indirect buffer.  With a
5430 numeric prefix argument N, go up to level N and then take that tree.  If N is
5431 negative, go up that many levels.  With a @kbd{C-u} prefix, do not remove the
5432 previously used indirect buffer.
5434 @kindex l
5435 @item l
5436 Toggle Logbook mode.  In Logbook mode, entries that where marked DONE while
5437 logging was on (variable @code{org-log-done}) are shown in the agenda,
5438 as are entries that have been clocked on that day.
5440 @tsubheading{Change display}
5441 @cindex display changing, in agenda
5442 @kindex o
5443 @item o
5444 Delete other windows.
5446 @kindex d
5447 @kindex w
5448 @kindex m
5449 @kindex y
5450 @item d w m y
5451 Switch to day/week/month/year view.  When switching to day or week view,
5452 this setting becomes the default for subsequent agenda commands.  Since
5453 month and year views are slow to create, they do not become the default.
5454 A numeric prefix argument may be used to jump directly to a specific day
5455 of the year, ISO week, month, or year, respectively.  For example,
5456 @kbd{32 d} jumps to February 1st, @kbd{9 w} to ISO week number 9.  When
5457 setting day, week, or month view, a year may be encoded in the prefix
5458 argument as well.  For example, @kbd{200712 w} will jump to week 12 in
5459 2007.  If such a year specification has only one or two digits, it will
5460 be mapped to the interval 1938-2037.
5462 @kindex D
5463 @item D
5464 Toggle the inclusion of diary entries.  See @ref{Weekly/Daily agenda}.
5466 @kindex G
5467 @item G
5468 Toggle the time grid on and off.  See also the variables
5469 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
5471 @kindex r
5472 @item r
5473 Recreate the agenda buffer, for example to reflect the changes
5474 after modification of the time stamps of items with S-@key{left} and
5475 S-@key{right}.  When the buffer is the global TODO list, a prefix
5476 argument is interpreted to create a selective list for a specific TODO
5477 keyword.
5478 @kindex g
5479 @item g
5480 Same as @kbd{r}.
5482 @kindex s
5483 @kindex C-x C-s
5484 @item s
5485 @itemx C-x C-s
5486 Save all Org-mode buffers in the current Emacs session.
5488 @kindex @key{right}
5489 @item @key{right}
5490 Display the following @code{org-agenda-ndays} days.  For example, if
5491 the display covers a week, switch to the following week.  With prefix
5492 arg, go forward that many times @code{org-agenda-ndays} days.
5494 @kindex @key{left}
5495 @item @key{left}
5496 Display the previous dates.
5498 @kindex .
5499 @item .
5500 Go to today.
5502 @tsubheading{Query editing}
5503 @cindex query editing, in agenda
5505 @kindex [
5506 @kindex ]
5507 @kindex @{
5508 @kindex @}
5509 @item [ ] @{ @}
5510 In the @i{search view} (@pxref{Keyword search}), these keys add new
5511 search words (@kbd{[} and @kbd{]}) or new regular expressions (@kbd{@{}
5512 and @kbd{@}}) to the query string.  The opening bracket/brace will add a
5513 positive search term prefixed by @samp{+}, indicating that this search
5514 term @i{must} occur/match in the entry.  Closing bracket/brace add a
5515 negative search term which @i{must not} occur/match in the entry for it
5516 to be selected.
5519 @tsubheading{Remote editing}
5520 @cindex remote editing, from agenda
5522 @item 0-9
5523 Digit argument.
5525 @cindex undoing remote-editing events
5526 @cindex remote editing, undo
5527 @kindex C-_
5528 @item C-_
5529 Undo a change due to a remote editing command.  The change is undone
5530 both in the agenda buffer and in the remote buffer.
5532 @kindex t
5533 @item t
5534 Change the TODO state of the item, both in the agenda and in the
5535 original org file.
5537 @kindex C-k
5538 @item C-k
5539 Delete the current agenda item along with the entire subtree belonging
5540 to it in the original Org-mode file.  If the text to be deleted remotely
5541 is longer than one line, the kill needs to be confirmed by the user.  See
5542 variable @code{org-agenda-confirm-kill}.
5544 @kindex $
5545 @item $
5546 Archive the subtree corresponding to the current headline.
5548 @kindex T
5549 @item T
5550 Show all tags associated with the current item.  Because of
5551 inheritance, this may be more than the tags listed in the line itself.
5553 @kindex :
5554 @item :
5555 Set tags for the current headline.  If there is an active region in the
5556 agenda, change a tag for all headings in the region.
5558 @kindex a
5559 @item a
5560 Toggle the ARCHIVE tag for the current headline.
5562 @kindex ,
5563 @item ,
5564 Set the priority for the current item.  Org-mode prompts for the
5565 priority character. If you reply with @key{SPC}, the priority cookie
5566 is removed from the entry.
5568 @kindex P
5569 @item P
5570 Display weighted priority of current item.
5572 @kindex +
5573 @kindex S-@key{up}
5574 @item +
5575 @itemx S-@key{up}
5576 Increase the priority of the current item.  The priority is changed in
5577 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
5578 key for this.
5580 @kindex -
5581 @kindex S-@key{down}
5582 @item -
5583 @itemx S-@key{down}
5584 Decrease the priority of the current item.
5586 @kindex C-c C-s
5587 @item C-c C-s
5588 Schedule this item
5590 @kindex C-c C-d
5591 @item C-c C-d
5592 Set a deadline for this item.
5594 @kindex S-@key{right}
5595 @item S-@key{right}
5596 Change the time stamp associated with the current line by one day into the
5597 future.  With a numeric prefix argument, change it by that many days.  For
5598 example, @kbd{3 6 5 S-@key{right}} will change it by a year.  The stamp is
5599 changed in the original org file, but the change is not directly reflected in
5600 the agenda buffer.  Use the @kbd{r} key to update the buffer.
5602 @kindex S-@key{left}
5603 @item S-@key{left}
5604 Change the time stamp associated with the current line by one day
5605 into the past.
5607 @kindex >
5608 @item >
5609 Change the time stamp associated with the current line to today.
5610 The key @kbd{>} has been chosen, because it is the same as @kbd{S-.}
5611 on my keyboard.
5613 @kindex I
5614 @item I
5615 Start the clock on the current item.  If a clock is running already, it
5616 is stopped first.
5618 @kindex O
5619 @item O
5620 Stop the previously started clock.
5622 @kindex X
5623 @item X
5624 Cancel the currently running clock.
5626 @kindex J
5627 @item J
5628 Jump to the running clock in another window.
5630 @tsubheading{Calendar commands}
5631 @cindex calendar commands, from agenda
5632 @kindex c
5633 @item c
5634 Open the Emacs calendar and move to the date at the agenda cursor.
5636 @item c
5637 When in the calendar, compute and show the Org-mode agenda for the
5638 date at the cursor.
5640 @cindex diary entries, creating from agenda
5641 @kindex i
5642 @item i
5643 Insert a new entry into the diary.  Prompts for the type of entry
5644 (day, weekly, monthly, yearly, anniversary, cyclic) and creates a new
5645 entry in the diary, just as @kbd{i d} etc. would do in the calendar.
5646 The date is taken from the cursor position.
5648 @kindex M
5649 @item M
5650 Show the phases of the moon for the three months around current date.
5652 @kindex S
5653 @item S
5654 Show sunrise and sunset times.  The geographical location must be set
5655 with calendar variables, see documentation of the Emacs calendar.
5657 @kindex C
5658 @item C
5659 Convert the date at cursor into many other cultural and historic
5660 calendars.
5662 @kindex H
5663 @item H
5664 Show holidays for three month around the cursor date.
5666 @c FIXME:  This should be a different key.
5667 @kindex C-c C-x C-c
5668 @item C-c C-x C-c
5669 Export a single iCalendar file containing entries from all agenda files.
5671 @tsubheading{Exporting to a file}
5672 @kindex C-x C-w
5673 @item C-x C-w
5674 @cindex exporting agenda views
5675 @cindex agenda views, exporting
5676 Write the agenda view to a file.  Depending on the extension of the
5677 selected file name, the view will be exported as HTML (extension
5678 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}), or
5679 plain text (any other extension).  Use the variable
5680 @code{org-agenda-exporter-settings} to set options for @file{ps-print}
5681 and for @file{htmlize} to be used during export.
5683 @tsubheading{Quit and Exit}
5684 @kindex q
5685 @item q
5686 Quit agenda, remove the agenda buffer.
5688 @kindex x
5689 @cindex agenda files, removing buffers
5690 @item x
5691 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
5692 for the compilation of the agenda.  Buffers created by the user to
5693 visit org files will not be removed.
5694 @end table
5697 @node Custom agenda views,  , Agenda commands, Agenda views
5698 @section Custom agenda views
5699 @cindex custom agenda views
5700 @cindex agenda views, custom
5702 Custom agenda commands serve two purposes: to store and quickly access
5703 frequently used TODO and tags searches, and to create special composite
5704 agenda buffers.  Custom agenda commands will be accessible through the
5705 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
5707 @menu
5708 * Storing searches::            Type once, use often
5709 * Block agenda::                All the stuff you need in a single buffer
5710 * Setting Options::             Changing the rules
5711 * Exporting Agenda Views::      Writing agendas to files.
5712 * Extracting Agenda Information for other programs::
5713 @end menu
5715 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
5716 @subsection Storing searches
5718 The first application of custom searches is the definition of keyboard
5719 shortcuts for frequently used searches, either creating an agenda
5720 buffer, or a sparse tree (the latter covering of course only the current
5721 buffer).
5722 @kindex C-c a C
5723 Custom commands are configured in the variable
5724 @code{org-agenda-custom-commands}.  You can customize this variable, for
5725 example by pressing @kbd{C-c a C}.  You can also directly set it with
5726 Emacs Lisp in @file{.emacs}.  The following example contains all valid
5727 search types:
5729 @lisp
5730 @group
5731 (setq org-agenda-custom-commands
5732       '(("w" todo "WAITING")
5733         ("W" todo-tree "WAITING")
5734         ("u" tags "+boss-urgent")
5735         ("v" tags-todo "+boss-urgent")
5736         ("U" tags-tree "+boss-urgent")
5737         ("f" occur-tree "\\<FIXME\\>")
5738         ("h" . "HOME+Name tags searches") ; description for "h" prefix
5739         ("hl" tags "+home+Lisa")
5740         ("hp" tags "+home+Peter")
5741         ("hk" tags "+home+Kim")))
5742 @end group
5743 @end lisp
5745 @noindent
5746 The initial string in each entry defines the keys you have to press
5747 after the dispatcher command @kbd{C-c a} in order to access the command.
5748 Usually this will be just a single character, but if you have many
5749 similar commands, you can also define two-letter combinations where the
5750 first character is the same in several combinations and serves as a
5751 prefix key@footnote{You can provide a description for a prefix key by
5752 inserting a cons cell with the prefix and the description.}.  The second
5753 parameter is the search type, followed by the string or regular
5754 expression to be used for the matching.  The example above will
5755 therefore define:
5757 @table @kbd
5758 @item C-c a w
5759 as a global search for TODO entries with @samp{WAITING} as the TODO
5760 keyword
5761 @item C-c a W
5762 as the same search, but only in the current buffer and displaying the
5763 results as a sparse tree
5764 @item C-c a u
5765 as a global tags search for headlines marked @samp{:boss:} but not
5766 @samp{:urgent:}
5767 @item C-c a v
5768 as the same search as @kbd{C-c a u}, but limiting the search to
5769 headlines that are also TODO items
5770 @item C-c a U
5771 as the same search as @kbd{C-c a u}, but only in the current buffer and
5772 displaying the result as a sparse tree
5773 @item C-c a f
5774 to create a sparse tree (again: current buffer only) with all entries
5775 containing the word @samp{FIXME}
5776 @item C-c a h
5777 as a prefix command for a HOME tags search where you have to press an
5778 additional key (@kbd{l}, @kbd{p} or @kbd{k}) to select a name (Lisa,
5779 Peter, or Kim) as additional tag to match.
5780 @end table
5782 @node Block agenda, Setting Options, Storing searches, Custom agenda views
5783 @subsection Block agenda
5784 @cindex block agenda
5785 @cindex agenda, with block views
5787 Another possibility is the construction of agenda views that comprise
5788 the results of @emph{several} commands, each of which creates a block in
5789 the agenda buffer.  The available commands include @code{agenda} for the
5790 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
5791 for the global TODO list (as constructed with @kbd{C-c a t}), and the
5792 matching commands discussed above: @code{todo}, @code{tags}, and
5793 @code{tags-todo}.  Here are two examples:
5795 @lisp
5796 @group
5797 (setq org-agenda-custom-commands
5798       '(("h" "Agenda and Home-related tasks"
5799          ((agenda "")
5800           (tags-todo "home")
5801           (tags "garden")))
5802         ("o" "Agenda and Office-related tasks"
5803          ((agenda "")
5804           (tags-todo "work")
5805           (tags "office")))))
5806 @end group
5807 @end lisp
5809 @noindent
5810 This will define @kbd{C-c a h} to create a multi-block view for stuff
5811 you need to attend to at home.  The resulting agenda buffer will contain
5812 your agenda for the current week, all TODO items that carry the tag
5813 @samp{home}, and also all lines tagged with @samp{garden}.  Finally the
5814 command @kbd{C-c a o} provides a similar view for office tasks.
5816 @node Setting Options, Exporting Agenda Views, Block agenda, Custom agenda views
5817 @subsection Setting Options for custom commands
5818 @cindex options, for custom agenda views
5820 Org-mode contains a number of variables regulating agenda construction
5821 and display.  The global variables define the behavior for all agenda
5822 commands, including the custom commands.  However, if you want to change
5823 some settings just for a single custom view, you can do so.  Setting
5824 options requires inserting a list of variable names and values at the
5825 right spot in @code{org-agenda-custom-commands}.  For example:
5827 @lisp
5828 @group
5829 (setq org-agenda-custom-commands
5830       '(("w" todo "WAITING"
5831          ((org-agenda-sorting-strategy '(priority-down))
5832           (org-agenda-prefix-format "  Mixed: ")))
5833         ("U" tags-tree "+boss-urgent"
5834          ((org-show-following-heading nil)
5835           (org-show-hierarchy-above nil)))
5836         ("N" search ""
5837          ((org-agenda-files '("~org/notes.org"))
5838           (org-agenda-text-search-extra-files nil)))))
5839 @end group
5840 @end lisp
5842 @noindent
5843 Now the @kbd{C-c a w} command will sort the collected entries only by
5844 priority, and the prefix format is modified to just say @samp{  Mixed: }
5845 instead of giving the category of the entry.  The sparse tags tree of
5846 @kbd{C-c a U} will now turn out ultra-compact, because neither the
5847 headline hierarchy above the match, nor the headline following the match
5848 will be shown.  The command @kbd{C-c a N} will do a text search limited
5849 to only a single file.
5851 For command sets creating a block agenda,
5852 @code{org-agenda-custom-commands} has two separate spots for setting
5853 options.  You can add options that should be valid for just a single
5854 command in the set, and options that should be valid for all commands in
5855 the set.  The former are just added to the command entry, the latter
5856 must come after the list of command entries.  Going back to the block
5857 agenda example (@pxref{Block agenda}), let's change the sorting strategy
5858 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
5859 the results for GARDEN tags query in the opposite order,
5860 @code{priority-up}.  This would look like this:
5862 @lisp
5863 @group
5864 (setq org-agenda-custom-commands
5865       '(("h" "Agenda and Home-related tasks"
5866          ((agenda)
5867           (tags-todo "home")
5868           (tags "garden"
5869                 ((org-agenda-sorting-strategy '(priority-up)))))
5870          ((org-agenda-sorting-strategy '(priority-down))))
5871         ("o" "Agenda and Office-related tasks"
5872          ((agenda)
5873           (tags-todo "work")
5874           (tags "office")))))
5875 @end group
5876 @end lisp
5878 As you see, the values and parenthesis setting is a little complex.
5879 When in doubt, use the customize interface to set this variable - it
5880 fully supports its structure.  Just one caveat: When setting options in
5881 this interface, the @emph{values} are just lisp expressions.  So if the
5882 value is a string, you need to add the double quotes around the value
5883 yourself.
5886 @node Exporting Agenda Views, Extracting Agenda Information for other programs, Setting Options, Custom agenda views
5887 @subsection Exporting Agenda Views
5888 @cindex agenda views, exporting
5890 If you are away from your computer, it can be very useful to have a
5891 printed version of some agenda views to carry around.  Org-mode can
5892 export custom agenda views as plain text, HTML@footnote{You need to
5893 install Hrvoje Niksic' @file{htmlize.el}.} postscript, and iCalendar
5894 files.  If you want to do this only occasionally, use the command
5896 @table @kbd
5897 @kindex C-x C-w
5898 @item C-x C-w
5899 @cindex exporting agenda views
5900 @cindex agenda views, exporting
5901 Write the agenda view to a file.  Depending on the extension of the
5902 selected file name, the view will be exported as HTML (extension
5903 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}),
5904 iCalendar (extension @file{.ics}), or plain text (any other extension).
5905 Use the variable @code{org-agenda-exporter-settings} to
5906 set options for @file{ps-print} and for @file{htmlize} to be used during
5907 export, for example
5909 @lisp
5910 (setq org-agenda-exporter-settings
5911       '((ps-number-of-columns 2)
5912         (ps-landscape-mode t)
5913         (htmlize-output-type 'css)))
5914 @end lisp
5915 @end table
5917 If you need to export certain agenda views frequently, you can associate
5918 any custom agenda command with a list of output file names
5919 @footnote{If you want to store standard views like the weekly agenda
5920 or the global TODO list as well, you need to define custom commands for
5921 them in order to be able to specify file names.}.  Here is an example
5922 that first does define custom commands for the agenda and the global
5923 todo list, together with a number of files to which to export them.
5924 Then we define two block agenda commands and specify file names for them
5925 as well.  File names can be relative to the current working directory,
5926 or absolute.
5928 @lisp
5929 @group
5930 (setq org-agenda-custom-commands
5931       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
5932         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
5933         ("h" "Agenda and Home-related tasks"
5934          ((agenda "")
5935           (tags-todo "home")
5936           (tags "garden"))
5937          nil
5938          ("~/views/home.html"))
5939         ("o" "Agenda and Office-related tasks"
5940          ((agenda)
5941           (tags-todo "work")
5942           (tags "office"))
5943          nil
5944          ("~/views/office.ps" "~/calendars/office.ics"))))
5945 @end group
5946 @end lisp
5948 The extension of the file name determines the type of export.  If it is
5949 @file{.html}, Org-mode will use the @file{htmlize.el} package to convert
5950 the buffer to HTML and save it to this file name.  If the extension is
5951 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
5952 postscript output.  If the extension is @file{.ics}, iCalendar export is
5953 run export over all files that were used to construct the agenda, and
5954 limit the export to entries listed in the agenda now.  Any other
5955 extension produces a plain ASCII file.
5957 The export files are @emph{not} created when you use one of those
5958 commands interactively because this might use too much overhead.
5959 Instead, there is a special command to produce @emph{all} specified
5960 files in one step:
5962 @table @kbd
5963 @kindex C-c a e
5964 @item C-c a e
5965 Export all agenda views that have export file names associated with
5966 them.
5967 @end table
5969 You can use the options section of the custom agenda commands to also
5970 set options for the export commands.  For example:
5972 @lisp
5973 (setq org-agenda-custom-commands
5974       '(("X" agenda ""
5975          ((ps-number-of-columns 2)
5976           (ps-landscape-mode t)
5977           (org-agenda-prefix-format " [ ] ")
5978           (org-agenda-with-colors nil)
5979           (org-agenda-remove-tags t))
5980          ("theagenda.ps"))))
5981 @end lisp
5983 @noindent
5984 This command sets two options for the postscript exporter, to make it
5985 print in two columns in landscape format - the resulting page can be cut
5986 in two and then used in a paper agenda.  The remaining settings modify
5987 the agenda prefix to omit category and scheduling information, and
5988 instead include a checkbox to check off items.  We also remove the tags
5989 to make the lines compact, and we don't want to use colors for the
5990 black-and-white printer.  Settings specified in
5991 @code{org-agenda-exporter-settings} will also apply, but the settings
5992 in @code{org-agenda-custom-commands} take precedence.
5994 @noindent
5995 From the command line you may also use
5996 @example
5997 emacs -f org-batch-store-agenda-views -kill
5998 @end example
5999 @noindent
6000 or, if you need to modify some parameters
6001 @example
6002 emacs -eval '(org-batch-store-agenda-views                      \
6003               org-agenda-ndays 30                               \
6004               org-agenda-start-day "2007-11-01"                 \
6005               org-agenda-include-diary nil                      \
6006               org-agenda-files (quote ("~/org/project.org")))'  \
6007       -kill
6008 @end example
6009 @noindent
6010 which will create the agenda views restricted to the file
6011 @file{~/org/project.org}, without diary entries and with 30 days
6012 extent.
6014 @node Extracting Agenda Information for other programs,  , Exporting Agenda Views, Custom agenda views
6015 @subsection Extracting Agenda Information for other programs
6016 @cindex agenda, pipe
6017 @cindex Scripts, for agenda processing
6019 Org-mode provides commands to access agenda information for the command
6020 line in emacs batch mode.  This extracted information can be sent
6021 directly to a printer, or it can be read by a program that does further
6022 processing of the data.  The first of these commands is the function
6023 @code{org-batch-agenda}, that produces an agenda view and sends it as
6024 ASCII text to STDOUT.  The command takes a single string as parameter.
6025 If the string has length 1, it is used as a key to one of the commands
6026 you have configured in @code{org-agenda-custom-commands}, basically any
6027 key you can use after @kbd{C-c a}.  For example, to directly print the
6028 current TODO list, you could use
6030 @example
6031 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
6032 @end example
6034 If the parameter is a string with 2 or more characters, it is used as a
6035 tags/todo match string.  For example, to print your local shopping list
6036 (all items with the tag @samp{shop}, but excluding the tag
6037 @samp{NewYork}), you could use
6039 @example
6040 emacs -batch -l ~/.emacs                                      \
6041       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
6042 @end example
6044 @noindent
6045 You may also modify parameters on the fly like this:
6047 @example
6048 emacs -batch -l ~/.emacs                                      \
6049    -eval '(org-batch-agenda "a"                               \
6050             org-agenda-ndays 30                               \
6051             org-agenda-include-diary nil                      \
6052             org-agenda-files (quote ("~/org/project.org")))'  \
6053    | lpr
6054 @end example
6056 @noindent
6057 which will produce a 30 day agenda, fully restricted to the Org file
6058 @file{~/org/projects.org}, not even including the diary.
6060 If you want to process the agenda data in more sophisticated ways, you
6061 can use the command @code{org-batch-agenda-csv} to get a comma-separated
6062 list of values for each agenda item.  Each line in the output will
6063 contain a number of fields separated by commas.  The fields in a line
6064 are:
6066 @example
6067 category     @r{The category of the item}
6068 head         @r{The headline, without TODO kwd, TAGS and PRIORITY}
6069 type         @r{The type of the agenda entry, can be}
6070                 todo               @r{selected in TODO match}
6071                 tagsmatch          @r{selected in tags match}
6072                 diary              @r{imported from diary}
6073                 deadline           @r{a deadline}
6074                 scheduled          @r{scheduled}
6075                 timestamp          @r{appointment, selected by timestamp}
6076                 closed             @r{entry was closed on date}
6077                 upcoming-deadline  @r{warning about nearing deadline}
6078                 past-scheduled     @r{forwarded scheduled item}
6079                 block              @r{entry has date block including date}
6080 todo         @r{The TODO keyword, if any}
6081 tags         @r{All tags including inherited ones, separated by colons}
6082 date         @r{The relevant date, like 2007-2-14}
6083 time         @r{The time, like 15:00-16:50}
6084 extra        @r{String with extra planning info}
6085 priority-l   @r{The priority letter if any was given}
6086 priority-n   @r{The computed numerical priority}
6087 @end example
6089 @noindent
6090 Time and date will only be given if a timestamp (or deadline/scheduled)
6091 lead to the selection of the item.
6093 A CSV list like this is very easy to use in a post processing script.
6094 For example, here is a Perl program that gets the TODO list from
6095 Emacs/org-mode and prints all the items, preceded by a checkbox:
6097 @example
6098 @group
6099 #!/usr/bin/perl
6101 # define the Emacs command to run
6102 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
6104 # run it and capture the output
6105 $agenda = qx@{$cmd 2>/dev/null@};
6107 # loop over all lines
6108 foreach $line (split(/\n/,$agenda)) @{
6110   # get the individual values
6111   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
6112    $priority_l,$priority_n) = split(/,/,$line);
6114   # proccess and print
6115   print "[ ] $head\n";
6117 @end group
6118 @end example
6120 @node Embedded LaTeX, Exporting, Agenda views, Top
6121 @chapter Embedded LaTeX
6122 @cindex @TeX{} interpretation
6123 @cindex La@TeX{} interpretation
6125 Plain ASCII is normally sufficient for almost all note taking.  One
6126 exception, however, are scientific notes which need to be able to
6127 contain mathematical symbols and the occasional formula.
6128 La@TeX{}@footnote{La@TeX{} is a macro system based on Donald E. Knuth's
6129 @TeX{} system.  Many of the features described here as ``La@TeX{}'' are
6130 really from @TeX{}, but for simplicity I am blurring this distinction.}
6131 is widely used to typeset scientific documents. Org-mode supports
6132 embedding La@TeX{} code into its files, because many academics are used
6133 to read La@TeX{} source code, and because it can be readily processed
6134 into images for HTML production.
6136 It is not necessary to mark La@TeX{} macros and code in any special way.
6137 If you observe a few conventions, Org-mode knows how to find it and what
6138 to do with it.
6140 @menu
6141 * Math symbols::                TeX macros for symbols and Greek letters
6142 * Subscripts and Superscripts::  Simple syntax for raising/lowering text
6143 * LaTeX fragments::             Complex formulas made easy
6144 * Processing LaTeX fragments::  Previewing LaTeX processing
6145 * CDLaTeX mode::                Speed up entering of formulas
6146 @end menu
6148 @node Math symbols, Subscripts and Superscripts, Embedded LaTeX, Embedded LaTeX
6149 @section Math symbols
6150 @cindex math symbols
6151 @cindex TeX macros
6153 You can use La@TeX{} macros to insert special symbols like @samp{\alpha}
6154 to indicate the Greek letter, or @samp{\to} to indicate an arrow.
6155 Completion for these macros is available, just type @samp{\} and maybe a
6156 few letters, and press @kbd{M-@key{TAB}} to see possible completions.
6157 Unlike La@TeX{} code, Org-mode allows these macros to be present
6158 without surrounding math delimiters, for example:
6160 @example
6161 Angles are written as Greek letters \alpha, \beta and \gamma.
6162 @end example
6164 During HTML export (@pxref{HTML export}), these symbols are translated
6165 into the proper syntax for HTML, for the above examples this is
6166 @samp{&alpha;} and @samp{&rarr;}, respectively.
6168 @node Subscripts and Superscripts, LaTeX fragments, Math symbols, Embedded LaTeX
6169 @section Subscripts and Superscripts
6170 @cindex subscript
6171 @cindex superscript
6173 Just like in La@TeX{}, @samp{^} and @samp{_} are used to indicate super-
6174 and subscripts.  Again, these can be used without embedding them in
6175 math-mode delimiters.  To increase the readability of ASCII text, it is
6176 not necessary (but OK) to surround multi-character sub- and superscripts
6177 with curly braces.  For example
6179 @example
6180 The mass if the sun is M_sun = 1.989 x 10^30 kg.  The radius of
6181 the sun is R_@{sun@} = 6.96 x 10^8 m.
6182 @end example
6184 To avoid interpretation as raised or lowered text, you can quote
6185 @samp{^} and @samp{_} with a backslash: @samp{\_} and @samp{\^}.
6187 During HTML export (@pxref{HTML export}), subscript and superscripts
6188 are surrounded with @code{<sub>} and @code{<sup>} tags, respectively.
6190 @node LaTeX fragments, Processing LaTeX fragments, Subscripts and Superscripts, Embedded LaTeX
6191 @section LaTeX fragments
6192 @cindex LaTeX fragments
6194 With symbols, sub- and superscripts, HTML is pretty much at its end when
6195 it comes to representing mathematical formulas@footnote{Yes, there is
6196 MathML, but that is not yet fully supported by many browsers, and there
6197 is no decent converter for turning La@TeX{} or ASCII representations of
6198 formulas into MathML. So for the time being, converting formulas into
6199 images seems the way to go.}. More complex expressions need a dedicated
6200 formula processor. To this end, Org-mode can contain arbitrary La@TeX{}
6201 fragments. It provides commands to preview the typeset result of these
6202 fragments, and upon export to HTML, all fragments will be converted to
6203 images and inlined into the HTML document@footnote{The La@TeX{} export
6204 will not use images for displaying La@TeX{} fragments but include these
6205 fragments directly into the La@TeX{} code.}. For this to work you
6206 need to be on a system with a working La@TeX{} installation. You also
6207 need the @file{dvipng} program, available at
6208 @url{http://sourceforge.net/projects/dvipng/}. The La@TeX{} header that
6209 will be used when processing a fragment can be configured with the
6210 variable @code{org-format-latex-header}.
6212 La@TeX{} fragments don't need any special marking at all.  The following
6213 snippets will be identified as La@TeX{} source code:
6214 @itemize @bullet
6215 @item
6216 Environments of any kind.  The only requirement is that the
6217 @code{\begin} statement appears on a new line, preceded by only
6218 whitespace.
6219 @item
6220 Text within the usual La@TeX{} math delimiters.  To avoid conflicts with
6221 currency specifications, single @samp{$} characters are only recognized
6222 as math delimiters if the enclosed text contains at most two line breaks,
6223 is directly attached to the @samp{$} characters with no whitespace in
6224 between, and if the closing @samp{$} is followed by whitespace or
6225 punctuation.  For the other delimiters, there is no such restriction, so
6226 when in doubt, use @samp{\(...\)} as inline math delimiters.
6227 @end itemize
6229 @noindent For example:
6231 @example
6232 \begin@{equation@}                          % arbitrary environments,
6233 x=\sqrt@{b@}                                % even tables, figures
6234 \end@{equation@}                            % etc
6236 If $a^2=b$ and \( b=2 \), then the solution must be
6237 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
6238 @end example
6240 @noindent
6241 If you need any of the delimiter ASCII sequences for other purposes, you
6242 can configure the option @code{org-format-latex-options} to deselect the
6243 ones you do not wish to have interpreted by the La@TeX{} converter.
6245 @node Processing LaTeX fragments, CDLaTeX mode, LaTeX fragments, Embedded LaTeX
6246 @section Processing LaTeX fragments
6247 @cindex LaTeX fragments, preview
6249 La@TeX{} fragments can be processed to produce a preview images of the
6250 typeset expressions:
6252 @table @kbd
6253 @kindex C-c C-x C-l
6254 @item C-c C-x C-l
6255 Produce a preview image of the La@TeX{} fragment at point and overlay it
6256 over the source code.  If there is no fragment at point, process all
6257 fragments in the current entry (between two headlines).  When called
6258 with a prefix argument, process the entire subtree.  When called with
6259 two prefix arguments, or when the cursor is before the first headline,
6260 process the entire buffer.
6261 @kindex C-c C-c
6262 @item C-c C-c
6263 Remove the overlay preview images.
6264 @end table
6266 During HTML export (@pxref{HTML export}), all La@TeX{} fragments are
6267 converted into images and inlined into the document if the following
6268 setting is active:
6270 @lisp
6271 (setq org-export-with-LaTeX-fragments t)
6272 @end lisp
6274 @node CDLaTeX mode,  , Processing LaTeX fragments, Embedded LaTeX
6275 @section Using CDLaTeX to enter math
6276 @cindex CDLaTeX
6278 CDLaTeX-mode is a minor mode that is normally used in combination with a
6279 major La@TeX{} mode like AUCTeX in order to speed-up insertion of
6280 environments and math templates.  Inside Org-mode, you can make use of
6281 some of the features of CDLaTeX-mode.  You need to install
6282 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
6283 AUCTeX) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
6284 Don't turn CDLaTeX-mode itself under Org-mode, but use the light
6285 version @code{org-cdlatex-mode} that comes as part of Org-mode.  Turn it
6286 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
6287 Org-mode files with
6289 @lisp
6290 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
6291 @end lisp
6293 When this mode is enabled, the following features are present (for more
6294 details see the documentation of CDLaTeX-mode):
6295 @itemize @bullet
6296 @kindex C-c @{
6297 @item
6298 Environment templates can be inserted with @kbd{C-c @{}.
6299 @item
6300 @kindex @key{TAB}
6301 The @key{TAB} key will do template expansion if the cursor is inside a
6302 La@TeX{} fragment@footnote{Org-mode has a method to test if the cursor is
6303 inside such a fragment, see the documentation of the function
6304 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
6305 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
6306 correctly inside the first brace.  Another @key{TAB} will get you into
6307 the second brace.  Even outside fragments, @key{TAB} will expand
6308 environment abbreviations at the beginning of a line.  For example, if
6309 you write @samp{equ} at the beginning of a line and press @key{TAB},
6310 this abbreviation will be expanded to an @code{equation} environment.
6311 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
6312 @item
6313 @kindex _
6314 @kindex ^
6315 Pressing @kbd{_} and @kbd{^} inside a La@TeX{} fragment will insert these
6316 characters together with a pair of braces.  If you use @key{TAB} to move
6317 out of the braces, and if the braces surround only a single character or
6318 macro, they are removed again (depending on the variable
6319 @code{cdlatex-simplify-sub-super-scripts}).
6320 @item
6321 @kindex `
6322 Pressing the backquote @kbd{`} followed by a character inserts math
6323 macros, also outside La@TeX{} fragments.  If you wait more than 1.5 seconds
6324 after the backquote, a help window will pop up.
6325 @item
6326 @kindex '
6327 Pressing the normal quote @kbd{'} followed by another character modifies
6328 the symbol before point with an accent or a font.  If you wait more than
6329 1.5 seconds after the backquote, a help window will pop up.  Character
6330 modification will work only inside La@TeX{} fragments, outside the quote
6331 is normal.
6332 @end itemize
6334 @node Exporting, Publishing, Embedded LaTeX, Top
6335 @chapter Exporting
6336 @cindex exporting
6338 Org-mode documents can be exported into a variety of other formats.  For
6339 printing and sharing of notes, ASCII export produces a readable and
6340 simple version of an Org-mode file.  HTML export allows you to publish a
6341 notes file on the web, while the XOXO format provides a solid base for
6342 exchange with a broad range of other applications. La@TeX{} export lets
6343 you use Org-mode and its structured editing functions to easily create
6344 La@TeX{} files.  To incorporate entries with associated times like
6345 deadlines or appointments into a desktop calendar program like iCal,
6346 Org-mode can also produce extracts in the iCalendar format.  Currently
6347 Org-mode only supports export, not import of these different formats.
6349 When exporting, Org-mode uses special conventions to enrich the output
6350 produced.  @xref{Text interpretation}, for more details.
6352 @table @kbd
6353 @kindex C-c C-e
6354 @item C-c C-e
6355 Dispatcher for export and publishing commands.  Displays a help-window
6356 listing the additional key(s) needed to launch an export or publishing
6357 command.
6358 @end table
6360 @menu
6361 * ASCII export::                Exporting to plain ASCII
6362 * HTML export::                 Exporting to HTML
6363 * LaTeX export::                Exporting to LaTeX
6364 * XOXO export::                 Exporting to XOXO
6365 * iCalendar export::            Exporting in iCalendar format
6366 * Text interpretation::         How the exporter looks at the file
6367 @end menu
6369 @node ASCII export, HTML export, Exporting, Exporting
6370 @section ASCII export
6371 @cindex ASCII export
6373 ASCII export produces a simple and very readable version of an Org-mode
6374 file.
6376 @cindex region, active
6377 @cindex active region
6378 @cindex transient-mark-mode
6379 @table @kbd
6380 @kindex C-c C-e a
6381 @item C-c C-e a
6382 Export as ASCII file.  For an org file @file{myfile.org}, the ASCII file
6383 will be @file{myfile.txt}.  The file will be overwritten without
6384 warning.  If there is an active region, only the region will be
6385 exported. If the selected region is a single tree, the tree head will
6386 become the document title.  If the tree head entry has or inherits an
6387 @code{:EXPORT_FILE_NAME:} property, that name will be used for the
6388 export.
6389 @kindex C-c C-e v a
6390 @item C-c C-e v a
6391 Export only the visible part of the document.
6392 @end table
6394 @cindex headline levels, for exporting
6395 In the exported version, the first 3 outline levels will become
6396 headlines, defining a general document structure.  Additional levels
6397 will be exported as itemized lists.  If you want that transition to occur
6398 at a different level, specify it with a prefix argument.  For example,
6400 @example
6401 @kbd{C-1 C-c C-e a}
6402 @end example
6404 @noindent
6405 creates only top level headlines and does the rest as items.  When
6406 headlines are converted to items, the indentation of the text following
6407 the headline is changed to fit nicely under the item.  This is done with
6408 the assumption that the first body line indicates the base indentation of
6409 the body text.  Any indentation larger than this is adjusted to preserve
6410 the layout relative to the first line.  Should there be lines with less
6411 indentation than the first, these are left alone.
6413 @node HTML export, LaTeX export, ASCII export, Exporting
6414 @section HTML export
6415 @cindex HTML export
6417 Org-mode contains an HTML (XHTML 1.0 strict) exporter with extensive
6418 HTML formatting, in ways similar to John Grubers @emph{markdown}
6419 language, but with additional support for tables.
6421 @menu
6422 * HTML Export commands::        How to invoke LaTeX export
6423 * Quoting HTML tags::           Using direct HTML in Org-mode
6424 * Links::                       Transformation of links for HTML
6425 * Images::                      How to include images
6426 * CSS support::                 Changing the appearance of the output
6427 @end menu
6429 @node HTML Export commands, Quoting HTML tags, HTML export, HTML export
6430 @subsection HTML export commands
6432 @cindex region, active
6433 @cindex active region
6434 @cindex transient-mark-mode
6435 @table @kbd
6436 @kindex C-c C-e h
6437 @item C-c C-e h
6438 Export as HTML file @file{myfile.html}.  For an org file
6439 @file{myfile.org}, the ASCII file will be @file{myfile.html}.  The file
6440 will be overwritten without warning.  If there is an active region, only
6441 the region will be exported. If the selected region is a single tree,
6442 the tree head will become the document title.  If the tree head entry
6443 has or inherits an @code{:EXPORT_FILE_NAME:} property, that name will be
6444 used for the export.
6445 @kindex C-c C-e b
6446 @item C-c C-e b
6447 Export as HTML file and immediately open it with a browser.
6448 @kindex C-c C-e H
6449 @item C-c C-e H
6450 Export to a temporary buffer, do not create a file.
6451 @kindex C-c C-e R
6452 @item C-c C-e R
6453 Export the active region to a temporary buffer.  With a prefix argument, do
6454 not produce the file header and footer, but just the plain HTML section for
6455 the region.  This is good for cut-and-paste operations.
6456 @kindex C-c C-e v h
6457 @kindex C-c C-e v b
6458 @kindex C-c C-e v H
6459 @kindex C-c C-e v R
6460 @item C-c C-e v h
6461 @item C-c C-e v b
6462 @item C-c C-e v H
6463 @item C-c C-e v R
6464 Export only the visible part of the document.
6465 @item M-x org-export-region-as-html
6466 Convert the region to HTML under the assumption that it was org-mode
6467 syntax before.  This is a global command that can be invoked in any
6468 buffer.
6469 @item M-x org-replace-region-by-HTML
6470 Replace the active region (assumed to be in Org-mode syntax) by HTML
6471 code.
6472 @end table
6474 @cindex headline levels, for exporting
6475 In the exported version, the first 3 outline levels will become headlines,
6476 defining a general document structure.  Additional levels will be exported as
6477 itemized lists.  If you want that transition to occur at a different level,
6478 specify it with a numeric prefix argument.  For example,
6480 @example
6481 @kbd{C-2 C-c C-e b}
6482 @end example
6484 @noindent
6485 creates two levels of headings and does the rest as items.
6487 @node Quoting HTML tags, Links, HTML Export commands, HTML export
6488 @subsection Quoting HTML tags
6490 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
6491 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
6492 which should be interpreted as such, mark them with @samp{@@} as in
6493 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
6494 simple tags.  For more extensive HTML that should be copied verbatim to
6495 the exported file use either
6497 @example
6498 #+HTML: Literal HTML code for export
6499 @end example
6501 @noindent or
6503 @example
6504 #+BEGIN_HTML
6505 All lines between these markers are exported literally
6506 #+END_HTML
6507 @end example
6510 @node Links, Images, Quoting HTML tags, HTML export
6511 @subsection Links
6513 @cindex links, in HTML export
6514 @cindex internal links, in HTML export
6515 @cindex external links, in HTML export
6516 Internal links (@pxref{Internal links}) will continue to work in HTML
6517 files only if they match a dedicated @samp{<<target>>}.  Automatic links
6518 created by radio targets (@pxref{Radio targets}) will also work in the
6519 HTML file.  Links to external files will still work if the HTML file is
6520 in the same directory as the Org-mode file.  Links to other @file{.org}
6521 files will be translated into HTML links under the assumption that an
6522 HTML version also exists of the linked file.  For information related to
6523 linking files while publishing them to a publishing directory see
6524 @ref{Publishing links}.
6526 @node Images, CSS support, Links, HTML export
6527 @subsection Images
6529 @cindex images, inline in HTML
6530 @cindex inlining images in HTML
6531 HTML export can inline images given as links in the Org-mode file, and
6532 it can make an image the clickable part of a link.  By
6533 default@footnote{but see the variable
6534 @code{org-export-html-inline-images}}, images are inlined if a link does
6535 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
6536 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
6537 @samp{the image} that points to the image.  If the description part
6538 itself is a @code{file:} link or a @code{http:} URL pointing to an
6539 image, this image will be inlined and activated so that clicking on the
6540 image will activate the link.  For example, to include a thumbnail that
6541 will link to a high resolution version of the image, you could use:
6543 @example
6544 [[file:highres.jpg][file:thumb.jpg]]
6545 @end example
6547 @noindent
6548 and you could use @code{http} addresses just as well.
6550 @node CSS support,  , Images, HTML export
6551 @subsection CSS support
6553 You can also give style information for the exported file.  The HTML
6554 exporter assigns the following CSS classes to appropriate parts of the
6555 document - your style specifications may change these:
6556 @example
6557 .todo           @r{TODO keywords}
6558 .done           @r{the DONE keyword}
6559 .timestamp      @r{time stamp}
6560 .timestamp-kwd  @r{keyword associated with a time stamp, like SCHEDULED}
6561 .tag            @r{tag in a headline}
6562 .target         @r{target for links}
6563 @end example
6565 The default style specification can be configured through the option
6566 @code{org-export-html-style}.  If you want to use a file-local style,
6567 you may use file variables, best wrapped into a COMMENT section at the
6568 end of the outline tree.  For example@footnote{Under Emacs 21, the
6569 continuation lines for a variable value should have no @samp{#} at the
6570 start of the line.}:
6572 @example
6573 * COMMENT html style specifications
6575 # Local Variables:
6576 # org-export-html-style: "   <style type=\"text/css\">
6577 #       p @{font-weight: normal; color: gray; @}
6578 #       h1 @{color: black; @}
6579 #   </style>"
6580 # End:
6581 @end example
6583 Remember to execute @kbd{M-x normal-mode} after changing this to make
6584 the new style visible to Emacs.  This command restarts org-mode for the
6585 current buffer and forces Emacs to re-evaluate the local variables
6586 section in the buffer.
6588 @c FIXME: More about header and footer styles
6589 @c FIXME: Talk about links and targets.
6591 @node LaTeX export, XOXO export, HTML export, Exporting
6592 @section LaTeX export
6593 @cindex LaTeX export
6595 Org-mode contains a La@TeX{} exporter written by Bastien Guerry.
6597 @menu
6598 * LaTeX export commands::       How to invoke LaTeX export
6599 * Quoting LaTeX code::          Incorporating literal LaTeX code
6600 * Sectioning structure::
6601 @end menu
6603 @node LaTeX export commands, Quoting LaTeX code, LaTeX export, LaTeX export
6604 @subsection LaTeX export commands
6606 @table @kbd
6607 @kindex C-c C-e l
6608 @item C-c C-e l
6609 Export as La@TeX{} file @file{myfile.tex}.
6610 @kindex C-c C-e L
6611 @item C-c C-e L
6612 Export to a temporary buffer, do not create a file.
6613 @kindex C-c C-e v l
6614 @kindex C-c C-e v L
6615 @item C-c C-e v l
6616 @item C-c C-e v L
6617 Export only the visible part of the document.
6618 @item M-x org-export-region-as-latex
6619 Convert the region to La@TeX{} under the assumption that it was org-mode
6620 syntax before.  This is a global command that can be invoked in any
6621 buffer.
6622 @item M-x org-replace-region-by-latex
6623 Replace the active region (assumed to be in Org-mode syntax) by La@TeX{}
6624 code.
6625 @end table
6627 @cindex headline levels, for exporting
6628 In the exported version, the first 3 outline levels will become
6629 headlines, defining a general document structure.  Additional levels
6630 will be exported as description lists.  The exporter can ignore them or
6631 convert them to a custom string depending on
6632 @code{org-latex-low-levels}.
6634 If you want that transition to occur at a different level, specify it
6635 with a numeric prefix argument. For example,
6637 @example
6638 @kbd{C-2 C-c C-e l}
6639 @end example
6641 @noindent
6642 creates two levels of headings and does the rest as items.
6644 @node Quoting LaTeX code, Sectioning structure, LaTeX export commands, LaTeX export
6645 @subsection Quoting LaTeX code
6647 Embedded La@TeX{} as described in @ref{Embedded LaTeX} will be correctly
6648 inserted into the La@TeX{} file.  Furthermore, you can add special code
6649 that should only be present in La@TeX{} export with the following
6650 constructs:
6652 @example
6653 #+LaTeX: Literal LaTeX code for export
6654 @end example
6656 @noindent or
6658 @example
6659 #+BEGIN_LaTeX
6660 All lines between these markers are exported literally
6661 #+END_LaTeX
6662 @end example
6666 @node   Sectioning structure,  , Quoting LaTeX code, LaTeX export
6667 @subsection Sectioning structure
6668 @cindex LaTeX class
6669 @cindex LaTeX sectioning structure
6671 By default, the La@TeX{} output uses the class @code{article}.
6673 You can change this globally by setting a different value for
6674 @code{org-export-latex-default-class} or locally by adding an option
6675 like @code{#+LaTeX_CLASS: myclass} in your file.  The class should be
6676 listed in @code{org-export-latex-classes}, where you can also define the
6677 sectioning structure for each class.
6680 @node XOXO export, iCalendar export, LaTeX export, Exporting
6681 @section XOXO export
6682 @cindex XOXO export
6684 Org-mode contains an exporter that produces XOXO-style output.
6685 Currently, this exporter only handles the general outline structure and
6686 does not interpret any additional Org-mode features.
6688 @table @kbd
6689 @kindex C-c C-e x
6690 @item C-c C-e x
6691 Export as XOXO file @file{myfile.html}.
6692 @kindex C-c C-e v
6693 @item C-c C-e v x
6694 Export only the visible part of the document.
6695 @end table
6697 @node iCalendar export, Text interpretation, XOXO export, Exporting
6698 @section iCalendar export
6699 @cindex iCalendar export
6701 Some people like to use Org-mode for keeping track of projects, but
6702 still prefer a standard calendar application for anniversaries and
6703 appointments.  In this case it can be useful to have deadlines and
6704 other time-stamped items in Org-mode files show up in the calendar
6705 application.  Org-mode can export calendar information in the standard
6706 iCalendar format.  If you also want to have TODO entries included in the
6707 export, configure the variable @code{org-icalendar-include-todo}.
6709 @table @kbd
6710 @kindex C-c C-e i
6711 @item C-c C-e i
6712 Create iCalendar entries for the current file and store them in the same
6713 directory, using a file extension @file{.ics}.
6714 @kindex C-c C-e I
6715 @item C-c C-e I
6716 Like @kbd{C-c C-e i}, but do this for all files in
6717 @code{org-agenda-files}.  For each of these files, a separate iCalendar
6718 file will be written.
6719 @kindex C-c C-e c
6720 @item C-c C-e c
6721 Create a single large iCalendar file from all files in
6722 @code{org-agenda-files} and write it to the file given by
6723 @code{org-combined-agenda-icalendar-file}.
6724 @end table
6726 The export will honor SUMMARY, DESCRIPTION and LOCATION properties if
6727 the selected entries have them.  If not, the summary will be derived
6728 from the headline, and the description from the body (limited to
6729 @code{org-icalendar-include-body} characters).
6731 How this calendar is best read and updated, depends on the application
6732 you are using.  The FAQ covers this issue.
6735 @node Text interpretation,  , iCalendar export, Exporting
6736 @section Text interpretation by the exporter
6738 The exporter backends interpret additional structure in the Org-mode file
6739 in order to produce better output.
6741 @menu
6742 * Comment lines::               Some lines will not be exported
6743 * Initial text::                Text before the first headline
6744 * Footnotes::                   Numbers like [1]
6745 * Quoted examples::             Inserting quoted chunks of text
6746 * Enhancing text::              Subscripts, symbols and more
6747 * Export options::              How to influence the export settings
6748 @end menu
6750 @node Comment lines, Initial text, Text interpretation, Text interpretation
6751 @subsection Comment lines
6752 @cindex comment lines
6753 @cindex exporting, not
6755 Lines starting with @samp{#} in column zero are treated as comments
6756 and will never be exported.  Also entire subtrees starting with the
6757 word @samp{COMMENT} will never be exported.
6759 @table @kbd
6760 @kindex C-c ;
6761 @item C-c ;
6762 Toggle the COMMENT keyword at the beginning of an entry.
6763 @end table
6765 @node Initial text, Footnotes, Comment lines, Text interpretation
6766 @subsection Text before the first headline
6768 Org-mode normally ignores any text before the first headline when
6769 exporting, leaving this region for internal links to speed up navigation
6770 etc.  However, in publishing-oriented files, you might want to have some
6771 text before the first headline, like a small introduction, special HTML
6772 code with a navigation bar, etc.  You can ask to have this part of the
6773 file exported as well by setting the variable
6774 @code{org-export-skip-text-before-1st-heading} to @code{nil}.  On a
6775 per-file basis, you can get the same effect with
6777 @example
6778 #+OPTIONS: skip:nil
6779 @end example
6781 The text before the first headline will be fully processed
6782 (@pxref{Enhancing text}), and the first non-comment line becomes the
6783 title of the exported document.  If you need to include literal HTML,
6784 use the special constructs described in @ref{Quoting HTML tags}.  The
6785 table of contents is normally inserted directly before the first
6786 headline of the file.  If you would like to get it to a different
6787 location, insert the string @code{[TABLE-OF-CONTENTS]} on a line by
6788 itself at the desired location.
6790 Finally, if you want to use the space before the first headline for
6791 internal purposes, but @emph{still} want to place something before the
6792 first headline when exporting the file, you can use the @code{#+TEXT}
6793 construct:
6795 @example
6796 #+OPTIONS: skip:t
6797 #+TEXT: This text will go before the *first* headline.
6798 #+TEXT: We place the table of contents here:
6799 #+TEXT: [TABLE-OF-CONTENTS]
6800 #+TEXT: This goes between the table of contents and the first headline
6801 @end example
6803 @node Footnotes, Quoted examples, Initial text, Text interpretation
6804 @subsection Footnotes
6805 @cindex footnotes
6806 @cindex @file{footnote.el}
6808 Numbers in square brackets are treated as footnotes, so that you can use
6809 the Emacs package @file{footnote.el} to create footnotes.  For example:
6811 @example
6812 The org-mode homepage[1] clearly needs help from
6813 a good web designer.
6815 [1] The link is: http://orgmode.org
6816 @end example
6818 @noindent
6819 @kindex C-c !
6820 Note that the @file{footnote} package uses @kbd{C-c !} to invoke its
6821 commands.  This binding conflicts with the org-mode command for
6822 inserting inactive time stamps.  You could use the variable
6823 @code{footnote-prefix} to switch footnotes commands to another key.  Or,
6824 if you are too used to this binding, you could use
6825 @code{org-replace-disputed-keys} and @code{org-disputed-keys} to change
6826 the settings in Org-mode.
6828 @node Quoted examples, Enhancing text, Footnotes, Text interpretation
6829 @subsection Quoted examples
6830 @cindex quoted examples
6831 @cindex examples, quoted
6832 @cindex text, fixed width
6833 @cindex fixed width text
6835 When writing technical documents, you often need to insert examples that
6836 are not further interpreted by Org-mode.  For historical reasons, there
6837 are several ways to do this:
6839 @itemize @bullet
6840 @item
6841 If a headline starts with the word @samp{QUOTE}, the text below the
6842 headline will be typeset as fixed-width, to allow quoting of computer
6843 codes etc.
6844 @item
6845 Lines starting with @samp{:} are also typeset in fixed-width font.
6846 @table @kbd
6847 @kindex C-c :
6848 @item C-c :
6849 Toggle fixed-width for entry (QUOTE) or region, see below.
6850 @end table
6851 @item
6852 Finally, text between
6853 @example
6854 #+BEGIN_EXAMPLE
6855 quoted text
6856 #+END_EXAMPLE
6857 @end example
6858 will also be exported in this way.
6859 @end itemize
6862 @node Enhancing text, Export options, Quoted examples, Text interpretation
6863 @subsection Enhancing text for export
6864 @cindex enhancing text
6865 @cindex richer text
6867 Some of the export backends of Org-mode allow for sophisticated text
6868 formatting, this is true in particular for the HTML and La@TeX{}
6869 backends.  Org-mode has a number of typing conventions that allow to
6870 produce a richly formatted output.
6872 @itemize @bullet
6874 @cindex hand-formatted lists
6875 @cindex lists, hand-formatted
6876 @item
6877 Plain lists @samp{-}, @samp{*} or @samp{+} as bullet, or with @samp{1.}
6878 or @samp{2)} as enumerator will be recognized and transformed if the
6879 backend supports lists.  See @xref{Plain lists}.
6881 @cindex underlined text
6882 @cindex bold text
6883 @cindex italic text
6884 @cindex verbatim text
6885 @item
6886 You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
6887 and @code{~verbatim~}, and, if you must, @samp{+strikethrough+}.  Text
6888 in the code and verbatim string is not processed for org-mode specific
6889 syntax, it is exported verbatim.
6891 @cindex horizontal rules, in exported files
6892 @item
6893 A line consisting of only dashes, and at least 5 of them, will be
6894 exported as a horizontal line (@samp{<hr/>} in HTML).
6896 @cindex LaTeX fragments, export
6897 @cindex TeX macros, export
6898 @item
6899 Many @TeX{} macros and entire La@TeX{} fragments are converted into HTML
6900 entities or images (@pxref{Embedded LaTeX}).
6902 @cindex tables, export
6903 @item
6904 Tables are transformed into native tables under the exporter, if the
6905 export backend supports this. Data fields before the first horizontal
6906 separator line will be formatted as table header fields.
6908 @cindex fixed width
6909 @item
6910 If a headline starts with the word @samp{QUOTE}, the text below the
6911 headline will be typeset as fixed-width, to allow quoting of computer
6912 codes etc.  Lines starting with @samp{:} are also typeset in fixed-width
6913 font.
6914 @table @kbd
6915 @kindex C-c :
6916 @item C-c :
6917 Toggle fixed-width for entry (QUOTE) or region, see below.
6918 @end table
6919 Finally, text between
6920 @example
6921 #+BEGIN_EXAMPLE
6922 quoted text
6923 #+END_EXAMPLE
6924 @end example
6925 will also be exported in this way.
6927 @cindex linebreak, forced
6928 @item
6929 A double backslash @emph{at the end of a line} enforces a line break at
6930 this position.
6932 @cindex HTML entities, LaTeX entities
6933 @item
6934 Strings like @code{\alpha} will be exported as @code{&alpha;}, in the
6935 HTML output.  These strings are exported as @code{$\alpha$} in the
6936 La@TeX{} output.  Similarly, @code{\nbsp} will become @code{&nbsp;} in
6937 HTML and in La@TeX{}.  This applies for a long list of entities, see
6938 the variable @code{org-html-entities} for the complete list.
6939 @c FIXME
6940 @end itemize
6942 If these conversions conflict with your habits of typing ASCII text,
6943 they can all be turned off with corresponding variables.  See the
6944 customization group @code{org-export-general}, and the following section
6945 which explains how to set export options with special lines in a
6946 buffer.
6949 @node Export options,  , Enhancing text, Text interpretation
6950 @subsection Export options
6951 @cindex options, for export
6953 @cindex completion, of option keywords
6954 The exporter recognizes special lines in the buffer which provide
6955 additional information.  These lines may be put anywhere in the file.
6956 The whole set of lines can be inserted into the buffer with @kbd{C-c
6957 C-e t}.  For individual lines, a good way to make sure the keyword is
6958 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
6959 (@pxref{Completion}).
6961 @table @kbd
6962 @kindex C-c C-e t
6963 @item C-c C-e t
6964 Insert template with export options, see example below.
6965 @end table
6967 @example
6968 #+TITLE:     the title to be shown (default is the buffer name)
6969 #+AUTHOR:    the author (default taken from @code{user-full-name})
6970 #+DATE:      A date, fixed, of a format string for @code{format-time-string}
6971 #+EMAIL:     his/her email address (default from @code{user-mail-address})
6972 #+LANGUAGE:  language for HTML, e.g. @samp{en} (@code{org-export-default-language})
6973 #+TEXT:      Some descriptive text to be inserted at the beginning.
6974 #+TEXT:      Several lines may be given.
6975 #+OPTIONS:   H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
6976 @end example
6978 @noindent
6979 The OPTIONS line is a compact form to specify export settings.  Here
6980 you can:
6981 @cindex headline levels
6982 @cindex section-numbers
6983 @cindex table of contents
6984 @cindex linebreak preservation
6985 @cindex quoted HTML tags
6986 @cindex fixed-width sections
6987 @cindex tables
6988 @cindex @TeX{}-like syntax for sub- and superscripts
6989 @cindex footnotes
6990 @cindex special strings
6991 @cindex emphasized text
6992 @cindex @TeX{} macros
6993 @cindex La@TeX{} fragments
6994 @cindex author info, in export
6995 @cindex time info, in export
6996 @example
6997 H:         @r{set the number of headline levels for export}
6998 num:       @r{turn on/off section-numbers}
6999 toc:       @r{turn on/off table of contents, or set level limit (integer)}
7000 \n:        @r{turn on/off linebreak-preservation}
7001 @@:         @r{turn on/off quoted HTML tags}
7002 ::         @r{turn on/off fixed-width sections}
7003 |:         @r{turn on/off tables}
7004 ^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
7005            @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
7006            @r{the simple @code{a_b} will be left as it is.}
7007 -:         @r{turn on/off conversion of special strings.}
7008 f:         @r{turn on/off foototes like this[1].}
7009 *:         @r{turn on/off emphasized text (bold, italic, underlined)}
7010 TeX:       @r{turn on/off simple @TeX{} macros in plain text}
7011 LaTeX:     @r{turn on/off La@TeX{} fragments}
7012 skip:      @r{turn on/off skipping the text before the first heading}
7013 author:    @r{turn on/off inclusion of author name/email into exported file}
7014 timestamp: @r{turn on/off inclusion creation time into exported file}
7015 d:         @r{turn on/off inclusion of drawers}
7016 @end example
7018 These options take effect in both the HTML and La@TeX{} export, except
7019 for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
7020 @code{nil} for the La@TeX{} export.
7022 @node Publishing, Miscellaneous, Exporting, Top
7023 @chapter Publishing
7024 @cindex publishing
7026 Org-mode includes@footnote{@file{org-publish.el} is not distributed with
7027 Emacs 21, if you are still using Emacs 21, you need you need to download
7028 this file separately.} a publishing management system that allows you to
7029 configure automatic HTML conversion of @emph{projects} composed of
7030 interlinked org files.  This system is called @emph{org-publish}.  You can
7031 also configure org-publish to automatically upload your exported HTML
7032 pages and related attachments, such as images and source code files, to
7033 a web server. Org-publish turns org-mode into a web-site authoring tool.
7035 You can also use Org-publish to convert files into La@TeX{}, or even
7036 combine HTML and La@TeX{} conversion so that files are available in both
7037 formats on the server@footnote{Since La@TeX{} files on a server are not
7038 that helpful, you surely want to perform further conversion on them --
7039 e.g. convert them to @code{PDF} format.}.
7041 Org-publish has been contributed to Org-mode by David O'Toole.
7043 @menu
7044 * Configuration::               Defining projects
7045 * Sample configuration::        Example projects
7046 * Triggering publication::      Publication commands
7047 @end menu
7049 @node Configuration, Sample configuration, Publishing, Publishing
7050 @section Configuration
7052 Publishing needs significant configuration to specify files, destination
7053 and many other properties of a project.
7055 @menu
7056 * Project alist::               The central configuration variable
7057 * Sources and destinations::    From here to there
7058 * Selecting files::             What files are part of the project?
7059 * Publishing action::           Setting the function doing the publishing
7060 * Publishing options::          Tweaking HTML export
7061 * Publishing links::            Which links keep working after publishing?
7062 * Project page index::          Publishing a list of project files
7063 @end menu
7065 @node Project alist, Sources and destinations, Configuration, Configuration
7066 @subsection The variable @code{org-publish-project-alist}
7067 @cindex org-publish-project-alist
7068 @cindex projects, for publishing
7070 Org-publish is configured almost entirely through setting the value of
7071 one variable, called @code{org-publish-project-alist}.
7072 Each element of the list configures one project, and may be in one of
7073 the two following forms:
7075 @lisp
7076 ("project-name" :property value :property value ...)
7078 @r{or}
7080 ("project-name" :components ("project-name" "project-name" ...))
7082 @end lisp
7084 In both cases, projects are configured by specifying property values.
7085 A project defines the set of files that will be published, as well as
7086 the publishing configuration to use when publishing those files.  When
7087 a project takes the second form listed above, the individual members
7088 of the ``components'' property are taken to be components of the
7089 project, which group together files requiring different publishing
7090 options. When you publish such a ``meta-project'' all the components
7091 will also publish.
7093 @node Sources and destinations, Selecting files, Project alist, Configuration
7094 @subsection Sources and destinations for files
7095 @cindex directories, for publishing
7097 Most properties are optional, but some should always be set. In
7098 particular, org-publish needs to know where to look for source files,
7099 and where to put published files.
7101 @multitable @columnfractions 0.3 0.7
7102 @item @code{:base-directory}
7103 @tab Directory containing publishing source files
7104 @item @code{:publishing-directory}
7105 @tab Directory (possibly remote) where output files will be published.
7106 @item @code{:preparation-function}
7107 @tab Function called before starting publishing process, for example to
7108 run @code{make} for updating files to be published.
7109 @end multitable
7110 @noindent
7112 @node Selecting files, Publishing action, Sources and destinations, Configuration
7113 @subsection Selecting files
7114 @cindex files, selecting for publishing
7116 By default, all files with extension @file{.org} in the base directory
7117 are considered part of the project.  This can be modified by setting the
7118 properties
7119 @multitable @columnfractions 0.25 0.75
7120 @item @code{:base-extension}
7121 @tab Extension (without the dot!) of source files.  This actually is a
7122 regular expression.
7124 @item @code{:exclude}
7125 @tab Regular expression to match file names that should not be
7126 published, even though they have been selected on the basis of their
7127 extension.
7129 @item @code{:include}
7130 @tab List of files to be included regardless of @code{:base-extension}
7131 and @code{:exclude}.
7132 @end multitable
7134 @node Publishing action, Publishing options, Selecting files, Configuration
7135 @subsection Publishing Action
7136 @cindex action, for publishing
7138 Publishing means that a file is copied to the destination directory and
7139 possibly transformed in the process.  The default transformation is to
7140 export Org-mode files as HTML files, and this is done by the function
7141 @code{org-publish-org-to-html} which calls the HTML exporter
7142 (@pxref{HTML export}). But you also can publish your files in La@TeX{} by
7143 using the function @code{org-publish-org-to-latex} instead. Other files
7144 like images only need to be copied to the publishing destination. For
7145 non-Org-mode files, you need to specify the publishing function.
7148 @multitable @columnfractions 0.3 0.7
7149 @item @code{:publishing-function}
7150 @tab Function executing the publication of a file.  This may also be a
7151 list of functions, which will all be called in turn.
7152 @end multitable
7154 The function must accept two arguments: a property list containing at
7155 least a @code{:publishing-directory} property, and the name of the file
7156 to be published.  It should take the specified file, make the necessary
7157 transformation (if any) and place the result into the destination folder.
7158 You can write your own publishing function, but @code{org-publish}
7159 provides one for attachments (files that only need to be copied):
7160 @code{org-publish-attachment}.
7162 @node Publishing options, Publishing links, Publishing action, Configuration
7163 @subsection Options for the HTML/LaTeX exporters
7164 @cindex options, for publishing
7166 The property list can be used to set many export options for the HTML
7167 and La@TeX{} exporters.  In most cases, these properties correspond to user
7168 variables in Org-mode.  The table below lists these properties along
7169 with the variable they belong to.  See the documentation string for the
7170 respective variable for details.
7172 @multitable @columnfractions 0.3 0.7
7173 @item @code{:language}              @tab @code{org-export-default-language}
7174 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
7175 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
7176 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
7177 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
7178 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
7179 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
7180 @item @code{:special-strings}       @tab @code{org-export-with-special-strings}
7181 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
7182 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
7183 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
7184 @item @code{:timestamps}           .@tab @code{org-export-with-timestamps}
7185 @item @code{:tags}                 .@tab @code{org-export-with-tags}
7186 @item @code{:tables}                @tab @code{org-export-with-tables}
7187 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
7188 @item @code{:style}                 @tab @code{org-export-html-style}
7189 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
7190 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
7191 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
7192 @item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
7193 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
7194 @item @code{:preamble}              @tab @code{org-export-html-preamble}
7195 @item @code{:postamble}             @tab @code{org-export-html-postamble}
7196 @item @code{:auto-preamble}         @tab @code{org-export-html-auto-preamble}
7197 @item @code{:auto-postamble}        @tab @code{org-export-html-auto-postamble}
7198 @item @code{:author}                @tab @code{user-full-name}
7199 @item @code{:email}                 @tab @code{user-mail-address}
7200 @end multitable
7202 If you use several email addresses, separate them by a semi-column.
7204 Most of the @code{org-export-with-*} variables have the same effect in
7205 both HTML and La@TeX{} exporters, except for @code{:TeX-macros} and
7206 @code{:LaTeX-fragments}, respectively @code{nil} and @code{t} in the
7207 La@TeX{} export.
7209 When a property is given a value in @code{org-publish-project-alist},
7210 its setting overrides the value of the corresponding user variable (if
7211 any) during publishing.  Options set within a file (@pxref{Export
7212 options}), however, override everything.
7214 @node Publishing links, Project page index, Publishing options, Configuration
7215 @subsection Links between published files
7216 @cindex links, publishing
7218 To create a link from one Org-mode file to another, you would use
7219 something like @samp{[[file:foo.org][The foo]]} or simply
7220 @samp{file:foo.org.} (@pxref{Hyperlinks}).  Upon publishing this link
7221 becomes a link to @file{foo.html}.  In this way, you can interlink the
7222 pages of your "org web" project and the links will work as expected when
7223 you publish them to HTML.
7225 You may also link to related files, such as images. Provided you are
7226 careful with relative pathnames, and provided you have also configured
7227 @code{org-publish} to upload the related files, these links will work
7228 too. @ref{Complex example} for an example of this usage.
7230 Sometime an Org-mode file to be published may contain links that are
7231 only valid in your production environment, but not in the publishing
7232 location.  In this case, use the property
7234 @multitable @columnfractions 0.4 0.6
7235 @item @code{:link-validation-function}
7236 @tab Function to validate links
7237 @end multitable
7239 @noindent
7240 to define a function for checking link validity.  This function must
7241 accept two arguments, the file name and a directory relative to which
7242 the file name is interpreted in the production environment.  If this
7243 function returns @code{nil}, then the HTML generator will only insert a
7244 description into the HTML file, but no link.  One option for this
7245 function is @code{org-publish-validate-link} which checks if the given
7246 file is part of any project in @code{org-publish-project-alist}.
7248 @node Project page index,  , Publishing links, Configuration
7249 @subsection Project page index
7250 @cindex index, of published pages
7252 The following properties may be used to control publishing of an
7253 index of files or summary page for a given project.
7255 @multitable @columnfractions 0.25 0.75
7256 @item @code{:auto-index}
7257 @tab When non-nil, publish an index during org-publish-current-project or
7258 org-publish-all.
7260 @item @code{:index-filename}
7261 @tab Filename for output of index. Defaults to @file{index.org} (which
7262 becomes @file{index.html}).
7264 @item @code{:index-title}
7265 @tab Title of index page. Defaults to name of file.
7267 @item @code{:index-function}
7268 @tab Plug-in function to use for generation of index.
7269 Defaults to @code{org-publish-org-index}, which generates a plain list
7270 of links to all files in the project.
7271 @end multitable
7273 @node Sample configuration, Triggering publication, Configuration, Publishing
7274 @section Sample configuration
7276 Below we provide two example configurations.  The first one is a simple
7277 project publishing only a set of Org-mode files.  The second example is
7278 more complex, with a multi-component project.
7280 @menu
7281 * Simple example::              One-component publishing
7282 * Complex example::             A multi-component publishing example
7283 @end menu
7285 @node Simple example, Complex example, Sample configuration, Sample configuration
7286 @subsection Example: simple publishing configuration
7288 This example publishes a set of Org-mode files to the @file{public_html}
7289 directory on the local machine.
7291 @lisp
7292 (setq org-publish-project-alist
7293       '(("org"
7294          :base-directory "~/org/"
7295          :publishing-directory "~/public_html"
7296          :section-numbers nil
7297          :table-of-contents nil
7298          :style "<link rel=stylesheet
7299                 href=\"../other/mystyle.css\"
7300                 type=\"text/css\">")))
7301 @end lisp
7303 @node Complex example,  , Simple example, Sample configuration
7304 @subsection Example: complex publishing configuration
7306 This more complicated example publishes an entire website, including
7307 org files converted to HTML, image files, emacs lisp source code, and
7308 style sheets. The publishing-directory is remote and private files are
7309 excluded.
7311 To ensure that links are preserved, care should be taken to replicate
7312 your directory structure on the web server, and to use relative file
7313 paths. For example, if your org files are kept in @file{~/org} and your
7314 publishable images in @file{~/images}, you'd link to an image with
7316 @example
7317 file:../images/myimage.png
7318 @end example
7320 On the web server, the relative path to the image should be the
7321 same. You can accomplish this by setting up an "images" folder in the
7322 right place on the web server, and publishing images to it.
7324 @lisp
7325 (setq org-publish-project-alist
7326       '(("orgfiles"
7327           :base-directory "~/org/"
7328           :base-extension "org"
7329           :publishing-directory "/ssh:user@@host:~/html/notebook/"
7330           :publishing-function org-publish-org-to-html
7331           :exclude "PrivatePage.org"   ;; regexp
7332           :headline-levels 3
7333           :section-numbers nil
7334           :table-of-contents nil
7335           :style "<link rel=stylesheet
7336                   href=\"../other/mystyle.css\" type=\"text/css\">"
7337           :auto-preamble t
7338           :auto-postamble nil)
7340          ("images"
7341           :base-directory "~/images/"
7342           :base-extension "jpg\\|gif\\|png"
7343           :publishing-directory "/ssh:user@@host:~/html/images/"
7344           :publishing-function org-publish-attachment)
7346          ("other"
7347           :base-directory "~/other/"
7348           :base-extension "css\\|el"
7349           :publishing-directory "/ssh:user@@host:~/html/other/"
7350           :publishing-function org-publish-attachment)
7351          ("website" :components ("orgfiles" "images" "other"))))
7352 @end lisp
7354 @node Triggering publication,  , Sample configuration, Publishing
7355 @section Triggering publication
7357 Once org-publish is properly configured, you can publish with the
7358 following functions:
7360 @table @kbd
7361 @item C-c C-e C
7362 Prompt for a specific project and publish all files that belong to it.
7363 @item C-c C-e P
7364 Publish the project containing the current file.
7365 @item C-c C-e F
7366 Publish only the current file.
7367 @item C-c C-e A
7368 Publish all projects.
7369 @end table
7371 Org uses timestamps to track when a file has changed. The above
7372 functions normally only publish changed files. You can override this and
7373 force publishing of all files by giving a prefix argument.
7375 @node Miscellaneous, Extensions and Hacking, Publishing, Top
7376 @chapter Miscellaneous
7378 @menu
7379 * Completion::                  M-TAB knows what you need
7380 * Customization::               Adapting Org-mode to your taste
7381 * In-buffer settings::          Overview of the #+KEYWORDS
7382 * The very busy C-c C-c key::   When in doubt, press C-c C-c
7383 * Clean view::                  Getting rid of leading stars in the outline
7384 * TTY keys::                    Using Org-mode on a tty
7385 * Interaction::                 Other Emacs packages
7386 * Bugs::                        Things which do not work perfectly
7387 @end menu
7389 @node Completion, Customization, Miscellaneous, Miscellaneous
7390 @section Completion
7391 @cindex completion, of @TeX{} symbols
7392 @cindex completion, of TODO keywords
7393 @cindex completion, of dictionary words
7394 @cindex completion, of option keywords
7395 @cindex completion, of tags
7396 @cindex completion, of property keys
7397 @cindex completion, of link abbreviations
7398 @cindex @TeX{} symbol completion
7399 @cindex TODO keywords completion
7400 @cindex dictionary word completion
7401 @cindex option keyword completion
7402 @cindex tag completion
7403 @cindex link abbreviations, completion of
7405 Org-mode supports in-buffer completion.  This type of completion does
7406 not make use of the minibuffer.  You simply type a few letters into
7407 the buffer and use the key to complete text right there.
7409 @table @kbd
7410 @kindex M-@key{TAB}
7411 @item M-@key{TAB}
7412 Complete word at point
7413 @itemize @bullet
7414 @item
7415 At the beginning of a headline, complete TODO keywords.
7416 @item
7417 After @samp{\}, complete @TeX{} symbols supported by the exporter.
7418 @item
7419 After @samp{*}, complete headlines in the current buffer so that they
7420 can be used in search links like @samp{[[*find this headline]]}.
7421 @item
7422 After @samp{:} in a headline, complete tags.  The list of tags is taken
7423 from the variable @code{org-tag-alist} (possibly set through the
7424 @samp{#+TAGS} in-buffer option, @pxref{Setting tags}), or it is created
7425 dynamically from all tags used in the current buffer.
7426 @item
7427 After @samp{:} and not in a headline, complete property keys.  The list
7428 of keys is constructed dynamically from all keys used in the current
7429 buffer.
7430 @item
7431 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
7432 @item
7433 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
7434 @samp{OPTIONS} which set file-specific options for Org-mode.  When the
7435 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
7436 will insert example settings for this keyword.
7437 @item
7438 In the line after @samp{#+STARTUP: }, complete startup keywords,
7439 i.e. valid keys for this line.
7440 @item
7441 Elsewhere, complete dictionary words using Ispell.
7442 @end itemize
7443 @end table
7445 @node Customization, In-buffer settings, Completion, Miscellaneous
7446 @section Customization
7447 @cindex customization
7448 @cindex options, for customization
7449 @cindex variables, for customization
7451 There are more than 180 variables that can be used to customize
7452 Org-mode.  For the sake of compactness of the manual, I am not
7453 describing the variables here.  A structured overview of customization
7454 variables is available with @kbd{M-x org-customize}.  Or select
7455 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
7456 settings can also be activated on a per-file basis, by putting special
7457 lines into the buffer (@pxref{In-buffer settings}).
7459 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
7460 @section Summary of in-buffer settings
7461 @cindex in-buffer settings
7462 @cindex special keywords
7464 Org-mode uses special lines in the buffer to define settings on a
7465 per-file basis.  These lines start with a @samp{#+} followed by a
7466 keyword, a colon, and then individual words defining a setting.  Several
7467 setting words can be in the same line, but you can also have multiple
7468 lines for the keyword.  While these settings are described throughout
7469 the manual, here is a summary.  After changing any of those lines in the
7470 buffer, press @kbd{C-c C-c} with the cursor still in the line to
7471 activate the changes immediately.  Otherwise they become effective only
7472 when the file is visited again in a new Emacs session.
7474 @table @kbd
7475 @item #+ARCHIVE: %s_done::
7476 This line sets the archive location for the agenda file.  It applies for
7477 all subsequent lines until the next @samp{#+ARCHIVE} line, or the end
7478 of the file.  The first such line also applies to any entries before it.
7479 The corresponding variable is @code{org-archive-location}.
7480 @item #+CATEGORY:
7481 This line sets the category for the agenda file.  The category applies
7482 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
7483 end of the file.  The first such line also applies to any entries before it.
7484 @item #+COLUMNS: %25ITEM .....
7485 Set the default format for columns view.  This format applies when
7486 columns view is invoked in location where no @code{COLUMNS} property
7487 applies.
7488 @item #+CONSTANTS: name1=value1 ...
7489 Set file-local values for constants to be used in table formulas.  This
7490 line set the local variable @code{org-table-formula-constants-local}.
7491 The global version of this variable is
7492 @code{org-table-formula-constants}.
7493 @item #+DRAWERS: NAME1 .....
7494 Set the file-local set of drawers.  The corresponding global variable is
7495 @code{org-drawers}.
7496 @item #+LINK:  linkword replace
7497 These lines (several are allowed) specify link abbreviations.
7498 @xref{Link abbreviations}.  The corresponding variable is
7499 @code{org-link-abbrev-alist}.
7500 @item #+PRIORITIES: highest lowest default
7501 This line sets the limits and the default for the priorities.  All three
7502 must be either letters A-Z or numbers 0-9.  The highest priority must
7503 have a lower ASCII number that the lowest priority.
7504 @item #+PROPERTY: Property_Name Value
7505 This line sets a default inheritance value for entries in the current
7506 buffer, most useful for specifying the allowed values of a property.
7507 @item #+STARTUP:
7508 This line sets options to be used at startup of Org-mode, when an
7509 Org-mode file is being visited.  The first set of options deals with the
7510 initial visibility of the outline tree.  The corresponding variable for
7511 global default settings is @code{org-startup-folded}, with a default
7512 value @code{t}, which means @code{overview}.
7513 @cindex @code{overview}, STARTUP keyword
7514 @cindex @code{content}, STARTUP keyword
7515 @cindex @code{showall}, STARTUP keyword
7516 @example
7517 overview   @r{top-level headlines only}
7518 content    @r{all headlines}
7519 showall    @r{no folding at all, show everything}
7520 @end example
7521 Then there are options for aligning tables upon visiting a file.  This
7522 is useful in files containing narrowed table columns.  The corresponding
7523 variable is @code{org-startup-align-all-tables}, with a default value
7524 @code{nil}.
7525 @cindex @code{align}, STARTUP keyword
7526 @cindex @code{noalign}, STARTUP keyword
7527 @example
7528 align      @r{align all tables}
7529 noalign    @r{don't align tables on startup}
7530 @end example
7531 Logging closing and reinstating TODO items, and clock intervals
7532 (variables @code{org-log-done}, @code{org-log-note-clock-out}, and
7533 @code{org-log-repeat}) can be configured using these options.
7534 @cindex @code{logdone}, STARTUP keyword
7535 @cindex @code{lognotedone}, STARTUP keyword
7536 @cindex @code{nologdone}, STARTUP keyword
7537 @cindex @code{lognoteclock-out}, STARTUP keyword
7538 @cindex @code{nolognoteclock-out}, STARTUP keyword
7539 @cindex @code{logrepeat}, STARTUP keyword
7540 @cindex @code{lognoterepeat}, STARTUP keyword
7541 @cindex @code{nologrepeat}, STARTUP keyword
7542 @example
7543 logdone            @r{record a timestamp when an item is marked DONE}
7544 lognotedone        @r{record timestamp and a note when DONE}
7545 nologdone          @r{don't record when items are marked DONE}
7546 logrepeat          @r{record a time when reinstating a repeating item}
7547 lognoterepeat      @r{record a note when reinstating a repeating item}
7548 nologrepeat        @r{do not record when reinstating repeating item}
7549 lognoteclock-out   @r{record a note when clocking out}
7550 nolognoteclock-out @r{don't record a note when clocking out}
7551 @end example
7552 Here are the options for hiding leading stars in outline headings.  The
7553 corresponding variables are @code{org-hide-leading-stars} and
7554 @code{org-odd-levels-only}, both with a default setting @code{nil}
7555 (meaning @code{showstars} and @code{oddeven}).
7556 @cindex @code{hidestars}, STARTUP keyword
7557 @cindex @code{showstars}, STARTUP keyword
7558 @cindex @code{odd}, STARTUP keyword
7559 @cindex @code{even}, STARTUP keyword
7560 @example
7561 hidestars  @r{make all but one of the stars starting a headline invisible.}
7562 showstars  @r{show all stars starting a headline}
7563 odd        @r{allow only odd outline levels (1,3,...)}
7564 oddeven    @r{allow all outline levels}
7565 @end example
7566 To turn on custom format overlays over time stamps (variables
7567 @code{org-put-time-stamp-overlays} and
7568 @code{org-time-stamp-overlay-formats}), use
7569 @cindex @code{customtime}, STARTUP keyword
7570 @example
7571 customtime @r{overlay custom time format}
7572 @end example
7573 The following options influence the table spreadsheet (variable
7574 @code{constants-unit-system}).
7575 @cindex @code{constcgs}, STARTUP keyword
7576 @cindex @code{constSI}, STARTUP keyword
7577 @example
7578 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
7579 constSI    @r{@file{constants.el} should use the SI unit system}
7580 @end example
7581 @item #+TAGS:  TAG1(c1) TAG2(c2)
7582 These lines (several such lines are allowed) specify the valid tags in
7583 this file, and (potentially) the corresponding @emph{fast tag selection}
7584 keys.  The corresponding variable is @code{org-tag-alist}.
7585 @item #+TBLFM:
7586 This line contains the formulas for the table directly above the line.
7587 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+OPTIONS, #+DATE:
7588 These lines provide settings for exporting files.  For more details see
7589 @ref{Export options}.
7590 @item #+SEQ_TODO:   #+TYP_TODO:
7591 These lines set the TODO keywords and their interpretation in the
7592 current file.  The corresponding variables are @code{org-todo-keywords}
7593 and @code{org-todo-interpretation}.
7594 @end table
7596 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
7597 @section The very busy C-c C-c key
7598 @kindex C-c C-c
7599 @cindex C-c C-c, overview
7601 The key @kbd{C-c C-c} has many purposes in org-mode, which are all
7602 mentioned scattered throughout this manual.  One specific function of
7603 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
7604 other circumstances it means something like @emph{Hey Org-mode, look
7605 here and update according to what you see here}.  Here is a summary of
7606 what this means in different contexts.
7608 @itemize @minus
7609 @item
7610 If there are highlights in the buffer from the creation of a sparse
7611 tree, or from clock display, remove these highlights.
7612 @item
7613 If the cursor is in one of the special @code{#+KEYWORD} lines, this
7614 triggers scanning the buffer for these lines and updating the
7615 information.
7616 @item
7617 If the cursor is inside a table, realign the table.  This command
7618 works even if the automatic table editor has been turned off.
7619 @item
7620 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
7621 the entire table.
7622 @item
7623 If the cursor is inside a table created by the @file{table.el} package,
7624 activate that table.
7625 @item
7626 If the current buffer is a remember buffer, close the note and file it.
7627 With a prefix argument, file it, without further interaction, to the
7628 default location.
7629 @item
7630 If the cursor is on a @code{<<<target>>>}, update radio targets and
7631 corresponding links in this buffer.
7632 @item
7633 If the cursor is in a property line or at the start or end of a property
7634 drawer, offer property commands.
7635 @item
7636 If the cursor is in a plain list item with a checkbox, toggle the status
7637 of the checkbox.
7638 @item
7639 If the cursor is on a numbered item in a plain list, renumber the
7640 ordered list.
7641 @item
7642 If the cursor is on the @code{#+BEGIN} line of a dynamical block, the
7643 block is updated.
7644 @end itemize
7646 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
7647 @section A cleaner outline view
7648 @cindex hiding leading stars
7649 @cindex clean outline view
7651 Some people find it noisy and distracting that the Org-mode headlines
7652 are starting with a potentially large number of stars.  For example
7653 the tree from @ref{Headlines}:
7655 @example
7656 * Top level headline
7657 ** Second level
7658 *** 3rd level
7659     some text
7660 *** 3rd level
7661     more text
7662 * Another top level headline
7663 @end example
7665 @noindent
7666 Unfortunately this is deeply ingrained into the code of Org-mode and
7667 cannot be easily changed.  You can, however, modify the display in such
7668 a way that all leading stars become invisible and the outline more easy
7669 to read.  To do this, customize the variable
7670 @code{org-hide-leading-stars} like this:
7672 @lisp
7673 (setq org-hide-leading-stars t)
7674 @end lisp
7676 @noindent
7677 or change this on a per-file basis with one of the lines (anywhere in
7678 the buffer)
7680 @example
7681 #+STARTUP: showstars
7682 #+STARTUP: hidestars
7683 @end example
7685 @noindent
7686 Press @kbd{C-c C-c} with the cursor in a @samp{STARTUP} line to activate
7687 the modifications.
7689 With stars hidden, the tree becomes:
7691 @example
7692 * Top level headline
7693  * Second level
7694   * 3rd level
7695     some text
7696   * 3rd level
7697     more text
7698 * Another top level headline
7699 @end example
7701 @noindent
7702 Note that the leading stars are not truly replaced by whitespace, they
7703 are only fontified with the face @code{org-hide} that uses the
7704 background color as font color.  If you are not using either white or
7705 black background, you may have to customize this face to get the wanted
7706 effect.  Another possibility is to set this font such that the extra
7707 stars are @i{almost} invisible, for example using the color
7708 @code{grey90} on a white background.
7710 Things become cleaner still if you skip all the even levels and use only
7711 odd levels 1, 3, 5..., effectively adding two stars to go from one
7712 outline level to the next:
7714 @example
7715 * Top level headline
7716   * Second level
7717     * 3rd level
7718       some text
7719     * 3rd level
7720       more text
7721 * Another top level headline
7722 @end example
7724 @noindent
7725 In order to make the structure editing and export commands handle this
7726 convention correctly, use
7728 @lisp
7729 (setq org-odd-levels-only t)
7730 @end lisp
7732 @noindent
7733 or set this on a per-file basis with one of the following lines (don't
7734 forget to press @kbd{C-c C-c} with the cursor in the startup line to
7735 activate changes immediately).
7737 @example
7738 #+STARTUP: odd
7739 #+STARTUP: oddeven
7740 @end example
7742 You can convert an Org-mode file from single-star-per-level to the
7743 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
7744 RET} in that file.  The reverse operation is @kbd{M-x
7745 org-convert-to-oddeven-levels}.
7747 @node TTY keys, Interaction, Clean view, Miscellaneous
7748 @section Using org-mode on a tty
7749 @cindex tty key bindings
7751 Because Org-mode contains a large number of commands, by default much of
7752 Org-mode's core commands are bound to keys that are generally not
7753 accessible on a tty, such as the cursor keys (@key{left}, @key{right},
7754 @key{up}, @key{down}), @key{TAB} and @key{RET}, in particular when used
7755 together with modifiers like @key{Meta} and/or @key{Shift}.  To access
7756 these commands on a tty when special keys are unavailable, the following
7757 alternative bindings can be used.  The tty bindings below will likely be
7758 more cumbersome; you may find for some of the bindings below that a
7759 customized work-around suits you better.  For example, changing a time
7760 stamp is really only fun with @kbd{S-@key{cursor}} keys, whereas on a
7761 tty you would rather use @kbd{C-c .} to re-insert the timestamp.
7763 @multitable @columnfractions 0.15 0.2 0.2
7764 @item @b{Default} @tab @b{Alternative 1} @tab @b{Alternative 2}
7765 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab
7766 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{@key{Esc} @key{left}}
7767 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab
7768 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{@key{Esc} @key{right}}
7769 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab
7770 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{@key{Esc} @key{up}}
7771 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab
7772 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{@key{Esc} @key{down}}
7773 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab
7774 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab
7775 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{@key{Esc} @key{RET}}
7776 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab
7777 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab
7778 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab
7779 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab
7780 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab
7781 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab
7782 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab
7783 @end multitable
7785 @node Interaction, Bugs, TTY keys, Miscellaneous
7786 @section Interaction with other packages
7787 @cindex packages, interaction with other
7788 Org-mode lives in the world of GNU Emacs and interacts in various ways
7789 with other code out there.
7791 @menu
7792 * Cooperation::                 Packages Org-mode cooperates with
7793 * Conflicts::                   Packages that lead to conflicts
7794 @end menu
7796 @node Cooperation, Conflicts, Interaction, Interaction
7797 @subsection Packages that Org-mode cooperates with
7799 @table @asis
7800 @cindex @file{calc.el}
7801 @item @file{calc.el} by Dave Gillespie
7802 Org-mode uses the calc package for implementing spreadsheet
7803 functionality in its tables (@pxref{The spreadsheet}).  Org-mode
7804 checks for the availability of calc by looking for the function
7805 @code{calc-eval} which should be autoloaded in your setup if calc has
7806 been installed properly.  As of Emacs 22, calc is part of the Emacs
7807 distribution.  Another possibility for interaction between the two
7808 packages is using calc for embedded calculations. @xref{Embedded Mode,
7809 , Embedded Mode, calc, GNU Emacs Calc Manual}.
7810 @cindex @file{constants.el}
7811 @item @file{constants.el} by Carsten Dominik
7812 In a table formula (@pxref{The spreadsheet}), it is possible to use
7813 names for natural constants or units.  Instead of defining your own
7814 constants in the variable @code{org-table-formula-constants}, install
7815 the @file{constants} package which defines a large number of constants
7816 and units, and lets you use unit prefixes like @samp{M} for
7817 @samp{Mega} etc.  You will need version 2.0 of this package, available
7818 at @url{http://www.astro.uva.nl/~dominik/Tools}. Org-mode checks for
7819 the function @code{constants-get}, which has to be autoloaded in your
7820 setup.  See the installation instructions in the file
7821 @file{constants.el}.
7822 @item @file{cdlatex.el} by Carsten Dominik
7823 @cindex @file{cdlatex.el}
7824 Org-mode can make use of the CDLaTeX package to efficiently enter
7825 La@TeX{} fragments into Org-mode files. See @ref{CDLaTeX mode}.
7826 @item @file{imenu.el} by Ake Stenhoff and Lars Lindberg
7827 @cindex @file{imenu.el}
7828 Imenu allows menu access to an index of items in a file.  Org-mode
7829 supports Imenu - all you need to do to get the index is the following:
7830 @lisp
7831 (add-hook 'org-mode-hook
7832           (lambda () 'imenu-add-to-menubar "Imenu"))
7833 @end lisp
7834 By default the index is two levels deep - you can modify the depth using
7835 the option @code{org-imenu-depth}.
7836 @item @file{remember.el} by John Wiegley
7837 @cindex @file{remember.el}
7838 Org mode cooperates with remember, see @ref{Remember}.
7839 @file{Remember.el} is not part of Emacs, find it on the web.
7840 @item @file{speedbar.el} by Eric M. Ludlam
7841 @cindex @file{speedbar.el}
7842 Speedbar is a package that creates a special frame displaying files and
7843 index items in files.  Org-mode supports Speedbar and allows you to
7844 drill into Org-mode files directly from the Speedbar.  It also allows to
7845 restrict the scope of agenda commands to a file or a subtree by using
7846 the command @kbd{<} in the Speedbar frame.
7847 @cindex @file{table.el}
7848 @item @file{table.el} by Takaaki Ota
7849 @kindex C-c C-c
7850 @cindex table editor, @file{table.el}
7851 @cindex @file{table.el}
7853 Complex ASCII tables with automatic line wrapping, column- and
7854 row-spanning, and alignment can be created using the Emacs table
7855 package by Takaaki Ota (@uref{http://sourceforge.net/projects/table},
7856 and also part of Emacs 22).
7857 When @key{TAB} or @kbd{C-c C-c} is pressed in such a table, Org-mode
7858 will call @command{table-recognize-table} and move the cursor into the
7859 table.  Inside a table, the keymap of Org-mode is inactive.  In order
7860 to execute Org-mode-related commands, leave the table.
7862 @table @kbd
7863 @kindex C-c C-c
7864 @item C-c C-c
7865 Recognize @file{table.el} table.  Works when the cursor is in a
7866 table.el table.
7868 @kindex C-c ~
7869 @item C-c ~
7870 Insert a table.el table.  If there is already a table at point, this
7871 command converts it between the table.el format and the Org-mode
7872 format.  See the documentation string of the command
7873 @code{org-convert-table} for the restrictions under which this is
7874 possible.
7875 @end table
7876 @file{table.el} is part of Emacs 22.
7877 @cindex @file{footnote.el}
7878 @item @file{footnote.el} by Steven L. Baur
7879 Org-mode recognizes numerical footnotes as provided by this package
7880 (@pxref{Footnotes}).
7881 @end table
7883 @node Conflicts,  , Cooperation, Interaction
7884 @subsection Packages that lead to conflicts with Org-mode
7886 @table @asis
7888 @cindex @file{allout.el}
7889 @item @file{allout.el} by Ken Manheimer
7890 Startup of Org-mode may fail with the error message
7891 @code{(wrong-type-argument keymapp nil)} when there is an outdated
7892 version @file{allout.el} on the load path, for example the version
7893 distributed with Emacs 21.x.  Upgrade to Emacs 22 and this problem will
7894 disappear.  If for some reason you cannot do this, make sure that org.el
7895 is loaded @emph{before} @file{allout.el}, for example by putting
7896 @code{(require 'org)} early enough into your @file{.emacs} file.
7898 @cindex @file{CUA.el}
7899 @item @file{CUA.el} by Kim. F. Storm
7900 Key bindings in Org-mode conflict with the @kbd{S-<cursor>} keys used by
7901 CUA-mode (as well as pc-select-mode and s-region-mode) to select and
7902 extend the region.  If you want to use one of these packages along with
7903 Org-mode, configure the variable @code{org-replace-disputed-keys}.  When
7904 set, Org-mode will move the following key bindings in Org-mode files, and
7905 in the agenda buffer (but not during date selection).
7907 @example
7908 S-UP    -> M-p             S-DOWN  -> M-n
7909 S-LEFT  -> M--             S-RIGHT -> M-+
7910 @end example
7912 Yes, these are unfortunately more difficult to remember.  If you want
7913 to have other replacement keys, look at the variable
7914 @code{org-disputed-keys}.
7915 @item @file{windmove.el} by Hovav Shacham
7916 @cindex @file{windmove.el}
7917 Also this package uses the @kbd{S-<cursor>} keys, so everything written
7918 in the paragraph above about CUA mode also applies here.
7920 @cindex @file{footnote.el}
7921 @item @file{footnote.el} by Steven L. Baur
7922 Org-mode supports the syntax of the footnote package, but only the
7923 numerical footnote markers.  Also, the default key for footnote
7924 commands, @kbd{C-c !} is already used by Org-mode.  You could use the
7925 variable @code{footnote-prefix} to switch footnotes commands to another
7926 key.  Or, you could use @code{org-replace-disputed-keys} and
7927 @code{org-disputed-keys} to change the settings in Org-mode.
7929 @end table
7932 @node Bugs,  , Interaction, Miscellaneous
7933 @section Bugs
7934 @cindex bugs
7936 Here is a list of things that should work differently, but which I
7937 have found too hard to fix.
7939 @itemize @bullet
7940 @item
7941 If a table field starts with a link, and if the corresponding table
7942 column is narrowed (@pxref{Narrow columns}) to a width too small to
7943 display the link, the field would look entirely empty even though it is
7944 not.  To prevent this, Org-mode throws an error.  The work-around is to
7945 make the column wide enough to fit the link, or to add some text (at
7946 least 2 characters) before the link in the same field.
7947 @item
7948 Narrowing table columns does not work on XEmacs, because the
7949 @code{format} function does not transport text properties.
7950 @item
7951 Text in an entry protected with the @samp{QUOTE} keyword should not
7952 autowrap.
7953 @item
7954 When the application called by @kbd{C-c C-o} to open a file link fails
7955 (for example because the application does not exist or refuses to open
7956 the file), it does so silently.  No error message is displayed.
7957 @item
7958 Recalculating a table line applies the formulas from left to right.
7959 If a formula uses @emph{calculated} fields further down the row,
7960 multiple recalculation may be needed to get all fields consistent.  You
7961 may use the command @code{org-table-iterate} (@kbd{C-u C-c *}) to
7962 recalculate until convergence.
7963 @item
7964 A single letter cannot be made bold, for example @samp{*a*}.
7965 @item
7966 The exporters work well, but could be made more efficient.
7967 @end itemize
7970 @node Extensions and Hacking, History and Acknowledgments, Miscellaneous, Top
7971 @appendix Extensions, Hooks and Hacking
7973 This appendix lists extensions for Org-mode written by other authors.
7974 It also covers some aspects where users can extend the functionality of
7975 Org-mode.
7977 @menu
7978 * Extensions::                  Existing 3rd-part extensions
7979 * Adding hyperlink types::      New custom link types
7980 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
7981 * Dynamic blocks::              Automatically filled blocks
7982 * Special agenda views::        Customized views
7983 * Using the property API::      Writing programs that use entry properties
7984 @end menu
7986 @node Extensions, Adding hyperlink types, Extensions and Hacking, Extensions and Hacking
7987 @section Third-party extensions for Org-mode
7988 @cindex extension, third-party
7990 The following extensions for Org-mode have been written by other people:
7992 @table @asis
7993 @cindex @file{org-publish.el}
7994 @item @file{org-publish.el} by David O'Toole
7995 This package provides facilities for publishing related sets of Org-mode
7996 files together with linked files like images as web pages.  It is
7997 highly configurable and can be used for other publishing purposes as
7998 well.  As of Org-mode version 4.30, @file{org-publish.el} is part of the
7999 Org-mode distribution.  It is not yet part of Emacs, however, a delay
8000 caused by the preparations for the 22.1 release.  In the mean time,
8001 @file{org-publish.el} can be downloaded from David's site:
8002 @url{http://dto.freeshell.org/e/org-publish.el}.
8003 @cindex @file{org-mouse.el}
8004 @item @file{org-mouse.el} by Piotr Zielinski
8005 This package implements extended mouse functionality for Org-mode.  It
8006 allows you to cycle visibility and to edit the document structure with
8007 the mouse.  Best of all, it provides a context-sensitive menu on
8008 @key{mouse-3} that changes depending on the context of a mouse-click.
8009 As of Org-mode version 4.53, @file{org-mouse.el} is part of the
8010 Org-mode distribution.  It is not yet part of Emacs, however, a delay
8011 caused by the preparations for the 22.1 release.  In the mean time,
8012 @file{org-mouse.el} can be downloaded from Piotr's site:
8013 @url{http://www.cl.cam.ac.uk/~pz215/files/org-mouse.el}.
8014 @cindex @file{org-blog.el}
8015 @item @file{org-blog.el} by David O'Toole
8016 A blogging plug-in for @file{org-publish.el}.@*
8017 @url{http://dto.freeshell.org/notebook/OrgMode.html}.
8018 @cindex @file{blorg.el}
8019 @item @file{blorg.el} by Bastien Guerry
8020 Publish Org-mode files as
8021 blogs. @url{http://www.cognition.ens.fr/~guerry/blorg.html}.
8022 @cindex @file{org2rem.el}
8023 @item @file{org2rem.el} by Bastien Guerry
8024 Translates Org-mode files into something readable by
8025 Remind. @url{http://www.cognition.ens.fr/~guerry/u/org2rem.el}.
8026 @item @file{org-toc.el} by Bastien Guerry
8027 Produces a simple table of contents of an Org-mode file, for easy
8028 navigation. @url{http://www.cognition.ens.fr/~guerry/u/org-registry.el}.
8029 @item @file{org-registry.el} by Bastien Guerry
8030 Find which Org-file link to a certain document.
8031 @url{http://www.cognition.ens.fr/~guerry/u/org2rem.el}.
8032 @end table
8034 @page
8036 @node Adding hyperlink types, Tables in arbitrary syntax, Extensions, Extensions and Hacking
8037 @section Adding hyperlink types
8038 @cindex hyperlinks, adding new types
8040 Org-mode has a large number of hyperlink types built-in
8041 (@pxref{Hyperlinks}).  If you would like to add new link types, it
8042 provides an interface for doing so.  Lets look at an example file
8043 @file{org-man.el} that will add support for creating links like
8044 @samp{[[man:printf][The printf manpage]]} to show Unix manual pages inside
8045 emacs:
8047 @lisp
8048 ;;; org-man.el - Support for links to manpages in Org-mode
8050 (require 'org)
8052 (org-add-link-type "man" 'org-man-open)
8053 (add-hook 'org-store-link-functions 'org-man-store-link)
8055 (defcustom org-man-command 'man
8056   "The Emacs command to be used to display a man page."
8057   :group 'org-link
8058   :type '(choice (const man) (const woman)))
8060 (defun org-man-open (path)
8061   "Visit the manpage on PATH.
8062 PATH should be a topic that can be thrown at the man command."
8063   (funcall org-man-command path))
8065 (defun org-man-store-link ()
8066   "Store a link to a manpage."
8067   (when (memq major-mode '(Man-mode woman-mode))
8068     ;; This is a man page, we do make this link
8069     (let* ((page (org-man-get-page-name))
8070            (link (concat "man:" page))
8071            (description (format "Manpage for %s" page)))
8072       (org-store-link-props
8073        :type "man"
8074        :link link
8075        :description description))))
8077 (defun org-man-get-page-name ()
8078   "Extract the page name from the buffer name."
8079   ;; This works for both `Man-mode' and `woman-mode'.
8080   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
8081       (match-string 1 (buffer-name))
8082     (error "Cannot create link to this man page")))
8084 (provide 'org-man)
8086 ;;; org-man.el ends here
8087 @end lisp
8089 @noindent
8090 You would activate this new link type in @file{.emacs} with
8092 @lisp
8093 (require 'org-man)
8094 @end lisp
8096 @noindent
8097 Lets go through the file and see what it does.
8098 @enumerate
8099 @item
8100 It does @code{(require 'org)} to make sure that @file{org.el} has been
8101 loaded.
8102 @item
8103 The next line calls @code{org-add-link-type} to define a new link type
8104 with prefix @samp{man}.  The call also contains the name of a function
8105 that will be called to follow such a link.
8106 @item
8107 The next line adds a function to @code{org-store-link-functions}, in
8108 order to allow the command @kbd{C-c l} to record a useful link in a
8109 buffer displaying a man page.
8110 @end enumerate
8112 The rest of the file defines the necessary variables and functions.
8113 First there is a customization variable that determines which emacs
8114 command should be used to display man pages.  There are two options,
8115 @code{man} and @code{woman}.  Then the function to follow a link is
8116 defined.  It gets the link path as an argument - in this case the link
8117 path is just a topic for the manual command.  The function calls the
8118 value of @code{org-man-command} to display the man page.
8120 Finally the function @code{org-man-store-link} is defined.  When you try
8121 to store a link with @kbd{C-c l}, also this function will be called to
8122 try to make a link.  The function must first decide if it is supposed to
8123 create the link for this buffer type, we do this by checking the value
8124 of the variable @code{major-mode}.  If not, the function must exit and
8125 return the value @code{nil}.  If yes, the link is created by getting the
8126 manual topic from the buffer name and prefixing it with the string
8127 @samp{man:}.  Then it must call the command @code{org-store-link-props}
8128 and set the @code{:type} and @code{:link} properties.  Optionally you
8129 can also set the @code{:description} property to provide a default for
8130 the link description when the link is later inserted into tan Org-mode
8131 buffer with @kbd{C-c C-l}.
8133 @node Tables in arbitrary syntax, Dynamic blocks, Adding hyperlink types, Extensions and Hacking
8134 @section Tables and Lists in arbitrary syntax
8135 @cindex tables, in other modes
8136 @cindex lists, in other modes
8137 @cindex Orgtbl-mode
8139 Since Orgtbl-mode can be used as a minor mode in arbitrary buffers, a
8140 frequent feature request has been to make it work with native tables in
8141 specific languages, for example La@TeX{}.  However, this is extremely
8142 hard to do in a general way, would lead to a customization nightmare,
8143 and would take away much of the simplicity of the Orgtbl-mode table
8144 editor.
8147 This appendix describes a different approach.  We keep the Orgtbl-mode
8148 table in its native format (the @i{source table}), and use a custom
8149 function to @i{translate} the table to the correct syntax, and to
8150 @i{install} it in the right location (the @i{target table}).  This puts
8151 the burden of writing conversion functions on the user, but it allows
8152 for a very flexible system.
8154 Bastien added the ability to do the same with lists.  You can use Org's
8155 facilities to edit and structure lists by turning @code{orgstruct-mode}
8156 on, then locally exporting such lists in another format (HTML, La@TeX{}
8157 or Texinfo.)
8160 @menu
8161 * Radio tables::                Sending and receiving
8162 * A LaTeX example::             Step by step, almost a tutorial
8163 * Translator functions::        Copy and modify
8164 * Radio lists::                 Doing the same for lists.
8165 @end menu
8167 @node Radio tables, A LaTeX example, Tables in arbitrary syntax, Tables in arbitrary syntax
8168 @subsection Radio tables
8169 @cindex radio tables
8171 To define the location of the target table, you first need to create two
8172 lines that are comments in the current mode, but contain magic words for
8173 Orgtbl-mode to find.  Orgtbl-mode will insert the translated table
8174 between these lines, replacing whatever was there before.  For example:
8176 @example
8177 /* BEGIN RECEIVE ORGTBL table_name */
8178 /* END RECEIVE ORGTBL table_name */
8179 @end example
8181 @noindent
8182 Just above the source table, we put a special line that tells
8183 Orgtbl-mode how to translate this table and where to install it.  For
8184 example:
8185 @example
8186 #+ORGTBL: SEND table_name translation_function arguments....
8187 @end example
8189 @noindent
8190 @code{table_name} is the reference name for the table that is also used
8191 in the receiver lines. @code{translation_function} is the Lisp function
8192 that does the translation.  Furthermore, the line can contain a list of
8193 arguments (alternating key and value) at the end.  The arguments will be
8194 passed as a property list to the translation function for
8195 interpretation.  A few standard parameters are already recognized and
8196 acted upon before the translation function is called:
8198 @table @code
8199 @item :skip N
8200 Skip the first N lines of the table. Hlines do count!
8201 @item :skipcols (n1 n2 ...)
8202 List of columns that should be skipped.  If the table has a column with
8203 calculation marks, that column is automatically discarded as well.
8204 Please note that the translator function sees the table @emph{after} the
8205 removal of these columns, the function never knows that there have been
8206 additional columns.
8207 @end table
8209 @noindent
8210 The one problem remaining is how to keep the source table in the buffer
8211 without disturbing the normal workings of the file, for example during
8212 compilation of a C file or processing of a La@TeX{} file.  There are a
8213 number of different solutions:
8215 @itemize @bullet
8216 @item
8217 The table could be placed in a block comment if that is supported by the
8218 language.  For example, in C-mode you could wrap the table between
8219 @samp{/*} and @samp{*/} lines.
8220 @item
8221 Sometimes it is possible to put the table after some kind of @i{END}
8222 statement, for example @samp{\bye} in TeX and @samp{\end@{document@}}
8223 in La@TeX{}.
8224 @item
8225 You can just comment the table line by line whenever you want to process
8226 the file, and uncomment it whenever you need to edit the table.  This
8227 only sounds tedious - the command @kbd{M-x orgtbl-toggle-comment} does
8228 make this comment-toggling very easy, in particular if you bind it to a
8229 key.
8230 @end itemize
8232 @node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
8233 @subsection A LaTeX example of radio tables
8234 @cindex LaTeX, and Orgtbl-mode
8236 The best way to wrap the source table in La@TeX{} is to use the
8237 @code{comment} environment provided by @file{comment.sty}.  It has to be
8238 activated by placing @code{\usepackage@{comment@}} into the document
8239 header.  Orgtbl-mode can insert a radio table skeleton@footnote{By
8240 default this works only for La@TeX{}, HTML, and Texinfo.  Configure the
8241 variable @code{orgtbl-radio-tables} to install templates for other
8242 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
8243 be prompted for a table name, lets say we use @samp{salesfigures}.  You
8244 will then get the following template:
8246 @example
8247 % BEGIN RECEIVE ORGTBL salesfigures
8248 % END RECEIVE ORGTBL salesfigures
8249 \begin@{comment@}
8250 #+ORGTBL: SEND salesfigures orgtbl-to-latex
8251 | | |
8252 \end@{comment@}
8253 @end example
8255 @noindent
8256 The @code{#+ORGTBL: SEND} line tells Orgtbl-mode to use the function
8257 @code{orgtbl-to-latex} to convert the table into La@TeX{} and to put it
8258 into the receiver location with name @code{salesfigures}.  You may now
8259 fill in the table, feel free to use the spreadsheet features@footnote{If
8260 the @samp{#+TBLFM} line contains an odd number of dollar characters,
8261 this may cause problems with font-lock in latex-mode.  As shown in the
8262 example you can fix this by adding an extra line inside the
8263 @code{comment} environment that is used to balance the dollar
8264 expressions.  If you are using AUCTeX with the font-latex library, a
8265 much better solution is to add the @code{comment} environment to the
8266 variable @code{LaTeX-verbatim-environments}.}:
8268 @example
8269 % BEGIN RECEIVE ORGTBL salesfigures
8270 % END RECEIVE ORGTBL salesfigures
8271 \begin@{comment@}
8272 #+ORGTBL: SEND salesfigures orgtbl-to-latex
8273 | Month | Days | Nr sold | per day |
8274 |-------+------+---------+---------|
8275 | Jan   |   23 |      55 |     2.4 |
8276 | Feb   |   21 |      16 |     0.8 |
8277 | March |   22 |     278 |    12.6 |
8278 #+TBLFM: $4=$3/$2;%.1f
8279 % $ (optional extra dollar to keep font-lock happy, see footnote)
8280 \end@{comment@}
8281 @end example
8283 @noindent
8284 When you are done, press @kbd{C-c C-c} in the table to get the converted
8285 table inserted between the two marker lines.
8287 Now lets assume you want to make the table header by hand, because you
8288 want to control how columns are aligned etc.  In this case we make sure
8289 that the table translator does skip the first 2 lines of the source
8290 table, and tell the command to work as a @i{splice}, i.e. to not produce
8291 header and footer commands of the target table:
8293 @example
8294 \begin@{tabular@}@{lrrr@}
8295 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
8296 % BEGIN RECEIVE ORGTBL salesfigures
8297 % END RECEIVE ORGTBL salesfigures
8298 \end@{tabular@}
8300 \begin@{comment@}
8301 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
8302 | Month | Days | Nr sold | per day |
8303 |-------+------+---------+---------|
8304 | Jan   |   23 |      55 |     2.4 |
8305 | Feb   |   21 |      16 |     0.8 |
8306 | March |   22 |     278 |    12.6 |
8307 #+TBLFM: $4=$3/$2;%.1f
8308 \end@{comment@}
8309 @end example
8311 The La@TeX{} translator function @code{orgtbl-to-latex} is already part of
8312 Orgtbl-mode.  It uses a @code{tabular} environment to typeset the table
8313 and marks horizontal lines with @code{\hline}.  Furthermore, it
8314 interprets the following parameters:
8316 @table @code
8317 @item :splice nil/t
8318 When set to t, return only table body lines, don't wrap them into a
8319 tabular environment.  Default is nil.
8321 @item :fmt fmt
8322 A format to be used to wrap each field, should contain @code{%s} for the
8323 original field value.  For example, to wrap each field value in dollars,
8324 you could use @code{:fmt "$%s$"}.  This may also be a property list with
8325 column numbers and formats. for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
8327 @item :efmt efmt
8328 Use this format to print numbers with exponentials.  The format should
8329 have @code{%s} twice for inserting mantissa and exponent, for example
8330 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
8331 may also be a property list with column numbers and formats, for example
8332 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
8333 @code{efmt} has been applied to a value, @code{fmt} will also be
8334 applied.
8335 @end table
8337 @node Translator functions, Radio lists, A LaTeX example, Tables in arbitrary syntax
8338 @subsection Translator functions
8339 @cindex HTML, and Orgtbl-mode
8340 @cindex translator function
8342 Orgtbl-mode has several translator functions built-in:
8343 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and
8344 @code{orgtbl-to-texinfo}.  Except for @code{orgtbl-to-html}@footnote{The
8345 HTML translator uses the same code that produces tables during HTML
8346 export.}, these all use a generic translator, @code{orgtbl-to-generic}.
8347 For example, @code{orgtbl-to-latex} itself is a very short function that
8348 computes the column definitions for the @code{tabular} environment,
8349 defines a few field and line separators and then hands over to the
8350 generic translator.  Here is the entire code:
8352 @lisp
8353 @group
8354 (defun orgtbl-to-latex (table params)
8355   "Convert the orgtbl-mode TABLE to LaTeX."
8356   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
8357                                org-table-last-alignment ""))
8358          (params2
8359           (list
8360            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
8361            :tend "\\end@{tabular@}"
8362            :lstart "" :lend " \\\\" :sep " & "
8363            :efmt "%s\\,(%s)" :hline "\\hline")))
8364     (orgtbl-to-generic table (org-combine-plists params2 params))))
8365 @end group
8366 @end lisp
8368 As you can see, the properties passed into the function (variable
8369 @var{PARAMS}) are combined with the ones newly defined in the function
8370 (variable @var{PARAMS2}).  The ones passed into the function (i.e. the
8371 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
8372 would like to use the La@TeX{} translator, but wanted the line endings to
8373 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
8374 overrule the default with
8376 @example
8377 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
8378 @end example
8380 For a new language, you can either write your own converter function in
8381 analogy with the La@TeX{} translator, or you can use the generic function
8382 directly.  For example, if you have a language where a table is started
8383 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
8384 started with @samp{!BL!}, ended with @samp{!EL!} and where the field
8385 separator is a TAB, you could call the generic translator like this (on
8386 a single line!):
8388 @example
8389 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
8390                               :lstart "!BL! " :lend " !EL!" :sep "\t"
8391 @end example
8393 @noindent
8394 Please check the documentation string of the function
8395 @code{orgtbl-to-generic} for a full list of parameters understood by
8396 that function and remember that you can pass each of them into
8397 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
8398 using the generic function.
8400 Of course you can also write a completely new function doing complicated
8401 things the generic translator cannot do.  A translator function takes
8402 two arguments.  The first argument is the table, a list of lines, each
8403 line either the symbol @code{hline} or a list of fields.  The second
8404 argument is the property list containing all parameters specified in the
8405 @samp{#+ORGTBL: SEND} line.  The function must return a single string
8406 containing the formatted table.  If you write a generally useful
8407 translator, please post it on @code{emacs-orgmode@@gnu.org} so that
8408 others can benefit from your work.
8410 @node  Radio lists,  , Translator functions, Tables in arbitrary syntax
8411 @subsection Radio lists
8412 @cindex radio lists
8413 @cindex org-list-insert-radio-list
8415 Sending and receiving radio lists works exactly the same way than
8416 sending and receiving radio tables (@pxref{Radio tables}) @footnote{You
8417 need to load the @code{org-export-latex.el} package to use radio lists
8418 since the relevant code is there for now.}.  As for radio tables, you
8419 can insert radio lists templates in HTML, La@TeX{} and Texinfo modes by
8420 calling @code{org-list-insert-radio-list}.
8422 Here are the differences with radio tables:
8424 @itemize @minus
8425 @item
8426 Use @code{ORGLST} instead of @code{ORGTBL}.
8427 @item
8428 The available translation functions for radio lists don't take
8429 parameters.
8430 @item
8431 `C-c C-c' will work when pressed on the first item of the list.
8432 @end itemize
8434 Here is a La@TeX{} example.  Let's say that you have this in your
8435 La@TeX{} file:
8437 @example
8438 % BEGIN RECEIVE ORGLST to-buy
8439 % END RECEIVE ORGLST to-buy
8440 \begin@{comment@}
8441 #+ORGLIST: SEND to-buy orgtbl-to-latex
8442 - a new house
8443 - a new computer
8444   + a new keyboard
8445   + a new mouse
8446 - a new life
8447 \end@{comment@}
8448 @end example
8450 Pressing `C-c C-c' on @code{a new house} and will insert the converted
8451 La@TeX{} list between the two marker lines.
8453 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Extensions and Hacking
8454 @section Dynamic blocks
8455 @cindex dynamic blocks
8457 Org-mode documents can contain @emph{dynamic blocks}.  These are
8458 specially marked regions that are updated by some user-written function.
8459 A good example for such a block is the clock table inserted by the
8460 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
8462 Dynamic block are enclosed by a BEGIN-END structure that assigns a name
8463 to the block and can also specify parameters for the function producing
8464 the content of the block.
8466 @example
8467 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
8469 #+END:
8470 @end example
8472 Dynamic blocks are updated with the following commands
8474 @table @kbd
8475 @kindex C-c C-x C-u
8476 @item C-c C-x C-u
8477 Update dynamic block at point.
8478 @kindex C-u C-c C-x C-u
8479 @item C-u C-c C-x C-u
8480 Update all dynamic blocks in the current file.
8481 @end table
8483 Updating a dynamic block means to remove all the text between BEGIN and
8484 END, parse the BEGIN line for parameters and then call the specific
8485 writer function for this block to insert the new content.  If you want
8486 to use the original content in the writer function, you can use the
8487 extra parameter @code{:content}.
8489 For a block with name @code{myblock}, the writer function is
8490 @code{org-dblock-write:myblock} with as only parameter a property list
8491 with the parameters given in the begin line.  Here is a trivial example
8492 of a block that keeps track of when the block update function was last
8493 run:
8495 @example
8496 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
8498 #+END:
8499 @end example
8501 @noindent
8502 The corresponding block writer function could look like this:
8504 @lisp
8505 (defun org-dblock-write:block-update-time (params)
8506    (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
8507      (insert "Last block update at: "
8508              (format-time-string fmt (current-time)))))
8509 @end lisp
8511 If you want to make sure that all dynamic blocks are always up-to-date,
8512 you could add the function @code{org-update-all-dblocks} to a hook, for
8513 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
8514 written in a way that is does nothing in buffers that are not in Org-mode.
8516 @node Special agenda views, Using the property API, Dynamic blocks, Extensions and Hacking
8517 @section Special Agenda Views
8518 @cindex agenda views, user-defined
8520 Org-mode provides a special hook that can be used to narrow down the
8521 selection made by any of the agenda views.  You may specify a function
8522 that is used at each match to verify if the match should indeed be part
8523 of the agenda view, and if not, how much should be skipped.
8525 Let's say you want to produce a list of projects that contain a WAITING
8526 tag anywhere in the project tree.  Let's further assume that you have
8527 marked all tree headings that define a project with the TODO keyword
8528 PROJECT.  In this case you would run a TODO search for the keyword
8529 PROJECT, but skip the match unless there is a WAITING tag anywhere in
8530 the subtree belonging to the project line.
8532 To achieve this, you must write a function that searches the subtree for
8533 the tag.  If the tag is found, the function must return @code{nil} to
8534 indicate that this match should not be skipped.  If there is no such
8535 tag, return the location of the end of the subtree, to indicate that
8536 search should continue from there.
8538 @lisp
8539 (defun my-skip-unless-waiting ()
8540   "Skip trees that are not waiting"
8541   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
8542     (if (re-search-forward ":waiting:" subtree-end t)
8543         nil          ; tag found, do not skip
8544       subtree-end))) ; tag not found, continue after end of subtree
8545 @end lisp
8547 Now you may use this function in an agenda custom command, for example
8548 like this:
8550 @lisp
8551 (org-add-agenda-custom-command
8552  '("b" todo "PROJECT"
8553    ((org-agenda-skip-function 'my-org-waiting-projects)
8554     (org-agenda-overriding-header "Projects waiting for something: "))))
8555 @end lisp
8557 Note that this also binds @code{org-agenda-overriding-header} to get a
8558 meaningful header in the agenda view.
8560 You may also put a Lisp form into @code{org-agenda-skip-function}.  In
8561 particular, you may use the functions @code{org-agenda-skip-entry-if}
8562 and @code{org-agenda-skip-subtree-if} in this form, for example:
8564 @table @code
8565 @item '(org-agenda-skip-entry-if 'scheduled)
8566 Skip current entry if it has been scheduled.
8567 @item '(org-agenda-skip-entry-if 'notscheduled)
8568 Skip current entry if it has not been scheduled.
8569 @item '(org-agenda-skip-entry-if 'deadline)
8570 Skip current entry if it has a deadline.
8571 @item '(org-agenda-skip-entry-if 'scheduled 'deadline)
8572 Skip current entry if it has a deadline, or if it is scheduled.
8573 @item '(org-agenda-skip-entry 'regexp "regular expression")
8574 Skip current entry if the regular expression matches in the entry.
8575 @item '(org-agenda-skip-entry 'notregexp "regular expression")
8576 Skip current entry unless the regular expression matches.
8577 @item '(org-agenda-skip-subtree-if 'regexp "regular expression")
8578 Same as above, but check and skip the entire subtree.
8579 @end table
8581 Therefore we could also have written the search for WAITING projects
8582 like this, even without defining a special function:
8584 @lisp
8585 (org-add-agenda-custom-command
8586  '("b" todo "PROJECT"
8587    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
8588                                 'regexp ":waiting:"))
8589     (org-agenda-overriding-header "Projects waiting for something: "))))
8590 @end lisp
8593 @node Using the property API,  , Special agenda views, Extensions and Hacking
8594 @section Using the property API
8595 @cindex API, for properties
8596 @cindex properties, API
8598 Here is a description of the functions that can be used to work with
8599 properties.
8601 @defun org-entry-properties &optional pom which
8602 Get all properties of the entry at point-or-marker POM.
8603 This includes the TODO keyword, the tags, time strings for deadline,
8604 scheduled, and clocking, and any additional properties defined in the
8605 entry.  The return value is an alist, keys may occur multiple times
8606 if the property key was used several times.
8607 POM may also be nil, in which case the current entry is used.
8608 If WHICH is nil or `all', get all properties.  If WHICH is
8609 `special' or `standard', only get that subclass.
8610 @end defun
8611 @defun org-entry-get pom property &optional inherit
8612 Get value of PROPERTY for entry at point-or-marker POM.  By default,
8613 this only looks at properties defined locally in the entry.  If INHERIT
8614 is non-nil and the entry does not have the property, then also check
8615 higher levels of the hierarchy.  If INHERIT is the symbol
8616 @code{selective}, use inheritance if and only if the setting of
8617 @code{org-use-property-inheritance} selects PROPERTY for inheritance.
8618 @end defun
8620 @defun org-entry-delete pom property
8621 Delete the property PROPERTY from entry at point-or-marker POM.
8622 @end defun
8624 @defun org-entry-put pom property value
8625 Set PROPERTY to VALUE for entry at point-or-marker POM.
8626 @end defun
8628 @defun org-buffer-property-keys &optional include-specials
8629 Get all property keys in the current buffer.
8630 @end defun
8632 @defun org-insert-property-drawer
8633 Insert a property drawer at point.
8634 @end defun
8636 @node History and Acknowledgments, Main Index, Extensions and Hacking, Top
8637 @appendix History and Acknowledgments
8638 @cindex acknowledgments
8639 @cindex history
8640 @cindex thanks
8642 Org-mode was borne in 2003, out of frustration over the user interface
8643 of the Emacs outline-mode.  I was trying to organize my notes and
8644 projects, and using Emacs seemed to be the natural way to go.  However,
8645 having to remember eleven different commands with two or three keys per
8646 command, only to hide and show parts of the outline tree, that seemed
8647 entirely unacceptable to me.  Also, when using outlines to take notes, I
8648 constantly want to restructure the tree, organizing it parallel to my
8649 thoughts and plans.  @emph{Visibility cycling} and @emph{structure
8650 editing} were originally implemented in the package
8651 @file{outline-magic.el}, but quickly moved to the more general
8652 @file{org.el}.  As this environment became comfortable for project
8653 planning, the next step was adding @emph{TODO entries}, basic @emph{time
8654 stamps}, and @emph{table support}.  These areas highlight the two main
8655 goals that Org-mode still has today: To create a new, outline-based,
8656 plain text mode with innovative and intuitive editing features, and to
8657 incorporate project planning functionality directly into a notes file.
8659 Since the first release, literally thousands of emails to me or on
8660 @code{emacs-orgmode@@gnu.org} have provided a constant stream of bug
8661 reports, feedback, new ideas, and sometimes patches and add-on code.
8662 Many thanks to everyone who has helped to improve this package.  I am
8663 trying to keep here a list of the people who had significant influence
8664 in shaping one or more aspects of Org-mode.  The list may not be
8665 complete, if I have forgotten someone, please accept my apologies and
8666 let me know.
8668 @itemize @bullet
8670 @item
8671 @i{Russel Adams} came up with the idea for drawers.
8672 @item
8673 @i{Thomas Baumann} contributed the code for links to the MH-E email
8674 system.
8675 @item
8676 @i{Alex Bochannek} provided a patch for rounding time stamps.
8677 @item
8678 @i{Charles Cave}'s suggestion sparked the implementation of templates
8679 for Remember.
8680 @item
8681 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
8682 specified time.
8683 @item
8684 @i{Gregory Chernov} patched support for lisp forms into table
8685 calculations and improved XEmacs compatibility, in particular by porting
8686 @file{nouline.el} to XEmacs.
8687 @item
8688 @i{Sacha Chua} suggested to copy some linking code from Planner.
8689 @item
8690 @i{Eddward DeVilla} proposed and tested checkbox statistics.  He also
8691 came up with the idea of properties, and that there should be an API for
8692 them.
8693 @item
8694 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
8695 inspired some of the early development, including HTML export.  He also
8696 asked for a way to narrow wide table columns.
8697 @item
8698 @i{Christian Egli} converted the documentation into Texinfo format,
8699 patched CSS formatting into the HTML exporter, and inspired the agenda.
8700 @item
8701 @i{David Emery} provided a patch for custom CSS support in exported
8702 HTML agendas.
8703 @item
8704 @i{Nic Ferrier} contributed mailcap and XOXO support.
8705 @item
8706 @i{Miguel A. Figueroa-Villanueva} implemented hierarchical checkboxes.
8707 @item
8708 @i{John Foerch} figured out how to make incremental search show context
8709 around a match in a hidden outline tree.
8710 @item
8711 @i{Niels Giesen} had the idea to automatically archive DONE trees.
8712 @item
8713 @i{Bastien Guerry} wrote the La@TeX{} exporter and has been prolific
8714 with patches, ideas, and bug reports.
8715 @item
8716 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
8717 @item
8718 @i{Scott Jaderholm} proposed footnotes, control over whitespace between
8719 folded entries, and column view for properties.
8720 @item
8721 @i{Shidai Liu} ("Leo") asked for embedded La@TeX{} and tested it.  He also
8722 provided frequent feedback and some patches.
8723 @item
8724 @i{Jason F. McBrayer} suggested agenda export to CSV format.
8725 @item
8726 @i{Max Mikhanosha} came up with the idea of refiling.
8727 @item
8728 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
8729 basis.
8730 @item
8731 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
8732 happy.
8733 @item
8734 @i{Rick Moynihan} proposed to allow multiple TODO sequences in a file
8735 and to be able to quickly restrict the agenda to a subtree.
8736 @item
8737 @i{Todd Neal} provided patches for links to Info files and elisp forms.
8738 @item
8739 @i{Tim O'Callaghan} suggested in-file links, search options for general
8740 file links, and TAGS.
8741 @item
8742 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
8743 into Japanese.
8744 @item
8745 @i{Oliver Oppitz} suggested multi-state TODO items.
8746 @item
8747 @i{Scott Otterson} sparked the introduction of descriptive text for
8748 links, among other things.
8749 @item
8750 @i{Pete Phillips} helped during the development of the TAGS feature, and
8751 provided frequent feedback.
8752 @item
8753 @i{T.V. Raman} reported bugs and suggested improvements.
8754 @item
8755 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
8756 control.
8757 @item
8758 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
8759 @item
8760 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
8761 conflict with @file{allout.el}.
8762 @item
8763 @i{Jason Riedy} sent a patch to fix a bug with export of TODO keywords.
8764 @item
8765 @i{Philip Rooke} created the Org-mode reference card and provided lots
8766 of feedback.
8767 @item
8768 @i{Christian Schlauer} proposed angular brackets around links, among
8769 other things.
8770 @item
8771 Linking to VM/BBDB/Gnus was inspired by @i{Tom Shannon}'s
8772 @file{organizer-mode.el}.
8773 @item
8774 @i{Daniel Sinder} came up with the idea of internal archiving by locking
8775 subtrees.
8776 @item
8777 @i{Dale Smith} proposed link abbreviations.
8778 @item
8779 @i{Adam Spiers} asked for global linking commands and inspired the link
8780 extension system.  support mairix.
8781 @item
8782 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
8783 chapter about publishing.
8784 @item
8785 @i{J@"urgen Vollmer} contributed code generating the table of contents
8786 in HTML output.
8787 @item
8788 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
8789 keyword.
8790 @item
8791 @i{David Wainberg} suggested archiving, and improvements to the linking
8792 system.
8793 @item
8794 @i{John Wiegley} wrote @file{emacs-wiki.el} and @file{planner.el}.  The
8795 development of Org-mode was fully independent, and both systems are
8796 really different beasts in their basic ideas and implementation details.
8797 I later looked at John's code, however, and learned from his
8798 implementation of (i) links where the link itself is hidden and only a
8799 description is shown, and (ii) popping up a calendar to select a date.
8800 John has also contributed a number of great ideas directly to Org-mode.
8801 @item
8802 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
8803 linking to Gnus.
8804 @item
8805 @i{Roland Winkler} requested additional key bindings to make Org-mode
8806 work on a tty.
8807 @item
8808 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
8809 and contributed various ideas and code snippets.
8810 @end itemize
8813 @node Main Index, Key Index, History and Acknowledgments, Top
8814 @unnumbered The Main Index
8816 @printindex cp
8818 @node Key Index,  , Main Index, Top
8819 @unnumbered Key Index
8821 @printindex ky
8823 @bye
8825 @ignore
8826         arch-tag: 7893d1Fe-cc57-4d13-b5e5-f494a1CBC7ac
8827 @end ignore
8829 @c Local variables:
8830 @c ispell-local-dictionary: "en_US-w_accents"
8831 @c ispell-local-pdict: "./.aspell.org.pws"
8832 @c fill-column: 77
8833 @c End: