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