Release 4.48
[org-mode.git] / org.texi
blob5994f067c09be030f3a856cff1637b2631cd175f
1 \input texinfo
2 @c %**start of header
3 @setfilename ../info/org
4 @settitle Org Mode Manual
6 @set VERSION 4.48
7 @set DATE September 2006
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://www.astro.uva.nl/~dominik/Tools/org/,maintainers webpage}
16 @set AUTHOR Carsten Dominik
17 @set MAINTAINER Carsten Dominik
18 @set MAINTAINEREMAIL @email{dominik@@science.uva.nl}
19 @set MAINTAINERCONTACT @uref{mailto:dominik@@science.uva.nl,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 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 * Timestamps::                  Assign date and time to items
84 * Tags::                        Tagging headlines and matching sets of tags
85 * Agenda views::                Collecting information into views
86 * Embedded LaTeX::              LaTeX fragments and formulas
87 * Exporting::                   Sharing and publishing of notes
88 * Publishing::                  Create a web site of linked Org-mode files
89 * Miscellaneous::               All the rest which did not fit elsewhere
90 * Extensions and Hacking::      It is possible to write add-on code
91 * History and Acknowledgments::  How Org-mode came into being 
92 * Index::                       The fast road to specific information
93 * Key Index::                   Key bindings and where they are described
95 @detailmenu
96  --- The Detailed Node Listing ---
98 Introduction
100 * Summary::                     Brief summary of what Org-mode does
101 * Installation::                How to install a downloaded version of Org-mode
102 * Activation::                  How to activate Org-mode for certain buffers.
103 * Feedback::                    Bug reports, ideas, patches etc.
105 Document Structure
107 * Outlines::                    Org-mode is based on outline-mode
108 * Headlines::                   How to typeset org-tree headlines
109 * Visibility cycling::          Show and hide, much simplified
110 * Motion::                      Jumping to other headlines
111 * Structure editing::           Changing sequence and level of headlines
112 * Archiving::                   Move done task trees to a different place
113 * Sparse trees::                Matches embedded in context
114 * Plain lists::                 Additional structure within an entry
116 Archiving
118 * ARCHIVE tag::                 Marking a tree as inactive
119 * Moving subtrees::             Moving a tree to an archive file
121 Tables
123 * Built-in table editor::       Simple tables
124 * Narrow columns::              Stop wasting space in tables   
125 * Table calculations::          Compute a field from other fields
126 * orgtbl-mode::                 The table editor as minor mode
127 * table.el::                    Complex tables
129 Calculations in tables
131 * Formula syntax::              How to write a formula
132 * Lisp formulas::               An alternative way to write formulas
133 * Column formulas::             Formulas valid for all fields in a column
134 * Advanced features::           Field names, parameters and automatic recalc
135 * Named-field formulas::        Formulas valid in single fields
136 * Editing/debugging formulas::  Changing a stored formula
137 * Appetizer::                   Taste the power of calc
139 Hyperlinks
141 * Link format::                 How links in Org-mode are formatted
142 * Internal links::              Links to other places in the current file
143 * External links::              URL-like links to the world
144 * Handling links::              Creating, inserting and following
145 * Search options::              Linking to a specific location
146 * Custom searches::             When the default search is not enough
147 * Remember::                    Org-trees store quick notes
149 Internal links
151 * Radio targets::               Make targets trigger links in plain text.
152 * CamelCase links::             Activating CamelCase words as links
154 TODO items
156 * TODO basics::                 Marking and displaying TODO entries
157 * TODO extensions::             Workflow and assignments
158 * Priorities::                  Some things are more important than others
159 * Breaking down tasks::         Splitting a task into managable pieces
160 * Checkboxes::                  Tick-off lists
162 Extended use of TODO keywords
164 * Workflow states::             From TODO to DONE in steps
165 * TODO types::                  I do this, Fred the rest
166 * Per file keywords::           Different files, different requirements
168 Timestamps
170 * Time stamps::                 Assigning a time to a tree entry
171 * Creating timestamps::         Commands which insert timestamps
172 * Progress logging::            Documenting when what work was done.
174 Progress Logging
176 * Closing items::               When was this entry marked DONE?
177 * Clocking work time::          When exactly did you work on this item?
179 Tags
181 * Tag inheritance::             Tags use the tree structure of the outline
182 * Setting tags::                How to assign tags to a headline
183 * Tag searches::                Searching for combinations of tags
185 Agenda Views
187 * Agenda files::                Files being searched for agenda information
188 * Agenda dispatcher::           Keyboard access to agenda views
189 * Weekly/Daily agenda::         The calendar page with current tasks
190 * Global TODO list::            All unfinished action items
191 * Matching headline tags::      Structured information with fine-tuned search
192 * Timeline::                    Time-sorted view for single file
193 * Presentation and sorting::    How agenda items are prepared for display
194 * Agenda commands::             Remote editing of org trees
195 * Custom agenda views::         Defining special searches and views
197 The weekly/daily agenda
199 * Calendar/Diary integration::  Integrating Anniversaries and more
201 Presentation and sorting
203 * Categories::                  Not all tasks are equal
204 * Time-of-day specifications::  How the agenda knows the time
205 * Sorting of agenda items::     The order of things
207 Custom agenda views
209 * Storing searches::            Type once, use often
210 * Block agenda::                All the stuff you need in a single buffer
211 * Setting Options::             Changing the rules
212 * Batch processing::            Agenda views from the command line
214 Embedded LaTeX
216 * Math symbols::                TeX macros for symbols and Greek letters
217 * Subscripts and Superscripts::  Simple syntax for raising/lowering text
218 * LaTeX fragments::             Complex formulas made easy
219 * Processing LaTeX fragments::  Previewing LaTeX processing
220 * CDLaTeX mode::                Speed up entering of formulas
222 Exporting
224 * ASCII export::                Exporting to plain ASCII
225 * HTML export::                 Exporting to HTML
226 * XOXO export::                 Exporting to XOXO
227 * iCalendar export::            Exporting in iCalendar format
228 * Text interpretation::         How the exporter looks at the file
230 Text interpretation by the exporter
232 * Comment lines::               Some lines will not be exported
233 * Enhancing text::              Subscripts, symbols and more
234 * Export options::              How to influence the export settings
236 Publishing
238 * Configuration::               Defining projects
239 * Sample configuration::        Example projects
240 * Triggering publication::      Publication commands
242 Configuration
244 * Project alist::               The central configuration variable
245 * Sources and destinations::    From here to there
246 * Selecting files::             What files are part of the project?
247 * Publishing action::           Setting the function doing the publishing
248 * Publishing options::          Tweaking HTML export
249 * Publishing links::            Which links keep working after publishing?
250 * Project page index::          Publishing a list of project files
252 Sample configuration
254 * Simple example::              One-component publishing
255 * Complex example::             A multi-component publishing example
257 Miscellaneous
259 * Completion::                  M-TAB knows what you need
260 * Customization::               Adapting Org-mode to your taste
261 * In-buffer settings::          Overview of the #+KEYWORDS
262 * The very busy C-c C-c key::   When in doubt, press C-c C-c
263 * Clean view::                  Getting rid of leading stars in the outline
264 * TTY keys::                    Using Org-mode on a tty
265 * Interaction::                 Other Emacs packages
266 * Bugs::                        Things which do not work perfectly
268 Interaction with other packages
270 * Cooperation::                 Packages Org-mode cooperates with
271 * Conflicts::                   Packages that lead to conflicts
273 Extensions, Hooks and Hacking
275 * Extensions::                  Existing 3rd-part extensions
276 * Dynamic blocks::              Automatically filled blocks
278 @end detailmenu
279 @end menu
281 @node Introduction, Document structure, Top, Top
282 @chapter Introduction
283 @cindex introduction
285 @menu
286 * Summary::                     Brief summary of what Org-mode does
287 * Installation::                How to install a downloaded version of Org-mode
288 * Activation::                  How to activate Org-mode for certain buffers.
289 * Feedback::                    Bug reports, ideas, patches etc.
290 @end menu
292 @node Summary, Installation, Introduction, Introduction
293 @section Summary
294 @cindex summary
296 Org-mode is a mode for keeping notes, maintaining ToDo lists, and doing
297 project planning with a fast and effective plain-text system.
299 Org-mode develops organizational tasks around NOTES files that contain
300 information about projects as plain text.  Org-mode is implemented on
301 top of outline-mode, which makes it possible to keep the content of
302 large files well structured.  Visibility cycling and structure editing
303 help to work with the tree.  Tables are easily created with a built-in
304 table editor.  Org-mode supports ToDo items, deadlines, time stamps,
305 and scheduling.  It dynamically compiles entries into an agenda that
306 utilizes and smoothly integrates much of the Emacs calendar and diary.
307 Plain text URL-like links connect to websites, emails, Usenet
308 messages, BBDB entries, and any files related to the projects.  For
309 printing and sharing of notes, an Org-mode file can be exported as a
310 structured ASCII file, as HTML, or (todo and agenda items only) as an
311 iCalendar file.  It can also serve as a publishing tool for a set of
312 linked webpages.
314 Org-mode keeps simple things simple.  When first fired up, it should
315 feel like a straightforward, easy to use outliner.  Complexity is not
316 imposed, but a large amount of functionality is available when you need
317 it.  Org-mode can be used on different levels and in different ways, for
318 example:
320 @example
321 @r{@bullet{} as an outline extension with visibility cycling and structure editing}
322 @r{@bullet{} as an ASCII system and table editor for taking structured notes}
323 @r{@bullet{} as an ASCII table editor with spreadsheet-like capabilities}
324 @r{@bullet{} as a TODO list editor}
325 @r{@bullet{} as a full agenda and planner with deadlines and work scheduling}
326 @r{@bullet{} as a simple hypertext system, with HTML export}
327 @r{@bullet{} as a publishing tool to create a set of interlinked webpages}
328 @end example
330 The Org-mode table editor can be integrated into any major mode by
331 activating the minor Orgtbl-mode.
333 @cindex FAQ
334 There is a website for Org-mode which provides links to the newest
335 version of Org-mode, as well as additional information, frequently asked
336 questions (FAQ), links to tutorials etc.  This page is located at
337 @uref{http://www.astro.uva.nl/~dominik/Tools/org/}.
339 @page
341 @node Installation, Activation, Summary, Introduction
342 @section Installation
343 @cindex installation
344 @cindex XEmacs
346 @b{Important:} If Org-mode is part of the Emacs distribution or an
347 XEmacs package, please skip this section and go directly to
348 @ref{Activation}.
350 If you have downloaded Org-mode from the Web, you must take the
351 following steps to install it: Go into the Org-mode distribution
352 directory and edit the top section of the file @file{Makefile}.  You
353 must set the name of the Emacs binary (likely either @file{emacs} or
354 @file{xemacs}), and the paths to the directories where local Lisp and
355 Info files are kept.  If you don't have access to the system-wide
356 directories, create your own two directories for these files, enter them
357 into the Makefile, and make sure Emacs finds the Lisp files by adding
358 the following line to @file{.emacs}:
360 @example
361 (setq load-path (cons "~/path/to/lispdir" load-path))
362 @end example
364 @b{XEmacs users now need to install the file @file{noutline.el} from
365 the @file{xemacs} subdirectory of the Org-mode distribution.  Use the
366 command:}
368 @example
369 @b{make install-noutline}
370 @end example
372 @noindent Now byte-compile and install the Lisp files with the shell
373 commands:
375 @example
376 make
377 make install
378 @end example
380 @noindent If you want to install the info documentation, use this command:
382 @example
383 make install-info
384 @end example
386 @noindent Then add to @file{.emacs}:
388 @lisp
389 ;; This line only if org-mode is not part of the X/Emacs distribution.
390 (require 'org-install)
391 @end lisp
393 @node Activation, Feedback, Installation, Introduction
394 @section Activation
395 @cindex activation
396 @cindex autoload
397 @cindex global keybindings
398 @cindex keybindings, global
400 Add the following lines to your @file{.emacs} file.  The last two lines
401 define @emph{global} keys for the commands @command{org-store-link} and
402 @command{org-agenda} - please choose suitable keys yourself.
404 @lisp
405 ;; The following lines are always needed.  Choose your own keys.
406 (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
407 (define-key global-map "\C-cl" 'org-store-link)
408 (define-key global-map "\C-ca" 'org-agenda)
409 @end lisp
411 Furthermore, you must activate @code{font-lock-mode} in org-mode
412 buffers, because significant functionality depends on font-locking being
413 active.  You can do this with either one of the following two lines
414 (XEmacs user must use the second option):
415 @lisp
416 (global-font-lock-mode 1)                     ; for all buffers
417 (add-hook 'org-mode-hook 'turn-on-font-lock)  ; org-mode buffers only
418 @end lisp
420 @cindex org-mode, turning on
421 With this setup, all files with extension @samp{.org} will be put
422 into Org-mode.  As an alternative, make the first line of a file look
423 like this:
425 @example
426 MY PROJECTS    -*- mode: org; -*-
427 @end example
429 @noindent which will select Org-mode for this buffer no matter what
430 the file's name is.  See also the variable
431 @code{org-insert-mode-line-in-empty-file}.
433 @node Feedback,  , Activation, Introduction
434 @section Feedback
435 @cindex feedback
436 @cindex bug reports
437 @cindex maintainer
438 @cindex author
440 If you find problems with Org-mode, or if you have questions, remarks,
441 or ideas about it, please contact the maintainer @value{MAINTAINER} at
442 @value{MAINTAINEREMAIL}.
444 For bug reports, please provide as much information as possible,
445 including the version information of Emacs (@kbd{C-h v emacs-version
446 @key{RET}}) and Org-mode (@kbd{C-h v org-version @key{RET}}), as well as
447 the Org-mode related setup in @file{.emacs}.  If an error occurs, a
448 traceback can be very useful.  Often a small example file helps, along
449 with clear information about:
451 @enumerate
452 @item What exactly did you do?
453 @item What did you expect to happen?
454 @item What happened instead?
455 @end enumerate
456 @noindent Thank you for helping to improve this mode.
458 @node Document structure, Tables, Introduction, Top
459 @chapter Document Structure
460 @cindex document structure
461 @cindex structure of document
463 Org-mode is based on outline mode and provides flexible commands to
464 edit the structure of the document.
466 @menu
467 * Outlines::                    Org-mode is based on outline-mode
468 * Headlines::                   How to typeset org-tree headlines
469 * Visibility cycling::          Show and hide, much simplified
470 * Motion::                      Jumping to other headlines
471 * Structure editing::           Changing sequence and level of headlines
472 * Archiving::                   Move done task trees to a different place
473 * Sparse trees::                Matches embedded in context
474 * Plain lists::                 Additional structure within an entry
475 @end menu
477 @node Outlines, Headlines, Document structure, Document structure
478 @section Outlines
479 @cindex outlines
480 @cindex outline-mode
482 Org-mode is implemented on top of outline-mode.  Outlines allow to
483 organize a document in a hierarchical structure, which (at least for
484 me) is the best representation of notes and thoughts.  Overview over
485 this structure is achieved by folding (hiding) large parts of the
486 document to show only the general document structure and the parts
487 currently being worked on.  Org-mode greatly simplifies the use of
488 outlines by compressing the entire show/hide functionality into a
489 single command @command{org-cycle}, which is bound to the @key{TAB}
490 key.
492 @node Headlines, Visibility cycling, Outlines, Document structure
493 @section Headlines
494 @cindex headlines
495 @cindex outline tree
497 Headlines define the structure of an outline tree.  The headlines in
498 Org-mode start with one or more stars, on the left margin.  For
499 example:
501 @example
502 * Top level headline
503 ** Second level
504 *** 3rd level
505     some text
506 *** 3rd level
507     more text
508 * Another top level headline
509 @end example
511 @noindent Some people find the many stars too noisy and would prefer an
512 outline that has whitespace followed by a single star as headline
513 starters.  @ref{Clean view} describes a setup to realize this.
515 @node Visibility cycling, Motion, Headlines, Document structure
516 @section Visibility cycling
517 @cindex cycling, visibility
518 @cindex visibility cycling
519 @cindex trees, visibility
520 @cindex show hidden text
521 @cindex hide text
523 Outlines make it possible to hide parts of the text in the buffer.
524 Org-mode uses just two commands, bound to @key{TAB} and
525 @kbd{S-@key{TAB}} to change the visibility in the buffer.
527 @cindex subtree visibility states
528 @cindex subtree cycling
529 @cindex folded, subtree visibility state
530 @cindex children, subtree visibility state
531 @cindex subtree, subtree visibility state
532 @table @kbd
533 @kindex @key{TAB}
534 @item @key{TAB}
535 @emph{Subtree cycling}: Rotate current subtree between the states
537 @example
538 ,-> FOLDED -> CHILDREN -> SUBTREE --.
539 '-----------------------------------'
540 @end example
542 The cursor must be on a headline for this to work@footnote{see, however,
543 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
544 beginning of the buffer and the first line is not a headline, then
545 @key{TAB} actually runs global cycling (see below)@footnote{see the
546 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
547 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
549 @cindex global visibility states
550 @cindex global cycling
551 @cindex overview, global visibility state
552 @cindex contents, global visibility state
553 @cindex show all, global visibility state
554 @kindex S-@key{TAB}
555 @item S-@key{TAB}
556 @itemx C-u @key{TAB}
557 @emph{Global cycling}: Rotate the entire buffer between the states
559 @example
560 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
561 '--------------------------------------'
562 @end example
564 Note that inside tables, @kbd{S-@key{TAB}} jumps to the previous field.
566 @cindex show all, command
567 @kindex C-c C-a
568 @item C-c C-a
569 Show all.
570 @end table
572 When Emacs first visits an Org-mode file, the global state is set to
573 OVERVIEW, i.e. only the top level headlines are visible.  This can be
574 configured through the variable @code{org-startup-folded}, or on a
575 per-file basis by adding one of the following lines anywhere in the
576 buffer:
578 @example
579 #+STARTUP: overview
580 #+STARTUP: content
581 #+STARTUP: showall
582 @end example
584 @node Motion, Structure editing, Visibility cycling, Document structure
585 @section Motion
586 @cindex motion, between headlines
587 @cindex jumping, to headlines
588 @cindex headline navigation
589 The following commands jump to other headlines in the buffer.
591 @table @kbd
592 @kindex C-c C-n
593 @item C-c C-n
594 Next heading.
595 @kindex C-c C-p
596 @item C-c C-p
597 Previous heading.
598 @kindex C-c C-f
599 @item C-c C-f
600 Next heading same level.
601 @kindex C-c C-b
602 @item C-c C-b
603 Previous heading same level.
604 @kindex C-c C-u
605 @item C-c C-u
606 Backward to higher level heading.
607 @kindex C-c C-j
608 @item C-c C-j
609 Jump to a different place without changing the current outline
610 visibility.  Shows the document structure in a temporary buffer, where
611 you can use visibility cycling (@key{TAB}) to find your destination.
612 After pressing @key{RET}, the cursor moves to the selected location in
613 the original buffer, and the headings hierarchy above it is made
614 visible.
615 @end table
617 @node Structure editing, Archiving, Motion, Document structure
618 @section Structure editing
619 @cindex structure editing
620 @cindex headline, promotion and demotion
621 @cindex promotion, of subtrees
622 @cindex demotion, of subtrees
623 @cindex subtree, cut and paste
624 @cindex pasting, of subtrees
625 @cindex cutting, of subtrees
626 @cindex copying, of subtrees
627 @cindex subtrees, cut and paste
629 @table @kbd
630 @kindex M-@key{RET}
631 @item M-@key{RET}
632 Insert new heading with same level as current.  If the cursor is in a
633 plain list item, a new item is created (@pxref{Plain lists}).  To force
634 creation of a new headline, use a prefix arg, or first press @key{RET}
635 to get to the beginning of the next line.  When this command is used in
636 the middle of a line, the line is split and the rest of the line becomes
637 the new headline.  If the command is used at the beginning of a
638 headline, the new headline is created before the current line.  If at
639 the beginning of any other line, the content of that line is made the
640 new heading.
641 @kindex M-S-@key{RET}
642 @item M-S-@key{RET}
643 Insert new TODO entry with same level as current heading.
644 @kindex M-@key{left}
645 @item M-@key{left}
646 Promote current heading by one level.
647 @kindex M-@key{right}
648 @item M-@key{right}
649 Demote current heading by one level.
650 @kindex M-S-@key{left}
651 @item M-S-@key{left}
652 Promote the current subtree by one level.
653 @kindex M-S-@key{right}
654 @item M-S-@key{right}
655 Demote the current subtree by one level.
656 @kindex M-S-@key{up}
657 @item M-S-@key{up}
658 Move subtree up (swap with previous subtree of same
659 level).
660 @kindex M-S-@key{down}
661 @item M-S-@key{down}
662 Move subtree down (swap with next subtree of same level).
663 @kindex C-c C-x C-w
664 @kindex C-c C-x C-k
665 @item C-c C-x C-w
666 @itemx C-c C-x C-k
667 Kill subtree, i.e. remove it from buffer but save in kill ring.
668 @kindex C-c C-x M-w
669 @item C-c C-x M-w
670 Copy subtree to kill ring.
671 @kindex C-c C-x C-y
672 @item C-c C-x C-y
673 Yank subtree from kill ring.  This does modify the level of the subtree to
674 make sure the tree fits in nicely at the yank position.  The yank
675 level can also be specified with a prefix arg, or by yanking after a
676 headline marker like @samp{****}.
677 @end table
679 @cindex region, active
680 @cindex active region
681 @cindex transient-mark-mode
682 When there is an active region (transient-mark-mode), promotion and
683 demotion work on all headlines in the region.  To select a region of
684 headlines, it is best to place both point and mark at the beginning of a
685 line, mark at the beginning of the first headline, and point at the line
686 just after the last headline to change.  Note that when the cursor is
687 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
688 functionality.
690 @node Archiving, Sparse trees, Structure editing, Document structure
691 @section Archiving
692 @cindex archiving
694 When a project represented by a (sub)tree is finished, you may want
695 to move the tree out of the way and to stop it from contributing to the
696 agenda.  Org-mode knows two ways of archiving.  You can mark a tree with
697 the ARCHIVE tag, or you can move an entire (sub)tree to a different
698 location.
700 @menu
701 * ARCHIVE tag::                 Marking a tree as inactive
702 * Moving subtrees::             Moving a tree to an archive file
703 @end menu
705 @node ARCHIVE tag, Moving subtrees, Archiving, Archiving
706 @subsection The ARCHIVE tag
707 @cindex internal archiving
709 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
710 its location in the outline tree, but behaves in the following way:
711 @itemize @minus
712 @item
713 It does not open when you attempt to do so with a visibility cycling
714 command (@pxref{Visibility cycling}).  You can force cycling archived
715 subtrees with @kbd{C-@key{TAB}}, or by setting the option
716 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
717 @code{show-all} will open archived subtrees.
718 @item
719 During sparse tree construction (@pxref{Sparse trees}), matches in
720 archived subtrees are not exposed, unless you configure the option
721 @code{org-sparse-tree-open-archived-trees}.
722 @item
723 During agenda view construction (@pxref{Agenda views}), the content of
724 archived trees is ignored unless you configure the option
725 @code{org-agenda-skip-archived-trees}.
726 @item
727 Archived trees are not exported (@pxref{Exporting}), only the headline
728 is.  Configure the details using the variable
729 @code{org-export-with-archived-trees}.
730 @end itemize
732 The following commands help managing the ARCHIVE tag:
734 @table @kbd
735 @kindex C-c C-x C-a
736 @item C-c C-x C-a
737 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
738 the headline changes to a shadowish face, and the subtree below it is
739 hidden.
740 @kindex C-u C-c C-x C-a
741 @item C-u C-c C-x C-a
742 Check if any direct children of the current headline should be archived.
743 To do this, each subtree is checked for open TODO entries.  If none are
744 found, the command offers to set the ARCHIVE tag for the child.  If the
745 cursor is @emph{not} on a headline when this command is invoked, the
746 level 1 trees will be checked.
747 @kindex C-@kbd{TAB}
748 @item C-@kbd{TAB}
749 Cycle a tree even if it is tagged with ARCHIVE.
750 @end table
752 @node Moving subtrees,  , ARCHIVE tag, Archiving
753 @subsection Moving subtrees
754 @cindex external archiving
756 Once an entire project is finished, you may want to move it to a
757 different location, either in the current file, or even in a different
758 file, the archive file.
760 @table @kbd
761 @kindex C-c $
762 @item C-c $
763 Archive the subtree starting at the cursor position to the location
764 given by @code{org-archive-location}.
765 @kindex C-u C-c $
766 @item C-u C-c $
767 Check if any direct children of the current headline could be moved to
768 the archive.  To do this, each subtree is checked for open TODO entries.
769 If none are found, the command offers to move it to the archive
770 location.  If the cursor is @emph{not} on a headline when this command
771 is invoked, the level 1 trees will be checked.
772 @end table
774 @cindex archive locations
775 The default archive location is a file in the same directory as the
776 current file, with the name derived by appending @file{_archive} to the
777 current file name.  For information and examples on how to change this,
778 see the documentation string of the variable
779 @code{org-archive-location}.
781 @node Sparse trees, Plain lists, Archiving, Document structure
782 @section Sparse trees
783 @cindex sparse trees
784 @cindex trees, sparse
785 @cindex folding, sparse trees
786 @cindex occur, command
788 An important feature of Org-mode is the ability to construct
789 @emph{sparse trees} for selected information in an outline tree.  A
790 sparse tree means that the entire document is folded as much as
791 possible, but the selected information is made visible along with the
792 headline structure above it@footnote{See also the variables
793 @code{org-show-hierarchy-above} and
794 @code{org-show-following-heading}.}.  Just try it out and you will see
795 immediately how it works.
797 Org-mode contains several commands creating such trees.  The most
798 basic one is @command{org-occur}:
800 @table @kbd
801 @kindex C-c /
802 @item C-c /
803 Occur.  Prompts for a regexp and shows a sparse tree with all matches.
804 If the match is in a headline, the headline is made visible.  If the
805 match is in the body of an entry, headline and body are made visible.
806 In order to provide minimal context, also the full hierarchy of
807 headlines above the match is shown, as well as the headline following
808 the match.  Each match is also highlighted; the highlights disappear
809 when the buffer is changed with an editing command.
810 @end table
811 @noindent
812 For frequently used sparse trees of specific search strings, you can
813 use the variable @code{org-agenda-custom-commands} to define fast
814 keyboard access to specific sparse trees.  These commands will then be
815 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
816 For example:
818 @lisp
819 (setq org-agenda-custom-commands
820       '(("f" occur-tree "FIXME")))
821 @end lisp
823 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
824 a sparse tree matching the string @samp{FIXME}.
826 Other commands use sparse trees as well.  For example @kbd{C-c
827 C-v} creates a sparse TODO tree (@pxref{TODO basics}).
829 @kindex C-c C-e v
830 @cindex printing sparse trees
831 @cindex visible text, printing
832 To print a sparse tree, you can use the Emacs command
833 @code{ps-print-buffer-with-faces} which does not print invisible parts
834 of the document @footnote{This does not work under XEmacs, because
835 XEmacs uses selective display for outlining, not text properties.}.
836 Or you can use the command @kbd{C-c C-e v} to export only the visible
837 part of the document and print the resulting file.
839 @node Plain lists,  , Sparse trees, Document structure
840 @section Plain lists
841 @cindex plain lists
842 @cindex lists, plain
843 @cindex lists, ordered
844 @cindex ordered lists
846 Within an entry of the outline tree, hand-formatted lists can provide
847 additional structure.  They also provide a way to create lists of
848 checkboxes (@pxref{Checkboxes}).  Org-mode supports editing such lists,
849 and the HTML exporter (@pxref{Exporting}) does parse and format them.
851 Org-mode knows ordered and unordered lists.  Unordered list items start
852 with @samp{-}, @samp{+}, or @samp{*}@footnote{When using @samp{*} as a
853 bullet, lines must be indented or they will be seen as top-level
854 headlines.  Also, when you are hiding leading stars to get a clean
855 outline view, plain list items starting with a star are visually
856 indistinguishable from true headlines.  In short: even though @samp{*}
857 is supported, it may be better not to use it for plain list items} as
858 bullets.  Ordered list items start with @samp{1.} or @samp{1)}.  Items
859 belonging to the same list must have the same indentation on the first
860 line.  In particular, if an ordered list reaches number @samp{10.}, then
861 the 2--digit numbers must be written left-aligned with the other numbers
862 in the list.  Indentation also determines the end of a list item.  It
863 ends before the next line that is indented like the bullet/number, or
864 less.  For example:
866 @example
867 @group
868 ** Lord of the Rings
869    My favorite scenes are (in this order)
870    1. The attack of the Rohirrim
871    2. Eowyns fight with the witch king
872       + this was already my favorite scene in the book
873       + I really like Miranda Otto.
874    3. Peter Jackson being shot by Legolas
875        - on DVD only
876       He makes a really funny face when it happens.
877    But in the end, not individual scenes matter but the film as a whole.
878 @end group
879 @end example
881 Org-mode supports these lists by tuning filling and wrapping commands to
882 deal with them correctly@footnote{Org-mode only changes the filling
883 settings for Emacs.  For XEmacs, you should use Kyle E. Jones'
884 @file{filladapt.el}.  To turn is on,  put into @file{.emacs}:
885 @example
886 (require 'filladapt)
887 @end example
890 The following commands act on items when the cursor is in the first line
891 of an item (the line with the bullet or number).
893 @table @kbd
894 @kindex @key{TAB}
895 @item @key{TAB}
896 Items can be folded just like headline levels if you set the variable
897 @code{org-cycle-include-plain-lists}.  The level of an item is then
898 given by the indentation of the bullet/number.  Items are always
899 subordinate to real headlines, however; the hierarchies remain
900 completely separated.
901 @kindex M-@key{RET}
902 @item M-@key{RET}
903 Insert new item at current level.  With prefix arg, force a new heading
904 (@pxref{Structure editing}).  If this command is used in the middle of a
905 line, the line is @emph{split} and the rest of the line becomes the new
906 item.  If this command is executed in the @emph{whitespace before a bullet or
907 number}, the new item is created @emph{before} the current item.  If the
908 command is executed in the white space before the text that is part of
909 an item but does not contain the bullet, a bullet is added to the
910 current line.
911 @kindex M-S-@key{RET}
912 @item M-S-@key{RET}
913 Insert a new item with a checkbox (@pxref{Checkboxes}).
914 @kindex S-@key{up}
915 @kindex S-@key{down}
916 @item S-@key{up}
917 @itemx S-@key{down}
918 Jump to the previous/next item in the current list.
919 @kindex M-S-@key{up}
920 @kindex M-S-@key{down}
921 @item M-S-@key{up}
922 @itemx M-S-@key{down}
923 Move the item including subitems up/down (swap with previous/next item
924 of same indentation).  If the list is ordered, renumbering is
925 automatic.
926 @kindex M-S-@key{left}
927 @kindex M-S-@key{right}
928 @item M-S-@key{left}
929 @itemx M-S-@key{right}
930 Decrease/increase the indentation of the item, including subitems.
931 Initially, the item tree is selected based on current indentation.
932 When these commands are executed several times in direct succession,
933 the initially selected region is used, even if the new indentation
934 would imply a different hierarchy.  To use the new hierarchy, break
935 the command chain with a cursor motion or so.
936 @kindex C-c C-c
937 @item C-c C-c
938 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
939 state of the checkbox.  Otherwise, if this is an ordered list, renumber
940 the ordered list at the cursor.
941 @end table
943 @node Tables, Hyperlinks, Document structure, Top
944 @chapter Tables
945 @cindex tables
946 @cindex editing tables
948 Org-mode has a very fast and intuitive table editor built-in.
949 Spreadsheet-like calculations are supported in connection with the
950 Emacs @file{calc} package.
952 @menu
953 * Built-in table editor::       Simple tables
954 * Narrow columns::              Stop wasting space in tables   
955 * Table calculations::          Compute a field from other fields
956 * orgtbl-mode::                 The table editor as minor mode
957 * table.el::                    Complex tables
958 @end menu
960 @node Built-in table editor, Narrow columns, Tables, Tables
961 @section The built-in table editor
962 @cindex table editor, builtin
964 Org-mode makes it easy to format tables in plain ASCII.  Any line with
965 @samp{|} as the first non-white character is considered part of a
966 table.  @samp{|} is also the column separator.  A table might look
967 like this:
969 @example
970 | Name  | Phone | Age |
971 |-------+-------+-----|
972 | Peter |  1234 |  17 |
973 | Anna  |  4321 |  25 |
974 @end example
976 A table is re-aligned automatically each time you press @key{TAB} or
977 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
978 the next field (@key{RET} to the next row) and creates new table rows
979 at the end of the table or before horizontal lines.  The indentation
980 of the table is set by the first line.  Any line starting with
981 @samp{|-} is considered as a horizontal separator line and will be
982 expanded on the next re-align to span the whole table width.  So, to
983 create the above table, you would only type
985 @example
986 |Name|Phone|Age|
988 @end example
990 @noindent and then press @key{TAB} to align the table and start filling in
991 fields.
993 When typing text into a field, Org-mode treats @key{DEL},
994 @key{Backspace}, and all character keys in a special way, so that
995 inserting and deleting avoids shifting other fields.  Also, when
996 typing @emph{immediately after the cursor was moved into a new field
997 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
998 field is automatically made blank.  If this behavior is too
999 unpredictable for you, configure the variables
1000 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
1002 @table @kbd
1003 @tsubheading{Creation and conversion}
1004 @kindex C-c |
1005 @item C-c |
1006 Convert the active region to table. If every line contains at least one
1007 TAB character, the function assumes that the material is tab separated.
1008 If not, lines are split at whitespace into fields.  You can use a prefix
1009 argument to indicate the minimum number of consecutive spaces required
1010 to identify a field separator (default: just one).@* 
1011 If there is no active region, this command creates an empty Org-mode
1012 table.  But it's easier just to start typing, like
1013 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
1015 @tsubheading{Re-aligning and field motion}
1016 @kindex C-c C-c
1017 @item C-c C-c
1018 Re-align the table without moving the cursor.
1020 @kindex @key{TAB}
1021 @item @key{TAB}
1022 Re-align the table, move to the next field.  Creates a new row if
1023 necessary.
1025 @kindex S-@key{TAB}
1026 @item S-@key{TAB}
1027 Re-align, move to previous field.
1029 @kindex @key{RET}
1030 @item @key{RET}
1031 Re-align the table and move down to next row.  Creates a new row if
1032 necessary.  At the beginning or end of a line, @key{RET} still does
1033 NEWLINE, so it can be used to split a table.
1035 @tsubheading{Column and row editing}
1036 @kindex M-@key{left}
1037 @kindex M-@key{right}
1038 @item M-@key{left}
1039 @itemx M-@key{right}
1040 Move the current column left/right.
1042 @kindex M-S-@key{left}
1043 @item M-S-@key{left}
1044 Kill the current column.
1046 @kindex M-S-@key{right}
1047 @item M-S-@key{right}
1048 Insert a new column to the left of the cursor position.
1050 @kindex M-@key{up}
1051 @kindex M-@key{down}
1052 @item M-@key{up}
1053 @itemx M-@key{down}
1054 Move the current row up/down.
1056 @kindex M-S-@key{up}
1057 @item M-S-@key{up}
1058 Kill the current row or horizontal line.
1060 @kindex M-S-@key{down}
1061 @item M-S-@key{down}
1062 Insert a new row above (with arg: below) the current row.
1064 @kindex C-c -
1065 @item C-c -
1066 Insert a horizontal line below current row. With prefix arg, the line
1067 is created above the current line.
1069 @kindex C-c ^
1070 @item C-c ^
1071 Sort the table lines in the region.  Point and mark must be in the first
1072 and last line to be included, and must be in the column that should be
1073 used for sorting.  The command prompts for numerical versus
1074 alphanumerical sorting.
1076 @tsubheading{Regions}
1077 @kindex C-c C-x M-w
1078 @item C-c C-x M-w
1079 Copy a rectangular region from a table to a special clipboard.  Point
1080 and mark determine edge fields of the rectangle.  The process ignores
1081 horizontal separator lines.
1082 @kindex C-c C-x C-w
1083 @item C-c C-x C-w
1084 Copy a rectangular region from a table to a special clipboard, and
1085 blank all fields in the rectangle.  So this is the ``cut'' operation.
1086 @kindex C-c C-x C-y
1087 @item C-c C-x C-y
1088 Paste a rectangular region into a table.
1089 The upper right corner ends up in the current field.  All involved fields
1090 will be overwritten.  If the rectangle does not fit into the present table,
1091 the table is enlarged as needed.  The process ignores horizontal separator
1092 lines.
1093 @kindex C-c C-q
1094 @item C-c C-q
1095 Wrap several fields in a column like a paragraph.  If there is an active
1096 region, and both point and mark are in the same column, the text in the
1097 column is wrapped to minimum width for the given number of lines.  A
1098 prefix ARG may be used to change the number of desired lines.  If there
1099 is no region, the current field is split at the cursor position and the
1100 text fragment to the right of the cursor is prepended to the field one
1101 line down. If there is no region, but you specify a prefix ARG, the
1102 current field is made blank, and the content is appended to the field
1103 above.
1105 @tsubheading{Calculations}
1106 @cindex formula, in tables
1107 @cindex calculations, in tables
1108 @kindex C-c =
1109 @item C-c =
1110 Install a new formula for the current column and replace current field
1111 with the result of the formula.
1113 @kindex C-u C-c =
1114 @item C-u C-c =
1115 Install a new formula for the current field, which must be a named
1116 field.  Evaluate the formula and replace the field content with the
1117 result.
1119 @kindex C-c '
1120 @item C-c '
1121 Edit all formulas associated with the current table in a separate
1122 buffer.
1124 @kindex C-c *
1125 @item C-c *
1126 Recalculate the current row by applying the stored formulas from left
1127 to right.  When called with a @kbd{C-u} prefix, recalculate the
1128 entire table, starting with the first non-header line (i.e. below the
1129 first horizontal separator line).  For details, see @ref{Table calculations}.
1131 @kindex C-#
1132 @item C-#
1133 Rotate the calculation mark in first column through the states
1134 @samp{}, @samp{#}, @samp{*}, @samp{!}, @samp{$}.  For the meaning of
1135 these marks see @ref{Advanced features}.  When there is an active
1136 region, change all marks in the region.
1138 @kindex C-c ?
1139 @item C-c ?
1140 Which table column is the cursor in?  Displays number >0 in echo
1141 area.
1143 @cindex region, active
1144 @cindex active region
1145 @cindex transient-mark-mode
1146 @kindex C-c +
1147 @item C-c +
1148 Sum the numbers in the current column, or in the rectangle defined by
1149 the active region.  The result is shown in the echo area and can
1150 be inserted with @kbd{C-y}.
1152 @kindex S-@key{RET}
1153 @item S-@key{RET}
1154 When current field is empty, copy from first non-empty field above.
1155 When not empty, copy current field down to next row and move cursor
1156 along with it.  Depending on the variable
1157 @code{org-table-copy-increment}, integer field values will be
1158 incremented during copy.  This key is also used by CUA-mode
1159 (@pxref{Cooperation}).
1161 @tsubheading{Miscellaneous}
1162 @kindex C-c `
1163 @item C-c `
1164 Edit the current field in a separate window.  This is useful for fields
1165 that are not fully visible (@pxref{Narrow columns}).  When called with a
1166 @kbd{C-u} prefix, just make the full field visible, so that it can be
1167 edited in place.
1169 @kindex C-c @key{TAB}
1170 @item C-c @key{TAB}
1171 This is an alias for @kbd{C-u C-c `} to make the current field fully
1172 visible.
1174 @item M-x org-table-import
1175 Import a file as a table.  The table should be TAB- or whitespace
1176 separated.  Useful, for example, to import an Excel table or data from a
1177 database, because these programs generally can write TAB-separated text
1178 files.  This command works by inserting the file into the buffer and
1179 then converting the region to a table.  Any prefix argument is passed on
1180 to the converter, which uses it to determine the separator.
1182 @item M-x org-table-export
1183 Export the table as a TAB-separated file.  Useful for data exchange with,
1184 for example, Excel or database programs.
1186 @end table
1188 If you don't like the automatic table editor because it gets in your
1189 way on lines which you would like to start with @samp{|}, you can turn
1190 it off with
1192 @lisp
1193 (setq org-enable-table-editor nil)
1194 @end lisp
1196 @noindent Then the only table command that still works is
1197 @kbd{C-c C-c} to do a manual re-align.
1199 @node Narrow columns, Table calculations, Built-in table editor, Tables
1200 @section Narrow columns
1201 @cindex narrow columns in tables
1203 The width of columns is automatically determined by the table editor.
1204 Sometimes a single field or a few fields need to carry more text,
1205 leading to inconveniently wide columns.  To limit@footnote{This feature
1206 does not work on XEmacs.} the width of a column, one field anywhere in
1207 the column may contain just the string @samp{<N>} where @samp{N} is an
1208 integer specifying the width of the column in characters.  The next
1209 re-align will then set the width of this column to no more than this
1210 value.
1212 @example
1213 |---+------------------------------|               |---+--------|
1214 |   |                              |               |   | <6>    |
1215 | 1 | one                          |               | 1 | one    |
1216 | 2 | two                          |     ----\     | 2 | two    |
1217 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
1218 | 4 | four                         |               | 4 | four   |
1219 |---+------------------------------|               |---+--------|
1220 @end example
1222 @noindent
1223 Fields that are wider become clipped and end in the string @samp{=>}.
1224 Note that the full text is still in the buffer, it is only invisible.
1225 To see the full text, hold the mouse over the field - a tooltip window
1226 will show the full content.  To edit such a field, use the command
1227 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
1228 open a new window with the full field.  Edit it and finish with @kbd{C-c
1229 C-c}.
1231 When visiting a file containing a table with narrowed columns, the
1232 necessary character hiding has not yet happened, and the table needs to
1233 be aligned before it looks nice.  Setting the option
1234 @code{org-startup-align-all-tables} will realign all tables in a file
1235 upon visiting, but also slow down startup.  You can also set this option
1236 on a per-file basis with:
1238 @example
1239 #+STARTUP: align
1240 #+STARTUP: noalign
1241 @end example
1243 @node Table calculations, orgtbl-mode, Narrow columns, Tables
1244 @section Calculations in tables
1245 @cindex calculations, in tables
1246 @cindex spreadsheet capabilities
1247 @cindex @file{calc} package
1249 The table editor makes use of the Emacs @file{calc} package to implement
1250 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
1251 derive fields from other fields.  Org-mode has two levels of complexity
1252 for table calculations.  On the basic level, tables do only horizontal
1253 computations, so a field can be computed from other fields @emph{in the
1254 same row}, and Org-mode assumes that there is only one formula for each
1255 column.  This is very efficient to work with and enough for many tasks.
1256 On the complex level, columns and individual fields can be named for
1257 easier referencing in formulas, individual named fields can have their
1258 own formula associated with them, and recalculation can be automated.
1260 @menu
1261 * Formula syntax::              How to write a formula
1262 * Lisp formulas::               An alternative way to write formulas
1263 * Column formulas::             Formulas valid for all fields in a column
1264 * Advanced features::           Field names, parameters and automatic recalc
1265 * Named-field formulas::        Formulas valid in single fields
1266 * Editing/debugging formulas::  Changing a stored formula
1267 * Appetizer::                   Taste the power of calc
1268 @end menu
1270 @node Formula syntax, Lisp formulas, Table calculations, Table calculations
1271 @subsection Formula syntax
1272 @cindex formula syntax
1273 @cindex syntax, of formulas
1275 A formula can be any algebraic expression understood by the Emacs
1276 @file{calc} package.  Note that @file{calc} has the slightly
1277 non-standard convention that @samp{/} has lower precedence than
1278 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.  Before
1279 evaluation by @code{calc-eval} (@pxref{Calling Calc from Your
1280 Programs,calc-eval,Calling calc from Your Lisp Programs,calc,GNU Emacs
1281 Calc Manual}), variable substitution takes place:
1283 @example
1284   $        @r{refers to the current field}
1285   $3       @r{refers to the field in column 3 of the current row}
1286   $3..$7   @r{a vector of the fields in columns 3-7 of current row}
1287   $P1..$P3 @r{vector of column range, using column names}
1288   &2       @r{second data field above the current, in same column}
1289   &5-2     @r{vector from fifth to second field above current}
1290   &III-II  @r{vector of fields between 2nd and 3rd hline above}
1291   &III     @r{vector of fields between third hline above and current field}
1292   $name    @r{a named field, parameter or constant}
1293 @end example
1295 @cindex vectors, in table calculations
1296 The range vectors can be directly fed into the calc vector functions
1297 like @samp{vmean} and @samp{vsum}.
1299 @cindex name, of column or field
1300 @cindex constants, in calculations
1301 @samp{$name} is interpreted as the name of a column, parameter or
1302 constant.  Constants are defined globally through the variable
1303 @code{org-table-formula-constants}.  If you have the
1304 @file{constants.el} package, it will also be used to resolve
1305 constants, including natural constants like @samp{$h} for Planck's
1306 constant, and units like @samp{$km} for kilometers.  Column names and
1307 parameters can be specified in special table lines.  These are
1308 described below, see @ref{Advanced features}.
1310 @cindex format specifier
1311 @cindex mode, for @file{calc}
1312 A formula can contain an optional mode string after a semicolon.  This
1313 string consists of flags to influence calc's modes@footnote{By
1314 default, Org-mode uses the standard calc modes (precision 12, angular
1315 units degrees, fraction and symbolic modes off).  The display format,
1316 however, has been changed to @code{(float 5)} to keep tables compact.
1317 The default settings can be configured using the variable
1318 @code{org-calc-default-modes}.} during execution, e.g.  @samp{p20} to
1319 switch the internal precision to 20 digits, @samp{n3}, @samp{s3},
1320 @samp{e2} or @samp{f4} to switch to normal, scientific, engineering,
1321 or fixed display format, respectively, and @samp{D}, @samp{R}, @samp{F},
1322 and @samp{S} to turn on degrees, radians, fraction and symbolic modes,
1323 respectively.  In addition, you may provide a @code{printf} format
1324 specifier to reformat the final result.  A few examples:
1326 @example
1327 $1+$2                @r{Sum of first and second field}
1328 $1+$2;%.2f           @r{Same, format result to two decimals}
1329 exp($2)+exp($1)      @r{Math functions can be used}
1330 $;%.1f               @r{Reformat current cell to 1 decimal}
1331 ($3-32)*5/9          @r{Degrees F -> C conversion}
1332 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
1333 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
1334 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
1335 vmean($2..$7)        @r{Compute column range mean, using vector function}
1336 vsum(&III)           @r{Sum numbers from 3rd hline above, up to here}
1337 taylor($3,x=7,2)     @r{taylor series of $3, at x=7, second degree}
1338 @end example
1340 @node Lisp formulas, Column formulas, Formula syntax, Table calculations
1341 @subsection Emacs Lisp forms as formulas
1342 @cindex Lisp forms, as table formulas
1344 It is also possible to write a formula in Emacs lisp; this can be useful
1345 for string manipulation and control structures.  If a formula starts
1346 with a single quote followed by an opening parenthesis, then it is
1347 evaluated as a lisp form.  The evaluation should return either a string
1348 or a number.  Just as with @file{calc} formulas, you can provide a
1349 format specifier after a semicolon.  A few examples:
1351 @example
1352 @r{swap the first two characters of the content of column 1}
1353 '(concat (substring "$1" 1 2) (substring "$1" 0 1) (substring "$1" 2))
1354 @r{Add columns 1 and 2, equivalent to the calc's @code{$1+$2}}
1355 '(+ $1 $2)
1356 @end example
1358 @node Column formulas, Advanced features, Lisp formulas, Table calculations
1359 @subsection Column formulas
1360 @cindex column formula
1361 @cindex formula, for table column
1363 To apply a formula to a field, type it directly into the field,
1364 preceded by an equal sign, like @samp{=$1+$2}.  When you press
1365 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the
1366 field, the formula will be stored as the formula for the current
1367 column, evaluated and the current field replaced with the result.  If
1368 the field contains only @samp{=}, the previously stored formula for
1369 this column is used.
1371 For each column, Org-mode will remember the most recently used
1372 formula.  The information is stored in a special line starting with
1373 @samp{#+TBLFM} directly below the table.  When adding/deleting/moving
1374 columns with the appropriate commands, the stored equations will be
1375 modified accordingly.  When a column used in a calculation is removed,
1376 references to this column become invalid and will cause an error upon
1377 applying the equation.
1379 Instead of typing an equation into the field, you may also use the
1380 command @kbd{C-c =}.  It prompts for a formula (with default taken
1381 from the @samp{#+TBLFM:} line) and applies it to the current field.  A
1382 numerical prefix (e.g. @kbd{C-5 C-c =}) will apply it to that many
1383 consecutive fields in the current column.
1385 @cindex recomputing table fields
1386 To recompute all the fields in a line, use the command @kbd{C-c *}.
1387 It re-applies all stored equations to the current row, from left to
1388 right.  With a @kbd{C-u} prefix, this will be done to every line in
1389 the table, so use this command it you want to make sure the entire
1390 table is up-to-date. @kbd{C-u C-c C-c} is another way to update the
1391 entire table.  Global updating does not touch the line(s) above the
1392 first horizontal separator line, assuming that this is the table
1393 header.
1395 @node Advanced features, Named-field formulas, Column formulas, Table calculations
1396 @subsection Advanced features
1398 If you want the recalculation of fields to happen automatically,
1399 or if you want to be able to assign a formula to an individual field
1400 (instead of an entire column) you need to reserve the first column of
1401 the table for special marking characters.  Here is an example of a
1402 table that collects exam results of students and makes use of these
1403 features:
1405 @example
1406 @group
1407 |---+---------+--------+--------+--------+-------+------|
1408 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
1409 |---+---------+--------+--------+--------+-------+------|
1410 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
1411 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
1412 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
1413 |---+---------+--------+--------+--------+-------+------|
1414 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
1415 | # | Sara    |      6 |     14 |     19 |    39 |  7.8 |
1416 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
1417 |---+---------+--------+--------+--------+-------+------|
1418 |   | Average |        |        |        |  29.7 |      |
1419 | ^ |         |        |        |        |    at |      |
1420 | $ | max=50  |        |        |        |       |      |
1421 |---+---------+--------+--------+--------+-------+------|
1422 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(&II);%.1f
1423 @end group
1424 @end example
1426 @noindent @b{Important}: Please note that for these special tables,
1427 recalculating the table with @kbd{C-u C-c *} will only affect rows
1428 that are marked @samp{#} or @samp{*}, and named fields.  The column
1429 formulas are not applied in rows with empty first field.
1431 @cindex marking characters, tables
1432 The marking characters have the following meaning:
1433 @table @samp
1434 @item !
1435 The fields in this line define names for the columns, so that you may
1436 refer to a column as @samp{$Tot} instead of @samp{$6}.
1437 @item ^
1438 This row defines names for the fields @emph{above} the row.  With such
1439 a definition, any formula in the table may use @samp{$m1} to refer to
1440 the value @samp{10}.  Also, named fields can have their own formula
1441 associated with them.
1442 @item _
1443 Similar to @samp{^}, but defines names for the fields in the row
1444 @emph{below}.
1445 @item $
1446 Fields in this row can define @emph{parameters} for formulas.  For
1447 example, if a field in a @samp{$} row contains @samp{max=50}, then
1448 formulas in this table can refer to the value 50 using @samp{$max}.
1449 Parameters work exactly like constants, only that they can be defined on
1450 a per-table basis.  Changing a parameter and then recalculating the
1451 table can be useful.
1452 @item #
1453 Fields in this row are automatically recalculated when pressing
1454 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
1455 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
1456 lines will be left alone by this command.
1457 @item *
1458 Selects this line for global recalculation with @kbd{C-u C-c *}, but
1459 not for automatic recalculation.  Use this when automatic
1460 recalculation slows down editing too much.
1461 @item
1462 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
1463 All lines that should be recalculated should be marked with @samp{#}
1464 or @samp{*}.
1465 @end table
1467 @node Named-field formulas, Editing/debugging formulas, Advanced features, Table calculations
1468 @subsection Named-field formulas
1469 @cindex named field formula
1470 @cindex formula, for named table field
1472 A named field can have its own formula associated with it.  In the
1473 example above, this is used for the @samp{at} field that contains
1474 the average result of the students.  To enter a formula for a named
1475 field, just type it into the buffer, preceded by @samp{:=}.  Or use
1476 @kbd{C-u C-c =}.  This equation will be stored below the table like
1477 @samp{$name=...}.  Any recalculation in the table (even if only
1478 requested for the current line) will also update all named field
1479 formulas.
1481 @node Editing/debugging formulas, Appetizer, Named-field formulas, Table calculations
1482 @subsection Editing and debugging formulas
1483 @cindex formula editing
1484 @cindex editing, of table formulas
1486 To edit a column or field formula, use the commands @kbd{C-c
1487 =} and @kbd{C-u C-c =}, respectively.  The currently active expression
1488 is then presented as default in the minibuffer, where it may be edited.
1490 Note that making a table field blank does not remove the formula
1491 associated with the field - during the next recalculation the field
1492 will be filled again.  To remove a formula from a field, you have to
1493 give an empty reply when prompted for the formula, or to edit the
1494 @samp{#+TBLFM} line.
1496 @kindex C-c C-c
1497 You may edit the @samp{#+TBLFM} directly and re-apply
1498 the changed equations with @kbd{C-c C-c} in that line, or with the
1499 normal recalculation commands in the table.
1501 @kindex C-c '
1502 @kindex C-c C-c
1503 @kindex C-c C-q
1504 @kindex C-c ?
1505 In particular for large tables with many formulas, it is convenient to
1506 use the command @kbd{C-c '} to edit the formulas of the current table
1507 in a separate buffer.  That buffer will show the formulas one per
1508 line, and you are free to edit, add and remove formulas.  Press
1509 @kbd{C-c ?} on a @samp{$...}  expression to get information about its
1510 interpretation.  Exiting the buffer with @kbd{C-c C-c} only stores the
1511 modified formulas below the table.  Exiting with @kbd{C-u C-c C-c}
1512 also applies them to the entire table.  @kbd{C-c C-q} exits without
1513 installing the changes.
1515 When the evaluation of a formula leads to an error, the field content
1516 becomes the string @samp{#ERROR}.  If you would like see what is going
1517 on during variable substitution and calculation in order to find a
1518 bug, turn on formula debugging in the menu and repeat the calculation,
1519 for example by pressing @kbd{C-c = @key{RET}} in a field.
1520 Detailed information will be displayed.
1522 @node Appetizer,  , Editing/debugging formulas, Table calculations
1523 @subsection Appetizer
1525 Finally, just to whet your appetite on what can be done with the fantastic
1526 @file{calc} package, here is a table that computes the Taylor series
1527 for a couple of functions (homework: try that with Excel :-)
1529 @example
1530 @group
1531 |---+-------------+---+-----+--------------------------------------|
1532 |   | Func        | n | x   | Result                               |
1533 |---+-------------+---+-----+--------------------------------------|
1534 | # | exp(x)      | 1 | x   | 1 + x                                |
1535 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
1536 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
1537 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
1538 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
1539 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
1540 |---+-------------+---+-----+--------------------------------------|
1541 #+TBLFM: $5=taylor($2,$4,$3);n3
1542 @end group
1543 @end example
1545 @node orgtbl-mode, table.el, Table calculations, Tables
1546 @section The Orgtbl minor mode
1547 @cindex orgtbl-mode
1548 @cindex minor mode for tables
1550 If you like the intuitive way the Org-mode table editor works, you
1551 might also want to use it in other modes like text-mode or mail-mode.
1552 The minor mode Orgtbl-mode makes this possible.  You can always toggle
1553 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
1554 example in mail mode, use
1556 @lisp
1557 (add-hook 'mail-mode-hook 'turn-on-orgtbl)
1558 @end lisp
1560 @node table.el,  , orgtbl-mode, Tables
1561 @section The @file{table.el} package
1562 @kindex C-c C-c
1563 @cindex table editor, @file{table.el}
1564 @cindex @file{table.el}
1566 Complex ASCII tables with automatic line wrapping, column- and
1567 row-spanning, and alignment can be created using the Emacs table
1568 package by Takaaki Ota (@uref{http://sourceforge.net/projects/table},
1569 and also part of Emacs 22).
1570 When @key{TAB} or @kbd{C-c C-c} is pressed in such a table, Org-mode
1571 will call @command{table-recognize-table} and move the cursor into the
1572 table.  Inside a table, the keymap of Org-mode is inactive.  In order
1573 to execute Org-mode-related commands, leave the table.
1575 @table @kbd
1576 @kindex C-c C-c
1577 @item C-c C-c
1578 Recognize @file{table.el} table.  Works when the cursor is in a
1579 table.el table.
1581 @kindex C-c ~
1582 @item C-c ~
1583 Insert a table.el table.  If there is already a table at point, this
1584 command converts it between the table.el format and the Org-mode
1585 format.  See the documentation string of the command
1586 @code{org-convert-table} for the restrictions under which this is
1587 possible.
1588 @end table
1590 @node Hyperlinks, TODO items, Tables, Top
1591 @chapter Hyperlinks
1592 @cindex hyperlinks
1594 Just like HTML, Org-mode provides links inside a file, and external
1595 links to other files, Usenet articles, emails, and much more.
1597 @menu
1598 * Link format::                 How links in Org-mode are formatted
1599 * Internal links::              Links to other places in the current file
1600 * External links::              URL-like links to the world
1601 * Handling links::              Creating, inserting and following
1602 * Search options::              Linking to a specific location
1603 * Custom searches::             When the default search is not enough
1604 * Remember::                    Org-trees store quick notes
1605 @end menu
1607 @node Link format, Internal links, Hyperlinks, Hyperlinks
1608 @section Link format
1609 @cindex link format
1610 @cindex format, of links
1612 Org-mode will recognize plain URL-like links and activate them as
1613 clickable links.  The general link format, however, looks like this:
1615 @example
1616 [[link][description]]       @r{or alternatively}           [[link]]  
1617 @end example
1619 Once a link in the buffer is complete (all brackets present), Org-mode
1620 will change the display so that @samp{description} is displayed instead
1621 of @samp{[[link][description]]} and @samp{link} is displayed instead of
1622 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
1623 which by default is an underlined face.  You can directly edit the
1624 visible part of a link.  Note that this can be either the @samp{link}
1625 part (if there is no description) or the @samp{description} part.  To
1626 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
1627 cursor on the link.
1629 If you place the cursor at the beginning or just behind the end of the
1630 displayed text and press @key{BACKSPACE}, you will remove the
1631 (invisible) bracket at that location.  This makes the link incomplete
1632 and the internals are again displayed as plain text.  Inserting the
1633 missing bracket hides the link internals again.  To show the
1634 internal structure of all links, use the menu entry
1635 @code{Org->Hyperlinks->Literal links}.
1637 @node Internal links, External links, Link format, Hyperlinks
1638 @section Internal links
1639 @cindex internal links
1640 @cindex links, internal
1641 @cindex CamelCase links
1643 If the link does not look like a URL, it is considered to be internal in
1644 the current file.  Links such as @samp{[[My Target]]} or @samp{[[My
1645 Target][Find my target]]} lead to a text search in the current file.
1646 The link can be followed with @kbd{C-c C-o} when the cursor is on the
1647 link, or with a mouse click (@pxref{Handling links}).  The preferred
1648 match for such a link is a dedicated target: the same string in double
1649 angular brackets.  Targets may be located anywhere; often it is
1650 convenient to put them into a comment line. For example
1652 @example
1653 # <<My Target>>
1654 @end example
1656 @noindent In HTML export (@pxref{HTML export}), such targets will become
1657 named anchors for direct access through @samp{http} links@footnote{Note
1658 that text before the first headline will never be exported, so the first
1659 such target must be after the first headline.}.
1661 If no dedicated target exists, Org-mode will search for the words in the
1662 link.  In the above example the search would be for @samp{my target}.
1663 Links starting with a star like @samp{*My Target} restrict the search to
1664 headlines.  When searching, Org-mode will first try an exact match, but
1665 then move on to more and more lenient searches.  For example, the link
1666 @samp{[[*My Targets]]} will find any of the following:
1668 @example
1669 ** My targets
1670 ** TODO my targets are bright
1671 ** my 20 targets are
1672 @end example
1674 To insert a link targeting a headline, in-buffer completion can be used.
1675 Just type a star followed by a few optional letters into the buffer and
1676 press @kbd{M-@key{TAB}}.  All headlines in the current buffer will be
1677 offered as completions.  @xref{Handling links}, for more commands
1678 creating links.
1680 Following a link pushes a mark onto Org-mode's own mark ring.  You can
1681 return to the previous position with @kbd{C-c &}.  Using this command
1682 several times in direct succession goes back to positions recorded
1683 earlier.
1685 @menu
1686 * Radio targets::               Make targets trigger links in plain text.
1687 * CamelCase links::             Activating CamelCase words as links
1688 @end menu
1690 @node Radio targets, CamelCase links, Internal links, Internal links
1691 @subsection Radio targets
1693 You can configure Org-mode to link any occurrences of certain target
1694 names in normal text.  So without explicitly creating a link, the text
1695 connects to the target radioing its position.  Radio targets are
1696 enclosed by triple angular brackets.  For example, a target
1697 @samp{<<<My Target>>>} causes each occurrence of @samp{my target} in
1698 normal text to become activated as a link.  The Org-mode file is
1699 scanned automatically for radio targets only when the file is first
1700 loaded into Emacs.  To update the target list during editing, press
1701 @kbd{C-c C-c} with the cursor on or at a target.
1703 @node CamelCase links,  , Radio targets, Internal links
1704 @subsection CamelCase words as links
1705 @cindex completion, of CamelCase links
1706 @cindex CamelCase links, completion of
1708 Org-mode also supports CamelCase words as links.  This feature is not
1709 turned on by default because of the inconsistencies this system suffers
1710 from.  To activate CamelCase words as links, you need to customize
1711 the option @code{org-activate-links}.  A CamelCase word then leads to a
1712 text search such that @samp{CamelCaseLink} is equivalent to
1713 @samp{[[camel case link]]}.
1715 @node External links, Handling links, Internal links, Hyperlinks
1716 @section External links
1717 @cindex links, external
1718 @cindex external links
1719 @cindex links, external
1720 @cindex GNUS links
1721 @cindex BBDB links
1722 @cindex URL links
1723 @cindex file links
1724 @cindex VM links
1725 @cindex RMAIL links
1726 @cindex WANDERLUST links
1727 @cindex MH-E links
1728 @cindex USENET links
1729 @cindex SHELL links
1730 @cindex Info links
1731 @cindex elisp links
1733 Org-mode supports links to files, websites, Usenet and email messages,
1734 and BBDB database entries.  External links are URL-like locators.  They
1735 start with a short identifying string followed by a colon.  There can be
1736 no space after the colon.  The following list shows examples for each
1737 link type.
1739 @example
1740 http://www.astro.uva.nl/~dominik          @r{on the web}
1741 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
1742 file:papers/last.pdf                      @r{file, relative path}
1743 news:comp.emacs                           @r{Usenet link}
1744 mailto:adent@@galaxy.net                   @r{Mail link}
1745 vm:folder                                 @r{VM folder link}
1746 vm:folder#id                              @r{VM message link}
1747 vm://myself@@some.where.org/folder#id      @r{VM on remote machine}
1748 wl:folder                                 @r{WANDERLUST folder link}
1749 wl:folder#id                              @r{WANDERLUST message link}
1750 mhe:folder                                @r{MH-E folder link}
1751 mhe:folder#id                             @r{MH-E message link}
1752 rmail:folder                              @r{RMAIL folder link}
1753 rmail:folder#id                           @r{RMAIL message link}
1754 gnus:group                                @r{GNUS group link}
1755 gnus:group#id                             @r{GNUS article link}
1756 bbdb:Richard Stallman                     @r{BBDB link}
1757 shell:ls *.org                            @r{A shell command}
1758 elisp:(find-file-other-frame "Elisp.org") @r{An elisp form to evaluate}
1759 @end example
1761 A link should be enclosed in double brackets and may contain a
1762 descriptive text to be displayed instead of the url (@pxref{Link
1763 format}), for example:
1765 @example
1766 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
1767 @end example
1769 @cindex angular brackets, around links
1770 @cindex plain text external links
1771 Org-mode also finds external links in the normal text and activates them
1772 as links.  If spaces must be part of the link (for example in
1773 @samp{bbdb:Richard Stallman}), or you need to remove ambiguities about the end of
1774 the link, enclose them in angular brackets.
1776 @node Handling links, Search options, External links, Hyperlinks
1777 @section Handling links
1779 Org-mode provides methods to create a link in the correct syntax, to
1780 insert it into an org-mode file, and to follow the link.
1782 @table @kbd
1783 @kindex C-c l
1784 @cindex storing links
1785 @item C-c l
1786 Store a link to the current location.  This is a @emph{global} command
1787 which can be used in any buffer to create a link.  The link will be
1788 stored for later insertion into an Org-mode buffer (see below).  For
1789 Org-mode files, if there is a @samp{<<target>>} at the cursor, the link
1790 points to the target.  Otherwise it points to the current headline.  For
1791 VM, RMAIL, WANDERLUST, MH-E, GNUS and BBDB buffers, the link will
1792 indicate the current article/entry.  For W3 and W3M buffers, the link
1793 goes to the current URL.  For any other files, the link will point to
1794 the file, with a search string (@pxref{Search options}) pointing to the
1795 contents of the current line.  If there is an active region, the
1796 selected words will form the basis of the search string.  If the
1797 automatically created link is not working correctly or accurately
1798 enough, you can write custom functions to select the search string and
1799 to do the search for particular file types - see @ref{Custom searches}.
1800 The key binding @kbd{C-c l} is only a suggestion - see @ref{Installation}.
1802 @kindex C-c C-l
1803 @cindex link completion
1804 @cindex completion, of links
1805 @cindex inserting links
1806 @item C-c C-l
1807 Insert a link.  This prompts for a link to be inserted into the buffer.
1808 You can just type a link, using text for an internal link, or one of the
1809 link type prefixes mentioned in the examples above.  Through completion,
1810 all links stored during the current session can be
1811 accessed@footnote{After insertion of a stored link, the link will be
1812 removed from the list of stored links.  To keep it in the list later
1813 use, use a triple @kbd{C-u} prefix to @kbd{C-c C-l}, or configure the
1814 option @code{org-keep-stored-link-after-insertion}.}.  The link
1815 will be inserted into the buffer, along with a descriptive text.  Note
1816 that you don't have to use this command to insert a link.  Links in
1817 Org-mode are plain text, and you can type or paste them straight into
1818 the buffer.  By using this command, the links are automatically enclosed
1819 in double brackets, and you will be asked for the optional descriptive
1820 text.  If the link is a @samp{file:} link and the linked file is located
1821 in the same directory as the current file or a subdirectory of it, the
1822 path of the file will be inserted relative to the current directory.
1824 @kindex C-u C-c C-l
1825 @cindex file name completion
1826 @cindex completion, of file names
1827 @item C-u C-c C-l
1828 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
1829 a file will be inserted and you may use file name completion to select
1830 the name of the file.  The path to the file is inserted relative to the
1831 directory of the current org file, if the linked file is in the current
1832 directory or in a subdirectory of it, or if the path is written relative
1833 to the current directory using @samp{../}.  Otherwise an absolute path
1834 is used, if possible with @samp{~/} for your home directory.  You can
1835 force an absolute path with two @kbd{C-u} prefixes.
1837 @item C-c C-l @r{with cursor on existing link}
1838 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
1839 link and description parts of the link.
1841 @cindex following links
1842 @kindex C-c C-o
1843 @item C-c C-o
1844 Open link at point.  This will launch a web browser for URLs (using
1845 @command{browse-url-at-point}), run vm/mh-e/wanderlust/rmail/gnus/bbdb
1846 for the corresponding links, and execute the command in a shell link.
1847 When the cursor is on an internal link, this commands runs the
1848 corresponding search.  When the cursor is on a TAG list in a headline,
1849 it creates the corresponding TAGS view.  If the cursor is on a time
1850 stamp, it compiles the agenda for that date.  Furthermore, it will visit
1851 text and remote files in @samp{file:} links with Emacs and select a
1852 suitable application for local non-text files.  Classification of files
1853 is based on file extension only.  See option @code{org-file-apps}.  If
1854 you want to override the default application and visit the file with
1855 Emacs, use a @kbd{C-u} prefix.
1857 @kindex mouse-2
1858 @kindex mouse-1
1859 @item mouse-2
1860 @itemx mouse-1
1861 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
1862 would.  Under Emacs 22, also @kbd{mouse-1} will follow a link.
1864 @kindex mouse-3
1865 @item mouse-3
1866 Like @kbd{mouse-2}, but force file links to be opened with Emacs.
1868 @cindex mark ring
1869 @kindex C-c %
1870 @item C-c %
1871 Push the current position onto the mark ring, to be able to return
1872 easily. Commands following an internal link do this automatically.
1874 @cindex links, returning to
1875 @kindex C-c &
1876 @item C-c &
1877 Jump back to a recorded position.  A position is recorded by the
1878 commands following internal links, and by @kbd{C-c %}.  Using this
1879 command several times in direct succession moves through a ring of
1880 previously recorded positions.
1881 @end table
1884 @node Search options, Custom searches, Handling links, Hyperlinks
1885 @section Search options in file links
1886 @cindex search option in file links
1887 @cindex file links, searching
1889 File links can contain additional information to make Emacs jump to a
1890 particular location in the file when following a link.  This can be a
1891 line number or a search option after a double@footnote{For backward
1892 compatibility, line numbers can also follow a single colon.} colon. For
1893 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
1894 links}) to a file, it encodes the words in the current line as a search
1895 string that can be used to find this line back later when following the
1896 link with @kbd{C-c C-o}. 
1898 Here is the syntax of the different ways to attach a search to a file
1899 link, together with an explanation:
1901 @example
1902 [[file:~/code/main.c::255]]
1903 [[file:~/xx.org::My Target]]
1904 [[file:~/xx.org::*My Target]]
1905 [[file:~/xx.org::/regexp/]]
1906 @end example
1908 @table @code
1909 @item 255
1910 Jump to line 255.
1911 @item My Target
1912 Search for a link target @samp{<<My Target>>}, or do a text search for
1913 @samp{my target}, similar to the search in internal links, see
1914 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
1915 link will become an HTML reference to the corresponding named anchor in
1916 the linked file.
1917 @item *My Target
1918 In an Org-mode file, restrict search to headlines.
1919 @item /regexp/
1920 Do a regular expression search for @code{regexp}.  This uses the Emacs
1921 command @code{occur} to list all matches in a separate window.  If the
1922 target file is in Org-mode, @code{org-occur} is used to create a
1923 sparse tree with the matches.
1924 @c If the target file is a directory,
1925 @c @code{grep} will be used to search all files in the directory.
1926 @end table
1928 As a degenerate case, a file link with an empty file name can be used
1929 to search the current file.  For example, @code{<file:::find me>} does
1930 a search for @samp{find me} in the current file, just as
1931 @samp{[[find me]]} would.
1933 @node Custom searches, Remember, Search options, Hyperlinks
1934 @section Custom Searches
1935 @cindex custom search strings
1937 The default mechanism for creating search strings and for doing the
1938 actual search related to a file link may not work correctly in all
1939 cases.  For example, BibTeX database files have many entries like
1940 @samp{year="1993"} which would not result in good search strings,
1941 because the only unique identification for a BibTeX entry is the
1942 citation key.
1944 If you come across such a problem, you can write custom functions to set
1945 the right search string for a particular file type, and to do the search
1946 for the string in the file.  Using @code{add-hook}, these functions need
1947 to be added to the hook variables
1948 @code{org-create-file-search-functions} and
1949 @code{org-execute-file-search-functions}.  See the docstring for these
1950 variables for more information.  Org-mode actually uses this mechanism
1951 for Bib@TeX{} database files, and you can use the corresponding code as
1952 an implementation example.  Search for @samp{BibTeX links} in the source
1953 file.
1956 @node Remember,  , Custom searches, Hyperlinks
1957 @section Remember
1958 @cindex @file{remember.el}
1960 Another way to create org entries with links to other files is through
1961 the @emph{Remember} package by John Wiegley.  @emph{Remember} lets you
1962 store quick notes with little interruption of your work flow.  See
1963 @uref{http://www.emacswiki.org/cgi-bin/wiki/RememberMode} for more
1964 information.  The notes produced by @emph{Remember} can be stored in
1965 different ways, and Org-mode files are a good target.  Org-mode allows
1966 you to file away notes either to a default file, or directly to the correct
1967 location in your Org-mode outline tree.  The following customization
1968 will tell @emph{Remember} to use org files as target, and to create
1969 annotations compatible with Org-mode links.
1971 @example
1972 (setq org-directory "~/path/to/my/orgfiles/")
1973 (setq org-default-notes-file "~/.notes")
1974 (setq remember-annotation-functions '(org-remember-annotation))
1975 (setq remember-handler-functions '(org-remember-handler))
1976 (add-hook 'remember-mode-hook 'org-remember-apply-template)
1977 @end example
1979 @cindex templates, for remember
1980 In combination with Org-mode, you can use templates to generate
1981 different types of remember notes.  For example, if you would like to
1982 use one template to create general TODO entries, and another one for
1983 journal entries, you could use:
1985 @example
1986 (setq org-remember-templates
1987       '((?t "* TODO %?\n  %i\n  %a" "~/org/TODO.org")
1988         (?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org")))
1989 @end example
1991 @noindent In these entries, the character specifies how to select the
1992 template, the first string specifies the template, and the (optional)
1993 second string specifies a default file (overruling
1994 @code{org-default-notes-file}) as a target for this note.
1996 When you call @kbd{M-x remember} to remember something, org will prompt
1997 for a key to select the template and then prepare the buffer like
1998 @example
1999 * TODO
2000   <file:link to where you called remember>
2001 @end example
2003 @noindent or
2005 @example
2006 * [2006-03-21 Tue 15:37]
2008   <file:link to where you called remember>
2009 @end example
2011 @noindent See the variable @code{org-remember-templates} for more details.
2013 When you are finished composing a note with remember, you have to press
2014 @kbd{C-c C-c} to file the note away.  The handler first prompts for a
2015 target file - if you press @key{RET}, the value of
2016 @code{org-default-notes-file} is used.  Then the command offers the
2017 headings tree of the selected file.  You can either immediately press
2018 @key{RET} to get the note appended to the file.  Or you can use vertical
2019 cursor motion (@key{up} and @key{down}) and visibility cycling
2020 (@key{TAB}) to find a better place.  Pressing @key{RET} or @key{left} or
2021 @key{right} leads to the following result.
2023 @multitable @columnfractions 0.2 0.1 0.7
2024 @item @b{Cursor position} @tab @b{Key} @tab @b{Note gets inserted}
2025 @item buffer-start @tab @key{RET} @tab as level 2 heading at end of file
2026 @item on headline @tab @key{RET} @tab as sublevel of the heading at cursor
2027 @item             @tab @key{left}  @tab as same level, before current heading
2028 @item             @tab @key{right} @tab as same level, after current heading
2029 @item not on headline @tab @key{RET}
2030       @tab at cursor position, level taken from context.
2031            Or use prefix arg to specify level manually.
2032 @end multitable
2034 So a fast way to store the note is to press @kbd{C-c C-c @key{RET}
2035 @key{RET}} to append it to the default file.  Even shorter would be
2036 @kbd{C-u C-c C-c}, which does the same without even showing the tree.
2037 But with little extra effort, you can push it directly to the correct
2038 location.
2040 Before inserting the text into a tree, the function ensures that the
2041 text has a headline, i.e. a first line that starts with a @samp{*}.
2042 If not, a headline is constructed from the current date and some
2043 additional data.  If the variable @code{org-adapt-indentation} is
2044 non-nil, the entire text is also indented so that it starts in the
2045 same column as the headline (after the asterisks).
2048 @node TODO items, Timestamps, Hyperlinks, Top
2049 @chapter TODO items
2050 @cindex TODO items
2052 Org-mode does not maintain TODO lists as a separate document.  TODO
2053 items are an integral part of the notes file, because TODO items
2054 usually come up while taking notes!  With Org-mode, you simply mark
2055 any entry in a tree as being a TODO item.  In this way, the
2056 information is not duplicated, and the entire context from which the
2057 item emerged is always present when you check.
2059 Of course, this technique causes TODO items to be scattered throughout
2060 your file.  Org-mode provides methods to give you an overview over all
2061 things you have to do.
2063 @menu
2064 * TODO basics::                 Marking and displaying TODO entries
2065 * TODO extensions::             Workflow and assignments
2066 * Priorities::                  Some things are more important than others
2067 * Breaking down tasks::         Splitting a task into managable pieces
2068 * Checkboxes::                  Tick-off lists
2069 @end menu
2071 @node TODO basics, TODO extensions, TODO items, TODO items
2072 @section Basic TODO functionality
2074 Any headline can become a TODO item by starting it with the word TODO,
2075 for example:
2077 @example
2078 *** TODO Write letter to Sam Fortune
2079 @end example
2081 @noindent
2082 The most important commands to work with TODO entries are:
2084 @table @kbd
2085 @kindex C-c C-t
2086 @cindex cycling, of TODO states
2087 @item C-c C-t
2088 Rotate the TODO state of the current item between
2090 @example
2091 ,-> (unmarked) -> TODO -> DONE --.
2092 '--------------------------------'
2093 @end example
2095 The same rotation can also be done ``remotely'' from the timeline and
2096 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
2097 @kindex S-@key{right}
2098 @kindex S-@key{left}
2099 @item S-@key{right}
2100 @itemx S-@key{left}
2101 Select the following/preceding TODO state, similar to cycling.  Mostly
2102 useful if more than two TODO states are possible (@pxref{TODO extensions}).
2103 @kindex C-c C-v
2104 @cindex sparse tree, for TODO
2105 @item C-c C-v
2106 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds
2107 the entire buffer, but shows all TODO items and the headings hierarchy
2108 above them.  With prefix arg, show also the DONE entries.  With
2109 numerical prefix N, show the tree for the Nth keyword in the variable
2110 @code{org-todo-keywords}.
2111 @kindex C-c a t
2112 @item C-c a t
2113 Show the global TODO list.  This collects the TODO items from all
2114 agenda files (@pxref{Agenda views}) into a single buffer.  The buffer is in
2115 @code{agenda-mode}, so there are commands to examine and manipulate
2116 the TODO entries directly from that buffer (@pxref{Agenda commands}).
2117 @xref{Global TODO list}, for more information.
2118 @c @item @code{org-agenda-include-all-todo}
2119 @c If you would like to have all your TODO items listed as part of your
2120 @c agenda, customize the variable @code{org-agenda-include-all-todo}.
2121 @end table
2124 @node TODO extensions, Priorities, TODO basics, TODO items
2125 @section Extended use of TODO keywords
2126 @cindex extended TODO keywords
2128 The default implementation of TODO entries is just two states: TODO and
2129 DONE.  You can, however, use the TODO feature for more complicated
2130 things by configuring the variables @code{org-todo-keywords} and
2131 @code{org-todo-interpretation}.  Using special setup, you can even use
2132 TODO keywords in different ways in different org files.
2134 Note that @i{tags} are another way to classify headlines in general and
2135 TODO items in particular (@pxref{Tags}).
2137 @menu
2138 * Workflow states::             From TODO to DONE in steps
2139 * TODO types::                  I do this, Fred the rest
2140 * Per file keywords::           Different files, different requirements
2141 @end menu
2143 @node Workflow states, TODO types, TODO extensions, TODO extensions
2144 @subsection TODO keywords as workflow states
2145 @cindex TODO workflow
2146 @cindex workflow states as TODO keywords
2148 You can use TODO keywords to indicate different states in the process
2149 of working on an item, for example:
2151 @lisp
2152 (setq org-todo-keywords '("TODO" "FEEDBACK" "VERIFY" "DONE")
2153       org-todo-interpretation 'sequence)
2154 @end lisp
2156 @cindex completion, of TODO keywords
2157 Changing these variables only becomes effective in a new Emacs session.
2158 With this setup, the command @kbd{C-c C-t} will cycle an entry from
2159 TODO to FEEDBACK, then to VERIFY, and finally to DONE.  You may also
2160 use a prefix argument to quickly select a specific state.  For example
2161 @kbd{C-3 C-c C-t} will change the state immediately to VERIFY.
2162 If you define many keywords, you can use in-buffer completion (see
2163 @ref{Completion}) to insert these words into the buffer.
2165 @node TODO types, Per file keywords, Workflow states, TODO extensions
2166 @subsection TODO keywords as types
2167 @cindex TODO types
2168 @cindex names as TODO keywords
2169 @cindex types as TODO keywords
2171 The second possibility is to use TODO keywords to indicate different
2172 types of action items.  For example, you might want to indicate that
2173 items are for ``work'' or ``home''.  If you are into David Allen's
2174 @emph{Getting Things DONE}, you might want to use todo types
2175 @samp{NEXTACTION}, @samp{WAITING}, @samp{MAYBE}.  Or, when you work
2176 with several people on a single project, you might want to assign
2177 action items directly to persons, by using their names as TODO
2178 keywords.  This would be set up like this:
2180 @lisp
2181 (setq org-todo-keywords '("Fred" "Sara" "Lucy" "Mike" "DONE")
2182       org-todo-interpretation 'type)
2183 @end lisp
2185 In this case, different keywords do not indicate a sequence, but
2186 rather different types.  So it is normally not useful to change from
2187 one type to another.  Therefore, in this case the behavior of the
2188 command @kbd{C-c C-t} is changed slightly@footnote{This is also true
2189 for the @kbd{t} command in the timeline and agenda buffers.}.  When
2190 used several times in succession, it will still cycle through all
2191 names.  But when you return to the item after some time and execute
2192 @kbd{C-c C-t} again, it will switch from each name directly to DONE.
2193 Use prefix arguments or completion to quickly select a specific name.
2194 You can also review the items of a specific TODO type in a sparse tree
2195 by using a numeric prefix to @kbd{C-c C-v}.  For example, to see all
2196 things Lucy has to do, you would use @kbd{C-3 C-c C-v}.  To collect
2197 Lucy's items from all agenda files into a single buffer, you
2198 would use the prefix arg as well when creating the global todo list:
2199 @kbd{C-3 C-c t}.
2201 @node Per file keywords,  , TODO types, TODO extensions
2202 @subsection Setting up TODO keywords for individual files
2203 @cindex keyword options
2204 @cindex per file keywords
2206 It can be very useful to use different aspects of the TODO mechanism
2207 in different files, which is not possible with the global settings
2208 described above.  For file-local settings, you need to add special
2209 lines to the file which set the keywords and interpretation for that
2210 file only.  For example, to set one of the two examples discussed
2211 above, you need one of the following lines, starting in column zero
2212 anywhere in the file:
2214 @example
2215 #+SEQ_TODO: TODO FEEDBACK VERIFY DONE
2216 #+TYP_TODO: Fred Sara Lucy Mike DONE
2217 @end example
2219 @cindex Completion, of option keywords
2220 @kindex M-@key{TAB}
2221 @noindent To make sure you are using the correct keyword, type
2222 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
2224 @cindex DONE, final TODO keyword
2225 Remember that the last keyword must always mean that the item is DONE
2226 (although you may use a different word).  Also note that in each file,
2227 only one of the two aspects of TODO keywords can be used.  After
2228 changing one of these lines, use @kbd{C-c C-c} with the cursor still
2229 in the line to make the changes known to Org-mode@footnote{Org-mode
2230 parses these lines only when Org-mode is activated after visiting a
2231 file.  @kbd{C-c C-c} with the cursor in a line starting with @samp{#+}
2232 is simply restarting Org-mode for the current buffer.}.
2234 If you want to use very many keywords, for example when working with a
2235 large group of people, you may split the names over several lines:
2237 @example
2238 #+TYP_TODO: Fred Sara Lucy Mike
2239 #+TYP_TODO: Luis George Jules Jessica
2240 #+TYP_TODO: Kim Arnold Peter
2241 #+TYP_TODO: DONE
2242 @end example
2244 @node Priorities, Breaking down tasks, TODO extensions, TODO items
2245 @section Priorities
2246 @cindex priorities
2248 If you use Org-mode extensively to organize your work, you may end up
2249 with a number of TODO entries so large that you'd like to prioritize
2250 them.  This can be done by placing a @emph{priority cookie} into the
2251 headline, like this
2253 @example
2254 *** TODO [#A] Write letter to Sam Fortune
2255 @end example
2257 @noindent
2258 With its standard setup, Org-mode supports priorities @samp{A},
2259 @samp{B}, and @samp{C}.  @samp{A} is the highest priority.  An entry
2260 without a cookie is treated as priority @samp{B}.  Priorities make a
2261 difference only in the agenda (@pxref{Weekly/Daily agenda}).
2263 @table @kbd
2264 @kindex @kbd{C-c ,}
2265 @item @kbd{C-c ,}
2266 Set the priority of the current headline.  The command prompts for a
2267 priority character @samp{A}, @samp{B} or @samp{C}.  When you press
2268 @key{SPC} instead, the priority cookie is removed from the headline.
2269 The priorities can also be changed ``remotely'' from the timeline and
2270 agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
2272 @kindex S-@key{up}
2273 @kindex S-@key{down}
2274 @item S-@key{up}
2275 @itemx S-@key{down}
2276 Increase/decrease priority of current headline.  Note that these keys
2277 are also used to modify time stamps (@pxref{Creating timestamps}).
2278 Furthermore, these keys are also used by CUA-mode (@pxref{Conflicts}).
2279 @end table
2281 @node Breaking down tasks, Checkboxes, Priorities, TODO items
2282 @section Breaking tasks down into subtasks
2283 @cindex tasks, breaking down
2285 It is often advisable to break down large tasks into smaller, managable
2286 subtasks.  You can do this by creating an outline tree below a TODO
2287 item, with detailed subtasks on the tree@footnote{To keep subtasks out
2288 of the global TODO list, see the
2289 @code{org-agenda-todo-list-sublevels}.}.  Another possibility is the use
2290 of checkboxes to ideantify (a hierarchy of) a large number of subtasks
2291 (@pxref{Checkboxes}).
2294 @node Checkboxes,  , Breaking down tasks, TODO items
2295 @section Checkboxes
2296 @cindex checkboxes
2298 Every item in a plain list (@pxref{Plain lists}) can be made a checkbox
2299 by starting it with the string @samp{[ ]}.  This feature is similar to
2300 TODO items (@pxref{TODO items}), but more lightweight.  Checkboxes are
2301 not included into the global TODO list, so they are often great to split
2302 a task into a number of simple steps.  Or you can use them in a shopping
2303 list.  To toggle a checkbox, use @kbd{C-c C-c}, or try Piotr Zielinski's
2304 @file{org-mouse.el}.  Here is an example of a checkbox list.
2306 @example
2307 * TODO Organize party [3/6]
2308   - call people [1/3]
2309     - [ ] Peter
2310     - [X] Sarah
2311     - [ ] Sam
2312   - [X] order food
2313   - [ ] think about what music to play
2314   - [X] talk to the neighbors
2315 @end example
2317 @cindex statistics, for checkboxes
2318 @cindex checkbox statistics
2319 The @samp{[3/6]} and @samp{[1/3]} in the first and second line are
2320 cookies indicating how many checkboxes are present in this entry, and
2321 how many of them have been checked off.  This can give you an idea on
2322 how many checkboxes remain, even without opening a folded entry.  The
2323 cookies can be placed into a headline or into (the first line of) a
2324 plain list item. Each cookie covers all checkboxes structurally below
2325 that headline/item.  You have to insert the cookie yourself by typing
2326 either @samp{[/]} or @samp{[%]}.  In the first case you get an @samp{n
2327 out of m} result, in the second case you get information about the
2328 percentage of checkboxes checked (in the above example, this would be
2329 @samp{[50%]} and @samp{[33%], respectively}).
2331 @noindent The following commands work with checkboxes:
2333 @table @kbd
2334 @kindex C-c C-c
2335 @item C-c C-c
2336 Toggle checkbox at point.
2337 @kindex C-c C-x C-b
2338 @item C-c C-x C-b
2339 Toggle checkbox at point.
2340 @itemize @minus
2341 @item
2342 If there is an active region, toggle the first checkbox in the region
2343 and set all remaining boxes to the same status as the first.  If you
2344 want to toggle all boxes in the region independently, use a prefix
2345 argument.
2346 @item
2347 If the cursor is in a headline, toggle checkboxes in the region between
2348 this headline and the next (so @emph{not} the entire subtree).
2349 @item
2350 If no active region, just toggle the checkbox at point.
2351 @end itemize
2352 @kindex M-S-@key{RET}
2353 @item M-S-@key{RET}
2354 Insert a new item with a checkbox.
2355 This works only if the cursor is already in a plain list item
2356 (@pxref{Plain lists}).
2357 @kindex C-c #
2358 @item C-c #
2359 Update the checkbox statistics in the current outline entry.  When
2360 called with a @kbd{C-u} prefix, update the entire file.  Checkbox
2361 statistic cookies are updated automatically if you toggle checkboxes
2362 with @kbd{C-c C-c} and make new ones with @kbd{M-S-@key{RET}}.  If you
2363 delete boxes or add/change them by hand, use this command to get things
2364 back into synch.  Or simply toggle any checkbox twice with @kbd{C-c C-c}.
2365 @end table
2367 @node Timestamps, Tags, TODO items, Top
2368 @chapter Timestamps
2370 Items can be labeled with timestamps to make them useful for project
2371 planning.
2373 @menu
2374 * Time stamps::                 Assigning a time to a tree entry
2375 * Creating timestamps::         Commands which insert timestamps
2376 * Progress logging::            Documenting when what work was done.
2377 @end menu
2380 @node Time stamps, Creating timestamps, Timestamps, Timestamps
2381 @section Time stamps, deadlines and scheduling
2382 @cindex time stamps
2383 @cindex ranges, time
2384 @cindex date stamps
2385 @cindex deadlines
2386 @cindex scheduling
2388 A time stamp is a specification of a date (possibly with time) in a
2389 special format, either @samp{<2003-09-16 Tue>} or @samp{<2003-09-16
2390 Tue 09:39>}.  A time stamp can appear anywhere in the headline or body
2391 of an org-tree entry.  Its presence allows entries to be shown on specific
2392 dates in the agenda (@pxref{Weekly/Daily agenda}).  We distinguish:
2394 @table @var
2395 @item Plain time stamp
2396 @cindex timestamp
2397 A simple time stamp just assigns a date/time to an item.  This is just
2398 like writing down an appointment in a paper agenda, or like writing down
2399 an event in a diary, when you want to take note of when something
2400 happened.  In the timeline and agenda displays, the headline of an entry
2401 associated with a plain time stamp will be shown exactly on that date.
2403 @item Time stamp range
2404 @cindex timerange
2405 Two time stamps connected by @samp{--} denote a time range.  The
2406 headline will be shown on the first and last day of the range, and on
2407 any dates that are displayed and fall in the range.  Here is an
2408 example:
2410 @example
2411 ** Meeting in Amsterdam
2412    <2004-08-23 Mon>--<2004-08-26 Thu>
2413 @end example
2415 @item Time stamp with SCHEDULED keyword
2416 @cindex SCHEDULED keyword
2417 If a time stamp is preceded by the word @samp{SCHEDULED:}, it means you
2418 are planning to start working on that task on the given date. So this is
2419 not about recording an event, but about planning your work.  The
2420 headline will be listed under the given date.  In addition, a reminder
2421 that the scheduled date has passed will be present in the compilation
2422 for @emph{today}, until the entry is marked DONE.  I.e., the task will
2423 automatically be forwarded until completed.
2425 @example
2426 *** TODO Call Trillian for a date on New Years Eve.
2427     SCHEDULED: <2004-12-25 Sat>
2428 @end example
2430 @item Time stamp with DEADLINE keyword
2431 @cindex DEADLINE keyword
2432 If a time stamp is preceded by the word @samp{DEADLINE:}, the task
2433 (most likely a TODO item) is supposed to be finished on that date, and
2434 it will be listed then.  In addition, the compilation for @emph{today}
2435 will carry a warning about the approaching or missed deadline,
2436 starting @code{org-deadline-warning-days} before the due date, and
2437 continuing until the entry is marked DONE.  An example:
2439 @example
2440 *** TODO write article about the Earth for the Guide
2441     The editor in charge is <bbdb:Ford Prefect>
2442     DEADLINE: <2004-02-29 Sun>
2443 @end example
2444 @item Time stamp with CLOSED keyword
2445 @cindex CLOSED keyword
2446 When @code{org-log-done} is non-nil, Org-mode will automatically insert
2447 a special time stamp each time a TODO entry is marked done
2448 (@pxref{Progress logging}).  This time stamp is enclosed in square
2449 brackets instead of angular brackets.
2451 @item Time range with CLOCK keyword
2452 @cindex CLOCK keyword
2453 When using the clock to time the work that is being done on specific
2454 items, time ranges preceded by the CLOCK keyword are inserted
2455 automatically into the file.  The time stamps are enclosed in square
2456 brackets instead of angular brackets.  @xref{Clocking work time}.
2457 @end table
2459 @node Creating timestamps, Progress logging, Time stamps, Timestamps
2460 @section Creating timestamps
2461 @cindex creating timestamps
2462 @cindex timestamps, creating
2464 For Org-mode to recognize time stamps, they need to be in the specific
2465 format.  All commands listed below produce time stamps in the correct
2466 format.
2468 @table @kbd
2469 @kindex C-c .
2470 @item C-c .
2471 Prompt for a date and insert a corresponding time stamp.  When the
2472 cursor is at a previously used time stamp, it is updated to NOW.  When
2473 this command is used twice in succession, a time range is inserted.
2475 @kindex C-u C-c .
2476 @item C-u C-c .
2477 Like @kbd{C-c .}, but use the alternative format which contains date
2478 and time.  The default time can be rounded to multiples of 5 minutes,
2479 see the option @code{org-time-stamp-rounding-minutes}.
2481 @kindex C-c !
2482 @item C-c !
2483 Like @kbd{C-c .}, but insert an inactive time stamp not triggering the
2484 agenda.
2486 @kindex C-c <
2487 @item C-c <
2488 Insert a time stamp corresponding to the cursor date in the Calendar.
2490 @kindex C-c >
2491 @item C-c >
2492 Access the Emacs calendar for the current date.  If there is a
2493 timestamp in the current line, goto the corresponding date
2494 instead.
2496 @kindex C-c C-o
2497 @item C-c C-o
2498 Access the agenda for the date given by the time stamp at point
2499 (@pxref{Weekly/Daily agenda}).
2501 @kindex C-c C-d
2502 @item C-c C-d
2503 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will
2504 happen in the line directly following the headline.  
2505 @c FIXME Any CLOSED timestamp will be removed.????????
2507 @kindex C-c C-w
2508 @cindex sparse tree, for deadlines
2509 @item C-c C-w
2510 Create a sparse tree with all deadlines that are either past-due, or
2511 which will become due within @code{org-deadline-warning-days}.
2512 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
2513 prefix, check that many days.  For example, @kbd{C-1 C-c C-w} shows
2514 all deadlines due tomorrow.
2516 @kindex C-c C-s
2517 @item C-c C-s
2518 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
2519 happen in the line directly following the headline.  Any CLOSED
2520 timestamp will be removed.
2522 @kindex S-@key{left}
2523 @kindex S-@key{right}
2524 @item S-@key{left}
2525 @itemx S-@key{right}
2526 Change date at cursor by one day.  These key bindings conflict with
2527 CUA-mode (@pxref{Conflicts}).
2529 @kindex S-@key{up}
2530 @kindex S-@key{down}
2531 @item S-@key{up}
2532 @itemx S-@key{down}
2533 Change the item under the cursor in a timestamp.  The cursor can be on
2534 a year, month, day, hour or minute.  Note that if the cursor is not at
2535 a time stamp, these same keys modify the priority of an item.
2536 (@pxref{Priorities}). The key bindings also conflict with CUA-mode
2537 (@pxref{Conflicts}).
2540 @kindex C-c C-y
2541 @cindex evaluate time range
2542 @item C-c C-y
2543 Evaluate a time range by computing the difference between start and
2544 end.  With prefix arg, insert result after the time range (in a table:
2545 into the following column).
2546 @end table
2548 @cindex date, reading in minibuffer
2549 @cindex time, reading in minibuffer
2550 @cindex calendar, for selecting date
2551 When Org-mode prompts for a date/time, the function reading your input
2552 will replace anything you choose not to specify with the current date
2553 and time.  For details, see the documentation string of
2554 @command{org-read-date}.  Also, a calender will pop up to allow
2555 selecting a date.  The calendar can be fully controlled from the
2556 minibuffer, and a date can be selected with the following commands:
2558 @table @kbd
2559 @kindex <
2560 @item <
2561 Scroll calendar backwards by one month.
2562 @kindex >
2563 @item >
2564 Scroll calendar forwards by one month.
2565 @kindex mouse-1
2566 @item mouse-1
2567 Select date by clicking on it.
2568 @kindex S-@key{right}
2569 @item S-@key{right}
2570 One day forward.
2571 @kindex S-@key{left}
2572 @item S-@key{left}
2573 One day back.
2574 @kindex S-@key{down}
2575 @item S-@key{down}
2576 One week forward.
2577 @kindex S-@key{up}
2578 @item S-@key{up}
2579 One week back.
2580 @kindex M-S-@key{right}
2581 @item M-S-@key{right}
2582 One month forward.
2583 @kindex M-S-@key{left}
2584 @item M-S-@key{left}
2585 One month back.
2586 @kindex @key{RET}
2587 @item @key{RET}
2588 Choose date in calendar (only if nothing typed into minibuffer).
2589 @end table
2591 @node Progress logging,  , Creating timestamps, Timestamps
2592 @section Progress Logging
2593 @cindex progress logging
2594 @cindex logging, of progress
2596 Org-mode can automatically record a time stamp when you mark a TODO item
2597 as DONE.  You can also measure precisely the time you spent on specific
2598 items in a project by starting and stopping a clock when you start and
2599 stop working on an aspect of a project.
2601 @menu
2602 * Closing items::               When was this entry marked DONE?
2603 * Clocking work time::          When exactly did you work on this item?
2604 @end menu
2606 @node Closing items, Clocking work time, Progress logging, Progress logging
2607 @subsection Closing items
2609 If you want to keep track of @emph{when} a certain TODO item was
2610 finished, turn on logging with
2612 @lisp
2613 (setq org-log-done t)
2614 @end lisp
2616 @noindent
2617 Then each time you turn a TODO entry into DONE using either @kbd{C-c
2618 C-t} in the Org-mode buffer or @kbd{t} in the agenda buffer, a line
2619 @samp{CLOSED: [timestamp]} will be inserted just after the headline.
2620 If you turn the entry back into a TODO item again through further
2621 state cycling, that line will be removed again.  In the timeline
2622 (@pxref{Timeline}) and in the agenda (@pxref{Weekly/Daily agenda}),
2623 you can then use the @kbd{l} key to display the TODO items closed on
2624 each day, giving you an overview of what has been done on a day.
2626 @node Clocking work time,  , Closing items, Progress logging
2627 @subsection Clocking work time
2629 Org-mode allows you to clock the time you spent on specific tasks in a
2630 project.  When you start working on an item, you can start the clock.
2631 When you stop working on that task, or when you mark the task done, the
2632 clock is stopped and the corresponding time interval is recorded.  It
2633 also computes the total time spent on each subtree of a project.
2635 @table @kbd
2636 @kindex C-c C-x C-i
2637 @item C-c C-x C-i
2638 Start the clock on the current item (clock-in).  This inserts the CLOCK
2639 keyword together with a timestamp.
2640 @kindex C-c C-x C-o
2641 @item C-c C-x C-o
2642 Stop the clock (clock-out).  The inserts another timestamp at the same
2643 location where the clock was last started.  It also directly computes
2644 the resulting time in inserts it after the time range as @samp{=>
2645 HH:MM}.  
2646 @kindex C-c C-y
2647 @item C-c C-y
2648 Recompute the time interval after changing one of the time stamps.  This
2649 is only necessary if you edit the time stamps directly.  If you change
2650 them with @kbd{S-@key{cursor}} keys, the update is automatic.
2651 @kindex C-c C-t
2652 @item C-c C-t
2653 Changing the TODO state of an item to DONE automatically stops the clock
2654 if it is running in this same item.
2655 @kindex C-c C-x C-x
2656 @item C-c C-x C-x
2657 Cancel the current clock.  This is useful if a clock was started by
2658 mistake, or if you ended up working on something else.
2659 @kindex C-c C-x C-d
2660 @item C-c C-x C-d
2661 Display time summaries for each subtree in the current buffer.  This
2662 puts overlays at the end of each headline, showing the total time
2663 recorded under that heading, including the time of any subheadings. You
2664 can use visibility cycling to study the tree, but the overlays disappear
2665 automatically when the buffer is changed.
2666 @kindex C-c C-x C-r
2667 @item C-c C-x C-r
2668 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
2669 report as an org-mode table into the current file.
2670 @example
2671 #+BEGIN: clocktable :maxlevel 2 :emphasize nil
2673 #+END: clocktable
2674 @end example
2675 @noindent
2676 If such a block already exists, its content is replaced by the new
2677 table.  The @samp{BEGIN} line can specify options:
2678 @example
2679 :maxlevels   @r{Maximum level depth to which times are listed in the table.}
2680 :emphasize   @r{When @code{t}, emphasize level one and level two items}
2681 :block       @r{The time block to consider.  This block is specified relative}
2682              @r{to the current time and may be any of these keywords:}
2683              @r{@code{today}, @code{yesterday}, @code{thisweek}, @code{lastweek},}
2684              @r{@code{thismonth}, @code{lastmonth}, @code{thisyear}, or @code{lastyear}}.
2685 :tstart      @r{A time string specifying when to start considering times}
2686 :tend        @r{A time string specifying when to stop considering times}
2687 @end example
2688 So to get a clock summary for the current day, you could write
2689 @example
2690 #+BEGIN: clocktable :maxlevel 2 :block today
2692 #+END: clocktable
2693 @end example
2694 and to use a specific time range you could write@footnote{Note that all
2695 parameters must be specified in a single line - the line is broken here
2696 only to fit it onto the manual.}
2697 @example
2698 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>" 
2699                     :tend "<2006-08-10 Thu 12:00>"
2701 #+END: clocktable
2702 @end example
2703 @kindex C-u C-c C-x C-u
2704 @item C-u C-c C-x C-u
2705 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
2706 you have several clocktable blocks in a buffer.
2707 @end table
2709 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
2710 the agenda (@pxref{Weekly/Daily agenda}) to show which tasks have been
2711 worked on or closed during a day.
2713 @node Tags, Agenda views, Timestamps, Top
2714 @chapter Tags
2715 @cindex tags
2716 @cindex headline tagging
2717 @cindex matching, tags
2718 @cindex sparse tree, tag based
2720 If you wish to implement a system of labels and contexts for
2721 cross-correlating information, an excellent way is to assign @i{tags} to
2722 headlines.  Org-mode has extensive support for using tags.
2724 Every headline can contain a list of tags, at the end of the headline.
2725 Tags are normal words containing letters, numbers, @samp{_}, and
2726 @samp{@@}.  Tags must be preceded and followed by a single colon; like
2727 @samp{:WORK:}.  Several tags can be specified like @samp{:WORK:URGENT:}.
2729 @menu
2730 * Tag inheritance::             Tags use the tree structure of the outline
2731 * Setting tags::                How to assign tags to a headline
2732 * Tag searches::                Searching for combinations of tags
2733 @end menu
2735 @node Tag inheritance, Setting tags, Tags, Tags
2736 @section Tag inheritance
2737 @cindex inheritance, of tags
2738 @cindex sublevels, inclusion into tags match
2740 @i{Tags} make use of the hierarchical structure of outline trees.  If a
2741 heading has a certain tag, all subheadings will inherit the tag as
2742 well.  For example, in the list
2744 @example
2745 * Meeting with the French group      :WORK:
2746 ** Summary by Frank                  :BOSS:NOTES:
2747 *** TODO Prepare slides for him      :ACTION:
2748 @end example
2750 @noindent
2751 the final heading will have the tags @samp{:WORK:}, @samp{:BOSS:},
2752 @samp{:NOTES:}, and @samp{:ACTION:}.  When executing tag searches and
2753 Org-mode finds that a certain headline matches the search criterion, it
2754 will not check any sublevel headline, assuming that these likely also
2755 match, and that the list of matches can become very long.  This may
2756 not be what you want, however, and you can influence inheritance and
2757 searching using the variables @code{org-use-tag-inheritance} and
2758 @code{org-tags-match-list-sublevels}.
2760 @node Setting tags, Tag searches, Tag inheritance, Tags
2761 @section Setting tags
2762 @cindex setting tags
2764 @kindex M-@key{TAB}
2765 Tags can simply be typed into the buffer at the end of a headline.
2766 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
2767 also a special command for inserting tags:
2769 @table @kbd
2770 @kindex C-c C-c
2771 @item C-c C-c
2772 @cindex completion, of tags
2773 Enter new tags for the current headline.  Org-mode will either offer
2774 completion or a special single-key interface for setting tags, see
2775 below.  After pressing @key{RET}, the tags will be inserted and aligned
2776 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
2777 tags in the current buffer will be aligned to that column, just to make
2778 things look nice.  TAGS are automatically realigned after promotion,
2779 demotion, and TODO state changes (@pxref{TODO basics}).
2780 @end table
2782 Org will support tag insertion based on a @emph{list of tags}.  By
2783 default this list is constructed dynamically, containing all tags
2784 currently used in the buffer.  You may also globally specify a hard list
2785 of tags with the variable @code{org-tag-alist}.  Finally you can set
2786 the allowed tags for a given file with lines like
2788 @example
2789 #+TAGS: @@WORK @@HOME @@TENNISCLUB
2790 #+TAGS: Laptop Car PC Sailboat
2791 @end example
2793 The default support method is minibuffer completion.  However, Org-mode
2794 also implements a much better method: @emph{fast tag selection}.  This
2795 method allows to select and deselect tags with a single key per tag.  To
2796 function efficiently, you should assign unique keys to all tags.  This
2797 can be done globally with
2799 @lisp
2800 (setq org-tag-alist '(("@@WORK" . ?w) ("@@HOME" . ?h) ("Laptop" . ?l)))
2801 @end lisp
2803 @noindent or on a per-file basis with
2805 @example
2806 #+TAGS: @@WORK(w)  @@HOME(h)  @@TENNISCLUB(t)  Laptop(l)  PC(p)
2807 @end example
2809 @noindent
2810 You can also group together tags that are mutually exclusive.  With
2811 curly braces@footnote{In @code{org-mode-alist} use
2812 @code{'(:startgroup)} and @code{'(:endgroup)}, respectively.  Several
2813 groups are allowed.}
2815 @example
2816 #+TAGS: @{ @@WORK(w)  @@HOME(h)  @@TENNISCLUB(t) @}  Laptop(l)  PC(p)
2817 @end example
2819 @noindent you indicate that at most one of @samp{@@WORK}, @samp{@@HOME},
2820 and @samp{@@SAILBOAT} should be selected.
2822 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
2823 these lines to activate any changes.
2825 If at least one tag has a selection key, pressing @kbd{C-c C-c} will
2826 automatically present you with a special interface, listing inherited
2827 tags, the tags of the current headline, and a list of all legal tags
2828 with corresponding keys@footnote{Keys will automatically assigned to
2829 tags which have no configured keys.}.  Pressing keys for the tags will
2830 add or remove them from the list of tags in the current line.  Selecting
2831 a tag in a group of mutually exclusive tags will turn off any other tags
2832 from that group.  @key{SPC} clears all tags for this line, @kbd{RET}
2833 accepts the modified set, and @kbd{C-g} aborts without installing
2834 changes.  This method lets you assign tags to a headline with very few
2835 keys.  With the above setup, you could clear the current tags and set
2836 @samp{@@HOME}, @samp{Laptop} and @samp{PC} tags with just the following
2837 keys: @kbd{C-c C-c @key{SPC} h l p @key{RET}}.  Switching from
2838 @samp{@@HOME} to @samp{@@WORK} would be done with @kbd{C-c C-c w
2839 @key{RET}}.
2841 What if you have globally defined your preferred set of tags using the
2842 variable @code{org-tag-alist}, but would like to use a dynamic tag list
2843 in a specific file?  Just add an empty TAGS option line to that file:
2845 @example
2846 #+TAGS:
2847 @end example
2851 @node Tag searches,  , Setting tags, Tags
2852 @section Tag searches
2853 @cindex tag searches
2855 Once a tags system has been set up, it can be used to collect related
2856 information into special lists.
2858 @table @kbd
2859 @kindex C-c \
2860 @item C-c \
2861 Create a sparse tree with all headlines matching a tags search.
2862 @kindex C-c a m
2863 @item C-c a m
2864 Create a global list of tag matches from all agenda files.
2865 @xref{Matching headline tags}.
2866 @kindex C-c a M
2867 @item C-c a M
2868 Create a global list of tag matches from all agenda files, but check
2869 only TODO items and force checking subitems (see variable
2870 @code{org-tags-match-list-sublevels}).
2871 @end table
2873 A @i{tags} search string can use Boolean operators @samp{&} for AND and
2874 @samp{|} for OR.  @samp{&} binds more strongly than @samp{|}.
2875 Parenthesis are currently not implemented.  A tag may also be preceded
2876 by @samp{-}, to select against it, and @samp{+} is syntactic sugar for
2877 positive selection.  The AND operator @samp{&} is optional when @samp{+}
2878 or @samp{-} is present.  For example, @samp{+WORK-BOSS} would select all
2879 headlines that are tagged @samp{:WORK:}, but discard those also tagged
2880 @samp{:BOSS:}.  The search string @samp{WORK|LAPTOP} selects all lines
2881 tagged @samp{:WORK:} or @samp{:LAPTOP:}.  The string
2882 @samp{WORK|LAPTOP&NIGHT} requires that the @samp{:LAPTOP:} lines are
2883 also tagged @samp{NIGHT}.
2885 @node Agenda views, Embedded LaTeX, Tags, Top
2886 @chapter Agenda Views
2887 @cindex agenda views
2889 Due to the way Org-mode works, TODO items, time-stamped items, and
2890 tagged headlines can be scattered throughout a file or even a number of
2891 files.  To get an overview over open action items, or over events that
2892 are important for a particular date, this information must be collected,
2893 sorted and displayed in an organized way.
2895 Org-mode can select items based on various criteria, and display them
2896 in a separate buffer.  Five different view types are provided:
2898 @itemize @bullet
2899 @item
2900 an @emph{agenda} that is like a calendar and shows information
2901 for specific dates
2902 @item
2903 a @emph{TODO list} that covers all unfinished
2904 action items,
2905 @item
2906 a @emph{tags view} that shows information based on
2907 the tags associated with headlines in the outline tree,
2908 @item
2909 a @emph{timeline view} that shows all events in a single Org-mode file,
2910 in time-sorted view
2911 @item
2912 @emph{custom views} that are special tag and keyword searches and
2913 combinations of different views.
2914 @end itemize
2916 @noindent
2917 The extracted information is displayed in a special @emph{agenda
2918 buffer}.  This buffer is read-only, but provides commands to visit the
2919 corresponding locations in the original Org-mode files, and even to
2920 edit these files remotely.
2922 @menu
2923 * Agenda files::                Files being searched for agenda information
2924 * Agenda dispatcher::           Keyboard access to agenda views
2925 * Weekly/Daily agenda::         The calendar page with current tasks
2926 * Global TODO list::            All unfinished action items
2927 * Matching headline tags::      Structured information with fine-tuned search
2928 * Timeline::                    Time-sorted view for single file
2929 * Presentation and sorting::    How agenda items are prepared for display
2930 * Agenda commands::             Remote editing of org trees
2931 * Custom agenda views::         Defining special searches and views
2932 @end menu
2934 @node Agenda files, Agenda dispatcher, Agenda views, Agenda views
2935 @section Agenda files
2936 @cindex agenda files
2938 The information to be shown is collected from all @emph{agenda files},
2939 the files listed in the variable @code{org-agenda-files}@footnote{If the
2940 value of that variable is not a list, but a single file name, then the
2941 list of agenda files will be maintained in that external file.}.  Thus even
2942 if you only work with a single Org-mode file, this file should be put
2943 into that list@footnote{When using the dispatcher, pressing @kbd{1}
2944 before selecting a command will actually limit the command to the
2945 current file, and ignore @code{org-agenda-files} until the next
2946 dispatcher command.}.  You can customize @code{org-agenda-files}, but
2947 the easiest way to maintain it is through the following commands
2949 @cindex files, adding to agenda list
2950 @table @kbd
2951 @kindex C-c [
2952 @item C-c [
2953 Add current file to the list of agenda files.  The file is added to
2954 the front of the list.  If it was already in the list, it is moved to
2955 the front.  With prefix arg, file is added/moved to the end.
2956 @kindex C-c ]
2957 @item C-c ]
2958 Remove current file from the list of agenda files.
2959 @kindex C-,
2960 @item C-,
2961 Cycle through agenda file list, visiting one file after the other.
2962 @end table
2964 @noindent
2965 The Org menu contains the current list of files and can be used
2966 to visit any of them.
2968 @node Agenda dispatcher, Weekly/Daily agenda, Agenda files, Agenda views
2969 @section The agenda dispatcher
2970 @cindex agenda dispatcher
2971 @cindex dispatching agenda commands
2972 The views are created through a dispatcher that should be bound to a
2973 global key, for example @kbd{C-c a} (@pxref{Installation}).  In the
2974 following we will assume that @kbd{C-c a} is indeed how the dispatcher
2975 is accessed and list keyboard access to commands accordingly.  After
2976 pressing @kbd{C-c a}, an additional letter is required to execute a
2977 command.  The dispatcher offers the following default commands:
2978 @table @kbd
2979 @item a
2980 Create the calendar-like agenda (@pxref{Weekly/Daily agenda}).
2981 @item t / T
2982 Create a list of all TODO items (@pxref{Global TODO list}).
2983 @item m / M
2984 Create a list of headlines matching a TAGS expression (@pxref{Matching
2985 headline tags}).
2986 @item L
2987 Create the timeline view for the current buffer (@pxref{Timeline}).
2988 @item 1
2989 Restrict an agenda command to the current buffer.  After pressing
2990 @kbd{1}, you still need to press the character selecting the command.
2991 @item 0
2992 If there is an active region, restrict the following agenda command to
2993 the region.  Otherwise, restrict it to the current subtree.  After
2994 pressing @kbd{0}, you still need to press the character selecting the
2995 command.
2996 @end table
2998 You can also define custom commands that will be accessible through the
2999 dispatcher, just like the default commands.  This includes the
3000 possibility to create extended agenda buffers that contain several
3001 blocks together, for example the weekly agenda, the global TODO list and
3002 a number of special tags matches.  @xref{Custom agenda views}.
3004 @node Weekly/Daily agenda, Global TODO list, Agenda dispatcher, Agenda views
3005 @section The weekly/daily agenda
3006 @cindex agenda
3007 @cindex weekly agenda
3008 @cindex daily agenda
3010 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
3011 paper agenda, showing all the tasks for the current week or day.
3013 @table @kbd
3014 @cindex org-agenda, command
3015 @kindex C-c a a
3016 @item C-c a a
3017 Compile an agenda for the current week from a list of org files.  The
3018 agenda shows the entries for each day.  With a @kbd{C-u} prefix (or
3019 when the variable @code{org-agenda-include-all-todo} is @code{t}), all
3020 unfinished TODO items (including those without a date) are also listed at
3021 the beginning of the buffer, before the first date.@*
3022 @end table
3024 Remote editing from the agenda buffer means, for example, that you can
3025 change the dates of deadlines and appointments from the agenda buffer.
3026 The commands available in the Agenda buffer are listed in @ref{Agenda
3027 commands}.
3029 @menu
3030 * Calendar/Diary integration::  Integrating Anniversaries and more
3031 @end menu
3034 @node Calendar/Diary integration,  , Weekly/Daily agenda, Weekly/Daily agenda
3035 @subsection Calendar/Diary integration
3036 @cindex calendar integration
3037 @cindex diary integration
3039 Emacs contains the calendar and diary by Edward M. Reingold.  The
3040 calendar displays a three-month calendar with holidays from different
3041 countries and cultures.  The diary allows you to keep track of
3042 anniversaries, lunar phases, sunrise/set, recurrent appointments
3043 (weekly, monthly) and more.  In this way, it is quite complementary to
3044 Org-mode.  It can be very useful to combine output from Org-mode with
3045 the diary.
3047 In order to include entries from the Emacs diary into Org-mode's
3048 agenda, you only need to customize the variable
3050 @lisp
3051 (setq org-agenda-include-diary t)
3052 @end lisp
3054 @noindent After that, everything will happen automatically.  All diary
3055 entries including holidays, anniversaries etc will be included in the
3056 agenda buffer created by Org-mode.  @key{SPC}, @key{TAB}, and
3057 @key{RET} can be used from the agenda buffer to jump to the diary
3058 file in order to edit existing diary entries.  The @kbd{i} command to
3059 insert new entries for the current date works in the agenda buffer, as
3060 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
3061 Sunrise/Sunset times, show lunar phases and to convert to other
3062 calendars, respectively.  @kbd{c} can be used to switch back and forth
3063 between calendar and agenda.
3066 @node Global TODO list, Matching headline tags, Weekly/Daily agenda, Agenda views
3067 @section The global TODO list
3068 @cindex global TODO list
3069 @cindex TODO list, global
3071 The global TODO list contains all unfinished TODO items, formatted and
3072 collected into a single place.
3074 @table @kbd
3075 @kindex C-c a t
3076 @item C-c a t
3077 Show the global TODO list.  This collects the TODO items from all
3078 agenda files (@pxref{Agenda views}) into a single buffer.  The buffer is in
3079 @code{agenda-mode}, so there are commands to examine and manipulate
3080 the TODO entries directly from that buffer (@pxref{Agenda commands}).
3081 @kindex C-c a T
3082 @item C-c a T
3083 Like the above, but allows selection of a specific TODO keyword.  You can
3084 also do this by specifying a prefix argument to @kbd{C-c a t}.  With a
3085 @kbd{C-u} prefix you are prompted for a keyword.  With a numeric
3086 prefix, the Nth keyword in @code{org-todo-keywords} is selected.
3087 @kindex r
3088 The @kbd{r} key in the agenda buffer regenerates it, and you can give
3089 a prefix argument to this command to change the selected TODO keyword,
3090 for example @kbd{3 r}.  If you often need a search for a specific
3091 keyword, define a custom command for it (@pxref{Agenda dispatcher}).
3092 @end table
3094 Remote editing of TODO items means that you can change the state of a
3095 TODO entry with a single key press.  The commands available in the
3096 TODO list are described in @ref{Agenda commands}.
3098 @cindex sublevels, inclusion into todo list
3099 Normally the global todo list simply shows all headlines with TODO
3100 keywords.  This list can become very long.  There are two ways to keep
3101 it more compact:
3102 @itemize @minus
3103 @item
3104 Some people view a TODO item that has been @emph{scheduled} for
3105 execution (@pxref{Time stamps}) as no longer @emph{open}.  Configure the
3106 variable @code{org-agenda-todo-ignore-scheduled} to exclude scheduled
3107 items from the global TODO list.
3108 @item
3109 TODO items may have sublevels to break up the task into subtasks.  In
3110 such cases it may be enough to list only the highest level TODO headline
3111 and omit the sublevels from the global list.  Configure the variable
3112 @code{org-agenda-todo-list-sublevels} to get this behavior.
3113 @end itemize
3115 @node Matching headline tags, Timeline, Global TODO list, Agenda views
3116 @section Matching headline tags
3117 @cindex matching, of tags
3118 @cindex tags view
3120 If headlines in the agenda files are marked with @emph{tags}
3121 (@pxref{Tags}), you can select headlines based on the tags that apply
3122 to them and collect them into an agenda buffer.
3124 @table @kbd
3125 @kindex C-c a m
3126 @item C-c a m
3127 Produce a list of all headlines that match a given set of tags.  The
3128 command prompts for a selection criterion, which is a boolean logic
3129 expression with tags, like @samp{+WORK+URGENT-WITHBOSS} or
3130 @samp{WORK|HOME} (@pxref{Tags}).  If you often need a specific search,
3131 define a custom command for it (@pxref{Agenda dispatcher}).
3132 @kindex C-c a M
3133 @item C-c a M
3134 Like @kbd{C-c a m}, but only select headlines that are also TODO items
3135 and force checking subitems (see variable
3136 @code{org-tags-match-list-sublevels}).
3137 @end table
3139 The commands available in the tags list are described in @ref{Agenda
3140 commands}.
3142 @node Timeline, Presentation and sorting, Matching headline tags, Agenda views
3143 @section Timeline for a single file
3144 @cindex timeline, single file
3145 @cindex time-sorted view
3147 The timeline summarizes all time-stamped items from a single Org-mode
3148 file in a @emph{time-sorted view}.  The main purpose of this command is
3149 to give an overview over events in a project.
3151 @table @kbd
3152 @kindex C-a a L
3153 @item C-c a L
3154 Show a time-sorted view of the org file, with all time-stamped items.
3155 When called with a @kbd{C-u} prefix, all unfinished TODO entries
3156 (scheduled or not) are also listed under the current date.
3157 @end table
3159 @noindent
3160 The commands available in the timeline buffer are listed in
3161 @ref{Agenda commands}.
3164 @node Presentation and sorting, Agenda commands, Timeline, Agenda views
3165 @section Presentation and sorting
3166 @cindex presentation, of agenda items
3168 Before displaying items in an agenda view, Org-mode visually prepares
3169 the items and sorts them.  Each item occupies a single line.  The line
3170 starts with a @emph{prefix} that contains the @emph{category}
3171 (@pxref{Categories}) of the item and other important information.  You can
3172 customize the prefix using the option @code{org-agenda-prefix-format}.
3173 The prefix is followed by a cleaned-up version of the outline headline
3174 associated with the item.
3176 @menu
3177 * Categories::                  Not all tasks are equal
3178 * Time-of-day specifications::  How the agenda knows the time
3179 * Sorting of agenda items::     The order of things
3180 @end menu
3182 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
3183 @subsection Categories
3185 @cindex category
3186 The category is a broad label assigned to each agenda item.  By default,
3187 the category is simply derived from the file name, but you can also
3188 specify it with a special line in the buffer, like this:
3190 @example
3191 #+CATEGORY: Thesis
3192 @end example
3194 If there are several such lines in a file, each specifies the category
3195 for the text below it (but the first category also applies to any text
3196 before the first CATEGORY line).  The display in the agenda buffer looks
3197 best if the category is not longer than 10 characters.
3199 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
3200 @subsection Time-of-Day Specifications
3201 @cindex time-of-day specification
3203 Org-mode checks each agenda item for a time-of-day specification.  The
3204 time can be part of the time stamp that triggered inclusion into the
3205 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
3206 ranges can be specified with two time stamps, like
3208 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
3210 In the headline of the entry itself, a time(range) may also appear as
3211 plain text (like @samp{12:45} or a @samp{8:30-1pm}.  If the agenda
3212 integrates the Emacs diary (@pxref{Calendar/Diary integration}), time
3213 specifications in diary entries are recognized as well.
3215 For agenda display, Org-mode extracts the time and displays it in a
3216 standard 24 hour format as part of the prefix.  The example times in
3217 the previous paragraphs would end up in the agenda like this:
3219 @example
3220     8:30-13:00 Arthur Dent lies in front of the bulldozer
3221    12:45...... Ford Prefect arrives and takes Arthur to the pub
3222    19:00...... The Vogon reads his poem
3223    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
3224 @end example
3226 @cindex time grid
3227 If the agenda is in single-day mode, or for the display of today, the
3228 timed entries are embedded in a time grid, like
3230 @example
3231     8:00...... ------------------
3232     8:30-13:00 Arthur Dent lies in front of the bulldozer
3233    10:00...... ------------------
3234    12:00...... ------------------
3235    12:45...... Ford Prefect arrives and takes Arthur to the pub
3236    14:00...... ------------------
3237    16:00...... ------------------
3238    18:00...... ------------------
3239    19:00...... The Vogon reads his poem
3240    20:00...... ------------------
3241    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
3242 @end example
3244 The time grid can be turned on and off with the variable
3245 @code{org-agenda-use-time-grid}, and can be configured with
3246 @code{org-agenda-time-grid}.
3248 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
3249 @subsection Sorting of agenda items
3250 @cindex sorting, of agenda items
3251 @cindex priorities, of agenda items
3252 Before being inserted into a view, the items are sorted.  How this is
3253 done depends on the type of view.
3254 @itemize @bullet
3255 @item
3256 For the daily/weekly agenda, the items for each day are sorted.  The
3257 default order is to first collect all items containing an explicit
3258 time-of-day specification.  These entries will be shown at the beginning
3259 of the list, as a @emph{schedule} for the day.  After that, items remain
3260 grouped in categories, in the sequence given by @code{org-agenda-files}.
3261 Within each category, items are sorted by priority (@pxref{Priorities}),
3262 which is composed of the base priority (2000 for priority @samp{A}, 1000
3263 for @samp{B}, and 0 for @samp{C}), plus additional increments for
3264 overdue scheduled or deadline items.
3265 @item 
3266 For the TODO list, items remain in the order of categories, but within
3267 each category, sorting takes place according to priority
3268 (@pxref{Priorities}).
3269 @item
3270 For tags matches, items are not sorted at all, but just appear in the
3271 sequence in which they are found in the agenda files.
3272 @end itemize
3274 Sorting can be customized using the variable
3275 @code{org-agenda-sorting-strategy}.
3278 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda views
3279 @section Commands in the agenda buffer
3280 @cindex commands, in agenda buffer
3282 Entries in the agenda buffer are linked back to the org file or diary
3283 file where they originate.  You are not allowed to edit the agenda
3284 buffer itself, but commands are provided to show and jump to the
3285 original entry location, and to edit the org-files ``remotely'' from
3286 the agenda buffer.  In this way, all information is stored only once,
3287 removing the risk that your agenda and note files may diverge.
3289 Some commands can be executed with mouse clicks on agenda lines.  For
3290 the other commands, the cursor needs to be in the desired line.
3292 @table @kbd
3293 @tsubheading{Motion}
3294 @cindex motion commands in agenda
3295 @kindex n
3296 @item n
3297 Next line (same as @key{up}).
3298 @kindex p
3299 @item p
3300 Previous line (same as @key{down}).
3301 @tsubheading{View/GoTo org file}
3302 @kindex mouse-3
3303 @kindex @key{SPC}
3304 @item mouse-3
3305 @itemx @key{SPC}
3306 Display the original location of the item in another window.
3308 @kindex L
3309 @item L
3310 Display original location and recenter that window.
3312 @kindex mouse-2
3313 @kindex mouse-1
3314 @kindex @key{TAB}
3315 @item mouse-2
3316 @itemx mouse-1
3317 @itemx @key{TAB}
3318 Go to the original location of the item in another window.  Under Emacs
3319 22, @kbd{mouse-1} will also works for this.
3321 @kindex @key{RET}
3322 @itemx @key{RET}
3323 Go to the original location of the item and delete other windows.
3325 @kindex f
3326 @item f
3327 Toggle Follow mode.  In Follow mode, as you move the cursor through
3328 the agenda buffer, the other window always shows the corresponding
3329 location in the org file.  The initial setting for this mode in new
3330 agenda buffers can be set with the variable
3331 @code{org-agenda-start-with-follow-mode}.
3333 @kindex l
3334 @item l
3335 Toggle Logbook mode.  In Logbook mode, entries that where marked DONE while
3336 logging was on (variable @code{org-log-done}) are shown in the agenda,
3337 as are entries that have been clocked on that day.
3339 @tsubheading{Change display}
3340 @cindex display changing, in agenda
3341 @kindex o
3342 @item o
3343 Delete other windows.
3345 @kindex w
3346 @item w
3347 Switch to weekly view (7 days displayed together).
3349 @kindex d
3350 @item d
3351 Switch to daily view (just one day displayed).
3353 @kindex D
3354 @item D
3355 Toggle the inclusion of diary entries.  See @ref{Calendar/Diary integration}.
3357 @kindex g
3358 @item g
3359 Toggle the time grid on and off.  See also the variables
3360 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
3362 @kindex r
3363 @item r
3364 Recreate the agenda buffer, for example to reflect the changes
3365 after modification of the time stamps of items with S-@key{left} and
3366 S-@key{right}.  When the buffer is the global todo list, a prefix
3367 argument is interpreted to create a selective list for a specific TODO
3368 keyword.
3370 @kindex s
3371 @item s
3372 Save all Org-mode buffers in the current Emacs session.
3374 @kindex @key{right}
3375 @item @key{right}
3376 Display the following @code{org-agenda-ndays} days.  For example, if
3377 the display covers a week, switch to the following week.  With prefix
3378 arg, go forward that many times @code{org-agenda-ndays} days.
3380 @kindex @key{left}
3381 @item @key{left}
3382 Display the previous dates.
3384 @kindex .
3385 @item .
3386 Goto today.
3388 @tsubheading{Remote editing}
3389 @cindex remote editing, from agenda
3391 @item 0-9
3392 Digit argument.
3394 @kindex t
3395 @item t
3396 Change the TODO state of the item, both in the agenda and in the
3397 original org file.
3399 @kindex T
3400 @item T
3401 Show all tags associated with the current item.  Because of
3402 inheritance, this may be more than the tags listed in the line itself.
3404 @kindex :
3405 @item :
3406 Set tags for the current headline.
3408 @kindex a
3409 @item a
3410 Toggle the ARCHIVE tag for the current headline.
3412 @kindex ,
3413 @item ,
3414 Set the priority for the current item.  Org-mode prompts for the
3415 priority character. If you reply with @key{SPC}, the priority cookie
3416 is removed from the entry.
3418 @kindex P
3419 @item p
3420 Display weighted priority of current item.
3422 @kindex +
3423 @kindex S-@key{up}
3424 @item +
3425 @itemx S-@key{up}
3426 Increase the priority of the current item.  The priority is changed in
3427 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
3428 key for this.
3430 @kindex -
3431 @kindex S-@key{down}
3432 @item -
3433 @itemx S-@key{down}
3434 Decrease the priority of the current item.
3436 @kindex C-c C-s
3437 @item C-c C-s
3438 Schedule this item
3440 @kindex C-c C-d
3441 @item C-c C-d
3442 Set a deadline for this item.
3444 @kindex S-@key{right}
3445 @item S-@key{right}
3446 Change the time stamp associated with the current line by one day into
3447 the future.  With prefix argument, change it by that many days.  For
3448 example, @kbd{3 6 5 S-@key{right}} will change it by a year.  The
3449 stamp is changed in the original org file, but the change is not
3450 directly reflected in the agenda buffer.  Use the
3451 @kbd{r} key to update the buffer.
3453 @kindex S-@key{left}
3454 @item S-@key{left}
3455 Change the time stamp associated with the current line by one day
3456 into the past.
3458 @kindex >
3459 @item >
3460 Change the time stamp associated with the current line to today.
3461 The key @kbd{>} has been chosen, because it is the same as @kbd{S-.}
3462 on my keyboard.
3464 @kindex I
3465 @item I
3466 Start the clock on the current item.  If a clock is running already, it
3467 is stopped first.
3468 @kindex O
3469 @item O
3470 Stop the previously started clock.
3471 @kindex X
3472 @item X
3473 Cancel the currently running clock.
3475 @tsubheading{Calendar commands}
3476 @cindex calendar commands, from agenda
3477 @kindex c
3478 @item c
3479 Open the Emacs calendar and move to the date at the agenda cursor.
3481 @item c
3482 When in the calendar, compute and show the Org-mode agenda for the
3483 date at the cursor.
3485 @cindex diary entries, creating from agenda
3486 @kindex i
3487 @item i
3488 Insert a new entry into the diary.  Prompts for the type of entry
3489 (day, weekly, monthly, yearly, anniversary, cyclic) and creates a new
3490 entry in the diary, just as @kbd{i d} etc. would do in the calendar.
3491 The date is taken from the cursor position.
3493 @kindex M
3494 @item M
3495 Show the phases of the moon for the three months around current date.
3497 @kindex S
3498 @item S
3499 Show sunrise and sunset times.  The geographical location must be set
3500 with calendar variables, see documentation of the Emacs calendar.
3502 @kindex C
3503 @item C
3504 Convert the date at cursor into many other cultural and historic
3505 calendars.
3507 @kindex H
3508 @item H
3509 Show holidays for three month around the cursor date.
3511 @c FIXME:  This should be a different key.
3512 @kindex C-c C-x C-c
3513 @item C-c C-x C-c
3514 Export a single iCalendar file containing entries from all agenda files.
3516 @tsubheading{Quit and Exit}
3517 @kindex q
3518 @item q
3519 Quit agenda, remove the agenda buffer.
3521 @kindex x
3522 @cindex agenda files, removing buffers
3523 @item x
3524 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
3525 for the compilation of the agenda.  Buffers created by the user to
3526 visit org files will not be removed.
3528 @end table
3531 @node Custom agenda views,  , Agenda commands, Agenda views
3532 @section Custom agenda views
3533 @cindex custom agenda views
3534 @cindex agenda views, custom
3536 Custom agenda commands serve two purposes: to store and quickly access
3537 frequently used TODO and tags searches, and to create special composite
3538 agenda buffers.  Custom agenda commands will be accessible through the
3539 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
3541 @menu
3542 * Storing searches::            Type once, use often
3543 * Block agenda::                All the stuff you need in a single buffer
3544 * Setting Options::             Changing the rules
3545 * Batch processing::            Agenda views from the command line
3546 @end menu
3548 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
3549 @subsection Storing searches
3551 The first application of custom searches is the definition of keyboard
3552 shortcuts for frequently used searches, either creating an agenda
3553 buffer, or a sparse tree (the latter covering of course only the current
3554 buffer).
3555 @kindex C-c a C
3556 Custom commands are configured in the variable
3557 @code{org-agenda-custom-commands}.  You can customize this variable, for
3558 example by pressing @kbd{C-c a C}.  You can also directly set it with
3559 Emacs Lisp in @file{.emacs}.  The following example contains all valid
3560 search types:
3562 @lisp
3563 @group
3564 (setq org-agenda-custom-commands
3565       '(("w" todo "WAITING")
3566         ("W" todo-tree "WAITING")
3567         ("u" tags "+BOSS-URGENT")
3568         ("v" tags-todo "+BOSS-URGENT")
3569         ("U" tags-tree "+BOSS-URGENT")
3570         ("f" occur-tree "\\<FIXME\\>")))
3571 @end group
3572 @end lisp
3574 @noindent
3575 The initial single-character string in each entry defines the character
3576 you have to press after the dispatcher command @kbd{C-c a} in order to
3577 access the command.   The second parameter is the search type, followed
3578 by the string or regular expression to be used for the matching.  The
3579 example above will therefore define:
3581 @table @kbd
3582 @item C-c a w
3583 as a global search for TODO entries with @samp{WAITING} as the TODO
3584 keyword
3585 @item C-c a W
3586 as the same search, but only in the current buffer and displaying the
3587 results as a sparse tree
3588 @item C-c a u
3589 as a global tags search for headlines marked @samp{:BOSS:} but not
3590 @samp{:URGENT:}
3591 @item C-c a v
3592 as the same search as @kbd{C-c a u}, but limiting the search to
3593 headlines that are also TODO items
3594 @item C-c a U
3595 as the same search as @kbd{C-c a u}, but only in the current buffer and
3596 displaying the result as a sparse tree
3597 @item C-c a f
3598 to create a sparse tree (again: current buffer only) with all entries
3599 containing the word @samp{FIXME}.
3600 @end table
3602 @node Block agenda, Setting Options, Storing searches, Custom agenda views
3603 @subsection Block agenda
3604 @cindex block agenda
3605 @cindex agenda, with block views
3607 Another possibility is the construction of agenda views that comprise
3608 the results of @emph{several} commands, each of which creates a block in
3609 the agenda buffer.  The available commands include @code{agenda} for the
3610 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
3611 for the global todo list (as constructed with @kbd{C-c a t}), and the
3612 matching commands discussed above: @code{todo}, @code{tags}, and
3613 @code{tags-todo}.  Here are two examples:
3615 @lisp
3616 @group
3617 (setq org-agenda-custom-commands
3618       '(("h" "Agenda and Home-related tasks"
3619          ((agenda)
3620           (tags-todo "HOME")
3621           (tags "GARDEN")))
3622         ("o" "Agenda and Office-related tasks"
3623          ((agenda)
3624           (tags-todo "WORK")
3625           (tags "OFFICE")))))
3626 @end group
3627 @end lisp
3629 @noindent
3630 This will define @kbd{C-c a h} to create a multi-block view for stuff
3631 you need to attend to at home.  The resulting agenda buffer will contain
3632 your agenda for the current week, all TODO items that carry the tag
3633 @samp{HOME}, and also all lines tagged with @samp{GARDEN}.  Finally the
3634 command @kbd{C-c a o} provides a similar view for office tasks.
3637 @node Setting Options, Batch processing, Block agenda, Custom agenda views
3638 @subsection Setting Options for custom commands
3639 @cindex options, for custom agenda views
3641 Org-mode contains a number of variables regulating agenda construction
3642 and display.  The global variables define the behavior for all agenda
3643 commands, including the custom commands.  However, if you want to change
3644 some settings just for a single custom view, you can do so.  Setting
3645 options requires inserting a list of variable names and values at the
3646 right spot in @code{org-agenda-custom-commands}.  For example:
3648 @lisp
3649 @group
3650 (setq org-agenda-custom-commands
3651       '(("w" todo "WAITING"
3652          ((org-agenda-sorting-strategy '(priority-down))
3653           (org-agenda-prefix-format "  Mixed: ")))
3654         ("U" tags-tree "+BOSS-URGENT"
3655          ((org-show-following-heading nil)
3656           (org-show-hierarchy-above nil)))))
3657 @end group
3658 @end lisp
3660 @noindent
3661 Now the @kbd{C-c a w} command will sort the collected entries only by
3662 priority, and the prefix format is modified to just say @samp{  Mixed:}
3663 instead of giving the category of the entry.  The sparse tags tree of
3664 @kbd{C-c a U} will now turn out ultra-compact, because neither the
3665 headline hierarchy above the match, nor the headline following the match
3666 will be shown.
3668 For command sets creating a block agenda,
3669 @code{org-agenda-custom-commands} has two separate spots for setting
3670 options.  You can add options that should be valid for just a single
3671 command in the set, and options that should be valid for all commands in
3672 the set.  The former are just added to the command entry, the latter
3673 must come after the list of command entries.  Going back to the block
3674 agenda example (@pxref{Block agenda}), let's change the sorting strategy
3675 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
3676 the results for GARDEN tags query in the opposite order,
3677 @code{priority-up}.  This would look like this:
3679 @lisp
3680 @group
3681 (setq org-agenda-custom-commands
3682       '(("h" "Agenda and Home-related tasks"
3683          ((agenda)
3684           (tags-todo "HOME")
3685           (tags "GARDEN" ((org-agenda-sorting-strategy '(priority-up)))))
3686          ((org-agenda-sorting-strategy '(priority-down))))
3687         ("o" "Agenda and Office-related tasks"
3688          ((agenda)
3689           (tags-todo "WORK")
3690           (tags "OFFICE")))))
3691 @end group
3692 @end lisp
3694 As you see, the values and parenthesis setting is a little complex.
3695 When in doubt, use the customize interface to set this variable - it
3696 fully supports its structure.  Just one caveat: When setting options in
3697 this interface, the @emph{values} are just lisp expressions.  So if the
3698 value is a string, you need to add the double quotes around the value
3699 yourself.
3701 @node Batch processing,  , Setting Options, Custom agenda views
3702 @subsection Creating agenda views in batch processing
3704 If you want to print or otherwise reprocess agenda views, it can be
3705 useful to create an agenda from the command line.  This is the purpose
3706 of the function @code{org-batch-agenda}.  It takes as a parameter one of
3707 the strings that are the keys in @code{org-agenda-custom-commands}.  For
3708 example, to directly print the current TODO list, you could use
3710 @example
3711 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
3712 @end example
3714 @noindent
3715 You may also modify parameters on the fly like this:
3717 @example
3718 emacs -batch -l ~/.emacs                                      \
3719    -eval '(org-batch-agenda "a"                               \
3720             org-agenda-ndays 300                              \
3721             org-agenda-include-diary nil                      \
3722             org-agenda-files (quote ("~/org/project.org")))'  \
3723    | lpr
3724 @end example
3726 @noindent
3727 which will produce a 300 day agenda, fully restricted to the Org file
3728 @file{~/org/projects.org}, not even including the diary.
3730 @node Embedded LaTeX, Exporting, Agenda views, Top
3731 @chapter Embedded LaTeX
3732 @cindex @TeX{} interpretation
3733 @cindex La@TeX{} interpretation
3735 Plain ASCII is normally sufficient for almost all note taking.  One
3736 exception, however, are scientific notes which need to be able to
3737 contain mathematical symbols and the occasional formula.
3738 La@TeX{}@footnote{La@TeX{} is a macro system based on Donald E. Knuth's
3739 @TeX{} system.  Many of the features described here as ``La@TeX{}'' are
3740 really from @TeX{}, but for simplicity I am blurring this distinction.}
3741 is widely used to typeset scientific documents. Org-mode supports
3742 embedding La@TeX{} code into its files, because many academics are used
3743 to read La@TeX{} source code, and because it can be readily processed
3744 into images for HTML production.
3746 It is not necessary to mark La@TeX{} macros and code in any special way.
3747 If you observe a few conventions, Org-mode knows how to find it and what
3748 to do with it.
3750 @menu
3751 * Math symbols::                TeX macros for symbols and Greek letters
3752 * Subscripts and Superscripts::  Simple syntax for raising/lowering text
3753 * LaTeX fragments::             Complex formulas made easy
3754 * Processing LaTeX fragments::  Previewing LaTeX processing
3755 * CDLaTeX mode::                Speed up entering of formulas
3756 @end menu
3758 @node Math symbols, Subscripts and Superscripts, Embedded LaTeX, Embedded LaTeX
3759 @section Math symbols
3761 You can use La@TeX{} macros to insert special symbols like @samp{\alpha}
3762 to indicate the Greek letter, or @samp{\to} to indicate an arrow.
3763 Completion for these macros is available, just type @samp{\} and maybe a
3764 few letters, and press @kbd{M-@key{TAB}} to see possible completions.
3765 Unlike La@TeX{} code, Org-mode allows these macros to be present
3766 without surrounding math delimiters, for example:
3768 @example
3769 Angles are written as Greek letters \alpha, \beta and \gamma.
3770 @end example
3772 During HTML export (@pxref{HTML export}), these symbols are translated
3773 into the proper syntax for HTML, for the above examples this is
3774 @samp{&alpha;} and @samp{&rarr;}, respectively.
3776 @node Subscripts and Superscripts, LaTeX fragments, Math symbols, Embedded LaTeX
3777 @section Subscripts and Superscripts
3779 Just like in La@TeX{}, @samp{^} and @samp{_} are used to indicate super-
3780 and subscripts.  Again, these can be used without embedding them in
3781 math-mode delimiters.  To increase the readability of ASCII text, it is
3782 not necessary (but OK) to surround multi-character sub- and superscripts
3783 with curly braces.  For example
3785 @example
3786 The mass if the sun is M_sun = 1.989 x 10^30 kg.  The radius of
3787 the sun is R_@{sun@} = 6.96 x 10^8 m.
3788 @end example
3790 To avoid interpretation as raised or lowered text, you can quote
3791 @samp{^} and @samp{_} with a backslash: @samp{\_} and @samp{\^}.
3793 During HTML export (@pxref{HTML export}), subscript and superscripts
3794 are surrounded with @code{<sub>} and @code{<sup>} tags, respectively.
3796 @node LaTeX fragments, Processing LaTeX fragments, Subscripts and Superscripts, Embedded LaTeX
3797 @section LaTeX fragments
3799 With symbols, sub- and superscripts, HTML is pretty much at its end when
3800 it comes to representing mathematical formulas.  More complex
3801 expressions need a dedicated formula processor.  To this end, Org-mode
3802 can contain arbitrary La@TeX{} fragments.  It provides commands to
3803 preview the typeset result of these fragments, and upon export to HTML,
3804 all fragments will be converted to images and inlined into the HTML
3805 document.  For this to work you need to be on a system with a working
3806 La@TeX{} installation.  You also need the @file{dvipng} program,
3807 available at @url{http://sourceforge.net/projects/dvipng/}.
3809 La@TeX{} fragments don't need any special marking at all.  The following
3810 snippets will be identified as LaTeX source code:
3811 @itemize @bullet
3812 @item
3813 Environments of any kind.  The only requirement is that the
3814 @code{\begin} statement appears on a new line, preceded by only
3815 whitespace.
3816 @item
3817 Text within the usual La@TeX{} math delimiters.  To avoid conflicts with
3818 currency specifications, single @samp{$} characters are only recognized
3819 as math delimiters if the enclosed text contains at most two line breaks,
3820 is directly attached to the @samp{$} characters with no whitespace in
3821 between, and if the closing @samp{$} is followed by whitespace or
3822 punctuation.  For the other delimiters, there is no such restriction, so
3823 when in doubt, use @samp{\(...\)} as inline math delimiters.
3824 @end itemize
3826 @noindent For example:
3828 @example
3829 \begin@{equation@}                          % arbitrary environments,
3830 x=\sqrt@{b@}                                % even tables, figures
3831 \end@{equation@}                            % etc
3833 If $a^2=b$ and \( b=2 \), then the solution must be
3834 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
3835 @end example
3837 @noindent
3838 If you need any of the delimiter ASCII sequences for other purposes, you
3839 can configure the option @code{org-format-latex-options} to deselect the
3840 ones you do not wish to have interpreted by the La@TeX{} converter.
3842 @node Processing LaTeX fragments, CDLaTeX mode, LaTeX fragments, Embedded LaTeX
3843 @section Processing LaTeX fragments
3845 La@TeX{} fragments can be processed to produce a preview images of the
3846 typeset expressions:
3848 @table @kbd
3849 @kindex C-c C-x C-l
3850 @item C-c C-x C-l
3851 Produce a preview image of the La@TeX{} fragment at point and overlay it
3852 over the source code.  If there is no fragment at point, process all
3853 fragments in the current entry (between two headlines).  When called
3854 with a prefix argument, process the entire subtree.  When called with
3855 two prefix arguments, or when the cursor is before the first headline,
3856 process the entire buffer.
3857 @kindex C-c C-c
3858 @item C-c C-c
3859 Remove the overlay preview images.
3860 @end table
3862 During HTML export (@pxref{HTML export}), all La@TeX{} fragments are
3863 converted into images and inlined into the document if the following
3864 setting is active:
3866 @lisp
3867 (setq org-export-with-LaTeX-fragments t)
3868 @end lisp
3870 @node CDLaTeX mode,  , Processing LaTeX fragments, Embedded LaTeX
3871 @section Using CDLaTeX to enter math
3873 CDLaTeX-mode is a minor mode that is normally used in combination with a
3874 major LaTeX mode like AUCTeX in order to speed-up insertion of
3875 environments and math templates.  Inside Org-mode, you can make use of
3876 some of the features of cdlatex-mode.  You need to install
3877 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
3878 AUCTeX) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
3879 Don't turn cdlatex-mode itself under Org-mode, but use the light
3880 version @code{org-cdlatex-mode} that comes as part of Org-mode.  Turn it
3881 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
3882 Org-mode files with
3884 @lisp
3885 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
3886 @end lisp
3888 When this mode is enabled, the following features are present (for more
3889 details see the documentation of cdlatex-mode):
3890 @itemize @bullet
3891 @kindex C-c @{
3892 @item
3893 Environment templates can be inserted with @kbd{C-c @{}.
3894 @item
3895 @kindex @key{TAB}
3896 The @key{TAB} key will do template expansion if the cursor is inside a
3897 LaTeX fragment@footnote{Org-mode has a method to test if the cursor is
3898 inside such a fragment, see the documentation of the function
3899 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
3900 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
3901 correctly inside the first brace.  Another @key{TAB} will get you into
3902 the second brace.  Even outside fragments, @key{TAB} will expand
3903 environment abbreviations at the beginning of a line.  For example, if
3904 you write @samp{equ} at the beginning of a line and press @key{TAB},
3905 this abbreviation will be expanded to an @code{equation} environment.
3906 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
3907 @item
3908 @kindex _
3909 @kindex ^
3910 Pressing @kbd{_} and @kbd{^} inside a LaTeX fragment will insert these
3911 characters together with a pair of braces.  If you use @key{TAB} to move
3912 out of the braces, and if the braces surround only a single character or
3913 macro, they are removed again (depending on the variable
3914 @code{cdlatex-simplify-sub-super-scripts}).
3915 @item
3916 @kindex `
3917 Pressing the backquote @kbd{`} followed by a character inserts math
3918 macros, also outside LaTeX fragments.  If you wait more than 1.5 seconds
3919 after the backquote, a help window will pop up.
3920 @item
3921 @kindex '
3922 Pressing the normal quote @kbd{'} followed by another character modifies
3923 the symbol before point with an accent or a font.  If you wait more than
3924 1.5 seconds after the backquote, a help window will pop up.  Character
3925 modification will work only inside La@TeX{} fragments, outside the quote
3926 is normal.
3927 @end itemize
3929 @node Exporting, Publishing, Embedded LaTeX, Top
3930 @chapter Exporting
3931 @cindex exporting
3933 Org-mode documents can be exported into a variety of other formats.  For
3934 printing and sharing of notes, ASCII export produces a readable and
3935 simple version of an Org-mode file.  HTML export allows you to publish a
3936 notes file on the web, while the XOXO format provides a solid base for
3937 exchange with a broad range of other applications.  To incorporate
3938 entries with associated times like deadlines or appointments into a
3939 desktop calendar program like iCal, Org-mode can also produce extracts
3940 in the iCalendar format.  Currently Org-mode only supports export, not
3941 import of these different formats.
3943 When exporting, Org-mode uses special conventions to enrich the output
3944 produced.  @xref{Text interpretation}, for more details.
3946 @table @kbd
3947 @kindex C-c C-e
3948 @item C-c C-e
3949 Dispatcher for export and publishing commands.  Displays a help-window
3950 listing the additional key(s) needed to launch an export or publishing
3951 command.
3952 @end table
3954 @menu
3955 * ASCII export::                Exporting to plain ASCII
3956 * HTML export::                 Exporting to HTML
3957 * XOXO export::                 Exporting to XOXO
3958 * iCalendar export::            Exporting in iCalendar format
3959 * Text interpretation::         How the exporter looks at the file
3960 @end menu
3962 @node ASCII export, HTML export, Exporting, Exporting
3963 @section ASCII export
3964 @cindex ASCII export
3966 ASCII export produces a simple and very readable version of an Org-mode
3967 file.
3969 @cindex region, active
3970 @cindex active region
3971 @cindex transient-mark-mode
3972 @table @kbd
3973 @kindex C-c C-e a
3974 @item C-c C-e a
3975 Export as ASCII file.  If there is an active region, only the region
3976 will be exported.  For an org file @file{myfile.org}, the ASCII file
3977 will be @file{myfile.txt}.  The file will be overwritten without
3978 warning.
3979 @kindex C-c C-e v a
3980 @item C-c C-e v a
3981 Export only the visible part of the document.
3982 @end table
3984 @cindex headline levels, for exporting
3985 In the exported version, the first 3 outline levels will become
3986 headlines, defining a general document structure.  Additional levels
3987 will be exported as itemized lists.  If you want that transition to occur
3988 at a different level, specify it with a prefix argument.  For example,
3990 @example
3991 @kbd{C-1 C-c C-e a}
3992 @end example
3994 @noindent
3995 creates only top level headlines and does the rest as items.  When
3996 headlines are converted to items, the indentation of the text following
3997 the headline is changed to fit nicely under the item.  This is done with
3998 the assumption that the first bodyline indicates the base indentation of
3999 the body text.  Any indentation larger than this is adjusted to preserve
4000 the layout relative to the first line.  Should there be lines with less
4001 indentation than the first, these are left alone.
4003 @node HTML export, XOXO export, ASCII export, Exporting
4004 @section HTML export
4005 @cindex HTML export
4007 Org-mode contains an HTML (XHTML 1.0 strict) exporter with extensive
4008 HTML formatting, in ways similar to John Grubers @emph{markdown}
4009 language, but with additional support for tables.
4011 @cindex region, active
4012 @cindex active region
4013 @cindex transient-mark-mode
4014 @table @kbd
4015 @kindex C-c C-e h
4016 @item C-c C-e h
4017 Export as HTML file @file{myfile.html}.
4018 @kindex C-c C-e b
4019 @item C-c C-e b
4020 Export as HTML file and open it with a browser.
4021 @kindex C-c C-e v h
4022 @kindex C-c C-e v b
4023 @item C-c C-e v h
4024 @item C-c C-e v b
4025 Export only the visible part of the document.
4026 @end table
4028 @cindex headline levels, for exporting
4029 In the exported version, the first 3 outline levels will become
4030 headlines, defining a general document structure.  Additional levels
4031 will be exported as itemized lists.  If you want that transition to occur
4032 at a different level, specify it with a prefix argument.  For example,
4034 @example
4035 @kbd{C-2 C-c C-e b}
4036 @end example
4038 @noindent
4039 creates two levels of headings and does the rest as items.
4041 If you want to include HTML tags which should be interpreted as such,
4042 mark them with @samp{@@} as in @samp{@@<b>bold text@@</b>}.
4043 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
4044 @samp{&gt;} in HTML export.
4046 @cindex links, in HTML export
4047 @cindex internal links, in HTML export
4048 @cindex external links, in HTML export
4049 Internal links (@pxref{Internal links}) will continue to work in HTML
4050 files only if they match a dedicated @samp{<<target>>}.  Automatic links
4051 created by radio targets (@pxref{Radio targets}) will also work in the
4052 HTML file.  Links to external files will still work if the HTML file is
4053 in the same directory as the Org-mode file.  Links to other @file{.org}
4054 files will be translated into HTML links under the assumption that an
4055 HTML version also exists of the linked file.  For information related to
4056 linking files while publishing them to a publishing directory see
4057 @ref{Publishing links}.
4059 You can also give style information for the exported file.  The HTML
4060 exporter assigns the following CSS classes to appropriate parts of the
4061 document - your style specifications may change these:
4062 @example
4063 .todo           @r{TODO keywords}
4064 .done           @r{the DONE keyword}
4065 .timestamp      @r{time stamp}
4066 .timestamp-kwd  @r{keyword associated with a time stamp, like SCHEDULED}
4067 .tag            @r{tag in a headline}
4068 .target         @r{target for links}
4069 @end example
4071 The default style specification can be configured through the option
4072 @code{org-export-html-style}.  If you want to use a file-local style,
4073 you may use file variables, best wrapped into a COMMENT section at the
4074 end of the outline tree.  For example:
4076 @example
4077 * COMMENT HTML style specifications
4079 # Local Variables:
4080 # org-export-html-style: "   <style type=\"text/css\">
4081 #       p @{font-weight: normal; color: gray; @}
4082 #       h1 @{color: black; @}
4083 #   </style>"
4084 # End:
4085 @end example
4087 Remember to execute @kbd{M-x normal-mode} after changing this to make
4088 the new style visible to Emacs.  This command restarts org-mode for the
4089 current buffer and forces Emacs to re-evaluate the local variables
4090 section in the buffer.
4092 @c FIXME: More about header and footer styles
4093 @c FIXME: Talk about links and targets.
4095 @node XOXO export, iCalendar export, HTML export, Exporting
4096 @section XOXO export
4097 @cindex XOXO export
4099 Org-mode contains an exporter that produces XOXO-style output.
4100 Currently, this exporter only handles the general outline structure and
4101 does not interpret any additional Org-mode features.
4103 @table @kbd
4104 @kindex C-c C-e x
4105 @item C-c C-e x
4106 Export as XOXO file @file{myfile.html}.
4107 @kindex C-c C-e v
4108 @item C-c C-e v x
4109 Export only the visible part of the document.
4110 @end table
4112 @node iCalendar export, Text interpretation, XOXO export, Exporting
4113 @section iCalendar export
4114 @cindex iCalendar export
4116 Some people like to use Org-mode for keeping track of projects, but
4117 still prefer a standard calendar application for anniversaries and
4118 appointments.  In this case it can be useful to have deadlines and
4119 other time-stamped items in Org-mode files show up in the calendar
4120 application.  Org-mode can export calendar information in the standard
4121 iCalendar format.
4123 @table @kbd
4124 @kindex C-c C-e i
4125 @item C-c C-e i
4126 Create iCalendar entries for the current file and store them in the same
4127 directory, using a file extension @file{.ics}.
4128 @kindex C-c C-e I
4129 @item C-c C-e I
4130 Like @kbd{C-c C-e i}, but do this for all files in
4131 @code{org-agenda-files}.  For each of these files, a separate iCalendar
4132 file will be written.
4133 @kindex C-c C-e c
4134 @item C-c C-e c
4135 Create a single large iCalendar file from all files in
4136 @code{org-agenda-files} and write it to the file given by
4137 @code{org-combined-agenda-icalendar-file}.
4138 @end table
4140 How this calendar is best read and updated, depends on the application
4141 you are using.  For example, when using iCal under Apple MacOS X, you
4142 could create a new calendar @samp{OrgMode} (the default name for the
4143 calendar created by @kbd{C-c C-e c}, see the variables
4144 @code{org-icalendar-combined-name} and
4145 @code{org-combined-agenda-icalendar-file}).  Then set Org-mode to
4146 overwrite the corresponding file
4147 @file{~/Library/Calendars/OrgMode.ics}.  You may even use AppleScript
4148 to make iCal re-read the calendar files each time a new version of
4149 @file{OrgMode.ics} is produced.  Here is the setup needed for this:
4151 @cindex applescript, for calendar update
4152 @lisp
4153 (setq org-combined-agenda-icalendar-file
4154     "~/Library/Calendars/OrgMode.ics")
4155 (add-hook 'org-after-save-iCalendar-file-hook
4156  (lambda ()
4157   (shell-command
4158    "osascript -e 'tell application \"iCal\" to reload calendars'")))
4159 @end lisp
4161 @node Text interpretation,  , iCalendar export, Exporting
4162 @section Text interpretation by the exporter
4164 The exporter backends interpret additional structure in the Org-mode file
4165 in order to produce better output.
4167 @menu
4168 * Comment lines::               Some lines will not be exported
4169 * Enhancing text::              Subscripts, symbols and more
4170 * Export options::              How to influence the export settings
4171 @end menu
4173 @node Comment lines, Enhancing text, Text interpretation, Text interpretation
4174 @subsection Comment lines
4175 @cindex comment lines
4176 @cindex exporting, not
4178 Lines starting with @samp{#} in column zero are treated as comments
4179 and will never be exported.  Also entire subtrees starting with the
4180 word @samp{COMMENT} will never be exported.  Finally, any text before
4181 the first headline will not be exported either.
4183 @table @kbd
4184 @kindex C-c ;
4185 @item C-c ;
4186 Toggle the COMMENT keyword at the beginning of an entry.
4187 @end table
4189 @node Enhancing text, Export options, Comment lines, Text interpretation
4190 @subsection Enhancing text for export
4191 @cindex enhancing text
4192 @cindex richer text
4194 Some of the export backends of Org-mode allow for sophisticated text
4195 formatting, this is true in particular for the HTML backend.  Org-mode
4196 has a number of typing conventions that allow to produce a richly
4197 formatted output.
4199 @itemize @bullet
4201 @cindex hand-formatted lists
4202 @cindex lists, hand-formatted
4203 @item
4204 Plain lists @samp{-}, @samp{*} or @samp{+} as bullet, or with @samp{1.}
4205 or @samp{2)} as enumerator will be recognized and transformed if the
4206 backend supports lists.  See @xref{Plain lists}.
4208 @cindex underlined text
4209 @cindex bold text
4210 @cindex italic text
4211 @item
4212 You can make words @b{*bold*}, @i{/italic/}, _underlined_,
4213 @code{=code=}, and @samp{+strikethrough+}.
4215 @cindex LaTeX fragments, export
4216 @cindex TeX macros, export
4217 @item
4218 Many @TeX{} macros and entire La@TeX{} fragments are converted into HTML
4219 entities or images (@pxref{Embedded LaTeX}).
4221 @cindex tables, export
4222 @item
4223 Tables are transformed into native tables under the exporter, if the
4224 export backend supports this. Data fields before the first horizontal
4225 separator line will be formatted as table header fields.
4227 @cindex fixed width
4228 @item
4229 If a headline starts with the word @samp{QUOTE}, the text below the
4230 headline will be typeset as fixed-width, to allow quoting of computer
4231 codes etc.  Lines starting with @samp{:} are also typeset in
4232 fixed-width font.
4233 @table @kbd
4234 @kindex C-c :
4235 @item C-c :
4236 Toggle fixed-width for entry (QUOTE) or region, see below.
4237 @end table
4239 @cindex linebreak, forced
4240 @item 
4241 A double backslash @emph{at the end of a line} enforces a line break at
4242 this position.
4243 @end itemize
4245 If these conversions conflict with your habits of typing ASCII text,
4246 they can all be turned off with corresponding variables (see the
4247 customization group @code{org-export-general}, and the following section
4248 which explains how to set export options with special lines in a
4249 buffer.
4252 @node Export options,  , Enhancing text, Text interpretation
4253 @subsection Export options
4254 @cindex options, for export
4256 @cindex completion, of option keywords
4257 The exporter recognizes special lines in the buffer which provide
4258 additional information.  These lines may be put anywhere in the file.
4259 The whole set of lines can be inserted into the buffer with @kbd{C-c
4260 C-e t}.  For individual lines, a good way to make sure the keyword is
4261 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
4262 (@pxref{Completion}).
4264 @table @kbd
4265 @kindex C-c C-e t
4266 @item C-c C-e t
4267 Insert template with export options, see example below.
4268 @end table
4270 @example
4271 #+TITLE:     the title to be shown (default is the buffer name)
4272 #+AUTHOR:    the author (default taken from @code{user-full-name})
4273 #+EMAIL:     his/her email address (default from @code{user-mail-address})
4274 #+LANGUAGE:  language for HTML, e.g. @samp{en} (@code{org-export-default-language})
4275 #+TEXT:      Some descriptive text to be inserted at the beginning.
4276 #+TEXT:      Several lines may be given.
4277 #+OPTIONS:   H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t *:nil TeX:t LaTeX:t
4278 @end example
4280 @noindent
4281 The OPTIONS line is a compact form to specify export settings.  Here
4282 you can:
4283 @cindex headline levels
4284 @cindex section-numbers
4285 @cindex table of contents
4286 @cindex linebreak preservation
4287 @cindex quoted HTML tags
4288 @cindex fixed-width sections
4289 @cindex tables
4290 @cindex @TeX{}-like syntax for sub- and superscripts
4291 @cindex emphasized text
4292 @cindex @TeX{} macros
4293 @cindex La@TeX{} fragments
4294 @example
4295 H:      @r{set the number of headline levels for export}
4296 num:    @r{turn on/off section-numbers}
4297 toc:    @r{turn on/off table of contents}
4298 \n:     @r{turn on/off linebreak-preservation}
4299 @@:      @r{turn on/off quoted HTML tags}
4300 ::      @r{turn on/off fixed-width sections}
4301 |:      @r{turn on/off tables}
4302 ^:      @r{turn on/off @TeX{}-like syntax for sub- and superscripts.}
4303 *:      @r{turn on/off emphasized text (bold, italic, underlined)}
4304 TeX:    @r{turn on/off simple @TeX{} macros in plain text}
4305 LaTeX:  @r{turn on/off La@TeX{} fragments}
4306 @end example
4308 @node Publishing, Miscellaneous, Exporting, Top
4309 @chapter Publishing
4310 @cindex publishing
4312 Org-mode includes@footnote{@file{org-publish.el} is not yet part of
4313 Emacs, so if you are using @file{org.el} as it comes with Emacs, you
4314 need to download this file separately.  Also make sure org.el is at
4315 least version 4.27.} a publishing management system
4316 that allows you to configure automatic HTML conversion of
4317 @emph{projects} composed of interlinked org files.  This system is
4318 called @emph{org-publish}.  You can also configure org-publish to
4319 automatically upload your exported HTML pages and related attachments,
4320 such as images and source code files, to a web server.  Org-publish turns
4321 org-mode into a web-site authoring tool.
4323 Org-publish has been contributed to Org-mode by David O'Toole.
4325 @menu
4326 * Configuration::               Defining projects
4327 * Sample configuration::        Example projects
4328 * Triggering publication::      Publication commands
4329 @end menu
4331 @node Configuration, Sample configuration, Publishing, Publishing
4332 @section Configuration
4334 Publishing needs significant configuration to specify files, destination
4335 and many other properties of a project.
4337 @menu
4338 * Project alist::               The central configuration variable
4339 * Sources and destinations::    From here to there
4340 * Selecting files::             What files are part of the project?
4341 * Publishing action::           Setting the function doing the publishing
4342 * Publishing options::          Tweaking HTML export
4343 * Publishing links::            Which links keep working after publishing?
4344 * Project page index::          Publishing a list of project files
4345 @end menu
4347 @node Project alist, Sources and destinations, Configuration, Configuration
4348 @subsection The variable @code{org-publish-project-alist}
4349 @cindex org-publish-project-alist
4350 @cindex projects, for publishing
4352 Org-publish is configured almost entirely through setting the value of
4353 one variable, called @code{org-publish-project-alist}.
4354 Each element of the list configures one project, and may be in one of
4355 the two following forms:
4357 @lisp
4358 ("project-name"  :property value :property value ...)
4360 @r{or} 
4362 ("project-name"  :components ("project-name" "project-name" ...))
4364 @end lisp
4366 In both cases, projects are configured by specifying property values.
4367 A project defines the set of files that will be published, as well as
4368 the publishing configuration to use when publishing those files.  When
4369 a project takes the second form listed above, the individual members
4370 of the ``components'' property are taken to be components of the
4371 project, which group together files requiring different publishing
4372 options. When you publish such a ``meta-project'' all the components
4373 will also publish.
4375 @node Sources and destinations, Selecting files, Project alist, Configuration
4376 @subsection Sources and destinations for files
4377 @cindex directories, for publishing
4379 Most properties are optional, but some should always be set. In
4380 particular, org-publish needs to know where to look for source files,
4381 and where to put published files.
4383 @multitable @columnfractions 0.3 0.7
4384 @item @code{:base-directory}
4385 @tab Directory containing publishing source files
4386 @item @code{:publishing-directory}
4387 @tab Directory (possibly remote) where output files will be published.
4388 @item @code{:preparation-function}
4389 @tab Function called before starting publishing proxess.
4390 @end multitable
4391 @noindent
4393 @node Selecting files, Publishing action, Sources and destinations, Configuration
4394 @subsection Selecting files
4395 @cindex files, selecting for publishing
4397 By default, all files with extension @file{.org} in the base directory
4398 are considered part of the project.  This can be modified by setting the
4399 properties 
4400 @multitable @columnfractions 0.25 0.75
4401 @item @code{:base-extension}
4402 @tab Extension (without the dot!) of source files.  This actually is a
4403 regular expression.
4405 @item @code{:exclude} 
4406 @tab Regular expression to match file names that should not be
4407 published, even though they have been selected on the basis of their
4408 extension.
4410 @item @code{:include}
4411 @tab List of files to be included regardless of @code{:base-extension}
4412 and @code{:exclude}.
4413 @end multitable
4415 @node Publishing action, Publishing options, Selecting files, Configuration
4416 @subsection Publishing Action
4417 @cindex action, for publishing
4419 Publishing means that a file is copied to the destination directory and
4420 possibly transformed in the process.  The default transformation is to
4421 export Org-mode files as HTML files, and this is done by the function
4422 @code{org-publish-org-to-html} which calls the HTML exporter
4423 (@pxref{HTML export}).  Other files like images only need to be copied
4424 to the publishing destination.  For non-Org-mode files, you need to
4425 specify the publishing function.
4427 @multitable @columnfractions 0.3 0.7
4428 @item @code{:publishing-function}
4429 @tab Function executing the publication of a file.
4430 @end multitable
4432 The function must accept two arguments: a property list containing at
4433 least a @code{:publishing-directory} property, and the name of the file
4434 to be published.  It should take the specified file, make the necessary
4435 transformation (if any) and place the result into the destination folder.
4436 You can write your own publishing function, but @code{org-publish}
4437 provides one for attachments (files that only need to be copied):
4438 @code{org-publish-attachment}.
4440 @node Publishing options, Publishing links, Publishing action, Configuration
4441 @subsection Options for the HTML exporter
4442 @cindex options, for publishing
4444 The property list can be used to set many export options for the HTML
4445 exporter.  In most cases, these properties correspond to user variables
4446 in Org-mode.  The table below lists these properties along with the
4447 variable they belong to.  See the documentation string for the
4448 respective variable for details.
4450 @multitable @columnfractions 0.3 0.7
4451 @item @code{:language}              @tab @code{org-export-default-language}
4452 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
4453 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
4454 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
4455 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
4456 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
4457 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
4458 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
4459 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
4460 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
4461 @item @code{:timestamps}           .@tab @code{org-export-with-timestamps}
4462 @item @code{:tags}                 .@tab @code{org-export-with-tags}
4463 @item @code{:tables}                @tab @code{org-export-with-tables}
4464 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
4465 @item @code{:style}                 @tab @code{org-export-html-style}
4466 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
4467 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
4468 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
4469 @item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
4470 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
4471 @item @code{:preamble}              @tab @code{org-export-html-preamble}
4472 @item @code{:postamble}             @tab @code{org-export-html-postamble}
4473 @item @code{:auto-preamble}         @tab @code{org-export-html-auto-preamble}
4474 @item @code{:auto-postamble}        @tab @code{org-export-html-auto-postamble}
4475 @item @code{:author}                @tab @code{user-full-name}
4476 @item @code{:email}                 @tab @code{user-mail-address}
4477 @end multitable
4479 When a property is given a value in org-publish-project-alist, its
4480 setting overrides the value of the corresponding user variable (if any)
4481 during publishing.  options set within a file (@pxref{Export
4482 options}), however, override everything.
4484 @node Publishing links, Project page index, Publishing options, Configuration
4485 @subsection Links between published files
4486 @cindex links, publishing
4488 To create a link from one Org-mode file to another, you would use
4489 something like @samp{[[file:foo.org][The foo]]} or simply
4490 @samp{file:foo.org.} (@pxref{Hyperlinks}).  Upon publishing this link
4491 becomes a link to @file{foo.html}.  In this way, you can interlink the
4492 pages of your "org web" project and the links will work as expected when
4493 you publish them to HTML.
4495 You may also link to related files, such as images. Provided you are
4496 careful with relative pathnames, and provided you have also configured
4497 org-publish to upload the related files, these links will work
4498 too. @ref{Complex example} for an example of this usage.
4500 Sometime an Org-mode file to be published may contain links that are
4501 only valid in your production environment, but not in the publishing
4502 location.  In this case, use the property 
4504 @multitable @columnfractions 0.4 0.6
4505 @item @code{:link-validation-function}
4506 @tab Function to validate links
4507 @end multitable
4509 @noindent
4510 to define a function for checking link validity.  This function must
4511 accept two arguments, the file name and a directory relative to which
4512 the file name is interpreted in the production environment.  If this
4513 function returns @code{nil}, then the HTML generator will only insert a
4514 description into the HTML file, but no link.  One option for this
4515 function is @code{org-publish-validate-link} which checks if the given
4516 file is part of any project in @code{org-publish-project-alist}.
4518 @node Project page index,  , Publishing links, Configuration
4519 @subsection Project page index
4520 @cindex index, of published pages
4522 The following properties may be used to control publishing of an
4523 index of files or summary page for a given project.
4525 @multitable @columnfractions 0.25 0.75
4526 @item @code{:auto-index}
4527 @tab When non-nil, publish an index during org-publish-current-project or
4528 org-publish-all.
4530 @item @code{:index-filename}
4531 @tab Filename for output of index. Defaults to @file{index.org} (which
4532 becomes @file{index.html}).
4534 @item @code{:index-title}
4535 @tab Title of index page. Defaults to name of file.
4537 @item @code{:index-function}
4538 @tab Plugin function to use for generation of index.
4539 Defaults to @code{org-publish-org-index}, which generates a plain list
4540 of links to all files in the project.
4541 @end multitable
4543 @node Sample configuration, Triggering publication, Configuration, Publishing
4544 @section Sample configuration
4546 Below we provide two example configurations.  The first one is a simple
4547 project publishing only a set of Org-mode files.  The second example is
4548 more complex, with a multi-component project.
4550 @menu
4551 * Simple example::              One-component publishing
4552 * Complex example::             A multi-component publishing example
4553 @end menu
4555 @node Simple example, Complex example, Sample configuration, Sample configuration
4556 @subsection Example: simple publishing configuration
4558 This example publishes a set of Org-mode files to the @file{public_html}
4559 directory on the local machine.
4561 @lisp
4562 (setq org-publish-project-alist
4563       '(("org" 
4564          :base-directory "~/org/"
4565          :publishing-directory "~/public_html"
4566          :section-numbers nil
4567          :table-of-contents nil
4568          :style "<link rel=stylesheet 
4569                 href=\"../other/mystyle.css\"
4570                 type=\"text/css\">")))
4571 @end lisp
4573 @node Complex example,  , Simple example, Sample configuration
4574 @subsection Example: complex publishing configuration
4576 This more complicated example publishes an entire website, including
4577 org files converted to HTML, image files, emacs lisp source code, and
4578 stylesheets. The publishing-directory is remote and private files are
4579 excluded.
4581 To ensure that links are preserved, care should be taken to replicate
4582 your directory structure on the web server, and to use relative file
4583 paths. For example, if your org files are kept in @file{~/org} and your
4584 publishable images in @file{~/images}, you'd link to an image with
4586 @example
4587 file:../images/myimage.png
4588 @end example
4590 On the web server, the relative path to the image should be the
4591 same. You can accomplish this by setting up an "images" folder in the
4592 right place on the webserver, and publishing images to it.
4594 @lisp
4595 (setq org-publish-project-alist
4596       '(("orgfiles"
4597           :base-directory "~/org/"
4598           :base-extension "org"
4599           :publishing-directory "/ssh:user@@host:~/html/notebook/"
4600           :publishing-function org-publish-org-to-html
4601           :exclude "PrivatePage.org"   ;; regexp
4602           :headline-levels 3
4603           :section-numbers nil
4604           :table-of-contents nil
4605           :style "<link rel=stylesheet 
4606                   href=\"../other/mystyle.css\" type=\"text/css\">"
4607           :auto-preamble t
4608           :auto-postamble nil)
4609          
4610          ("images"
4611           :base-directory "~/images/"
4612           :base-extension "jpg\\|gif\\|png"
4613           :publishing-directory "/ssh:user@@host:~/html/images/"
4614           :publishing-function org-publish-attachment)
4616          ("other"
4617           :base-directory "~/other/"
4618           :base-extension "css\\|el"
4619           :publishing-directory "/ssh:user@@host:~/html/other/"
4620           :publishing-function org-publish-attachment)
4621          ("website" :components ("orgfiles" "images" "other"))))
4622 @end lisp
4624 @node Triggering publication,  , Sample configuration, Publishing
4625 @section Triggering publication
4627 Once org-publish is properly configured, you can publish with the
4628 following functions: 
4630 @table @kbd
4631 @item C-c C-e c
4632 Prompt for a specific project and publish all files that belong to it.
4633 @item C-c C-e p
4634 Publish the project containing the current file.
4635 @item C-c C-e f
4636 Publish only the current file.
4637 @item C-c C-e a
4638 Publish all projects.
4639 @end table
4641 Org uses timestamps to track when a file has changed. The above
4642 functions normally only publish changed files. You can override this and
4643 force publishing of all files by giving a prefix argument.
4645 @node Miscellaneous, Extensions and Hacking, Publishing, Top
4646 @chapter Miscellaneous
4648 @menu
4649 * Completion::                  M-TAB knows what you need
4650 * Customization::               Adapting Org-mode to your taste
4651 * In-buffer settings::          Overview of the #+KEYWORDS
4652 * The very busy C-c C-c key::   When in doubt, press C-c C-c
4653 * Clean view::                  Getting rid of leading stars in the outline
4654 * TTY keys::                    Using Org-mode on a tty
4655 * Interaction::                 Other Emacs packages
4656 * Bugs::                        Things which do not work perfectly
4657 @end menu
4659 @node Completion, Customization, Miscellaneous, Miscellaneous
4660 @section Completion
4661 @cindex completion, of @TeX{} symbols
4662 @cindex completion, of TODO keywords
4663 @cindex completion, of dictionary words
4664 @cindex completion, of option keywords
4665 @cindex completion, of CamelCase links
4666 @cindex completion, of tags
4667 @cindex @TeX{} symbol completion
4668 @cindex TODO keywords completion
4669 @cindex dictionary word completion
4670 @cindex option keyword completion
4671 @cindex CamelCase link completion
4672 @cindex tag completion
4674 Org-mode supports in-buffer completion.  This type of completion does
4675 not make use of the minibuffer.  You simply type a few letters into
4676 the buffer and use the key to complete text right there.
4678 @table @kbd
4679 @kindex M-@key{TAB}
4680 @item M-@key{TAB}
4681 Complete word at point
4682 @itemize @bullet
4683 @item
4684 At the beginning of a headline, complete TODO keywords.
4685 @item
4686 After @samp{\}, complete @TeX{} symbols supported by the exporter.
4687 @item
4688 After @samp{*}, complete headlines in the current buffer so that they
4689 can be used in search links like @samp{[[*find this headline]]}.
4690 @item
4691 After @samp{:}, complete tags.  The list of tags is taken from the
4692 variable @code{org-tag-alist} (possibly set through the @samp{#+TAGS}
4693 in-buffer option, @pxref{Setting tags}), or it is created dynamically
4694 from all tags used in the current buffer.
4695 @item
4696 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
4697 @samp{OPTIONS} which set file-specific options for Org-mode.  When the
4698 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
4699 will insert example settings for this keyword.
4700 @item
4701 In the line after @samp{#+STARTUP: }, complete startup keywords,
4702 i.e. valid keys for this line.
4703 @item
4704 Elsewhere, complete dictionary words using ispell.
4705 @end itemize
4706 @end table
4708 @node Customization, In-buffer settings, Completion, Miscellaneous
4709 @section Customization
4710 @cindex customization
4711 @cindex options, for customization
4712 @cindex variables, for customization
4714 There are more than 100 variables that can be used to customize
4715 Org-mode.  For the sake of compactness of the manual, we are not
4716 describing the variables here.  A structured overview of customization
4717 variables is available with @kbd{M-x org-customize}.  Or select
4718 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
4719 settings can also be activated on a per-file basis, by putting special
4720 lines into the buffer (@pxref{In-buffer settings}).
4722 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
4723 @section Summary of in-buffer settings
4724 @cindex in-buffer settings
4725 @cindex special keywords
4727 Org-mode uses special lines in the buffer to define settings on a
4728 per-file basis.  These lines start with a @samp{#+} followed by a
4729 keyword, a colon, and then individual words defining a setting.  Several
4730 setting words can be in the same line, but you can also have multiple
4731 lines for the keyword.  While these settings are described throughout
4732 the manual, here is a summary.  After changing any of those lines in the
4733 buffer, press @kbd{C-c C-c} with the cursor still in the line to
4734 activate the changes immediately.  Otherwise they become effective only
4735 when the file is visited again in a new Emacs session.
4737 @table @kbd
4738 @item #+STARTUP:
4739 This line sets options to be used at startup of org-mode, when an
4740 Org-mode file is being visited.  The first set of options deals with the
4741 initial visibility of the outline tree.  The corresponding variable for
4742 global default settings is @code{org-startup-folded}, with a default
4743 value @code{t}, which means @code{overview}.
4744 @example
4745 overview   @r{top-level headlines only}
4746 content    @r{all headlines}
4747 showall    @r{no folding at all, show everything}
4748 @end example
4749 Then there are options for aligning tables upon visiting a file.  This
4750 is useful in files containing narrowed table columns.  The corresponding
4751 variable is @code{org-startup-align-all-tables}, with a default value
4752 @code{nil}. 
4753 @example
4754 align      @r{align all tables}
4755 noalign    @r{don't align tables on startup}
4756 @end example
4757 Logging when a TODO item is marked DONE (variable @code{org-log-done})
4758 can be configured using these options.
4759 @example
4760 logging    @r{record a timestamp when an item is marked DONE}
4761 nologging  @r{don't record when items are marked DONE}
4762 @end example
4763 Here are the options for hiding leading stars in outline headings.  The
4764 corresponding variables are @code{org-hide-leading-stars} and
4765 @code{org-odd-levels-only}, both with a default setting @code{nil}
4766 (meaning @code{showstars} and @code{oddeven}).
4767 @example
4768 hidestars  @r{make all but one of the stars starting a headline invisible.}
4769 showstars  @r{show all stars starting a headline}
4770 odd        @r{allow only odd outline levels (1,3,...)}
4771 oddeven    @r{allow all outline levels}
4772 @end example
4773 @item #+SEQ_TODO:   #+TYP_TODO:
4774 These lines set the TODO keywords and their interpretation in the
4775 current file.  The corresponding variables are @code{org-todo-keywords}
4776 and @code{org-todo-interpretation}.
4777 @item #+TAGS:  TAG1(c1) TAG2(c2)
4778 These lines (several such lines are allowed) specify the legal tags in
4779 this file, and (potentially) the corresponding @emph{fast tag selection}
4780 keys.  The corresponding variable is @code{org-tag-alist}.
4781 @item #+CATEGORY:
4782 This line sets the category for the agenda file.  The category applies
4783 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
4784 end of the file.
4785 @item #+TBLFM:
4786 This line contains the formulas for the table directly above the line.
4787 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+OPTIONS:
4788 These lines provide settings for exporting files.  For more details see
4789 @ref{Export options}.
4790 @end table
4792 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
4793 @section The very busy C-c C-c key
4794 @kindex C-c C-c
4796 The key @kbd{C-c C-c} has many purposes in org-mode, which are all
4797 mentioned scattered throughout this manual.  One specific function of
4798 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
4799 other circumstances it means something like @emph{Hey Org-mode, look
4800 here and update according to what you see here}.  Here is a summary of
4801 what this means in different contexts.
4803 @itemize @minus
4804 @item
4805 If there are highlights in the buffer from the creation of a sparse
4806 tree, or from clock display, remove these highlights.
4807 @item
4808 If the cursor is in one of the special @code{#+KEYWORD} lines, this
4809 triggers scanning the buffer for these lines and updating the
4810 information. 
4811 @item
4812 If the cursor is inside a table, realign the table.  This command
4813 works even if the automatic table editor has been turned off.
4814 @item
4815 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
4816 the entire table.
4817 @item
4818 If the cursor is inside a table created by the @file{table.el} package,
4819 activate that table.
4820 @item
4821 If the current buffer is a remember buffer, close the note and file it.
4822 With a prefix argument, file it, without further interaction, to the
4823 default location.
4824 @item
4825 If the cursor is on a @code{<<<target>>>}, update radio targets and
4826 corresponding links in this buffer.
4827 @item
4828 If the cursor is in a plain list item with a checkbox, toggle the status
4829 of the checkbox.
4830 @item
4831 If the cursor is on a numbered item in a plain list, renumber the
4832 ordered list.
4833 @end itemize
4835 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
4836 @section A cleaner outline view
4837 @cindex hiding leading stars
4838 @cindex clean outline view
4840 Some people find it noisy and distracting that the Org-mode headlines
4841 are starting with a potentially large number of stars.  For example
4842 the tree from @ref{Headlines}:
4844 @example
4845 * Top level headline
4846 ** Second level
4847 *** 3rd level
4848     some text
4849 *** 3rd level
4850     more text
4851 * Another top level headline
4852 @end example
4854 @noindent
4855 Unfortunately this is deeply ingrained into the code of Org-mode and
4856 cannot be easily changed.  You can, however, modify the display in such
4857 a way that all leading stars become invisible and the outline more easy
4858 to read.  To do this, customize the variable
4859 @code{org-hide-leading-stars} like this:
4861 @lisp
4862 (setq org-hide-leading-stars t)
4863 @end lisp
4865 @noindent
4866 or change this on a per-file basis with one of the lines (anywhere in
4867 the buffer)
4869 @example
4870 #+STARTUP: showstars
4871 #+STARTUP: hidestars
4872 @end example
4874 @noindent
4875 Press @kbd{C-c C-c} with the cursor in a @samp{STARTUP} line to activate
4876 the modifications.
4878 With stars hidden, the tree becomes:
4880 @example
4881 * Top level headline
4882  * Second level
4883   * 3rd level
4884     some text
4885   * 3rd level
4886     more text
4887 * Another top level headline
4888 @end example
4890 @noindent
4891 Note that the leading stars are not truly replaced by whitespace, they
4892 are only fontified with the face @code{org-hide} that uses the
4893 background color as font color.  If are are not using either white or
4894 black background, you may have to customize this face to get the wanted
4895 effect.  Another possibility is to set this font such that the extra
4896 stars are @i{almost} invisible, for example using the color
4897 @code{grey90} on a white background.
4899 Things become cleaner still if you skip all the even levels and use only
4900 odd levels 1, 3, 5..., effectively adding two stars to go from one
4901 outline level to the next:
4903 @example
4904 * Top level headline
4905   * Second level
4906     * 3rd level
4907       some text
4908     * 3rd level
4909       more text
4910 * Another top level headline
4911 @end example
4913 @noindent
4914 In order to make the structure editing and export commands handle this
4915 convention correctly, use
4917 @lisp
4918 (setq org-odd-levels-only t)
4919 @end lisp
4921 @noindent
4922 or set this on a per-file basis with one of the following lines (don't
4923 forget to press @kbd{C-c C-c} with the cursor in the startup line to
4924 activate changes immediately).
4926 @example
4927 #+STARTUP: odd
4928 #+STARTUP: oddeven
4929 @end example
4931 You can convert an Org-mode file from single-star-per-level to the
4932 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
4933 RET} in that file.  The reverse operation is @kbd{M-x
4934 org-convert-to-oddeven-levels}.
4936 @node TTY keys, Interaction, Clean view, Miscellaneous
4937 @section Using org-mode on a tty
4938 @cindex tty keybindings
4940 Org-mode uses a number of keys that are not accessible on a tty.  This
4941 applies to most special keys like cursor keys, @key{TAB} and
4942 @key{RET}, when these are combined with modifier keys like @key{Meta}
4943 and/or @key{Shift}.  Org-mode uses these bindings because it needs to
4944 provide keys for a large number of commands, and because these keys
4945 appeared particularly easy to remember.  In order to still be able to
4946 access the core functionality of Org-mode on a tty, alternative
4947 bindings are provided.  Here is a complete list of these bindings,
4948 which are obviously more cumbersome to use.  Note that sometimes a
4949 work-around can be better.  For example changing a time stamp is
4950 really only fun with @kbd{S-@key{cursor}} keys.  On a tty you would
4951 rather use @kbd{C-c .}  to re-insert the timestamp.
4953 @multitable @columnfractions 0.15 0.2 0.2
4954 @item @b{Default} @tab @b{Alternative 1} @tab @b{Alternative 2}
4955 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab
4956 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{@key{Esc} @key{left}}
4957 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab
4958 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{@key{Esc} @key{right}}
4959 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab
4960 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{@key{Esc} @key{up}}
4961 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab
4962 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{@key{Esc} @key{down}}
4963 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab
4964 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab
4965 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{@key{Esc} @key{RET}}
4966 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab
4967 @item @kbd{S-@key{left}}    @tab @kbd{C-c C-x @key{left}}  @tab
4968 @item @kbd{S-@key{right}}   @tab @kbd{C-c C-x @key{right}} @tab
4969 @item @kbd{S-@key{up}}      @tab @kbd{C-c C-x @key{up}}    @tab
4970 @item @kbd{S-@key{down}}    @tab @kbd{C-c C-x @key{down}}  @tab
4971 @end multitable
4973 @node Interaction, Bugs, TTY keys, Miscellaneous
4974 @section Interaction with other packages
4975 @cindex packages, interaction with other
4976 Org-mode lives in the world of GNU Emacs and interacts in various ways
4977 with other code out there.
4979 @menu
4980 * Cooperation::                 Packages Org-mode cooperates with
4981 * Conflicts::                   Packages that lead to conflicts
4982 @end menu
4985 @node Cooperation, Conflicts, Interaction, Interaction
4986 @subsection Packages that Org-mode cooperates with
4988 @table @asis
4989 @cindex @file{calc.el}
4990 @item @file{calc.el} by Dave Gillespie
4991 Org-mode uses the calc package for implementing spreadsheet
4992 functionality in its tables (@pxref{Table calculations}).  Org-modes
4993 checks for the availability of calc by looking for the function
4994 @code{calc-eval} which should be autoloaded in your setup if calc has
4995 been installed properly.  As of Emacs 22, calc is part of the Emacs
4996 distribution.  Another possibility for interaction between the two
4997 packages is using calc for embedded calculations. @xref{Embedded Mode,
4998 , Embedded Mode, calc, GNU Emacs Calc Manual}.
4999 @cindex @file{constants.el}
5000 @item @file{constants.el} by Carsten Dominik
5001 In a table formula (@pxref{Table calculations}), it is possible to use
5002 names for natural constants or units.  Instead of defining your own
5003 constants in the variable @code{org-table-formula-constants}, install
5004 the @file{constants} package which defines a large number of constants
5005 and units, and lets you use unit prefixes like @samp{M} for
5006 @samp{Mega} etc.  You will need version 2.0 of this package, available
5007 at @url{http://www.astro.uva.nl/~dominik/Tools}. Org-mode checks for
5008 the function @code{constants-get}, which has to be autoloaded in your
5009 setup.  See the installation instructions in the file
5010 @file{constants.el}.
5011 @item @file{cdlatex.el} by Carsten Dominik
5012 @cindex @file{cdlatex.el}
5013 Org-mode can make use of the cdlatex package to efficiently enter
5014 La@TeX{} fragments into Org-mode files. See @ref{CDLaTeX mode}.
5015 @item @file{remember.el} by John Wiegley
5016 @cindex @file{remember.el}
5017 Org mode cooperates with remember, see @ref{Remember}.
5018 @file{Remember.el} is not part of Emacs, find it on the web.
5019 @cindex @file{table.el}
5020 @item @file{table.el} by Takaaki Ota
5021 Org mode cooperates with table.el, see @ref{table.el}.  @file{table.el}
5022 is part of Emacs 22.
5023 @end table
5025 @node Conflicts,  , Cooperation, Interaction
5026 @subsection Packages that lead to conflicts with Org-mode
5028 @table @asis
5030 @cindex @file{allout.el}
5031 @item @file{allout.el} by Ken Manheimer
5032 Startup of Org-mode may fail with the error message
5033 @code{(wrong-type-argument keymapp nil)} when there is an outdated
5034 version @file{allout.el} on the load path, for example the version
5035 distributed with Emacs 21.x.  Upgrade to Emacs 22 and this problem will
5036 disappear.  If for some reason you cannot do this, make sure that org.el
5037 is loaded @emph{before} @file{allout.el}, for example by putting
5038 @code{(require 'org)} early enough into your @file{.emacs} file.
5040 @cindex @file{CUA.el}
5041 @item @file{CUA.el} by Kim. F. Storm
5042 Keybindings in Org-mode conflict with the @kbd{S-<cursor>} keys
5043 used by CUA-mode (as well as pc-select-mode and s-region-mode) to
5044 select and extend the region.  If you want to use one of these
5045 packages along with Org-mode, configure the variable
5046 @code{org-CUA-compatible}.  When set, Org-mode will move the following
5047 keybindings in org-mode files, and in the agenda buffer (but not
5048 during date selection).
5050 @example
5051 S-UP    -> M-p             S-DOWN  -> M-n
5052 S-LEFT  -> M--             S-RIGHT -> M-+
5053 S-RET   -> C-S-RET
5054 @end example
5056 Yes, these are unfortunately more difficult to remember.  If you want
5057 to have other replacement keys, look at the variable
5058 @code{org-disputed-keys}.
5059 @item @file{windmove.el} by Hovav Shacham
5060 @cindex @file{windmove.el}
5061 Also this package uses the @kbd{S-<cursor>} keys, so everything written
5062 in the paragraph above about CUA mode also applies here.
5063 @end table
5066 @node Bugs,  , Interaction, Miscellaneous
5067 @section Bugs
5068 @cindex bugs
5070 Here is a list of things that should work differently, but which I
5071 have found too hard to fix.
5073 @itemize @bullet
5074 @item
5075 If a table field starts with a link, and if the corresponding table
5076 column is narrowed (@pxref{Narrow columns}) to a width too small to
5077 display the link, the field would look entirely empty even though it is
5078 not.  To prevent this, Org-mode throws an error.  The work-around is to
5079 make the column wide enough to fit the link, or to add some text (at
5080 least 2 characters) before the link in the same field.
5081 @item
5082 Narrowing table columns does not work on XEmacs, because the
5083 @code{format} function does not transport text properties.
5084 @item
5085 Text in an entry protected with the @samp{QUOTE} keyword should not
5086 autowrap.
5087 @item
5088 When the application called by @kbd{C-c C-o} to open a file link fails
5089 (for example because the application does not exist or refuses to open
5090 the file), it does so silently.  No error message is displayed.
5091 @item
5092 The remote-editing commands in the agenda buffer cannot be undone with
5093 @code{undo} called from within the agenda buffer.  But you can go to
5094 the corresponding buffer (using @key{TAB} or @key{RET} and execute
5095 @code{undo} there.
5096 @item
5097 Recalculating a table line applies the formulas from left to right.
5098 If a formula uses @emph{calculated} fields further down the row,
5099 multiple recalculation may be needed to get all fields consistent.
5100 @item
5101 A single letter cannot be made bold, for example @samp{*a*}.
5102 @item
5103 The exporters work well, but could be made more efficient.
5104 @end itemize
5107 @node Extensions and Hacking, History and Acknowledgments, Miscellaneous, Top
5108 @appendix Extensions, Hooks and Hacking
5110 This appendix lists extensions for Org-mode written by other authors.
5111 It also covers some aspects where users can easily extend the
5112 functionality of Org-mode.
5114 @menu
5115 * Extensions::                  Existing 3rd-part extensions
5116 * Dynamic blocks::              Automatically filled blocks
5117 @end menu
5119 @node Extensions, Dynamic blocks, Extensions and Hacking, Extensions and Hacking
5120 @section Third-party extensions for Org-mode
5122 The following extensions for Org-mode have been written by other people:
5124 @table @asis
5125 @cindex @file{org-mouse.el}
5126 @item @file{org-mouse.el} by Piotr Zielinski
5127 This package implements extended mouse functionality for Org-mode.  It
5128 allows you to cycle visibility and to edit the document structure with
5129 the mouse.  Best of all, it provides a context-sensitive menu on
5130 @key{mouse-3} that changes depending on the context of a mouse-click.
5131 @file{org-mouse.el} is freely available at @url{http://www.cl.cam.ac.uk/~pz215/files/org-mouse.el}.
5132 @cindex @file{org-publish.el}
5133 @item @file{org-publish.el} by David O'Toole
5134 This package provides facilities for publishing related sets of Org-mode
5135 files together with linked files like images as a webpages.  It is
5136 highly configurable and can be used for other publishing purposes as
5137 well.  As of Org-mode version 4.30, @file{org-publish.el} is part of the
5138 Org-mode distribution.  It is not yet part of Emacs, however, a delay
5139 caused by the preparations for the 22.1 release.  In the mean time,
5140 @file{org-publish.el} can be downloaded from David's site:
5141 @url{http://dto.freeshell.org/e/org-publish.el}.
5142 @cindex @file{org-blog.el}
5143 @item @file{org-blog.el} by David O'Toole
5144 A blogging plug-in for @file{org-publish.el}.@*
5145 @url{http://dto.freeshell.org/notebook/OrgMode.html}.
5146 @cindex @file{org-blogging.el}
5147 @item @file{org-blogging.el} by  Bastien Guerry
5148 Publish Org-mode files as
5149 blogs. @url{http://www.cognition.ens.fr/~guerry/org-blogging.html}.
5150 @end table
5152 @node Dynamic blocks,  , Extensions, Extensions and Hacking
5153 @section Dynamic blocks
5155 Org-mode documents can contain @emph{dynamic blocks}.  These are
5156 specially marked regions that are updated by some user-written
5157 function.  A good example for such a block is the clock table inserted
5158 by the command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
5160 Dynamic block are enclosed by a BEGIN-END structure that assigns a name
5161 to the block and can also specify parameters for the function producing
5162 the content of the block.
5164 @example
5165 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
5167 #+END:
5168 @end example
5170 Dynamic blocks are updated with the following commands
5172 @table @kbd
5173 @kindex C-c C-x C-u
5174 @item C-c C-x C-u
5175 Update dynamic block at point.
5176 @kindex C-u C-c C-x C-u
5177 @item C-u C-c C-x C-u
5178 Update all dynamic blocks in the current file.
5179 @end table
5181 Updating a dynamic block means to remove all the text between BEGIN and
5182 END, parse the BEGIN line for parameters and then call the specific
5183 writer function for this block to insert the new content.  For a block
5184 with name @code{myblock}, the writer function is
5185 @code{org-dblock-write:myblock} with as only parameter a property list
5186 with the parameters given in the begin line.  Here is a trivial example
5187 of a block that keeps track of when the block update function was last
5188 run:
5190 @example
5191 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
5193 #+END:
5194 @end example
5196 @noindent
5197 The corresponding block writer function could look like this:
5199 @lisp
5200 (defun org-dblock-write:block-update-time (params)
5201    (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
5202      (insert "Last block update at: "
5203              (format-time-string fmt (current-time)))))
5204 @end lisp
5206 If you want to make sure that all dynamic blocks are always up-to-date,
5207 you could add the function @code{org-update-all-dblocks} to a hook, for
5208 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
5209 written in a way that is does nothing in buffers that are not in Org-mode.
5211 @node History and Acknowledgments, Index, Extensions and Hacking, Top
5212 @appendix History and Acknowledgments
5213 @cindex acknowledgments
5214 @cindex history
5215 @cindex thanks
5217 Org-mode was borne in 2003, out of frustration over the user interface
5218 of the Emacs outline-mode.  All I wanted was to make working with an
5219 outline tree possible without having to remember more than 10 commands
5220 just for hiding and unhiding parts of the outline tree, and to allow to
5221 restructure a tree easily.  Visibility cycling and structure editing
5222 were originally implemented in the package @file{outline-magic.el}, but
5223 quickly moved to the more general @file{org.el}.  TODO entries, basic
5224 time stamps, and table support were added next, and highlight the two
5225 main goals that Org-mode still has today: To create a new,
5226 outline-based, plain text mode with innovative and intuitive editing
5227 features, and to incorporate project planning functionality directly
5228 into a notes file.
5230 Since the first release, hundreds of emails to me or on
5231 @code{emacs-orgmode@@gnu.org} have provided a constant stream of bug
5232 reports, feedback, new ideas, and sometimes even patches and add-on
5233 code.  Many thanks to everyone who has helped to improve this package.
5234 I am trying to keep here a list of the people who had significant
5235 influence in shaping one or more aspects of Org-mode.  The list may not
5236 be complete, if I have forgotten someone, please accept my apologies and
5237 let me know.
5239 @itemize @bullet
5240 @item
5241 @i{Thomas Baumann} contributed the code for links to the MH-E email
5242 system.
5243 @item
5244 @i{Alex Bochannek} provided a patch for rounding time stamps.
5245 @item
5246 @i{Charles Cave}'s suggestion sparked the implementation of templates
5247 for Remember.
5248 @item
5249 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
5250 specified time.
5251 @item
5252 @i{Gregory Chernov} patched support for lisp forms into table
5253 calculations and improved XEmacs compatibility, in particular by porting
5254 @file{nouline.el} to XEmacs.
5255 @item
5256 @i{Sacha Chua} suggested to copy some linking code from Planner.
5257 @item
5258 @i{Eddward DeVilla} proposed and tested checkbox statistics.
5259 @item
5260 @i{Kees Dullemond} inspired the use of narrowed tabled columns.
5261 @item
5262 @i{Christian Egli} converted the documentation into TeXInfo format,
5263 patched CSS formatting into the HTML exporter, and inspired the agenda.
5264 @item
5265 @i{Nic Ferrier} contributed mailcap and XOXO support.
5266 @item
5267 @i{Niels Giessen} had the idea to automatically archive DONE trees.
5268 @item
5269 @i{Bastien Guerry} provided extensive feedback.
5270 @item
5271 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
5272 @item
5273 @i{Leon Liu} asked for embedded LaTeX and tested it.
5274 @item
5275 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
5276 happy.
5277 @item
5278 @i{Todd Neal} provided patches for links to Info files and elisp forms.
5279 @item
5280 @i{Tim O'Callaghan} suggested in-file links, search options for general
5281 file links, and TAGS.
5282 @item
5283 @i{Oliver Oppitz} suggested multi-state TODO items.
5284 @item
5285 @i{Scott Otterson} sparked the introduction of descriptive text for
5286 links, among other things.
5287 @item
5288 @i{Pete Phillips} helped during the development of the TAGS feature, and
5289 provided frequent feedback.
5290 @item
5291 @i{T.V. Raman} reported bugs and suggested improvements.
5292 @item
5293 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
5294 control.
5295 @item
5296 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
5297 @item
5298 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
5299 conflict with @file{allout.el}.
5300 @item
5301 @i{Jason Riedy} sent a patch to fix a bug with export of TODO keywerds.
5302 @item
5303 @i{Philip Rooke} created the Org-mode reference card and provided lots
5304 of feedback.
5305 @item
5306 @i{Christian Schlauer} proposed angular brackets around links, among
5307 other things.
5308 @item
5309 Linking to VM/BBDB/GNUS was inspired by @i{Tom Shannon}'s
5310 @file{organizer-mode.el}.
5311 @item
5312 @i{Daniel Sinder} came up with the idea of internal archiving by locking
5313 subtrees.
5314 @item
5315 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
5316 chapter about publishing.
5317 @item
5318 @i{J@"urgen Vollmer} contributed code generating the table of contents
5319 in HTML output.
5320 @item
5321 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
5322 keyword.
5323 @item
5324 @i{David Wainberg} suggested archiving, and improvements to the linking
5325 system.
5326 @item
5327 @i{John Wiegley} wrote @file{emacs-wiki.el} and @file{planner.el}.  The
5328 development of Org-mode was fully independent, and both systems are
5329 really different beasts in their basic ideas and implementation details.
5330 I later looked at John's code, however, and learned from his
5331 implementation of (i) links where the link itself is hidden and only a
5332 description is shown, and (ii) popping up a calendar to select a date.
5333 @item
5334 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
5335 linking to GNUS.
5336 @item
5337 @i{Roland Winkler} requested additional keybindings to make Org-mode
5338 work on a tty.
5339 @item
5340 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed angenda blocks
5341 and contributed various ideas and code snippets.
5342 @end itemize
5345 @node Index, Key Index, History and Acknowledgments, Top
5346 @unnumbered Index
5348 @printindex cp
5350 @node Key Index,  , Index, Top
5351 @unnumbered Key Index
5353 @printindex ky
5355 @bye
5357 @ignore
5358    arch-tag: 7893d1fe-cc57-4d13-b5e5-f494a1bcc7ac
5359 @end ignore