Release 4.74
[org-mode/org-tableheadings.git] / org.texi
blobbb72cd4e4e9109a8e3dab76d2fc7555cf5a7c909
1 \input texinfo
2 @c %**start of header
3 @setfilename ../info/org
4 @settitle Org Mode Manual
6 @set VERSION 4.74
7 @set DATE April 2007
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 at science dot uva dot nl}
19 @set MAINTAINERCONTACT @uref{mailto:dominik at science dot uva dot 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, 2007 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 * orgtbl-mode::                 The table editor as minor mode
126 * The spreadsheet::             The table editor has spreadsheet capabilities.
128 The spreadsheet
130 * References::                  How to refer to another field or range
131 * Formula syntax for Calc::     Using Calc to compute stuff
132 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
133 * Field formulas::              Formulas valid for a single field
134 * Column formulas::             Formulas valid for an entire column
135 * Editing and debugging formulas::  Fixing formulas
136 * Updating the table::          Recomputing all dependent fields
137 * Advanced features::           Field names, parameters and automatic recalc
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 * Link abbreviations::          Shortcuts for writing complex links
146 * Search options::              Linking to a specific location
147 * Custom searches::             When the default search is not enough
148 * Remember::                    Org-trees store quick notes
150 Internal links
152 * Radio targets::               Make targets trigger links in plain text.
154 Remember
156 * Setting up remember::         Some code for .emacs to get things going
157 * Remember templates::          Define the outline of different note types
158 * Storing notes::               Directly get the note to where it belongs
160 TODO items
162 * TODO basics::                 Marking and displaying TODO entries
163 * TODO extensions::             Workflow and assignments
164 * Priorities::                  Some things are more important than others
165 * Breaking down tasks::         Splitting a task into manageable pieces
166 * Checkboxes::                  Tick-off lists
168 Extended use of TODO keywords
170 * Workflow states::             From TODO to DONE in steps
171 * TODO types::                  I do this, Fred the rest
172 * Multiple sets in one file::   Mixing it all, and still finding your way
173 * Per file keywords::           Different files, different requirements
175 Timestamps
177 * Time stamps::                 Assigning a time to a tree entry
178 * Creating timestamps::         Commands which insert timestamps
179 * Custom time format::          If you cannot work with the ISO format
180 * Repeating items::             Deadlines that come back again and again
181 * Progress logging::            Documenting when what work was done.
183 Creating timestamps
185 * The date/time prompt::        How org-mode helps you entering date and time
187 Progress Logging
189 * Closing items::               When was this entry marked DONE?
190 * Tracking TODO state changes::  When did the status change?
191 * Clocking work time::          When exactly did you work on this item?
193 Tags
195 * Tag inheritance::             Tags use the tree structure of the outline
196 * Setting tags::                How to assign tags to a headline
197 * Tag searches::                Searching for combinations of tags
199 Agenda Views
201 * Agenda files::                Files being searched for agenda information
202 * Agenda dispatcher::           Keyboard access to agenda views
203 * Built-in agenda views::       What is available out of the box?
204 * Presentation and sorting::    How agenda items are prepared for display
205 * Agenda commands::             Remote editing of org trees
206 * Custom agenda views::         Defining special searches and views
208 The built-in agenda views
210 * Weekly/Daily agenda::         The calendar page with current tasks
211 * Global TODO list::            All unfinished action items
212 * Matching headline tags::      Structured information with fine-tuned search
213 * Timeline::                    Time-sorted view for single file
214 * Stuck projects::              Find projects you need to review
216 Presentation and sorting
218 * Categories::                  Not all tasks are equal
219 * Time-of-day specifications::  How the agenda knows the time
220 * Sorting of agenda items::     The order of things
222 Custom agenda views
224 * Storing searches::            Type once, use often
225 * Block agenda::                All the stuff you need in a single buffer
226 * Setting Options::             Changing the rules
227 * Exporting Agenda Views::      Writing agendas to files.
228 * Extracting Agenda Information for other programs::  
230 Embedded LaTeX
232 * Math symbols::                TeX macros for symbols and Greek letters
233 * Subscripts and Superscripts::  Simple syntax for raising/lowering text
234 * LaTeX fragments::             Complex formulas made easy
235 * Processing LaTeX fragments::  Previewing LaTeX processing
236 * CDLaTeX mode::                Speed up entering of formulas
238 Exporting
240 * ASCII export::                Exporting to plain ASCII
241 * HTML export::                 Exporting to HTML
242 * XOXO export::                 Exporting to XOXO
243 * iCalendar export::            Exporting in iCalendar format
244 * Text interpretation::         How the exporter looks at the file
246 HTML export
248 * Export commands::             How to invoke HTML export
249 * Quoting HTML tags::           Using direct HTML in Org-mode
250 * Links::                       How hyperlinks get transferred to HTML
251 * Images::                      To inline or not to inline?
252 * CSS support::                 Style specifications
254 Text interpretation by the exporter
256 * Comment lines::               Some lines will not be exported
257 * Initial text::                Text before the first headline
258 * Enhancing text::              Subscripts, symbols and more
259 * Export options::              How to influence the export settings
261 Publishing
263 * Configuration::               Defining projects
264 * Sample configuration::        Example projects
265 * Triggering publication::      Publication commands
267 Configuration
269 * Project alist::               The central configuration variable
270 * Sources and destinations::    From here to there
271 * Selecting files::             What files are part of the project?
272 * Publishing action::           Setting the function doing the publishing
273 * Publishing options::          Tweaking HTML export
274 * Publishing links::            Which links keep working after publishing?
275 * Project page index::          Publishing a list of project files
277 Sample configuration
279 * Simple example::              One-component publishing
280 * Complex example::             A multi-component publishing example
282 Miscellaneous
284 * Completion::                  M-TAB knows what you need
285 * Customization::               Adapting Org-mode to your taste
286 * In-buffer settings::          Overview of the #+KEYWORDS
287 * The very busy C-c C-c key::   When in doubt, press C-c C-c
288 * Clean view::                  Getting rid of leading stars in the outline
289 * TTY keys::                    Using Org-mode on a tty
290 * Interaction::                 Other Emacs packages
291 * Bugs::                        Things which do not work perfectly
293 Interaction with other packages
295 * Cooperation::                 Packages Org-mode cooperates with
296 * Conflicts::                   Packages that lead to conflicts
298 Extensions, Hooks and Hacking
300 * Extensions::                  Existing 3rd-part extensions
301 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
302 * Dynamic blocks::              Automatically filled blocks
303 * Special agenda views::        Customized views
305 Tables in arbitrary syntax
307 * Radio tables::                Sending and receiving
308 * A LaTeX example::             Step by step, almost a tutorial
309 * Translator functions::        Copy and modify
311 @end detailmenu
312 @end menu
314 @node Introduction, Document structure, Top, Top
315 @chapter Introduction
316 @cindex introduction
318 @menu
319 * Summary::                     Brief summary of what Org-mode does
320 * Installation::                How to install a downloaded version of Org-mode
321 * Activation::                  How to activate Org-mode for certain buffers.
322 * Feedback::                    Bug reports, ideas, patches etc.
323 @end menu
325 @node Summary, Installation, Introduction, Introduction
326 @section Summary
327 @cindex summary
329 Org-mode is a mode for keeping notes, maintaining ToDo lists, and doing
330 project planning with a fast and effective plain-text system.
332 Org-mode develops organizational tasks around NOTES files that contain
333 lists or information about projects as plain text.  Org-mode is
334 implemented on top of outline-mode, which makes it possible to keep the
335 content of large files well structured.  Visibility cycling and
336 structure editing help to work with the tree.  Tables are easily created
337 with a built-in table editor.  Org-mode supports ToDo items, deadlines,
338 time stamps, and scheduling.  It dynamically compiles entries into an
339 agenda that utilizes and smoothly integrates much of the Emacs calendar
340 and diary.  Plain text URL-like links connect to websites, emails,
341 Usenet messages, BBDB entries, and any files related to the projects.
342 For printing and sharing of notes, an Org-mode file can be exported as a
343 structured ASCII file, as HTML, or (todo and agenda items only) as an
344 iCalendar file.  It can also serve as a publishing tool for a set of
345 linked webpages.
347 An important design aspect that distinguishes Org-mode from for example
348 Planner/Muse is that it encourages to store every piece of information
349 only once.  In Planner, you have project pages, day pages and possibly
350 other files, duplicating some information such as tasks.  In Org-mode,
351 you only have notes files.  In your notes you mark entries as tasks,
352 label them with tags and timestamps.  All necessary lists like a
353 schedule for the day, the agenda for a meeting, tasks lists selected by
354 tags etc are created dynamically when you need them.
356 Org-mode keeps simple things simple.  When first fired up, it should
357 feel like a straightforward, easy to use outliner.  Complexity is not
358 imposed, but a large amount of functionality is available when you need
359 it.  Org-mode can be used on different levels and in different ways, for
360 example as:
362 @example
363 @r{@bullet{} outline extension with visibility cycling and structure editing}
364 @r{@bullet{} ASCII system and table editor for taking structured notes}
365 @r{@bullet{} ASCII table editor with spreadsheet-like capabilities}
366 @r{@bullet{} TODO list editor}
367 @r{@bullet{} full agenda and planner with deadlines and work scheduling}
368 @r{@bullet{} environment to implement David Allen's GTD system}
369 @r{@bullet{} simple hypertext system, with HTML export}
370 @r{@bullet{} publishing tool to create a set of interlinked webpages}
371 @end example
373 Org-mode's automatic, context sensitive table editor with spreadsheet
374 capabilities can be integrated into any major mode by activating the
375 minor Orgtbl-mode.  Using a translation step, it can be used to maintain
376 tables in arbitrary file types, for example in LaTeX.
378 @cindex FAQ
379 There is a website for Org-mode which provides links to the newest
380 version of Org-mode, as well as additional information, frequently asked
381 questions (FAQ), links to tutorials etc.  This page is located at
382 @uref{http://www.astro.uva.nl/~dominik/Tools/org/}.
384 @page
387 @node Installation, Activation, Summary, Introduction
388 @section Installation
389 @cindex installation
390 @cindex XEmacs
392 @b{Important:} @i{If Org-mode is part of the Emacs distribution or an
393 XEmacs package, please skip this section and go directly to
394 @ref{Activation}.}
396 If you have downloaded Org-mode from the Web, you must take the
397 following steps to install it: Go into the Org-mode distribution
398 directory and edit the top section of the file @file{Makefile}.  You
399 must set the name of the Emacs binary (likely either @file{emacs} or
400 @file{xemacs}), and the paths to the directories where local Lisp and
401 Info files are kept.  If you don't have access to the system-wide
402 directories, create your own two directories for these files, enter them
403 into the Makefile, and make sure Emacs finds the Lisp files by adding
404 the following line to @file{.emacs}:
406 @example
407 (setq load-path (cons "~/path/to/lispdir" load-path))
408 @end example
410 @b{XEmacs users now need to install the file @file{noutline.el} from
411 the @file{xemacs} subdirectory of the Org-mode distribution.  Use the
412 command:}
414 @example
415 @b{make install-noutline}
416 @end example
418 @noindent Now byte-compile and install the Lisp files with the shell
419 commands:
421 @example
422 make
423 make install
424 @end example
426 @noindent If you want to install the info documentation, use this command:
428 @example
429 make install-info
430 @end example
432 @noindent Then add to @file{.emacs}:
434 @lisp
435 ;; This line only if org-mode is not part of the X/Emacs distribution.
436 (require 'org-install)
437 @end lisp
439 @node Activation, Feedback, Installation, Introduction
440 @section Activation
441 @cindex activation
442 @cindex autoload
443 @cindex global keybindings
444 @cindex keybindings, global
446 @iftex
447 @b{Important:} @i{If you use copy-and-paste to copy lisp code from the
448 PDF documentation to your .emacs file, the single quote character comes
449 out incorrectly and the code will not work.  You need to fix the single
450 quotes by hand, or copy from Info documentation.}
451 @end iftex
453 Add the following lines to your @file{.emacs} file.  The last two lines
454 define @emph{global} keys for the commands @command{org-store-link} and
455 @command{org-agenda} - please choose suitable keys yourself.
457 @lisp
458 ;; The following lines are always needed.  Choose your own keys.
459 (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
460 (define-key global-map "\C-cl" 'org-store-link)
461 (define-key global-map "\C-ca" 'org-agenda)
462 @end lisp
464 Furthermore, you must activate @code{font-lock-mode} in org-mode
465 buffers, because significant functionality depends on font-locking being
466 active.  You can do this with either one of the following two lines
467 (XEmacs user must use the second option):
468 @lisp
469 (global-font-lock-mode 1)                     ; for all buffers
470 (add-hook 'org-mode-hook 'turn-on-font-lock)  ; org-mode buffers only
471 @end lisp
473 @cindex org-mode, turning on
474 With this setup, all files with extension @samp{.org} will be put
475 into Org-mode.  As an alternative, make the first line of a file look
476 like this:
478 @example
479 MY PROJECTS    -*- mode: org; -*-
480 @end example
482 @noindent which will select Org-mode for this buffer no matter what
483 the file's name is.  See also the variable
484 @code{org-insert-mode-line-in-empty-file}.
486 @node Feedback,  , Activation, Introduction
487 @section Feedback
488 @cindex feedback
489 @cindex bug reports
490 @cindex maintainer
491 @cindex author
493 If you find problems with Org-mode, or if you have questions, remarks,
494 or ideas about it, please contact the maintainer @value{MAINTAINER} at
495 @value{MAINTAINEREMAIL}.
497 For bug reports, please provide as much information as possible,
498 including the version information of Emacs (@kbd{C-h v emacs-version
499 @key{RET}}) and Org-mode (@kbd{C-h v org-version @key{RET}}), as well as
500 the Org-mode related setup in @file{.emacs}.  If an error occurs, a
501 backtrace can be very useful (see below on how to create one).  Often a
502 small example file helps, along with clear information about:
504 @enumerate
505 @item What exactly did you do?
506 @item What did you expect to happen?
507 @item What happened instead?
508 @end enumerate
509 @noindent Thank you for helping to improve this mode.
511 @subsubheading How to create a useful backtrace
513 @cindex backtrace of an error
514 If working with Org-mode produces an error with a message you don't
515 understand, you may have hit a bug.  The best way to report this is by
516 providing, in addition to what was mentioned above, a @emph{Backtrace}.
517 This is information from the built-in debugger about where and how the
518 error occurred.  Here is how to produce a useful backtrace:
520 @enumerate
521 @item
522 Start a fresh Emacs or XEmacs, and make sure that it will load the
523 original Lisp code in @file{org.el} instead of the compiled version in
524 @file{org.elc}.  The backtrace contains much more information if it is
525 produced with uncompiled code.  To do this, either rename @file{org.elc}
526 to something else before starting Emacs, or ask Emacs explicitly to load
527 @file{org.el} by using the command line
528 @example
529 emacs -l /path/to/org.el
530 @end example
531 @item
532 Go to the @code{Options} menu and select @code{Enter Debugger on Error}
533 (XEmacs has this option in the @code{Troubleshooting} sub-menu).
534 @item
535 Do whatever you have to do to hit the error.  Don't forget to
536 document the steps you take.
537 @item
538 When you hit the error, a @file{*Backtrace*} buffer will appear on the
539 screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
540 attach it to your bug report.
541 @end enumerate
543 @node Document structure, Tables, Introduction, Top
544 @chapter Document Structure
545 @cindex document structure
546 @cindex structure of document
548 Org-mode is based on outline mode and provides flexible commands to
549 edit the structure of the document.
551 @menu
552 * Outlines::                    Org-mode is based on outline-mode
553 * Headlines::                   How to typeset org-tree headlines
554 * Visibility cycling::          Show and hide, much simplified
555 * Motion::                      Jumping to other headlines
556 * Structure editing::           Changing sequence and level of headlines
557 * Archiving::                   Move done task trees to a different place
558 * Sparse trees::                Matches embedded in context
559 * Plain lists::                 Additional structure within an entry
560 @end menu
562 @node Outlines, Headlines, Document structure, Document structure
563 @section Outlines
564 @cindex outlines
565 @cindex outline-mode
567 Org-mode is implemented on top of outline-mode.  Outlines allow to
568 organize a document in a hierarchical structure, which (at least for
569 me) is the best representation of notes and thoughts.  Overview over
570 this structure is achieved by folding (hiding) large parts of the
571 document to show only the general document structure and the parts
572 currently being worked on.  Org-mode greatly simplifies the use of
573 outlines by compressing the entire show/hide functionality into a
574 single command @command{org-cycle}, which is bound to the @key{TAB}
575 key.
577 @node Headlines, Visibility cycling, Outlines, Document structure
578 @section Headlines
579 @cindex headlines
580 @cindex outline tree
582 Headlines define the structure of an outline tree.  The headlines in
583 Org-mode start with one or more stars, on the left margin@footnote{See
584 the variable @code{org-special-ctrl-a} to configure special behavior of
585 @kbd{C-a} in headlines.}.  For example:
587 @example
588 * Top level headline
589 ** Second level
590 *** 3rd level
591     some text
592 *** 3rd level
593     more text
595 * Another top level headline
596 @end example
598 @noindent Some people find the many stars too noisy and would prefer an
599 outline that has whitespace followed by a single star as headline
600 starters.  @ref{Clean view} describes a setup to realize this.
602 An empty line after the end of a subtree is considered part of it and
603 will be hidden when the subtree is folded.  However, if you leave at
604 least two empty lines, one empty line will remain visible after folding
605 the subtree, in order to structure the collapsed view.  See the
606 variable @code{org-cycle-separator-lines} for modifying this behavior.
608 @node Visibility cycling, Motion, Headlines, Document structure
609 @section Visibility cycling
610 @cindex cycling, visibility
611 @cindex visibility cycling
612 @cindex trees, visibility
613 @cindex show hidden text
614 @cindex hide text
616 Outlines make it possible to hide parts of the text in the buffer.
617 Org-mode uses just two commands, bound to @key{TAB} and
618 @kbd{S-@key{TAB}} to change the visibility in the buffer.
620 @cindex subtree visibility states
621 @cindex subtree cycling
622 @cindex folded, subtree visibility state
623 @cindex children, subtree visibility state
624 @cindex subtree, subtree visibility state
625 @table @kbd
626 @kindex @key{TAB}
627 @item @key{TAB}
628 @emph{Subtree cycling}: Rotate current subtree among the states
630 @example
631 ,-> FOLDED -> CHILDREN -> SUBTREE --.
632 '-----------------------------------'
633 @end example
635 The cursor must be on a headline for this to work@footnote{see, however,
636 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
637 beginning of the buffer and the first line is not a headline, then
638 @key{TAB} actually runs global cycling (see below)@footnote{see the
639 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
640 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
642 @cindex global visibility states
643 @cindex global cycling
644 @cindex overview, global visibility state
645 @cindex contents, global visibility state
646 @cindex show all, global visibility state
647 @kindex S-@key{TAB}
648 @item S-@key{TAB}
649 @itemx C-u @key{TAB}
650 @emph{Global cycling}: Rotate the entire buffer among the states
652 @example
653 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
654 '--------------------------------------'
655 @end example
657 When @kbd{S-@key{TAB}} is called with a numerical prefix N, the CONTENTS
658 view up to headlines of level N will be shown.
659 Note that inside tables, @kbd{S-@key{TAB}} jumps to the previous field.
661 @cindex show all, command
662 @kindex C-c C-a
663 @item C-c C-a
664 Show all.
665 @kindex C-c C-r
666 @item C-c C-r
667 Reveal context around point, showing the current entry, the following
668 heading and the hierarchy above.  Useful for working near a location
669 exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda
670 command (@pxref{Agenda commands}).  With prefix arg show, on each
671 level, all sibling headings.
672 @kindex C-c C-x b
673 @item C-c C-x b
674 Show the current subtree in an indirect buffer@footnote{The indirect
675 buffer
676 @ifinfo
677 (@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
678 @end ifinfo
679 @ifnotinfo
680 (see the Emacs manual for more information about indirect buffers)
681 @end ifnotinfo
682 will contain the entire buffer, but will be narrowed to the current
683 tree.  Editing the indirect buffer will also change the original buffer,
684 but without affecting visibility in that buffer.}.  With numerical
685 prefix ARG, go up to this level and then take that tree.  If ARG is
686 negative, go up that many levels.  With @kbd{C-u} prefix, do not remove
687 the previously used indirect buffer.
688 @end table
690 When Emacs first visits an Org-mode file, the global state is set to
691 OVERVIEW, i.e. only the top level headlines are visible.  This can be
692 configured through the variable @code{org-startup-folded}, or on a
693 per-file basis by adding one of the following lines anywhere in the
694 buffer:
696 @example
697 #+STARTUP: overview
698 #+STARTUP: content
699 #+STARTUP: showall
700 @end example
702 @node Motion, Structure editing, Visibility cycling, Document structure
703 @section Motion
704 @cindex motion, between headlines
705 @cindex jumping, to headlines
706 @cindex headline navigation
707 The following commands jump to other headlines in the buffer.
709 @table @kbd
710 @kindex C-c C-n
711 @item C-c C-n
712 Next heading.
713 @kindex C-c C-p
714 @item C-c C-p
715 Previous heading.
716 @kindex C-c C-f
717 @item C-c C-f
718 Next heading same level.
719 @kindex C-c C-b
720 @item C-c C-b
721 Previous heading same level.
722 @kindex C-c C-u
723 @item C-c C-u
724 Backward to higher level heading.
725 @kindex C-c C-j
726 @item C-c C-j
727 Jump to a different place without changing the current outline
728 visibility.  Shows the document structure in a temporary buffer, where
729 you can use the following keys to find your destination:
730 @example
731 @key{TAB}         @r{Cycle visibility.}
732 @key{down} / @key{up}   @r{Next/previous visible headline.}
733 n / p        @r{Next/previous visible headline.}
734 f / b        @r{Next/previous headline same level.}
735 u            @r{One level up.}
736 0-9          @r{Digit argument.}
737 @key{RET}         @r{Select this location.}
738 @end example
739 @end table
741 @node Structure editing, Archiving, Motion, Document structure
742 @section Structure editing
743 @cindex structure editing
744 @cindex headline, promotion and demotion
745 @cindex promotion, of subtrees
746 @cindex demotion, of subtrees
747 @cindex subtree, cut and paste
748 @cindex pasting, of subtrees
749 @cindex cutting, of subtrees
750 @cindex copying, of subtrees
751 @cindex subtrees, cut and paste
753 @table @kbd
754 @kindex M-@key{RET}
755 @item M-@key{RET}
756 Insert new heading with same level as current.  If the cursor is in a
757 plain list item, a new item is created (@pxref{Plain lists}).  To force
758 creation of a new headline, use a prefix arg, or first press @key{RET}
759 to get to the beginning of the next line.  When this command is used in
760 the middle of a line, the line is split and the rest of the line becomes
761 the new headline.  If the command is used at the beginning of a
762 headline, the new headline is created before the current line.  If at
763 the beginning of any other line, the content of that line is made the
764 new heading.  If the command is used at the end of a folded subtree
765 (i.e. behind the ellipses at the end of a headline), then a headline
766 like the current one will be inserted after the end of the subtree.
767 @kindex M-S-@key{RET}
768 @item M-S-@key{RET}
769 Insert new TODO entry with same level as current heading.
770 @kindex M-@key{left}
771 @item M-@key{left}
772 Promote current heading by one level.
773 @kindex M-@key{right}
774 @item M-@key{right}
775 Demote current heading by one level.
776 @kindex M-S-@key{left}
777 @item M-S-@key{left}
778 Promote the current subtree by one level.
779 @kindex M-S-@key{right}
780 @item M-S-@key{right}
781 Demote the current subtree by one level.
782 @kindex M-S-@key{up}
783 @item M-S-@key{up}
784 Move subtree up (swap with previous subtree of same
785 level).
786 @kindex M-S-@key{down}
787 @item M-S-@key{down}
788 Move subtree down (swap with next subtree of same level).
789 @kindex C-c C-x C-w
790 @kindex C-c C-x C-k
791 @item C-c C-x C-w
792 @itemx C-c C-x C-k
793 Kill subtree, i.e. remove it from buffer but save in kill ring.
794 @kindex C-c C-x M-w
795 @item C-c C-x M-w
796 Copy subtree to kill ring.
797 @kindex C-c C-x C-y
798 @item C-c C-x C-y
799 Yank subtree from kill ring.  This does modify the level of the subtree to
800 make sure the tree fits in nicely at the yank position.  The yank
801 level can also be specified with a prefix arg, or by yanking after a
802 headline marker like @samp{****}.
803 @kindex C-c ^
804 @item C-c ^
805 Sort same-level entries.  When there is an active region, all entries in
806 the region will be sorted.  Otherwise the children of the current
807 headline are sorted.  The command prompts for the sorting method, which
808 can be alphabetically, numerically, by time (using the first time stamp
809 in each entry), and each of these in reverse order.  With a @kbd{C-u}
810 prefix, sorting will be case-sensitive.  With two @kbd{C-u C-u}
811 prefixes, duplicate entries will also be removed.
812 @end table
814 @cindex region, active
815 @cindex active region
816 @cindex transient-mark-mode
817 When there is an active region (transient-mark-mode), promotion and
818 demotion work on all headlines in the region.  To select a region of
819 headlines, it is best to place both point and mark at the beginning of a
820 line, mark at the beginning of the first headline, and point at the line
821 just after the last headline to change.  Note that when the cursor is
822 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
823 functionality.
825 @node Archiving, Sparse trees, Structure editing, Document structure
826 @section Archiving
827 @cindex archiving
829 When a project represented by a (sub)tree is finished, you may want
830 to move the tree out of the way and to stop it from contributing to the
831 agenda.  Org-mode knows two ways of archiving.  You can mark a tree with
832 the ARCHIVE tag, or you can move an entire (sub)tree to a different
833 location.
835 @menu
836 * ARCHIVE tag::                 Marking a tree as inactive
837 * Moving subtrees::             Moving a tree to an archive file
838 @end menu
840 @node ARCHIVE tag, Moving subtrees, Archiving, Archiving
841 @subsection The ARCHIVE tag
842 @cindex internal archiving
844 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
845 its location in the outline tree, but behaves in the following way:
846 @itemize @minus
847 @item
848 It does not open when you attempt to do so with a visibility cycling
849 command (@pxref{Visibility cycling}).  You can force cycling archived
850 subtrees with @kbd{C-@key{TAB}}, or by setting the option
851 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
852 @code{show-all} will open archived subtrees.
853 @item
854 During sparse tree construction (@pxref{Sparse trees}), matches in
855 archived subtrees are not exposed, unless you configure the option
856 @code{org-sparse-tree-open-archived-trees}.
857 @item
858 During agenda view construction (@pxref{Agenda views}), the content of
859 archived trees is ignored unless you configure the option
860 @code{org-agenda-skip-archived-trees}.
861 @item
862 Archived trees are not exported (@pxref{Exporting}), only the headline
863 is.  Configure the details using the variable
864 @code{org-export-with-archived-trees}.
865 @end itemize
867 The following commands help managing the ARCHIVE tag:
869 @table @kbd
870 @kindex C-c C-x C-a
871 @item C-c C-x C-a
872 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
873 the headline changes to a shadowish face, and the subtree below it is
874 hidden.
875 @kindex C-u C-c C-x C-a
876 @item C-u C-c C-x C-a
877 Check if any direct children of the current headline should be archived.
878 To do this, each subtree is checked for open TODO entries.  If none are
879 found, the command offers to set the ARCHIVE tag for the child.  If the
880 cursor is @emph{not} on a headline when this command is invoked, the
881 level 1 trees will be checked.
882 @kindex C-@kbd{TAB}
883 @item C-@kbd{TAB}
884 Cycle a tree even if it is tagged with ARCHIVE.
885 @end table
887 @node Moving subtrees,  , ARCHIVE tag, Archiving
888 @subsection Moving subtrees
889 @cindex external archiving
891 Once an entire project is finished, you may want to move it to a
892 different location, either in the current file, or even in a different
893 file, the archive file.
895 @table @kbd
896 @kindex C-c C-x C-s
897 @item C-c C-x C-s
898 Archive the subtree starting at the cursor position to the location
899 given by @code{org-archive-location}.
900 @kindex C-u C-c C-x C-s
901 @item C-u C-c C-x C-s
902 Check if any direct children of the current headline could be moved to
903 the archive.  To do this, each subtree is checked for open TODO entries.
904 If none are found, the command offers to move it to the archive
905 location.  If the cursor is @emph{not} on a headline when this command
906 is invoked, the level 1 trees will be checked.
907 @end table
909 @cindex archive locations
910 The default archive location is a file in the same directory as the
911 current file, with the name derived by appending @file{_archive} to the
912 current file name.  For information and examples on how to change this,
913 see the documentation string of the variable
914 @code{org-archive-location}.  There is also an in-buffer option for
915 setting this variable, for example
917 @example
918 #+ARCHIVE: %s_done::
919 @end example
921 @noindent
922 You may have several such lines in the buffer, they will then be valid
923 for the entries following the line (the first will also apply to any
924 text before it).
926 @node Sparse trees, Plain lists, Archiving, Document structure
927 @section Sparse trees
928 @cindex sparse trees
929 @cindex trees, sparse
930 @cindex folding, sparse trees
931 @cindex occur, command
933 An important feature of Org-mode is the ability to construct
934 @emph{sparse trees} for selected information in an outline tree.  A
935 sparse tree means that the entire document is folded as much as
936 possible, but the selected information is made visible along with the
937 headline structure above it@footnote{See also the variables
938 @code{org-show-hierarchy-above}, @code{org-show-following-heading}, and
939 @code{org-show-siblings} for detailed control on how much context is
940 shown around each match.}.  Just try it out and you will see immediately
941 how it works.
943 Org-mode contains several commands creating such trees.  The most
944 basic one is @command{org-occur}:
946 @table @kbd
947 @kindex C-c /
948 @item C-c /
949 Occur.  Prompts for a regexp and shows a sparse tree with all matches.
950 If the match is in a headline, the headline is made visible.  If the
951 match is in the body of an entry, headline and body are made visible.
952 In order to provide minimal context, also the full hierarchy of
953 headlines above the match is shown, as well as the headline following
954 the match.  Each match is also highlighted; the highlights disappear
955 when the buffer is changes an editing command, or by pressing @kbd{C-c
956 C-c}.  When called with a @kbd{C-u} prefix argument, previous highlights
957 are kept, so several calls to this command can be stacked.
958 @end table
959 @noindent
960 For frequently used sparse trees of specific search strings, you can
961 use the variable @code{org-agenda-custom-commands} to define fast
962 keyboard access to specific sparse trees.  These commands will then be
963 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
964 For example:
966 @lisp
967 (setq org-agenda-custom-commands
968       '(("f" occur-tree "FIXME")))
969 @end lisp
971 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
972 a sparse tree matching the string @samp{FIXME}.
974 Other commands use sparse trees as well.  For example @kbd{C-c
975 C-v} creates a sparse TODO tree (@pxref{TODO basics}).
977 @kindex C-c C-e v
978 @cindex printing sparse trees
979 @cindex visible text, printing
980 To print a sparse tree, you can use the Emacs command
981 @code{ps-print-buffer-with-faces} which does not print invisible parts
982 of the document @footnote{This does not work under XEmacs, because
983 XEmacs uses selective display for outlining, not text properties.}.
984 Or you can use the command @kbd{C-c C-e v} to export only the visible
985 part of the document and print the resulting file.
987 @node Plain lists,  , Sparse trees, Document structure
988 @section Plain lists
989 @cindex plain lists
990 @cindex lists, plain
991 @cindex lists, ordered
992 @cindex ordered lists
994 Within an entry of the outline tree, hand-formatted lists can provide
995 additional structure.  They also provide a way to create lists of
996 checkboxes (@pxref{Checkboxes}).  Org-mode supports editing such lists,
997 and the HTML exporter (@pxref{Exporting}) does parse and format them.
999 Org-mode knows ordered and unordered lists.  Unordered list items start
1000 with @samp{-}, @samp{+}, or @samp{*}@footnote{When using @samp{*} as a
1001 bullet, lines must be indented or they will be seen as top-level
1002 headlines.  Also, when you are hiding leading stars to get a clean
1003 outline view, plain list items starting with a star are visually
1004 indistinguishable from true headlines.  In short: even though @samp{*}
1005 is supported, it may be better not to use it for plain list items.} as
1006 bullets.  Ordered list items start with @samp{1.} or @samp{1)}.  Items
1007 belonging to the same list must have the same indentation on the first
1008 line.  In particular, if an ordered list reaches number @samp{10.}, then
1009 the 2--digit numbers must be written left-aligned with the other numbers
1010 in the list.  Indentation also determines the end of a list item.  It
1011 ends before the next line that is indented like the bullet/number, or
1012 less.  Empty lines are part of the previous item, so you can have
1013 several paragraphs in one item.  If you would like an emtpy line to
1014 terminate all currently open plain lists, configure the variable
1015 @code{org-empty-line-terminates-plain-lists}.  Here is an for example:
1017 @example
1018 @group
1019 ** Lord of the Rings
1020    My favorite scenes are (in this order)
1021    1. The attack of the Rohirrim
1022    2. Eowyns fight with the witch king
1023       + this was already my favorite scene in the book
1024       + I really like Miranda Otto.
1025    3. Peter Jackson being shot by Legolas
1026        - on DVD only
1027       He makes a really funny face when it happens.
1028    But in the end, not individual scenes matter but the film as a whole.
1029 @end group
1030 @end example
1032 Org-mode supports these lists by tuning filling and wrapping commands to
1033 deal with them correctly@footnote{Org-mode only changes the filling
1034 settings for Emacs.  For XEmacs, you should use Kyle E. Jones'
1035 @file{filladapt.el}.  To turn this on,  put into @file{.emacs}:
1036 @example
1037 (require 'filladapt)
1038 @end example
1041 The following commands act on items when the cursor is in the first line
1042 of an item (the line with the bullet or number).
1044 @table @kbd
1045 @kindex @key{TAB}
1046 @item @key{TAB}
1047 Items can be folded just like headline levels if you set the variable
1048 @code{org-cycle-include-plain-lists}.  The level of an item is then
1049 given by the indentation of the bullet/number.  Items are always
1050 subordinate to real headlines, however; the hierarchies remain
1051 completely separated.
1052 @kindex M-@key{RET}
1053 @item M-@key{RET}
1054 Insert new item at current level.  With prefix arg, force a new heading
1055 (@pxref{Structure editing}).  If this command is used in the middle of a
1056 line, the line is @emph{split} and the rest of the line becomes the new
1057 item.  If this command is executed in the @emph{whitespace before a bullet or
1058 number}, the new item is created @emph{before} the current item.  If the
1059 command is executed in the white space before the text that is part of
1060 an item but does not contain the bullet, a bullet is added to the
1061 current line.
1062 @kindex M-S-@key{RET}
1063 @item M-S-@key{RET}
1064 Insert a new item with a checkbox (@pxref{Checkboxes}).
1065 @kindex S-@key{up}
1066 @kindex S-@key{down}
1067 @item S-@key{up}
1068 @itemx S-@key{down}
1069 Jump to the previous/next item in the current list.
1070 @kindex M-S-@key{up}
1071 @kindex M-S-@key{down}
1072 @item M-S-@key{up}
1073 @itemx M-S-@key{down}
1074 Move the item including subitems up/down (swap with previous/next item
1075 of same indentation).  If the list is ordered, renumbering is
1076 automatic.
1077 @kindex M-S-@key{left}
1078 @kindex M-S-@key{right}
1079 @item M-S-@key{left}
1080 @itemx M-S-@key{right}
1081 Decrease/increase the indentation of the item, including subitems.
1082 Initially, the item tree is selected based on current indentation.
1083 When these commands are executed several times in direct succession,
1084 the initially selected region is used, even if the new indentation
1085 would imply a different hierarchy.  To use the new hierarchy, break
1086 the command chain with a cursor motion or so.
1087 @kindex C-c C-c
1088 @item C-c C-c
1089 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1090 state of the checkbox.  Otherwise, if this is an ordered list, renumber
1091 the ordered list at the cursor.
1092 @end table
1094 @node Tables, Hyperlinks, Document structure, Top
1095 @chapter Tables
1096 @cindex tables
1097 @cindex editing tables
1099 Org-mode has a very fast and intuitive table editor built-in.
1100 Spreadsheet-like calculations are supported in connection with the
1101 Emacs @file{calc} package.
1103 @menu
1104 * Built-in table editor::       Simple tables
1105 * Narrow columns::              Stop wasting space in tables   
1106 * orgtbl-mode::                 The table editor as minor mode
1107 * The spreadsheet::             The table editor has spreadsheet capabilities.
1108 @end menu
1110 @node Built-in table editor, Narrow columns, Tables, Tables
1111 @section The built-in table editor
1112 @cindex table editor, built-in
1114 Org-mode makes it easy to format tables in plain ASCII.  Any line with
1115 @samp{|} as the first non-white character is considered part of a
1116 table.  @samp{|} is also the column separator.  A table might look
1117 like this:
1119 @example
1120 | Name  | Phone | Age |
1121 |-------+-------+-----|
1122 | Peter |  1234 |  17 |
1123 | Anna  |  4321 |  25 |
1124 @end example
1126 A table is re-aligned automatically each time you press @key{TAB} or
1127 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
1128 the next field (@key{RET} to the next row) and creates new table rows
1129 at the end of the table or before horizontal lines.  The indentation
1130 of the table is set by the first line.  Any line starting with
1131 @samp{|-} is considered as a horizontal separator line and will be
1132 expanded on the next re-align to span the whole table width.  So, to
1133 create the above table, you would only type
1135 @example
1136 |Name|Phone|Age|
1138 @end example
1140 @noindent and then press @key{TAB} to align the table and start filling in
1141 fields.
1143 When typing text into a field, Org-mode treats @key{DEL},
1144 @key{Backspace}, and all character keys in a special way, so that
1145 inserting and deleting avoids shifting other fields.  Also, when
1146 typing @emph{immediately after the cursor was moved into a new field
1147 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
1148 field is automatically made blank.  If this behavior is too
1149 unpredictable for you, configure the variables
1150 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
1152 @table @kbd
1153 @tsubheading{Creation and conversion}
1154 @kindex C-c |
1155 @item C-c |
1156 Convert the active region to table. If every line contains at least one
1157 TAB character, the function assumes that the material is tab separated.
1158 If not, lines are split at whitespace into fields.  You can use a prefix
1159 argument to indicate the minimum number of consecutive spaces required
1160 to identify a field separator (default: just one).@* 
1161 If there is no active region, this command creates an empty Org-mode
1162 table.  But it's easier just to start typing, like
1163 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
1165 @tsubheading{Re-aligning and field motion}
1166 @kindex C-c C-c
1167 @item C-c C-c
1168 Re-align the table without moving the cursor.
1170 @kindex @key{TAB}
1171 @item @key{TAB}
1172 Re-align the table, move to the next field.  Creates a new row if
1173 necessary.
1175 @kindex S-@key{TAB}
1176 @item S-@key{TAB}
1177 Re-align, move to previous field.
1179 @kindex @key{RET}
1180 @item @key{RET}
1181 Re-align the table and move down to next row.  Creates a new row if
1182 necessary.  At the beginning or end of a line, @key{RET} still does
1183 NEWLINE, so it can be used to split a table.
1185 @tsubheading{Column and row editing}
1186 @kindex M-@key{left}
1187 @kindex M-@key{right}
1188 @item M-@key{left}
1189 @itemx M-@key{right}
1190 Move the current column left/right.
1192 @kindex M-S-@key{left}
1193 @item M-S-@key{left}
1194 Kill the current column.
1196 @kindex M-S-@key{right}
1197 @item M-S-@key{right}
1198 Insert a new column to the left of the cursor position.
1200 @kindex M-@key{up}
1201 @kindex M-@key{down}
1202 @item M-@key{up}
1203 @itemx M-@key{down}
1204 Move the current row up/down.
1206 @kindex M-S-@key{up}
1207 @item M-S-@key{up}
1208 Kill the current row or horizontal line.
1210 @kindex M-S-@key{down}
1211 @item M-S-@key{down}
1212 Insert a new row above (with arg: below) the current row.
1214 @kindex C-c -
1215 @item C-c -
1216 Insert a horizontal line below current row. With prefix arg, the line
1217 is created above the current line.
1219 @kindex C-c ^
1220 @item C-c ^
1221 Sort the table lines in the region.  The position of point indicates the
1222 column to be used for sorting, and the range of lines is the range
1223 between the nearest horizontal separator lines, or the entire table.  If
1224 point is before the first column, you will be prompted for the sorting
1225 column.  If there is an active region, the mark specifies the first line
1226 and the sorting column, while point should be in the last line to be
1227 included into the sorting.  The command prompts for the sorting type
1228 (alphabetically, numerically, or by time).  When called with a prefix
1229 argument, alphabetic sorting will be case-sensitive.
1231 @tsubheading{Regions}
1232 @kindex C-c C-x M-w
1233 @item C-c C-x M-w
1234 Copy a rectangular region from a table to a special clipboard.  Point
1235 and mark determine edge fields of the rectangle.  The process ignores
1236 horizontal separator lines.
1238 @kindex C-c C-x C-w
1239 @item C-c C-x C-w
1240 Copy a rectangular region from a table to a special clipboard, and
1241 blank all fields in the rectangle.  So this is the ``cut'' operation.
1243 @kindex C-c C-x C-y
1244 @item C-c C-x C-y
1245 Paste a rectangular region into a table.
1246 The upper right corner ends up in the current field.  All involved fields
1247 will be overwritten.  If the rectangle does not fit into the present table,
1248 the table is enlarged as needed.  The process ignores horizontal separator
1249 lines.
1251 @kindex C-c C-q
1252 @item C-c C-q
1253 Wrap several fields in a column like a paragraph.  If there is an active
1254 region, and both point and mark are in the same column, the text in the
1255 column is wrapped to minimum width for the given number of lines.  A
1256 prefix ARG may be used to change the number of desired lines.  If there
1257 is no region, the current field is split at the cursor position and the
1258 text fragment to the right of the cursor is prepended to the field one
1259 line down. If there is no region, but you specify a prefix ARG, the
1260 current field is made blank, and the content is appended to the field
1261 above.
1263 @tsubheading{Calculations}
1264 @cindex formula, in tables
1265 @cindex calculations, in tables
1266 @cindex region, active
1267 @cindex active region
1268 @cindex transient-mark-mode
1269 @kindex C-c +
1270 @item C-c +
1271 Sum the numbers in the current column, or in the rectangle defined by
1272 the active region.  The result is shown in the echo area and can
1273 be inserted with @kbd{C-y}.
1275 @kindex S-@key{RET}
1276 @item S-@key{RET}
1277 When current field is empty, copy from first non-empty field above.
1278 When not empty, copy current field down to next row and move cursor
1279 along with it.  Depending on the variable
1280 @code{org-table-copy-increment}, integer field values will be
1281 incremented during copy.  This key is also used by CUA-mode
1282 (@pxref{Cooperation}).
1284 @tsubheading{Miscellaneous}
1285 @kindex C-c `
1286 @item C-c `
1287 Edit the current field in a separate window.  This is useful for fields
1288 that are not fully visible (@pxref{Narrow columns}).  When called with a
1289 @kbd{C-u} prefix, just make the full field visible, so that it can be
1290 edited in place.
1292 @kindex C-c @key{TAB}
1293 @item C-c @key{TAB}
1294 This is an alias for @kbd{C-u C-c `} to make the current field fully
1295 visible.
1297 @item M-x org-table-import
1298 Import a file as a table.  The table should be TAB- or whitespace
1299 separated.  Useful, for example, to import an Excel table or data from a
1300 database, because these programs generally can write TAB-separated text
1301 files.  This command works by inserting the file into the buffer and
1302 then converting the region to a table.  Any prefix argument is passed on
1303 to the converter, which uses it to determine the separator.
1304 @item C-c |
1305 Tables can also be imported by pasting tabular text into the org-mode
1306 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
1307 @kbd{C-c |} command (see above under @i{Creation and conversion}.
1309 @item M-x org-table-export
1310 Export the table as a TAB-separated file.  Useful for data exchange with,
1311 for example, Excel or database programs.
1312 @end table
1314 If you don't like the automatic table editor because it gets in your
1315 way on lines which you would like to start with @samp{|}, you can turn
1316 it off with
1318 @lisp
1319 (setq org-enable-table-editor nil)
1320 @end lisp
1322 @noindent Then the only table command that still works is
1323 @kbd{C-c C-c} to do a manual re-align.
1325 @node Narrow columns, orgtbl-mode, Built-in table editor, Tables
1326 @section Narrow columns
1327 @cindex narrow columns in tables
1329 The width of columns is automatically determined by the table editor.
1330 Sometimes a single field or a few fields need to carry more text,
1331 leading to inconveniently wide columns.  To limit@footnote{This feature
1332 does not work on XEmacs.} the width of a column, one field anywhere in
1333 the column may contain just the string @samp{<N>} where @samp{N} is an
1334 integer specifying the width of the column in characters.  The next
1335 re-align will then set the width of this column to no more than this
1336 value.
1338 @example
1339 @group
1340 |---+------------------------------|               |---+--------|
1341 |   |                              |               |   | <6>    |
1342 | 1 | one                          |               | 1 | one    |
1343 | 2 | two                          |     ----\     | 2 | two    |
1344 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
1345 | 4 | four                         |               | 4 | four   |
1346 |---+------------------------------|               |---+--------|
1347 @end group
1348 @end example
1350 @noindent
1351 Fields that are wider become clipped and end in the string @samp{=>}.
1352 Note that the full text is still in the buffer, it is only invisible.
1353 To see the full text, hold the mouse over the field - a tool-tip window
1354 will show the full content.  To edit such a field, use the command
1355 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
1356 open a new window with the full field.  Edit it and finish with @kbd{C-c
1357 C-c}.
1359 When visiting a file containing a table with narrowed columns, the
1360 necessary character hiding has not yet happened, and the table needs to
1361 be aligned before it looks nice.  Setting the option
1362 @code{org-startup-align-all-tables} will realign all tables in a file
1363 upon visiting, but also slow down startup.  You can also set this option
1364 on a per-file basis with:
1366 @example
1367 #+STARTUP: align
1368 #+STARTUP: noalign
1369 @end example
1371 @node orgtbl-mode, The spreadsheet, Narrow columns, Tables
1372 @section The Orgtbl minor mode
1373 @cindex orgtbl-mode
1374 @cindex minor mode for tables
1376 If you like the intuitive way the Org-mode table editor works, you
1377 might also want to use it in other modes like text-mode or mail-mode.
1378 The minor mode Orgtbl-mode makes this possible.  You can always toggle
1379 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
1380 example in mail mode, use
1382 @lisp
1383 (add-hook 'mail-mode-hook 'turn-on-orgtbl)
1384 @end lisp
1386 Furthermore, with some special setup, it is possible to maintain tables
1387 in arbitrary syntax with Orgtbl-mode.  For example, it is possible to
1388 construct LaTeX tables with the underlying ease and power of
1389 Orgtbl-mode, including spreadsheet capabilities.  For details, see
1390 @ref{Tables in arbitrary syntax}.
1392 @node The spreadsheet,  , orgtbl-mode, Tables
1393 @section The spreadsheet
1394 @cindex calculations, in tables
1395 @cindex spreadsheet capabilities
1396 @cindex @file{calc} package
1398 The table editor makes use of the Emacs @file{calc} package to implement
1399 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
1400 derive fields from other fields.  While fully featured, Org-mode's
1401 implementation is not identical to other spreadsheets.  For example,
1402 Org-mode knows the concept of a @emph{column formula} that will be
1403 applied to all non-header fields in a column without having to copy the
1404 formula to each relevant field.
1406 @menu
1407 * References::                  How to refer to another field or range
1408 * Formula syntax for Calc::     Using Calc to compute stuff
1409 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
1410 * Field formulas::              Formulas valid for a single field
1411 * Column formulas::             Formulas valid for an entire column
1412 * Editing and debugging formulas::  Fixing formulas
1413 * Updating the table::          Recomputing all dependent fields
1414 * Advanced features::           Field names, parameters and automatic recalc
1415 @end menu
1417 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
1418 @subsection References
1419 @cindex references
1421 To compute fields in the table from other fields, formulas must
1422 reference other fields or ranges.  In Org-mode, fields can be referenced
1423 by name, by absolute coordinates, and by relative coordinates.  To find
1424 out what the coordinates of a field are, press @kbd{C-c ?} in that
1425 field, or press @kbd{C-c @}} to toggle the display of a grid.
1427 @subsubheading Field references
1428 @cindex field references
1429 @cindex references, to fields
1431 Formulas can reference the value of another field in two ways.  Like in
1432 any other spreadsheet, you may reference fields with a letter/number
1433 combination like @code{B3}, meaning the 2nd field in the 3rd row.
1434 @c Such references are always fixed to that field, they don't change
1435 @c when you copy and paste a formula to a different field.  So
1436 @c Org-mode's @code{B3} behaves like @code{$B$3} in other spreadsheets.
1438 @noindent
1439 Org-mode also uses another, more general operator that looks like this:
1440 @example
1441 @@row$column
1442 @end example
1444 @noindent
1445 Column references can be absolute like @samp{1}, @samp{2},...@samp{N},
1446 or relative to the current column like @samp{+1} or @samp{-2}.
1448 The row specification only counts data lines and ignores horizontal
1449 separator lines (hlines).  You can use absolute row numbers
1450 @samp{1}...@samp{N}, and row numbers relative to the current row like
1451 @samp{+3} or @samp{-1}.  Or specify the row relative to one of the
1452 hlines: @samp{I} refers to the first hline, @samp{II} to the second etc.
1453 @samp{-I} refers to the first such line above the current line,
1454 @samp{+I} to the first such line below the current line.  You can also
1455 write @samp{III+2} which is the second data line after the third hline
1456 in the table.  Relative row numbers like @samp{-3} will not cross hlines
1457 if the current line is too close to the hline.  Instead, the value
1458 directly at the hline is used.
1460 @samp{0} refers to the current row and column.  Also, if you omit
1461 either the column or the row part of the reference, the current
1462 row/column is implied. 
1464 Org-mode's references with @emph{unsigned} numbers are fixed references
1465 in the sense that if you use the same reference in the formula for two
1466 different fields, the same field will be referenced each time.
1467 Org-mode's references with @emph{signed} numbers are floating
1468 references because the same reference operator can reference different
1469 fields depending on the field being calculated by the formula.
1471 Here are a few examples:
1473 @example
1474 @@2$3      @r{2nd row, 3rd column}
1475 C2        @r{same as previous}
1476 $5        @r{column 5 in the current row}
1477 E&        @r{same as previous}
1478 @@2        @r{current column, row 2}
1479 @@-1$-3    @r{the field one row up, three columns to the left}
1480 @@-I$2     @r{field just under hline above current row, column 2}
1481 @end example
1483 @subsubheading Range references
1484 @cindex range references
1485 @cindex references, to ranges
1487 You may reference a rectangular range of fields by specifying two field
1488 references connected by two dots @samp{..}.  If both fields are in the
1489 current row, you may simply use @samp{$2..$7}, but if at least one field
1490 is in a different row, you need to use the general @code{@@row$column}
1491 format at least for the first field (i.e the reference must start with
1492 @samp{@@} in order to be interpreted correctly).  Examples:
1494 @example
1495 $1..$3        @r{First three fields in the current row.}
1496 $P..$Q        @r{Range, using column names (see under Advanced)}
1497 @@2$1..@@4$3    @r{6 fields between these two fields.}
1498 A2..C4        @r{Same as above.}
1499 @@-1$-2..@@-1   @r{3 numbers from the column to the left, 2 up to current row}
1500 @end example
1502 @noindent Range references return a vector of values that can be fed
1503 into Calc vector functions.  Empty fields in ranges are normally
1504 suppressed, so that the vector contains only the non-empty fields (but
1505 see the @samp{E} mode switch below).  If there are no non-empty fields,
1506 @samp{[0]} is returned to avoid syntax errors in formulas.
1508 @subsubheading Named references
1509 @cindex named references
1510 @cindex references, named
1511 @cindex name, of column or field
1512 @cindex constants, in calculations
1514 @samp{$name} is interpreted as the name of a column, parameter or
1515 constant.  Constants are defined globally through the variable
1516 @code{org-table-formula-constants}.  If you have the @file{constants.el}
1517 package, it will also be used to resolve constants, including natural
1518 constants like @samp{$h} for Planck's constant, and units like
1519 @samp{$km} for kilometers@footnote{@file{Constant.el} can supply the
1520 values of constants in two different unit systems, @code{SI} and
1521 @code{cgs}.  Which one is used depends on the value of the variable
1522 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
1523 @code{constSI} and @code{constcgs} to set this value for the current
1524 buffer.}.  Column names and parameters can be specified in special table
1525 lines.  These are described below, see @ref{Advanced features}.  All
1526 names must start with a letter, and further consist of letters and
1527 numbers.
1529 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
1530 @subsection Formula syntax for Calc
1531 @cindex formula syntax, Calc
1532 @cindex syntax, of formulas
1534 A formula can be any algebraic expression understood by the Emacs
1535 @file{Calc} package.  @b{Note that @file{calc} has the
1536 non-standard convention that @samp{/} has lower precedence than
1537 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
1538 evaluation by @code{calc-eval} (@pxref{Calling Calc from
1539 Your Programs,calc-eval,Calling calc from Your Lisp Programs,calc,GNU
1540 Emacs Calc Manual}),
1541 @c FIXME:  The link to the calc manual in HTML does not work.
1542 variable substitution takes place according to the rules described above.
1543 @cindex vectors, in table calculations
1544 The range vectors can be directly fed into the calc vector functions
1545 like @samp{vmean} and @samp{vsum}.
1547 @cindex format specifier
1548 @cindex mode, for @file{calc}
1549 A formula can contain an optional mode string after a semicolon.  This
1550 string consists of flags to influence Calc and other modes during
1551 execution.  By default, Org-mode uses the standard calc modes (precision
1552 12, angular units degrees, fraction and symbolic modes off.  The display
1553 format, however, has been changed to @code{(float 5)} to keep tables
1554 compact.  The default settings can be configured using the variable
1555 @code{org-calc-default-modes}.
1557 @example
1558 p20           @r{switch the internal precision to 20 digits}
1559 n3 s3 e2 f4   @r{normal, scientific, engineering, or fixed display format}
1560 D R           @r{angle modes: degrees, radians}
1561 F S           @r{fraction and symbolic modes}
1562 N             @r{interpret all fields as numbers, use 0 for non-numbers}
1563 T             @r{force text interpretation}
1564 E             @r{keep empty fields in ranges}
1565 @end example
1567 @noindent
1568 In addition, you may provide a @code{printf} format specifier to
1569 reformat the final result.  A few examples:
1571 @example
1572 $1+$2                @r{Sum of first and second field}
1573 $1+$2;%.2f           @r{Same, format result to two decimals}
1574 exp($2)+exp($1)      @r{Math functions can be used}
1575 $0;%.1f              @r{Reformat current cell to 1 decimal}
1576 ($3-32)*5/9          @r{Degrees F -> C conversion}
1577 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
1578 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
1579 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
1580 vmean($2..$7)        @r{Compute column range mean, using vector function}
1581 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
1582 taylor($3,x=7,2)     @r{taylor series of $3, at x=7, second degree}
1583 @end example
1585 Calc also contains a complete set of logical operations.  For example
1587 @example
1588 if($1<20,teen,string(""))  @r{``teen'' if age $1 less than 20, else empty}
1589 @end example
1591 @node Formula syntax for Lisp, Field formulas, Formula syntax for Calc, The spreadsheet
1592 @subsection Emacs Lisp forms as formulas
1593 @cindex Lisp forms, as table formulas
1595 It is also possible to write a formula in Emacs Lisp; this can be useful
1596 for string manipulation and control structures, if the Calc's
1597 functionality is not enough.  If a formula starts with a single quote
1598 followed by an opening parenthesis, then it is evaluated as a lisp form.
1599 The evaluation should return either a string or a number.  Just as with
1600 @file{calc} formulas, you can specify modes and a printf format after a
1601 semicolon.  A reference will be replaced with a string (in double
1602 quotes) containing the field.  If you provide the @samp{N} mode switch,
1603 all referenced elements will be numbers.  Ranges are inserted as
1604 space-separated fields, so you can embed them in list or vector syntax.
1605 A few examples, note how the @samp{N} mode is used when we do
1606 computations in lisp.
1608 @example
1609 @r{Swap the first two characters of the content of column 1}
1610   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
1611 @r{Add columns 1 and 2, equivalent to the Calc's @code{$1+$2}}
1612   '(+ $1 $2);N
1613 @r{Compute the sum of columns 1-4, like Calc's @code{vsum($1..$4)}}
1614   '(apply '+ '($1..$4));N
1615 @end example
1617 @node Field formulas, Column formulas, Formula syntax for Lisp, The spreadsheet
1618 @subsection Field formulas
1619 @cindex field formula
1620 @cindex formula, for individual table field
1622 To assign a formula to a particular field, type it directly into the
1623 field, preceded by @samp{:=}, for example @samp{:=$1+$2}.  When you
1624 press @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in
1625 the field, the formula will be stored as the formula for this field,
1626 evaluated, and the current field replaced with the result.
1628 Formulas are stored in a special line starting with @samp{#+TBLFM:}
1629 directly below the table.  If you typed the equation in the 4th field of
1630 the 3rd data line in the table, the formula will look like
1631 @samp{@@3$4=$1+$2}.  When inserting/deleting/swapping column and rows
1632 with the appropriate commands, @i{absolute references} (but not relative
1633 ones) in stored formulas are modified in order to still reference the
1634 same field.  Of cause this is not true if you edit the table structure
1635 with normal editing commands - then you must fix the equations yourself.
1637 Instead of typing an equation into the field, you may also use the
1638 following command
1640 @table @kbd
1641 @kindex C-u C-c =
1642 @item C-u C-c =
1643 Install a new formula for the current field.  The command prompts for a
1644 formula, with default taken from the @samp{#+TBLFM:} line, applies
1645 it to the current field and stores it.
1646 @end table
1648 @node Column formulas, Editing and debugging formulas, Field formulas, The spreadsheet
1649 @subsection Column formulas
1650 @cindex column formula
1651 @cindex formula, for table column
1653 Often in a table, the same formula should be used for all fields in a
1654 particular column.  Instead of having to copy the formula to all fields
1655 in that column, org-mode allows to assign a single formula to an entire
1656 column.  If the table contains horizontal separator hlines, everything
1657 before the first such line is considered part of the table @emph{header}
1658 and will not be modified by column formulas.
1660 To assign a formula to a column, type it directly into any field in the
1661 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
1662 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the
1663 field, the formula will be stored as the formula for the current column,
1664 evaluated and the current field replaced with the result.  If the field
1665 contains only @samp{=}, the previously stored formula for this column is
1666 used.  For each column, Org-mode will only remember the most recently
1667 used formula.  In the @samp{TBLFM:} line, column formulas will look like
1668 @samp{$4=$1+$2}.
1670 Instead of typing an equation into the field, you may also use the
1671 following command:
1673 @table @kbd
1674 @kindex C-c =
1675 @item C-c =
1676 Install a new formula for the current column and replace current field
1677 with the result of the formula.  The command prompts for a formula, with
1678 default taken from the @samp{#+TBLFM} line, applies it to the current
1679 field and stores it.  With a numerical prefix (e.g. @kbd{C-5 C-c =})
1680 will apply it to that many consecutive fields in the current column.
1681 @end table
1684 @node Editing and debugging formulas, Updating the table, Column formulas, The spreadsheet
1685 @subsection Editing and Debugging formulas
1686 @cindex formula editing
1687 @cindex editing, of table formulas
1689 You can edit individual formulas in the minibuffer or directly in the
1690 field.  Org-mode can also prepare a special buffer with all active
1691 formulas of a table.  When offering a formula for editing, Org-mode
1692 converts references to the standard format (like @code{B3} or @code{D&})
1693 if possible.  If you prefer to only work with the internal format (like
1694 @code{@@3$2} or @code{$4}), configure the variable
1695 @code{org-table-use-standard-references}.
1697 @table @kbd
1698 @kindex C-c =
1699 @kindex C-u C-c =
1700 @item C-c =
1701 @itemx C-u C-c =
1702 Edit the formula associated with the current column/field in the
1703 minibuffer.  See @ref{Column formulas} and @ref{Field formulas}.
1704 @kindex C-u C-u C-c =
1705 @item C-u C-u C-c =
1706 Re-insert the active formula (either a
1707 field formula, or a column formula) into the current field, so that you
1708 can edit it directly in the field.  The advantage over editing in the
1709 minibuffer is that you can use the command @kbd{C-c ?}.
1710 @kindex C-c ?
1711 @item C-c ?
1712 While editing a formula in a table field, highlight the field(s)
1713 referenced by the reference at the cursor position in the formula.
1714 @kindex C-c @}
1715 @item C-c @}
1716 Toggle the display of row and column numbers for a table, using
1717 overlays.  These are updated each time the table is aligned, you can
1718 force it with @kbd{C-c C-c}.
1719 @kindex C-c @{
1720 @item C-c @{
1721 Toggle the formula debugger on and off.  See below.
1722 @kindex C-c '
1723 @item C-c '
1724 Edit all formulas for the current table in a special buffer, where the
1725 formulas will be displayed one per line.  If the current field has an
1726 active formula, the cursor in the formula editor will mark it.
1727 While inside the special buffer, Org-mode will automatically highlight
1728 any field or range reference at the cursor position.  You may edit,
1729 remove and add formulas, and use the following commands:
1730 @table @kbd
1731 @kindex C-c C-c
1732 @kindex C-x C-s
1733 @item C-c C-c
1734 @itemx C-x C-s
1735 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
1736 prefix, also apply the new formulas to the entire table.
1737 @kindex C-c C-q
1738 @item C-c C-q
1739 Exit the formula editor without installing changes.
1740 @kindex C-c C-r
1741 @item C-c C-r
1742 Toggle all references in the formula editor between standard (like
1743 @code{B3}) and internal (like @code{@@3$2}).
1744 @kindex @key{TAB}
1745 @item @key{TAB}
1746 Pretty-print or indent lisp formula at point.  When in a line containing
1747 a lisp formula, format the formula according to Emacs Lisp rules.
1748 Another @key{TAB} collapses the formula back again.  In the open
1749 formula, @key{TAB} re-indents just like in Emacs-lisp-mode.
1750 @kindex M-@key{TAB}
1751 @item M-@key{TAB}
1752 Complete Lisp symbols, just like in Emacs-lisp-mode.
1753 @kindex S-@key{up}
1754 @kindex S-@key{down}
1755 @kindex S-@key{left}
1756 @kindex S-@key{right}
1757 @item S-@key{up}/@key{down}/@key{left}/@key{right}
1758 Shift the reference at point.  For example, if the reference is
1759 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
1760 This also works for relative references, and for hline references.
1761 @kindex M-S-@key{up}
1762 @kindex M-S-@key{down}
1763 @item M-S-@key{up}/@key{down}
1764 Move the test line for column formulas in the Org-mode buffer up and
1765 down.
1766 @kindex M-@key{up}
1767 @kindex M-@key{down}
1768 @item M-@key{up}/@key{down}
1769 Scroll the window displaying the table.
1770 @kindex C-c @}
1771 @item C-c @}
1772 Turn the coordinate grid in the table on and off.
1773 @end table
1774 @end table
1776 Making a table field blank does not remove the formula associated with
1777 the field, because that is stored in a different line (the @samp{TBLFM}
1778 line) - during the next recalculation the field will be filled again.
1779 To remove a formula from a field, you have to give an empty reply when
1780 prompted for the formula, or to edit the @samp{#+TBLFM} line.
1782 @kindex C-c C-c
1783 You may edit the @samp{#+TBLFM} directly and re-apply the changed
1784 equations with @kbd{C-c C-c} in that line, or with the normal
1785 recalculation commands in the table.
1787 @subsubheading Debugging formulas
1788 @cindex formula debugging
1789 @cindex debugging, of table formulas
1790 When the evaluation of a formula leads to an error, the field content
1791 becomes the string @samp{#ERROR}.  If you would like see what is going
1792 on during variable substitution and calculation in order to find a bug,
1793 turn on formula debugging in the @code{Tbl} menu and repeat the
1794 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
1795 field.  Detailed information will be displayed.
1797 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
1798 @subsection Updating the Table
1799 @cindex recomputing table fields
1800 @cindex updating, table
1802 Recalculation of a table is normally not automatic, but needs to be
1803 triggered by a command.  See @ref{Advanced features} for a way to make
1804 recalculation at least semi-automatically.
1806 In order to recalculate a line of a table or the entire table, use the
1807 following commands:
1809 @table @kbd
1810 @kindex C-c *
1811 @item C-c *
1812 Recalculate the current row by first applying the stored column formulas
1813 from left to right, and all field formulas in the current row.
1815 @kindex C-u C-c *
1816 @item C-u C-c *
1817 @kindex C-u C-c C-c
1818 @itemx C-u C-c C-c
1819 Recompute the entire table, line by line.  Any lines before the first
1820 hline are left alone, assuming that these are part of the table header.
1822 @kindex C-u C-u C-c *
1823 @item C-u C-u C-c *
1824 Iterate the table by recomputing it until no further changes occur.
1825 This may be necessary if some computed fields use the value of other
1826 fields that are computed @i{later} in the calculation sequence.
1827 @end table
1829 @node Advanced features,  , Updating the table, The spreadsheet
1830 @subsection Advanced features
1832 If you want the recalculation of fields to happen automatically, or if
1833 you want to be able to assign @i{names} to fields and columns, you need
1834 to reserve the first column of the table for special marking characters.
1835 @table @kbd
1836 @kindex C-#
1837 @item C-#
1838 Rotate the calculation mark in first column through the states @samp{},
1839 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  The meaning of these characters
1840 is discussed below.  When there is an active region, change all marks in
1841 the region.
1842 @end table
1844 Here is an example of a table that collects exam results of students and
1845 makes use of these features:
1847 @example
1848 @group
1849 |---+---------+--------+--------+--------+-------+------|
1850 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
1851 |---+---------+--------+--------+--------+-------+------|
1852 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
1853 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
1854 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
1855 |---+---------+--------+--------+--------+-------+------|
1856 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
1857 | # | Sara    |      6 |     14 |     19 |    39 |  7.8 |
1858 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
1859 |---+---------+--------+--------+--------+-------+------|
1860 |   | Average |        |        |        |  29.7 |      |
1861 | ^ |         |        |        |        |    at |      |
1862 | $ | max=50  |        |        |        |       |      |
1863 |---+---------+--------+--------+--------+-------+------|
1864 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
1865 @end group
1866 @end example
1868 @noindent @b{Important}: Please note that for these special tables,
1869 recalculating the table with @kbd{C-u C-c *} will only affect rows that
1870 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
1871 to the field itself.  The column formulas are not applied in rows with
1872 empty first field.
1874 @cindex marking characters, tables
1875 The marking characters have the following meaning:
1876 @table @samp
1877 @item !
1878 The fields in this line define names for the columns, so that you may
1879 refer to a column as @samp{$Tot} instead of @samp{$6}.
1880 @item ^
1881 This row defines names for the fields @emph{above} the row.  With such
1882 a definition, any formula in the table may use @samp{$m1} to refer to
1883 the value @samp{10}.  Also, if you assign a formula to a names field, it
1884 will be stored as @samp{$name=...}.
1885 @item _
1886 Similar to @samp{^}, but defines names for the fields in the row
1887 @emph{below}.
1888 @item $
1889 Fields in this row can define @emph{parameters} for formulas.  For
1890 example, if a field in a @samp{$} row contains @samp{max=50}, then
1891 formulas in this table can refer to the value 50 using @samp{$max}.
1892 Parameters work exactly like constants, only that they can be defined on
1893 a per-table basis.
1894 @item #
1895 Fields in this row are automatically recalculated when pressing
1896 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
1897 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
1898 lines will be left alone by this command.
1899 @item *
1900 Selects this line for global recalculation with @kbd{C-u C-c *}, but
1901 not for automatic recalculation.  Use this when automatic
1902 recalculation slows down editing too much.
1903 @item
1904 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
1905 All lines that should be recalculated should be marked with @samp{#}
1906 or @samp{*}.
1907 @item /
1908 Do not export this line.  Useful for lines that contain the narrowing
1909 @samp{<N>} markers.
1910 @end table
1912 Finally, just to whet your appetite on what can be done with the
1913 fantastic @file{calc} package, here is a table that computes the Taylor
1914 series of degree @code{n} at location @code{x} for a couple of functions
1915 (homework: try that with Excel :-)
1917 @example
1918 @group
1919 |---+-------------+---+-----+--------------------------------------|
1920 |   | Func        | n | x   | Result                               |
1921 |---+-------------+---+-----+--------------------------------------|
1922 | # | exp(x)      | 1 | x   | 1 + x                                |
1923 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
1924 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
1925 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
1926 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
1927 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
1928 |---+-------------+---+-----+--------------------------------------|
1929 #+TBLFM: $5=taylor($2,$4,$3);n3
1930 @end group
1931 @end example
1933 @node Hyperlinks, TODO items, Tables, Top
1934 @chapter Hyperlinks
1935 @cindex hyperlinks
1937 Just like HTML, Org-mode provides links inside a file, and external
1938 links to other files, Usenet articles, emails, and much more.
1940 @menu
1941 * Link format::                 How links in Org-mode are formatted
1942 * Internal links::              Links to other places in the current file
1943 * External links::              URL-like links to the world
1944 * Handling links::              Creating, inserting and following
1945 * Link abbreviations::          Shortcuts for writing complex links
1946 * Search options::              Linking to a specific location
1947 * Custom searches::             When the default search is not enough
1948 * Remember::                    Org-trees store quick notes
1949 @end menu
1951 @node Link format, Internal links, Hyperlinks, Hyperlinks
1952 @section Link format
1953 @cindex link format
1954 @cindex format, of links
1956 Org-mode will recognize plain URL-like links and activate them as
1957 clickable links.  The general link format, however, looks like this:
1959 @example
1960 [[link][description]]       @r{or alternatively}           [[link]]  
1961 @end example
1963 Once a link in the buffer is complete (all brackets present), Org-mode
1964 will change the display so that @samp{description} is displayed instead
1965 of @samp{[[link][description]]} and @samp{link} is displayed instead of
1966 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
1967 which by default is an underlined face.  You can directly edit the
1968 visible part of a link.  Note that this can be either the @samp{link}
1969 part (if there is no description) or the @samp{description} part.  To
1970 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
1971 cursor on the link.
1973 If you place the cursor at the beginning or just behind the end of the
1974 displayed text and press @key{BACKSPACE}, you will remove the
1975 (invisible) bracket at that location.  This makes the link incomplete
1976 and the internals are again displayed as plain text.  Inserting the
1977 missing bracket hides the link internals again.  To show the
1978 internal structure of all links, use the menu entry
1979 @code{Org->Hyperlinks->Literal links}.
1981 @node Internal links, External links, Link format, Hyperlinks
1982 @section Internal links
1983 @cindex internal links
1984 @cindex links, internal
1985 @cindex targets, for links
1987 If the link does not look like a URL, it is considered to be internal in
1988 the current file.  Links such as @samp{[[My Target]]} or @samp{[[My
1989 Target][Find my target]]} lead to a text search in the current file.
1990 The link can be followed with @kbd{C-c C-o} when the cursor is on the
1991 link, or with a mouse click (@pxref{Handling links}).  The preferred
1992 match for such a link is a dedicated target: the same string in double
1993 angular brackets.  Targets may be located anywhere; sometimes it is
1994 convenient to put them into a comment line. For example
1996 @example
1997 # <<My Target>>
1998 @end example
2000 @noindent In HTML export (@pxref{HTML export}), such targets will become
2001 named anchors for direct access through @samp{http} links@footnote{Note
2002 that text before the first headline will never be exported, so the first
2003 such target must be after the first headline.}.
2005 If no dedicated target exists, Org-mode will search for the words in the
2006 link.  In the above example the search would be for @samp{my target}.
2007 Links starting with a star like @samp{*My Target} restrict the search to
2008 headlines.  When searching, Org-mode will first try an exact match, but
2009 then move on to more and more lenient searches.  For example, the link
2010 @samp{[[*My Targets]]} will find any of the following:
2012 @example
2013 ** My targets
2014 ** TODO my targets are bright
2015 ** my 20 targets are
2016 @end example
2018 To insert a link targeting a headline, in-buffer completion can be used.
2019 Just type a star followed by a few optional letters into the buffer and
2020 press @kbd{M-@key{TAB}}.  All headlines in the current buffer will be
2021 offered as completions.  @xref{Handling links}, for more commands
2022 creating links.
2024 Following a link pushes a mark onto Org-mode's own mark ring.  You can
2025 return to the previous position with @kbd{C-c &}.  Using this command
2026 several times in direct succession goes back to positions recorded
2027 earlier.
2029 @menu
2030 * Radio targets::               Make targets trigger links in plain text.
2031 @end menu
2033 @node Radio targets,  , Internal links, Internal links
2034 @subsection Radio targets
2035 @cindex radio targets
2036 @cindex targets, radio
2037 @cindex links, radio targets
2039 You can configure Org-mode to link any occurrences of certain target
2040 names in normal text.  So without explicitly creating a link, the text
2041 connects to the target radioing its position.  Radio targets are
2042 enclosed by triple angular brackets.  For example, a target
2043 @samp{<<<My Target>>>} causes each occurrence of @samp{my target} in
2044 normal text to become activated as a link.  The Org-mode file is
2045 scanned automatically for radio targets only when the file is first
2046 loaded into Emacs.  To update the target list during editing, press
2047 @kbd{C-c C-c} with the cursor on or at a target.
2049 @node External links, Handling links, Internal links, Hyperlinks
2050 @section External links
2051 @cindex links, external
2052 @cindex external links
2053 @cindex links, external
2054 @cindex GNUS links
2055 @cindex BBDB links
2056 @cindex URL links
2057 @cindex file links
2058 @cindex VM links
2059 @cindex RMAIL links
2060 @cindex WANDERLUST links
2061 @cindex MH-E links
2062 @cindex USENET links
2063 @cindex SHELL links
2064 @cindex Info links
2065 @cindex elisp links
2067 Org-mode supports links to files, websites, Usenet and email messages,
2068 and BBDB database entries.  External links are URL-like locators.  They
2069 start with a short identifying string followed by a colon.  There can be
2070 no space after the colon.  The following list shows examples for each
2071 link type.
2073 @example
2074 http://www.astro.uva.nl/~dominik          @r{on the web}
2075 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
2076 file:papers/last.pdf                      @r{file, relative path}
2077 news:comp.emacs                           @r{Usenet link}
2078 mailto:adent@@galaxy.net                   @r{Mail link}
2079 vm:folder                                 @r{VM folder link}
2080 vm:folder#id                              @r{VM message link}
2081 vm://myself@@some.where.org/folder#id      @r{VM on remote machine}
2082 wl:folder                                 @r{WANDERLUST folder link}
2083 wl:folder#id                              @r{WANDERLUST message link}
2084 mhe:folder                                @r{MH-E folder link}
2085 mhe:folder#id                             @r{MH-E message link}
2086 rmail:folder                              @r{RMAIL folder link}
2087 rmail:folder#id                           @r{RMAIL message link}
2088 gnus:group                                @r{GNUS group link}
2089 gnus:group#id                             @r{GNUS article link}
2090 bbdb:Richard Stallman                     @r{BBDB link}
2091 shell:ls *.org                            @r{A shell command}
2092 elisp:(find-file-other-frame "Elisp.org") @r{An elisp form to evaluate}
2093 @end example
2095 A link should be enclosed in double brackets and may contain a
2096 descriptive text to be displayed instead of the url (@pxref{Link
2097 format}), for example:
2099 @example
2100 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
2101 @end example
2103 @noindent
2104 If the description is a file name or URL that points to an image, HTML
2105 export (@pxref{HTML export}) will inline the image as a clickable
2106 button.  If there is no description at all and the link points to an
2107 image,
2108 that image will be inlined into the exported HTML file.
2110 @cindex angular brackets, around links
2111 @cindex plain text external links
2112 Org-mode also finds external links in the normal text and activates them
2113 as links.  If spaces must be part of the link (for example in
2114 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
2115 about the end of the link, enclose them in angular brackets.
2117 @node Handling links, Link abbreviations, External links, Hyperlinks
2118 @section Handling links
2119 @cindex links, handling
2121 Org-mode provides methods to create a link in the correct syntax, to
2122 insert it into an org-mode file, and to follow the link.
2124 @table @kbd
2125 @kindex C-c l
2126 @cindex storing links
2127 @item C-c l
2128 Store a link to the current location.  This is a @emph{global} command
2129 which can be used in any buffer to create a link.  The link will be
2130 stored for later insertion into an Org-mode buffer (see below).  For
2131 Org-mode files, if there is a @samp{<<target>>} at the cursor, the link
2132 points to the target.  Otherwise it points to the current headline.  For
2133 VM, RMAIL, WANDERLUST, MH-E, GNUS and BBDB buffers, the link will
2134 indicate the current article/entry.  For W3 and W3M buffers, the link
2135 goes to the current URL.  For any other files, the link will point to
2136 the file, with a search string (@pxref{Search options}) pointing to the
2137 contents of the current line.  If there is an active region, the
2138 selected words will form the basis of the search string.  If the
2139 automatically created link is not working correctly or accurately
2140 enough, you can write custom functions to select the search string and
2141 to do the search for particular file types - see @ref{Custom searches}.
2142 The key binding @kbd{C-c l} is only a suggestion - see @ref{Installation}.
2144 @kindex C-c C-l
2145 @cindex link completion
2146 @cindex completion, of links
2147 @cindex inserting links
2148 @item C-c C-l
2149 Insert a link.  This prompts for a link to be inserted into the buffer.
2150 You can just type a link, using text for an internal link, or one of the
2151 link type prefixes mentioned in the examples above.  All links stored
2152 during the current session are part of the history for this prompt, so
2153 you can access them with @key{up} and @key{down}, or with
2154 completion@footnote{After insertion of a stored link, the link will be
2155 removed from the list of stored links.  To keep it in the list later
2156 use, use a triple @kbd{C-u} prefix to @kbd{C-c C-l}, or configure the
2157 option @code{org-keep-stored-link-after-insertion}.}.  The link will be
2158 inserted into the buffer, along with a descriptive text.  If some text
2159 was selected when this command is called, the selected text becomes the
2160 default description.@* Note that you don't have to use this command to
2161 insert a link.  Links in Org-mode are plain text, and you can type or
2162 paste them straight into the buffer.  By using this command, the links
2163 are automatically enclosed in double brackets, and you will be asked for
2164 the optional descriptive text.
2166 @c  If the link is a @samp{file:} link and
2167 @c the linked file is located in the same directory as the current file or
2168 @c a subdirectory of it, the path of the file will be inserted relative to
2169 @c the current directory.
2171 @kindex C-u C-c C-l
2172 @cindex file name completion
2173 @cindex completion, of file names
2174 @item C-u C-c C-l
2175 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
2176 a file will be inserted and you may use file name completion to select
2177 the name of the file.  The path to the file is inserted relative to the
2178 directory of the current org file, if the linked file is in the current
2179 directory or in a subdirectory of it, or if the path is written relative
2180 to the current directory using @samp{../}.  Otherwise an absolute path
2181 is used, if possible with @samp{~/} for your home directory.  You can
2182 force an absolute path with two @kbd{C-u} prefixes.
2184 @item C-c C-l @r{(with cursor on existing link)}
2185 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
2186 link and description parts of the link.
2188 @cindex following links
2189 @kindex C-c C-o
2190 @item C-c C-o
2191 Open link at point.  This will launch a web browser for URLs (using
2192 @command{browse-url-at-point}), run vm/mh-e/wanderlust/rmail/gnus/bbdb
2193 for the corresponding links, and execute the command in a shell link.
2194 When the cursor is on an internal link, this commands runs the
2195 corresponding search.  When the cursor is on a TAG list in a headline,
2196 it creates the corresponding TAGS view.  If the cursor is on a time
2197 stamp, it compiles the agenda for that date.  Furthermore, it will visit
2198 text and remote files in @samp{file:} links with Emacs and select a
2199 suitable application for local non-text files.  Classification of files
2200 is based on file extension only.  See option @code{org-file-apps}.  If
2201 you want to override the default application and visit the file with
2202 Emacs, use a @kbd{C-u} prefix.
2204 @kindex mouse-2
2205 @kindex mouse-1
2206 @item mouse-2
2207 @itemx mouse-1
2208 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
2209 would.  Under Emacs 22, also @kbd{mouse-1} will follow a link.
2211 @kindex mouse-3
2212 @item mouse-3
2213 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
2214 internal links to be displayed in another window@footnote{See the
2215 variable @code{org-display-internal-link-with-indirect-buffer}}.
2217 @cindex mark ring
2218 @kindex C-c %
2219 @item C-c %
2220 Push the current position onto the mark ring, to be able to return
2221 easily. Commands following an internal link do this automatically.
2223 @cindex links, returning to
2224 @kindex C-c &
2225 @item C-c &
2226 Jump back to a recorded position.  A position is recorded by the
2227 commands following internal links, and by @kbd{C-c %}.  Using this
2228 command several times in direct succession moves through a ring of
2229 previously recorded positions.
2231 @kindex C-c C-x C-n
2232 @kindex C-c C-x C-p
2233 @cindex links, finding next/previous
2234 @item C-c C-x C-n
2235 @itemx C-c C-x C-p
2236 Move forward/backward to the next link in the buffer.  At the limit of
2237 the buffer, the search fails once, and then wraps around.  The key
2238 bindings for this are really too long, you might want to bind this also
2239 to @kbd{C-n} and @kbd{C-p}
2240 @lisp
2241 (add-hook 'org-load-hook
2242   (lambda ()
2243     (define-key 'org-mode-map "\C-n" 'org-next-link)
2244     (define-key 'org-mode-map "\C-p" 'org-previous-link)))
2245 @end lisp
2246 @end table
2248 @node Link abbreviations, Search options, Handling links, Hyperlinks
2249 @section Link abbreviations
2250 @cindex link abbreviations
2251 @cindex abbreviation, links
2253 Long URLs can be cumbersome to type, and often many similar links are
2254 needed in a document.  For this you can use link abbreviations.  An
2255 abbreviated link looks like this
2257 @example
2258 [[linkword:tag][description]]
2259 @end example
2261 @noindent
2262 where the tag is optional.  Such abbreviations are resolved according to
2263 the information in the variable @code{org-link-abbrev-alist} that
2264 relates the linkwords to replacement text.  Here is an example:
2266 @lisp
2267 @group
2268 (setq org-link-abbrev-alist
2269   '(("bugzilla" . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
2270     ("google"   . "http://www.google.com/search?q=")
2271     ("ads"      . "http://adsabs.harvard.edu/cgi-bin/
2272                    nph-abs_connect?author=%s&db_key=AST")))
2273 @end group
2274 @end lisp
2276 If the replacement text contains the string @samp{%s}, it will be
2277 replaced with the tag.  Otherwise the tag will be appended to the string
2278 in order to create the link.  You may also specify a function that will
2279 be called with the tag as the only argument to create the link.
2281 With the above setting, you could link to a specific bug with
2282 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
2283 @code{[[google:OrgMode]]} and find out what the Org-mode author is
2284 doing besides Emacs hacking with @code{[[ads:Dominik,C]]}.
2286 If you need special abbreviations just for a single Org-mode buffer, you
2287 can define them in the file with
2289 @example
2290 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
2291 #+LINK: google    http://www.google.com/search?q=%s
2292 @end example
2294 @noindent
2295 In-buffer completion @pxref{Completion} can be used after @samp{[} to
2296 complete link abbreviations.
2298 @node Search options, Custom searches, Link abbreviations, Hyperlinks
2299 @section Search options in file links
2300 @cindex search option in file links
2301 @cindex file links, searching
2303 File links can contain additional information to make Emacs jump to a
2304 particular location in the file when following a link.  This can be a
2305 line number or a search option after a double@footnote{For backward
2306 compatibility, line numbers can also follow a single colon.} colon. For
2307 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
2308 links}) to a file, it encodes the words in the current line as a search
2309 string that can be used to find this line back later when following the
2310 link with @kbd{C-c C-o}. 
2312 Here is the syntax of the different ways to attach a search to a file
2313 link, together with an explanation:
2315 @example
2316 [[file:~/code/main.c::255]]
2317 [[file:~/xx.org::My Target]]
2318 [[file:~/xx.org::*My Target]]
2319 [[file:~/xx.org::/regexp/]]
2320 @end example
2322 @table @code
2323 @item 255
2324 Jump to line 255.
2325 @item My Target
2326 Search for a link target @samp{<<My Target>>}, or do a text search for
2327 @samp{my target}, similar to the search in internal links, see
2328 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
2329 link will become an HTML reference to the corresponding named anchor in
2330 the linked file.
2331 @item *My Target
2332 In an Org-mode file, restrict search to headlines.
2333 @item /regexp/
2334 Do a regular expression search for @code{regexp}.  This uses the Emacs
2335 command @code{occur} to list all matches in a separate window.  If the
2336 target file is in Org-mode, @code{org-occur} is used to create a
2337 sparse tree with the matches.
2338 @c If the target file is a directory,
2339 @c @code{grep} will be used to search all files in the directory.
2340 @end table
2342 As a degenerate case, a file link with an empty file name can be used
2343 to search the current file.  For example, @code{[[file:::find me]]} does
2344 a search for @samp{find me} in the current file, just as
2345 @samp{[[find me]]} would.
2347 @node Custom searches, Remember, Search options, Hyperlinks
2348 @section Custom Searches
2349 @cindex custom search strings
2350 @cindex search strings, custom
2352 The default mechanism for creating search strings and for doing the
2353 actual search related to a file link may not work correctly in all
2354 cases.  For example, BibTeX database files have many entries like
2355 @samp{year="1993"} which would not result in good search strings,
2356 because the only unique identification for a BibTeX entry is the
2357 citation key.
2359 If you come across such a problem, you can write custom functions to set
2360 the right search string for a particular file type, and to do the search
2361 for the string in the file.  Using @code{add-hook}, these functions need
2362 to be added to the hook variables
2363 @code{org-create-file-search-functions} and
2364 @code{org-execute-file-search-functions}.  See the docstring for these
2365 variables for more information.  Org-mode actually uses this mechanism
2366 for Bib@TeX{} database files, and you can use the corresponding code as
2367 an implementation example.  Search for @samp{BibTeX links} in the source
2368 file.
2371 @node Remember,  , Custom searches, Hyperlinks
2372 @section Remember
2373 @cindex @file{remember.el}
2375 Another way to create org entries with links to other files is through
2376 the @i{remember} package by John Wiegley.  @i{Remember} lets you store
2377 quick notes with little interruption of your work flow.  See
2378 @uref{http://www.emacswiki.org/cgi-bin/wiki/RememberMode} for more
2379 information.  The notes produced by @i{Remember} can be stored in
2380 different ways, and Org-mode files are a good target.  Org-mode
2381 significantly expands the possibilities of @i{remember}: You may define
2382 templates for different note types, and to associate target files and
2383 headlines with specific templates.  It also allows you to select the
2384 location where a note should be stored interactively, on the fly.
2386 @menu
2387 * Setting up remember::         Some code for .emacs to get things going
2388 * Remember templates::          Define the outline of different note types
2389 * Storing notes::               Directly get the note to where it belongs
2390 @end menu
2392 @node Setting up remember, Remember templates, Remember, Remember
2393 @subsection Setting up remember
2395 The following customization will tell @i{remember} to use org files as
2396 target, and to create annotations compatible with Org-mode links.
2398 @example
2399 (setq org-directory "~/path/to/my/orgfiles/")
2400 (setq org-default-notes-file "~/.notes")
2401 (setq remember-annotation-functions '(org-remember-annotation))
2402 (setq remember-handler-functions '(org-remember-handler))
2403 (add-hook 'remember-mode-hook 'org-remember-apply-template)
2404 @end example
2406 @node Remember templates, Storing notes, Setting up remember, Remember
2407 @subsection Remember templates
2408 @cindex templates, for remember
2410 In combination with Org-mode, you can use templates to generate
2411 different types of @i{remember} notes.  For example, if you would like
2412 to use one template to create general TODO entries, another one for
2413 journal entries, and a third one for collecting random ideas, you could
2414 use:
2416 @example
2417 (setq org-remember-templates
2418  '((?t "* TODO %?\n  %i\n  %a" "~/org/TODO.org")
2419    (?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org")
2420    (?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
2421 @end example
2423 @noindent In these entries, the character specifies how to select the
2424 template.  The first string specifies the template.  Two more (optional)
2425 strings give the file in which, and the headline under which the new
2426 note should be stored.  The file defaults (if not present or @code{nil})
2427 to @code{org-default-notes-file}, the heading to
2428 @code{org-remember-default-headline}.  Both defaults help to get to the
2429 storing location quickly, but you can change the location interactively
2430 while storing the note.
2432 When you call @kbd{M-x remember} (or @kbd{M-x org-remember}) to remember
2433 something, org will prompt for a key to select the template (if you have
2434 more than one template) and then prepare the buffer like
2435 @example
2436 * TODO
2437   [[file:link to where you called remember]]
2438 @end example
2440 @noindent or
2442 @example
2443 * [2006-03-21 Tue 15:37]
2445   [[file:link to where you called remember]]
2446 @end example
2448 @noindent
2449 During expansion of the template, special @kbd{%}-escapes allow dynamic
2450 insertion of content:
2451 @example
2452 %^@{prompt@}  @r{prompt the user for a string and replace this sequence with it.}
2453 %t          @r{time stamp, date only}
2454 %T          @r{time stamp with date and time}
2455 %u, %U      @r{like the above, but inactive time stamps}
2456 %^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
2457             @r{You may define a prompt like @code{%^@{Birthday@}t}}
2458 %n          @r{user name (taken from @code{user-full-name})}
2459 %a          @r{annotation, normally the link created with @code{org-store-link}}
2460 %i          @r{initial content, the region when remember is called with C-u.}
2461             @r{The entire text will be indented like @code{%i} itself.}
2462 %:keyword   @r{specific information for certain link types, see below}
2463 @end example
2465 @noindent
2466 For specific link types, the following keywords will be defined:
2468 @example
2469 Link type          |  Available keywords
2470 -------------------+----------------------------------------------
2471 bbdb               |  %:name %:company
2472 vm, wl, mh, rmail  |  %:type %:subject %:message-id
2473                    |  %:from %:fromname %:fromaddress
2474                    |  %:to   %:toname   %:toaddress
2475                    |  %:fromto @r{(either "to NAME" or "from NAME")@footnote{This will always be the other, not the user.  See the variable @code{org-from-is-user-regexp}.}}       
2476 gnus               |  %:group, @r{for messages also all email fields}
2477 w3, w3m            |  %:url
2478 info               |  %:file %:node
2479 calendar           |  %:date"
2480 @end example
2482 @noindent
2483 To place the cursor after template expansion use:
2485 @example
2486 %?          @r{After completing the template, position cursor here.}
2487 @end example
2489 @noindent
2490 If you change you mind about which template to use, call
2491 @code{org-remember} in the remember buffer.  You may then select a new
2492 template that will be filled with the previous context information.
2494 @node Storing notes,  , Remember templates, Remember
2495 @subsection Storing notes
2497 When you are finished preparing a note with @i{remember}, you have to press
2498 @kbd{C-c C-c} to file the note away.  The handler first prompts for a
2499 target file - if you press @key{RET}, the value specified for the
2500 template is used.  Then the command offers the headings tree of the
2501 selected file, with the cursor position at the default headline (if you
2502 had specified one in the template).  You can either immediately press
2503 @key{RET} to get the note placed there.  Or you can use the following
2504 keys to find a better location:
2505 @example
2506 @key{TAB}         @r{Cycle visibility.}
2507 @key{down} / @key{up}   @r{Next/previous visible headline.}
2508 n / p        @r{Next/previous visible headline.}
2509 f / b        @r{Next/previous headline same level.}
2510 u            @r{One level up.}
2511 @c 0-9          @r{Digit argument.}
2512 @end example
2513 @noindent
2514 Pressing @key{RET} or @key{left} or @key{right}
2515 then leads to the following result.
2517 @multitable @columnfractions 0.2 0.15 0.65
2518 @item @b{Cursor position} @tab @b{Key} @tab @b{Note gets inserted}
2519 @item buffer-start @tab @key{RET} @tab as level 2 heading at end of file
2520 @item on headline @tab @key{RET} @tab as sublevel of the heading at cursor
2521 @item             @tab @key{left}/@key{right} @tab as same level, before/after current heading
2522 @item not on headline @tab @key{RET}
2523       @tab at cursor position, level taken from context.
2524 @end multitable
2526 So a fast way to store the note to its default location is to press
2527 @kbd{C-c C-c @key{RET} @key{RET}}.  Even shorter would be @kbd{C-u C-c
2528 C-c}, which does the same without even asking for a file or showing the
2529 tree.
2531 Before inserting the text into a tree, the function ensures that the
2532 text has a headline, i.e. a first line that starts with a @samp{*}.
2533 If not, a headline is constructed from the current date and some
2534 additional data.  If the variable @code{org-adapt-indentation} is
2535 non-nil, the entire text is also indented so that it starts in the
2536 same column as the headline (after the asterisks).
2539 @node TODO items, Timestamps, Hyperlinks, Top
2540 @chapter TODO items
2541 @cindex TODO items
2543 Org-mode does not maintain TODO lists as a separate document.  TODO
2544 items are an integral part of the notes file, because TODO items
2545 usually come up while taking notes!  With Org-mode, you simply mark
2546 any entry in a tree as being a TODO item.  In this way, the
2547 information is not duplicated, and the entire context from which the
2548 item emerged is always present when you check.
2550 Of course, this technique causes TODO items to be scattered throughout
2551 your file.  Org-mode provides methods to give you an overview over all
2552 things you have to do.
2554 @menu
2555 * TODO basics::                 Marking and displaying TODO entries
2556 * TODO extensions::             Workflow and assignments
2557 * Priorities::                  Some things are more important than others
2558 * Breaking down tasks::         Splitting a task into manageable pieces
2559 * Checkboxes::                  Tick-off lists
2560 @end menu
2562 @node TODO basics, TODO extensions, TODO items, TODO items
2563 @section Basic TODO functionality
2565 Any headline can become a TODO item by starting it with the word TODO,
2566 for example:
2568 @example
2569 *** TODO Write letter to Sam Fortune
2570 @end example
2572 @noindent
2573 The most important commands to work with TODO entries are:
2575 @table @kbd
2576 @kindex C-c C-t
2577 @cindex cycling, of TODO states
2578 @item C-c C-t
2579 Rotate the TODO state of the current item among
2581 @example
2582 ,-> (unmarked) -> TODO -> DONE --.
2583 '--------------------------------'
2584 @end example
2586 The same rotation can also be done ``remotely'' from the timeline and
2587 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
2588 @kindex S-@key{right}
2589 @kindex S-@key{left}
2590 @item S-@key{right}
2591 @itemx S-@key{left}
2592 Select the following/preceding TODO state, similar to cycling.  Mostly
2593 useful if more than two TODO states are possible (@pxref{TODO extensions}).
2594 @kindex C-c C-v
2595 @cindex sparse tree, for TODO
2596 @item C-c C-v
2597 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds
2598 the entire buffer, but shows all TODO items and the headings hierarchy
2599 above them.  With prefix arg, search for a specific TODO.  You will be
2600 prompted for the keyword, and you can also give a list of keywords like
2601 @code{kwd1|kwd2|...}.  With numerical prefix N, show the tree for the
2602 Nth keyword in the variable @code{org-todo-keywords}.  With two prefix
2603 args, find all TODO and DONE entries.
2604 @kindex C-c a t
2605 @item C-c a t
2606 Show the global TODO list.  This collects the TODO items from all
2607 agenda files (@pxref{Agenda views}) into a single buffer.  The buffer is in
2608 @code{agenda-mode}, so there are commands to examine and manipulate
2609 the TODO entries directly from that buffer (@pxref{Agenda commands}).
2610 @xref{Global TODO list}, for more information.
2611 @c @item @code{org-agenda-include-all-todo}
2612 @c If you would like to have all your TODO items listed as part of your
2613 @c agenda, customize the variable @code{org-agenda-include-all-todo}.
2614 @end table
2616 @node TODO extensions, Priorities, TODO basics, TODO items
2617 @section Extended use of TODO keywords
2618 @cindex extended TODO keywords
2620 The default implementation of TODO entries is just two states: TODO and
2621 DONE.  You can use the TODO feature for more complicated things by
2622 configuring the variable @code{org-todo-keywords}.  With special setup,
2623 the TODO keyword system can work differently in different files.
2625 Note that @i{tags} are another way to classify headlines in general and
2626 TODO items in particular (@pxref{Tags}).
2628 @menu
2629 * Workflow states::             From TODO to DONE in steps
2630 * TODO types::                  I do this, Fred the rest
2631 * Multiple sets in one file::   Mixing it all, and still finding your way
2632 * Per file keywords::           Different files, different requirements
2633 @end menu
2635 @node Workflow states, TODO types, TODO extensions, TODO extensions
2636 @subsection TODO keywords as workflow states
2637 @cindex TODO workflow
2638 @cindex workflow states as TODO keywords
2640 You can use TODO keywords to indicate different @emph{sequential} states
2641 in the process of working on an item, for example@footnote{Changing
2642 this variable only becomes effective after restarting Org-mode in a
2643 buffer.}:
2645 @lisp
2646 (setq org-todo-keywords
2647   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
2648 @end lisp
2650 The vertical bar separates the TODO keywords (states that @emph{need
2651 action}) from the DONE states (which need @emph{no further action}.  If
2652 you don't provide the separator bar, the last state is used as the DONE
2653 state.
2654 @cindex completion, of TODO keywords
2655 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
2656 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED.  You may
2657 also use a prefix argument to quickly select a specific state.  For
2658 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY.
2659 If you define many keywords, you can use in-buffer completion (see
2660 @ref{Completion}) to insert these words into the buffer.  Changing a
2661 todo state can be logged with a timestamp, see @ref{Tracking TODO state
2662 changes} for more information.
2664 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
2665 @subsection TODO keywords as types
2666 @cindex TODO types
2667 @cindex names as TODO keywords
2668 @cindex types as TODO keywords
2670 The second possibility is to use TODO keywords to indicate different
2671 @emph{types} of action items.  For example, you might want to indicate
2672 that items are for ``work'' or ``home''.  Or, when you work with several
2673 people on a single project, you might want to assign action items
2674 directly to persons, by using their names as TODO keywords.  This would
2675 be set up like this:
2677 @lisp
2678 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
2679 @end lisp
2681 In this case, different keywords do not indicate a sequence, but rather
2682 different types.  So the normal work flow would be to assign a task to a
2683 person, and later to mark it DONE.  Org-mode supports this style by
2684 adapting the workings of the command @kbd{C-c C-t}@footnote{This is also
2685 true for the @kbd{t} command in the timeline and agenda buffers.}.  When
2686 used several times in succession, it will still cycle through all names,
2687 in order to first select the right type for a task.  But when you return
2688 to the item after some time and execute @kbd{C-c C-t} again, it will
2689 switch from any name directly to DONE.  Use prefix arguments or
2690 completion to quickly select a specific name.  You can also review the
2691 items of a specific TODO type in a sparse tree by using a numeric prefix
2692 to @kbd{C-c C-v}.  For example, to see all things Lucy has to do, you
2693 would use @kbd{C-3 C-c C-v}.  To collect Lucy's items from all agenda
2694 files into a single buffer, you would use the prefix arg as well when
2695 creating the global todo list: @kbd{C-3 C-c t}.
2697 @node Multiple sets in one file, Per file keywords, TODO types, TODO extensions
2698 @subsection Multiple keyword sets in one file
2699 @cindex todo keyword sets
2701 Sometimes you may want to use different sets of TODO keywords in
2702 parallel.  For example, you may want to have the basic
2703 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
2704 separate state indicating that an item has been canceled (so it is not
2705 DONE, but also does not require action).  Your setup would then look
2706 like this:
2708 @lisp
2709 (setq org-todo-keywords
2710       '((sequence "TODO" "|" "DONE")
2711         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
2712         (sequence "|" "CANCELED")))
2713 @end lisp
2715 The keywords should all be different, this helps Org-mode to keep track
2716 of which subsequence should be used for a given entry.  In this setup,
2717 @kbd{C-c C-t} only operates within a subsequence, so it switches from
2718 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
2719 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
2720 select the correct sequence.  Besides the obvious ways like typing a
2721 keyword or using completion, you may also apply the following commands:
2723 @table @kbd
2724 @kindex C-S-@key{right}
2725 @kindex C-S-@key{left}
2726 @item C-S-@key{right}
2727 @itemx C-S-@key{left}
2728 These keys jump from one TODO subset to the next.  In the above example,
2729 @kbd{C-S-@key{right}} would jump from @code{TODO} or @code{DONE} to
2730 @code{REPORT}, and any of the words in the second row to @code{CANCELED}.
2731 @kindex S-@key{right}
2732 @kindex S-@key{left}
2733 @item S-@key{right}
2734 @itemx S-@key{left}
2735 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through
2736 @emph{all} keywords from all sets, so for example @kbd{S-@key{<right>}}
2737 would switch from @code{DONE} to @code{REPORT} in the example above.
2738 @end table
2740 @node Per file keywords,  , Multiple sets in one file, TODO extensions
2741 @subsection Setting up keywords for individual files
2742 @cindex keyword options
2743 @cindex per file keywords
2745 It can be very useful to use different aspects of the TODO mechanism in
2746 different files.  For file-local settings, you need to add special lines
2747 to the file which set the keywords and interpretation for that file
2748 only.  For example, to set one of the two examples discussed above, you
2749 need one of the following lines, starting in column zero anywhere in the
2750 file:
2752 @example
2753 #+SEQ_TODO: TODO FEEDBACK VERIFY | DONE CANCELED
2754 @end example
2756 @example
2757 #+TYP_TODO: Fred Sara Lucy Mike | DONE
2758 @end example
2760 A setup for using several sets in parallel would be:
2762 @example
2763 #+SEQ_TODO: "TODO" "|" "DONE"
2764 #+SEQ_TODO: "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED"
2765 #+SEQ_TODO: "|" "CANCELED"
2766 @end example
2769 @cindex completion, of option keywords
2770 @kindex M-@key{TAB}
2771 @noindent To make sure you are using the correct keyword, type
2772 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
2774 @cindex DONE, final TODO keyword
2775 Remember that the keywords after the vertical bar (or the last keyword
2776 if no bar is there) must always mean that the item is DONE (although you
2777 may use a different word).  After changing one of these lines, use
2778 @kbd{C-c C-c} with the cursor still in the line to make the changes
2779 known to Org-mode@footnote{Org-mode parses these lines only when
2780 Org-mode is activated after visiting a file.  @kbd{C-c C-c} with the
2781 cursor in a line starting with @samp{#+} is simply restarting Org-mode
2782 for the current buffer.}.
2784 @node Priorities, Breaking down tasks, TODO extensions, TODO items
2785 @section Priorities
2786 @cindex priorities
2788 If you use Org-mode extensively to organize your work, you may end up
2789 with a number of TODO entries so large that you'd like to prioritize
2790 them.  This can be done by placing a @emph{priority cookie} into the
2791 headline, like this
2793 @example
2794 *** TODO [#A] Write letter to Sam Fortune
2795 @end example
2797 @noindent
2798 With its standard setup, Org-mode supports priorities @samp{A},
2799 @samp{B}, and @samp{C}.  @samp{A} is the highest priority.  An entry
2800 without a cookie is treated as priority @samp{B}.  Priorities make a
2801 difference only in the agenda (@pxref{Weekly/Daily agenda}).
2803 @table @kbd
2804 @kindex @kbd{C-c ,}
2805 @item @kbd{C-c ,}
2806 Set the priority of the current headline.  The command prompts for a
2807 priority character @samp{A}, @samp{B} or @samp{C}.  When you press
2808 @key{SPC} instead, the priority cookie is removed from the headline.
2809 The priorities can also be changed ``remotely'' from the timeline and
2810 agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
2812 @kindex S-@key{up}
2813 @kindex S-@key{down}
2814 @item S-@key{up}
2815 @itemx S-@key{down}
2816 Increase/decrease priority of current headline.  Note that these keys
2817 are also used to modify time stamps (@pxref{Creating timestamps}).
2818 Furthermore, these keys are also used by CUA-mode (@pxref{Conflicts}).
2819 @end table
2821 @node Breaking down tasks, Checkboxes, Priorities, TODO items
2822 @section Breaking tasks down into subtasks
2823 @cindex tasks, breaking down
2825 It is often advisable to break down large tasks into smaller, manageable
2826 subtasks.  You can do this by creating an outline tree below a TODO
2827 item, with detailed subtasks on the tree@footnote{To keep subtasks out
2828 of the global TODO list, see the
2829 @code{org-agenda-todo-list-sublevels}.}.  Another possibility is the use
2830 of checkboxes to identify (a hierarchy of) a large number of subtasks
2831 (@pxref{Checkboxes}).
2834 @node Checkboxes,  , Breaking down tasks, TODO items
2835 @section Checkboxes
2836 @cindex checkboxes
2838 Every item in a plain list (@pxref{Plain lists}) can be made a checkbox
2839 by starting it with the string @samp{[ ]}.  This feature is similar to
2840 TODO items (@pxref{TODO items}), but more lightweight.  Checkboxes are
2841 not included into the global TODO list, so they are often great to split
2842 a task into a number of simple steps.  Or you can use them in a shopping
2843 list.  To toggle a checkbox, use @kbd{C-c C-c}, or try Piotr Zielinski's
2844 @file{org-mouse.el}.  Here is an example of a checkbox list.
2846 @example
2847 * TODO Organize party [3/6]
2848   - call people [1/3]
2849     - [ ] Peter
2850     - [X] Sarah
2851     - [ ] Sam
2852   - [X] order food
2853   - [ ] think about what music to play
2854   - [X] talk to the neighbors
2855 @end example
2857 @cindex statistics, for checkboxes
2858 @cindex checkbox statistics
2859 The @samp{[3/6]} and @samp{[1/3]} in the first and second line are
2860 cookies indicating how many checkboxes are present in this entry, and
2861 how many of them have been checked off.  This can give you an idea on
2862 how many checkboxes remain, even without opening a folded entry.  The
2863 cookies can be placed into a headline or into (the first line of) a
2864 plain list item. Each cookie covers all checkboxes structurally below
2865 that headline/item.  You have to insert the cookie yourself by typing
2866 either @samp{[/]} or @samp{[%]}.  In the first case you get an @samp{n
2867 out of m} result, in the second case you get information about the
2868 percentage of checkboxes checked (in the above example, this would be
2869 @samp{[50%]} and @samp{[33%], respectively}).
2871 @noindent The following commands work with checkboxes:
2873 @table @kbd
2874 @kindex C-c C-c
2875 @item C-c C-c
2876 Toggle checkbox at point.
2877 @kindex C-c C-x C-b
2878 @item C-c C-x C-b
2879 Toggle checkbox at point.
2880 @itemize @minus
2881 @item
2882 If there is an active region, toggle the first checkbox in the region
2883 and set all remaining boxes to the same status as the first.  If you
2884 want to toggle all boxes in the region independently, use a prefix
2885 argument.
2886 @item
2887 If the cursor is in a headline, toggle checkboxes in the region between
2888 this headline and the next (so @emph{not} the entire subtree).
2889 @item
2890 If there is no active region, just toggle the checkbox at point.
2891 @end itemize
2892 @kindex M-S-@key{RET}
2893 @item M-S-@key{RET}
2894 Insert a new item with a checkbox.
2895 This works only if the cursor is already in a plain list item
2896 (@pxref{Plain lists}).
2897 @kindex C-c #
2898 @item C-c #
2899 Update the checkbox statistics in the current outline entry.  When
2900 called with a @kbd{C-u} prefix, update the entire file.  Checkbox
2901 statistic cookies are updated automatically if you toggle checkboxes
2902 with @kbd{C-c C-c} and make new ones with @kbd{M-S-@key{RET}}.  If you
2903 delete boxes or add/change them by hand, use this command to get things
2904 back into synch.  Or simply toggle any checkbox twice with @kbd{C-c C-c}.
2905 @end table
2907 @node Timestamps, Tags, TODO items, Top
2908 @chapter Timestamps
2909 @cindex time stamps
2910 @cindex date stamps
2912 Items can be labeled with timestamps to make them useful for project
2913 planning.
2915 @menu
2916 * Time stamps::                 Assigning a time to a tree entry
2917 * Creating timestamps::         Commands which insert timestamps
2918 * Custom time format::          If you cannot work with the ISO format
2919 * Repeating items::             Deadlines that come back again and again
2920 * Progress logging::            Documenting when what work was done.
2921 @end menu
2924 @node Time stamps, Creating timestamps, Timestamps, Timestamps
2925 @section Time stamps, deadlines and scheduling
2926 @cindex time stamps
2927 @cindex ranges, time
2928 @cindex date stamps
2929 @cindex deadlines
2930 @cindex scheduling
2932 A time stamp is a specification of a date (possibly with time) in a
2933 special format, either @samp{<2003-09-16 Tue>} or @samp{<2003-09-16 Tue
2934 09:39>}@footnote{This is the standard ISO date/time format.  If you
2935 cannot get used to these, see @ref{Custom time format}}.  A time stamp
2936 can appear anywhere in the headline or body of an org-tree entry.  Its
2937 presence allows entries to be shown on specific dates in the agenda
2938 (@pxref{Weekly/Daily agenda}).  We distinguish:
2940 @table @var
2941 @item Plain time stamp
2942 @cindex timestamp
2943 A simple time stamp just assigns a date/time to an item.  This is just
2944 like writing down an appointment in a paper agenda, or like writing down
2945 an event in a diary, when you want to take note of when something
2946 happened.  In the timeline and agenda displays, the headline of an entry
2947 associated with a plain time stamp will be shown exactly on that date.
2949 @example
2950 * Meet Peter at the movies <2006-11-01 Wed 19:15>
2951 @end example
2953 @item Inactive time stamp
2954 @cindex timestamp, inactive
2955 @cindex inactive timestamp
2956 Just like a plain time stamp, but with square brackets instead of
2957 angular ones.  These time stamps are inactive in the sense that they do
2958 @emph{not} trigger an entry to show up in the agenda.
2960 @example
2961 * Gillian comes late for the fifth time [2006-11-01 Wed]
2962 @end example
2964 @item Time stamp range
2965 @cindex timerange
2966 Two time stamps connected by @samp{--} denote a time range.  The
2967 headline will be shown on the first and last day of the range, and on
2968 any dates that are displayed and fall in the range.  Here is an
2969 example:
2971 @example
2972 ** Meeting in Amsterdam
2973    <2004-08-23 Mon>--<2004-08-26 Thu>
2974 @end example
2976 @item Time stamp with SCHEDULED keyword
2977 @cindex SCHEDULED keyword
2978 If a time stamp is preceded by the word @samp{SCHEDULED:}, it means you
2979 are planning to start working on that task on the given date. So this is
2980 not about recording an event, but about planning your work.  The
2981 headline will be listed under the given date@footnote{It will still be
2982 listed on that date after it has been marked DONE.  If you don't like
2983 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
2984 addition, a reminder that the scheduled date has passed will be present
2985 in the compilation for @emph{today}, until the entry is marked DONE.
2986 I.e., the task will automatically be forwarded until completed.
2988 @example
2989 *** TODO Call Trillian for a date on New Years Eve.
2990     SCHEDULED: <2004-12-25 Sat>
2991 @end example
2993 @item Time stamp with DEADLINE keyword
2994 @cindex DEADLINE keyword
2995 If a time stamp is preceded by the word @samp{DEADLINE:}, the task
2996 (most likely a TODO item) is supposed to be finished on that date, and
2997 it will be listed then.  In addition, the compilation for @emph{today}
2998 will carry a warning about the approaching or missed deadline,
2999 starting @code{org-deadline-warning-days} before the due date, and
3000 continuing until the entry is marked DONE.  An example:
3002 @example
3003 *** TODO write article about the Earth for the Guide
3004     The editor in charge is [[bbdb:Ford Prefect]]
3005     DEADLINE: <2004-02-29 Sun>
3006 @end example
3007 @item Time stamp with CLOSED keyword
3008 @cindex CLOSED keyword
3009 When @code{org-log-done} is non-nil, Org-mode will automatically insert
3010 a special time stamp each time a TODO entry is marked done
3011 (@pxref{Progress logging}).  This time stamp is enclosed in square
3012 brackets instead of angular brackets.
3014 @item Time range with CLOCK keyword
3015 @cindex CLOCK keyword
3016 When using the clock to time the work that is being done on specific
3017 items, time ranges preceded by the CLOCK keyword are inserted
3018 automatically into the file.  The time stamps are enclosed in square
3019 brackets instead of angular brackets.  @xref{Clocking work time}.
3020 @end table
3022 @node Creating timestamps, Custom time format, Time stamps, Timestamps
3023 @section Creating timestamps
3024 @cindex creating timestamps
3025 @cindex timestamps, creating
3027 For Org-mode to recognize time stamps, they need to be in the specific
3028 format.  All commands listed below produce time stamps in the correct
3029 format.
3031 @table @kbd
3032 @kindex C-c .
3033 @item C-c .
3034 Prompt for a date and insert a corresponding time stamp.  When the
3035 cursor is at a previously used time stamp, it is updated to NOW.  When
3036 this command is used twice in succession, a time range is inserted.
3038 @kindex C-u C-c .
3039 @item C-u C-c .
3040 Like @kbd{C-c .}, but use the alternative format which contains date
3041 and time.  The default time can be rounded to multiples of 5 minutes,
3042 see the option @code{org-time-stamp-rounding-minutes}.
3044 @kindex C-c !
3045 @item C-c !
3046 Like @kbd{C-c .}, but insert an inactive time stamp that will not cause
3047 an agenda entry.
3049 @kindex C-c <
3050 @item C-c <
3051 Insert a time stamp corresponding to the cursor date in the Calendar.
3053 @kindex C-c >
3054 @item C-c >
3055 Access the Emacs calendar for the current date.  If there is a
3056 timestamp in the current line, goto the corresponding date
3057 instead.
3059 @kindex C-c C-o
3060 @item C-c C-o
3061 Access the agenda for the date given by the time stamp or -range at
3062 point (@pxref{Weekly/Daily agenda}).
3064 @kindex C-c C-d
3065 @item C-c C-d
3066 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will
3067 happen in the line directly following the headline.  
3068 @c FIXME Any CLOSED timestamp will be removed.????????
3070 @kindex C-c C-w
3071 @cindex sparse tree, for deadlines
3072 @item C-c C-w
3073 Create a sparse tree with all deadlines that are either past-due, or
3074 which will become due within @code{org-deadline-warning-days}.
3075 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
3076 prefix, check that many days.  For example, @kbd{C-1 C-c C-w} shows
3077 all deadlines due tomorrow.
3079 @kindex C-c C-s
3080 @item C-c C-s
3081 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
3082 happen in the line directly following the headline.  Any CLOSED
3083 timestamp will be removed.
3085 @kindex S-@key{left}
3086 @kindex S-@key{right}
3087 @item S-@key{left}
3088 @itemx S-@key{right}
3089 Change date at cursor by one day.  These key bindings conflict with
3090 CUA-mode (@pxref{Conflicts}).
3092 @kindex S-@key{up}
3093 @kindex S-@key{down}
3094 @item S-@key{up}
3095 @itemx S-@key{down}
3096 Change the item under the cursor in a timestamp.  The cursor can be on a
3097 year, month, day, hour or minute.  Note that if the cursor is in a
3098 headline and not at a time stamp, these same keys modify the priority of
3099 an item.  (@pxref{Priorities}). The key bindings also conflict with
3100 CUA-mode (@pxref{Conflicts}).
3102 @kindex C-c C-y
3103 @cindex evaluate time range
3104 @item C-c C-y
3105 Evaluate a time range by computing the difference between start and
3106 end.  With prefix arg, insert result after the time range (in a table:
3107 into the following column).
3108 @end table
3111 @menu
3112 * The date/time prompt::        How org-mode helps you entering date and time
3113 @end menu
3115 @node The date/time prompt,  , Creating timestamps, Creating timestamps
3116 @subsection The date/time prompt
3117 @cindex date, reading in minibuffer
3118 @cindex time, reading in minibuffer
3120 When Org-mode prompts for a date/time, the prompt suggests to enter an
3121 ISO date.  But it will in fact accept any string containing some date
3122 and/or time information.  You can, for example, use @kbd{C-y} to paste a
3123 (possibly multi-line) string copied from an email message.  Org-mode
3124 will find whatever information is in there and will replace anything not
3125 specified with the current date and time.  For example:
3127 @example
3128   3-2-5         --> 2003-02-05
3129   feb 15        --> currentyear-02-15
3130   sep 12 9      --> 2009-09-12
3131   12:45         --> today 12:45
3132   22 sept 0:34  --> currentyear-09-22 0:34
3133   12            --> currentyear-currentmonth-12
3134   Fri           --> nearest Friday (today or later)
3135   +4            --> 4 days from now (if +N is the only thing given)
3136 @end example
3138 The function understands English month and weekday abbreviations.  If
3139 you want to use unabbreviated names and/or other languages, configure
3140 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
3142 @cindex calendar, for selecting date
3143 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
3144 you don't need/want the calendar, configure the variable
3145 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
3146 prompt, either by clicking on a date in the calendar, or by pressing
3147 @key{RET}, the date selected in the calendar will be combined with the
3148 information entered at the prompt.  You can control the calendar fully
3149 from the minibuffer:
3151 @table @kbd
3152 @kindex <
3153 @item <
3154 Scroll calendar backwards by one month.
3155 @kindex >
3156 @item >
3157 Scroll calendar forwards by one month.
3158 @kindex mouse-1
3159 @item mouse-1
3160 Select date by clicking on it.
3161 @kindex S-@key{right}
3162 @item S-@key{right}
3163 One day forward.
3164 @kindex S-@key{left}
3165 @item S-@key{left}
3166 One day back.
3167 @kindex S-@key{down}
3168 @item S-@key{down}
3169 One week forward.
3170 @kindex S-@key{up}
3171 @item S-@key{up}
3172 One week back.
3173 @kindex M-S-@key{right}
3174 @item M-S-@key{right}
3175 One month forward.
3176 @kindex M-S-@key{left}
3177 @item M-S-@key{left}
3178 One month back.
3179 @kindex @key{RET}
3180 @item @key{RET}
3181 Choose date in calendar (only if nothing was typed into minibuffer).
3182 @end table
3184 @node Custom time format, Repeating items, Creating timestamps, Timestamps
3185 @section Custom time format
3186 @cindex custom date/time format
3187 @cindex time format, custom
3188 @cindex date format, custom
3190 Org-mode uses the standard ISO notation for dates and times as it is
3191 defined in ISO 8601.  If you cannot get used to this and require another
3192 representation of date and time to keep you happy, you can get it by
3193 customizing the variables @code{org-display-custom-times} and
3194 @code{org-time-stamp-custom-formats}.
3196 @table @kbd
3197 @kindex C-c C-x C-t
3198 @item C-c C-x C-t
3199 Toggle the display of custom formats for dates and times.
3200 @end table
3202 @noindent
3203 Org-mode needs the default format for scanning, so the custom date/time
3204 format does not @emph{replace} the default format - instead it is put
3205 @emph{over} the default format using text properties.  This has the
3206 following consequences:
3207 @itemize @bullet
3208 @item 
3209 You cannot place the cursor onto a time stamp anymore, only before or
3210 after.
3211 @item
3212 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
3213 each component of a time stamp.  If the cursor is at the beginning of
3214 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
3215 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
3216 time will be changed by one minute.
3217 @item
3218 When you delete a time stamp character-by-character, it will only
3219 disappear from the buffer after @emph{all} (invisible) characters
3220 belonging to the ISO timestamp have been removed.
3221 @item
3222 If the custom time stamp format is longer than the default and you are
3223 using dates in tables, table alignment will be messed up.  If the custom
3224 format is shorter, things do work as expected.
3225 @end itemize
3227 @node Repeating items, Progress logging, Custom time format, Timestamps
3228 @section Repeating items
3229 @cindex TODO items, repeating
3230 @cindex deadlines, repeating
3231 @cindex scheduling, repeating
3233 Org-mode integrates with the Emacs calendar and diary to display cyclic
3234 appointments, anniversaries and other special entries in the agenda
3235 (@pxref{Weekly/Daily agenda}).  However, it can be useful to have
3236 certain deadlines and scheduling items to auto-repeat.  The advantage of
3237 a deadline or scheduled item is that the they produce warnings ahead of
3238 time and automatically forward themselves in the agenda until they are
3239 done.  The abstract difference is therefore between cyclic
3240 @i{appointments} and cyclic @i{action items}.  For appointments you
3241 should use the diary, for actions you can uses an org-mode deadline or
3242 scheduling time stamp together with a REPEAT cookie.  For example:
3244 @example
3245 * TODO Replace batteries in smoke detector REPEAT(+18m)
3246   SCHEDULED: <2007-01-01 Mon>
3248 * TODO Get dentist appointment REPEAT(+6m)
3249   SCHEDULED: <2006-12-19 Tue>
3251 * TODO Tax report to IRS REPEAT(+1y)
3252   DEADLINE: <2007-04-01 Sun>
3253 @end example
3255 Each time you try to mark one of these entries DONE using @kbd{C-c C-t},
3256 they will automatically switch back to the state TODO, and the
3257 deadline/scheduling will be shifted accordingly.  The time units
3258 recognized by org-mode are year (y), month (m), week (w), and day (d).
3259 Org-mode will also prompt you for a note and record the fact that you
3260 have closed this item in a note under the headline.
3262 One unusual property of these repeating items is that only one instance
3263 of each exist at any given time.  So if you look back or ahead in the
3264 agenda, you will not find past and future instances, only the current
3265 one will show up.  Use a cyclic diary entry if you need all past and
3266 future instances to be visible in the agenda.
3268 @c FIXME: Document that a note is always being taken.
3270 @node Progress logging,  , Repeating items, Timestamps
3271 @section Progress Logging
3272 @cindex progress logging
3273 @cindex logging, of progress
3275 Org-mode can automatically record a time stamp when you mark a TODO item
3276 as DONE, or even each time when you change the state of a TODO item.
3277 You can also measure precisely the time you spent on specific items in a
3278 project by starting and stopping a clock when you start and stop working
3279 on an aspect of a project.
3281 @menu
3282 * Closing items::               When was this entry marked DONE?
3283 * Tracking TODO state changes::  When did the status change?
3284 * Clocking work time::          When exactly did you work on this item?
3285 @end menu
3287 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
3288 @subsection Closing items
3290 If you want to keep track of @emph{when} a certain TODO item was
3291 finished, turn on logging with@footnote{The corresponding in-buffer
3292 setting is: @code{#+STARTUP: logdone}}
3294 @lisp
3295 (setq org-log-done t)
3296 @end lisp
3298 @noindent
3299 Then each time you turn a TODO entry into DONE using either @kbd{C-c
3300 C-t} in the Org-mode buffer or @kbd{t} in the agenda buffer, a line
3301 @samp{CLOSED: [timestamp]} will be inserted just after the headline.  If
3302 you turn the entry back into a TODO item through further state cycling,
3303 that line will be removed again.  In the timeline (@pxref{Timeline}) and
3304 in the agenda (@pxref{Weekly/Daily agenda}), you can then use the
3305 @kbd{l} key to display the TODO items closed on each day, giving you an
3306 overview of what has been done on a day.  If you want to record a note
3307 along with the timestamp, use@footnote{The corresponding in-buffer
3308 setting is: @code{#+STARTUP: lognotedone}}
3310 @lisp
3311 (setq org-log-done '(done))
3312 @end lisp
3314 @node Tracking TODO state changes, Clocking work time, Closing items, Progress logging
3315 @subsection Tracking TODO state changes
3317 When TODO keywords are used as workflow states (@pxref{Workflow
3318 states}), you might want to keep track of when a state change occurred,
3319 and you may even want to attach notes to that state change.  With the
3320 setting
3322 @lisp
3323 (setq org-log-done '(state))
3324 @end lisp
3326 @noindent
3327 each state change will prompt you for a note that will be attached to
3328 the current headline.  Very likely you do not want this verbose tracking
3329 all the time, so it is probably better to configure this behavior with
3330 in-buffer options.  For example, if you are tracking purchases, put
3331 these into a separate file that starts with:
3333 @example
3334 #+SEQ_TODO: TODO ORDERED INVOICE PAYED RECEIVED SENT
3335 #+STARTUP: lognotestate
3336 @end example
3338 @node Clocking work time,  , Tracking TODO state changes, Progress logging
3339 @subsection Clocking work time
3341 Org-mode allows you to clock the time you spent on specific tasks in a
3342 project.  When you start working on an item, you can start the clock.
3343 When you stop working on that task, or when you mark the task done, the
3344 clock is stopped and the corresponding time interval is recorded.  It
3345 also computes the total time spent on each subtree of a project.
3347 @table @kbd
3348 @kindex C-c C-x C-i
3349 @item C-c C-x C-i
3350 Start the clock on the current item (clock-in).  This inserts the CLOCK
3351 keyword together with a timestamp.
3352 @kindex C-c C-x C-o
3353 @item C-c C-x C-o
3354 Stop the clock (clock-out).  The inserts another timestamp at the same
3355 location where the clock was last started.  It also directly computes
3356 the resulting time in inserts it after the time range as @samp{=>
3357 HH:MM}.  See the variable @code{org-log-done} for the possibility to
3358 record an additional note together with the clock-out time
3359 stamp@footnote{The corresponding in-buffer setting is: @code{#+STARTUP:
3360 lognoteclock-out}}.
3361 @kindex C-c C-y
3362 @item C-c C-y
3363 Recompute the time interval after changing one of the time stamps.  This
3364 is only necessary if you edit the time stamps directly.  If you change
3365 them with @kbd{S-@key{cursor}} keys, the update is automatic.
3366 @kindex C-c C-t
3367 @item C-c C-t
3368 Changing the TODO state of an item to DONE automatically stops the clock
3369 if it is running in this same item.
3370 @kindex C-c C-x C-x
3371 @item C-c C-x C-x
3372 Cancel the current clock.  This is useful if a clock was started by
3373 mistake, or if you ended up working on something else.
3374 @kindex C-c C-x C-d
3375 @item C-c C-x C-d
3376 Display time summaries for each subtree in the current buffer.  This
3377 puts overlays at the end of each headline, showing the total time
3378 recorded under that heading, including the time of any subheadings. You
3379 can use visibility cycling to study the tree, but the overlays disappear
3380 when you change the buffer (see variable
3381 @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
3382 @kindex C-c C-x C-r
3383 @item C-c C-x C-r
3384 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
3385 report as an org-mode table into the current file.
3386 @example
3387 #+BEGIN: clocktable :maxlevel 2 :emphasize nil
3389 #+END: clocktable
3390 @end example
3391 @noindent
3392 If such a block already exists, its content is replaced by the new
3393 table.  The @samp{BEGIN} line can specify options:
3394 @example
3395 :maxlevels   @r{Maximum level depth to which times are listed in the table.}
3396 :emphasize   @r{When @code{t}, emphasize level one and level two items}
3397 :block       @r{The time block to consider.  This block is specified relative}
3398              @r{to the current time and may be any of these keywords:}
3399              @r{@code{today}, @code{yesterday}, @code{thisweek}, @code{lastweek},}
3400              @r{@code{thismonth}, @code{lastmonth}, @code{thisyear}, or @code{lastyear}}.
3401 :tstart      @r{A time string specifying when to start considering times}
3402 :tend        @r{A time string specifying when to stop considering times}
3403 @end example
3404 So to get a clock summary for the current day, you could write
3405 @example
3406 #+BEGIN: clocktable :maxlevel 2 :block today
3408 #+END: clocktable
3409 @end example
3410 and to use a specific time range you could write@footnote{Note that all
3411 parameters must be specified in a single line - the line is broken here
3412 only to fit it onto the manual.}
3413 @example
3414 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>" 
3415                     :tend "<2006-08-10 Thu 12:00>"
3417 #+END: clocktable
3418 @end example
3419 @kindex C-u C-c C-x C-u
3420 @item C-u C-c C-x C-u
3421 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
3422 you have several clocktable blocks in a buffer.
3423 @end table
3425 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
3426 the agenda (@pxref{Weekly/Daily agenda}) to show which tasks have been
3427 worked on or closed during a day.
3429 @node Tags, Agenda views, Timestamps, Top
3430 @chapter Tags
3431 @cindex tags
3432 @cindex headline tagging
3433 @cindex matching, tags
3434 @cindex sparse tree, tag based
3436 If you wish to implement a system of labels and contexts for
3437 cross-correlating information, an excellent way is to assign @i{tags} to
3438 headlines.  Org-mode has extensive support for using tags.
3440 Every headline can contain a list of tags, at the end of the headline.
3441 Tags are normal words containing letters, numbers, @samp{_}, and
3442 @samp{@@}.  Tags must be preceded and followed by a single colon; like
3443 @samp{:WORK:}.  Several tags can be specified like @samp{:WORK:URGENT:}.
3445 @menu
3446 * Tag inheritance::             Tags use the tree structure of the outline
3447 * Setting tags::                How to assign tags to a headline
3448 * Tag searches::                Searching for combinations of tags
3449 @end menu
3451 @node Tag inheritance, Setting tags, Tags, Tags
3452 @section Tag inheritance
3453 @cindex inheritance, of tags
3454 @cindex sublevels, inclusion into tags match
3456 @i{Tags} make use of the hierarchical structure of outline trees.  If a
3457 heading has a certain tag, all subheadings will inherit the tag as
3458 well.  For example, in the list
3460 @example
3461 * Meeting with the French group      :WORK:
3462 ** Summary by Frank                  :BOSS:NOTES:
3463 *** TODO Prepare slides for him      :ACTION:
3464 @end example
3466 @noindent
3467 the final heading will have the tags @samp{:WORK:}, @samp{:BOSS:},
3468 @samp{:NOTES:}, and @samp{:ACTION:}.  When executing tag searches and
3469 Org-mode finds that a certain headline matches the search criterion, it
3470 will not check any sublevel headline, assuming that these likely also
3471 match, and that the list of matches can become very long.  This may
3472 not be what you want, however, and you can influence inheritance and
3473 searching using the variables @code{org-use-tag-inheritance} and
3474 @code{org-tags-match-list-sublevels}.
3476 @node Setting tags, Tag searches, Tag inheritance, Tags
3477 @section Setting tags
3478 @cindex setting tags
3479 @cindex tags, setting
3481 @kindex M-@key{TAB}
3482 Tags can simply be typed into the buffer at the end of a headline.
3483 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
3484 also a special command for inserting tags:
3486 @table @kbd
3487 @kindex C-c C-c
3488 @item C-c C-c
3489 @cindex completion, of tags
3490 Enter new tags for the current headline.  Org-mode will either offer
3491 completion or a special single-key interface for setting tags, see
3492 below.  After pressing @key{RET}, the tags will be inserted and aligned
3493 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
3494 tags in the current buffer will be aligned to that column, just to make
3495 things look nice.  TAGS are automatically realigned after promotion,
3496 demotion, and TODO state changes (@pxref{TODO basics}).
3497 @end table
3499 Org will support tag insertion based on a @emph{list of tags}.  By
3500 default this list is constructed dynamically, containing all tags
3501 currently used in the buffer.  You may also globally specify a hard list
3502 of tags with the variable @code{org-tag-alist}.  Finally you can set
3503 the default tags for a given file with lines like
3505 @example
3506 #+TAGS: @@WORK @@HOME @@TENNISCLUB
3507 #+TAGS: Laptop Car PC Sailboat
3508 @end example
3510 If you have globally defined your preferred set of tags using the
3511 variable @code{org-tag-alist}, but would like to use a dynamic tag list
3512 in a specific file: Just add an empty TAGS option line to that file:
3514 @example
3515 #+TAGS:
3516 @end example
3518 The default support method for entering tags is minibuffer completion.
3519 However, Org-mode also implements a much better method: @emph{fast tag
3520 selection}.  This method allows to select and deselect tags with a
3521 single key per tag.  To function efficiently, you should assign unique
3522 keys to most tags.  This can be done globally with
3524 @lisp
3525 (setq org-tag-alist '(("@@WORK" . ?w) ("@@HOME" . ?h) ("Laptop" . ?l)))
3526 @end lisp
3528 @noindent or on a per-file basis with
3530 @example
3531 #+TAGS: @@WORK(w)  @@HOME(h)  @@TENNISCLUB(t)  Laptop(l)  PC(p)
3532 @end example
3534 @noindent
3535 You can also group together tags that are mutually exclusive.  With
3536 curly braces@footnote{In @code{org-mode-alist} use
3537 @code{'(:startgroup)} and @code{'(:endgroup)}, respectively.  Several
3538 groups are allowed.}
3540 @example
3541 #+TAGS: @{ @@WORK(w)  @@HOME(h)  @@TENNISCLUB(t) @}  Laptop(l)  PC(p)
3542 @end example
3544 @noindent you indicate that at most one of @samp{@@WORK}, @samp{@@HOME},
3545 and @samp{@@TENNISCLUB} should be selected.
3547 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
3548 these lines to activate any changes.
3550 If at least one tag has a selection key, pressing @kbd{C-c C-c} will
3551 automatically present you with a special interface, listing inherited
3552 tags, the tags of the current headline, and a list of all legal tags
3553 with corresponding keys@footnote{Keys will automatically be assigned to
3554 tags which have no configured keys.}.  In this interface, you can use
3555 the following keys:
3557 @table @kbd
3558 @item a-z...
3559 Pressing keys assigned to tags will add or remove them from the list of
3560 tags in the current line.  Selecting a tag in a group of mutually
3561 exclusive tags will turn off any other tags from that group.
3562 @kindex @key{TAB}
3563 @item @key{TAB}
3564 Enter a tag in the minibuffer, even if the tag is not in the predefined
3565 list.  You will be able to complete on all tags present in the buffer.
3566 @kindex @key{SPC}
3567 @item @key{SPC}
3568 Clear all tags for this line.
3569 @kindex @key{RET}
3570 @item @key{RET}
3571 Accept the modified set.
3572 @item C-g
3573 Abort without installing changes.
3574 @item q
3575 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
3576 @item !
3577 Turn off groups of mutually exclusive tags.  Use this to (as an
3578 exception) assign several tags from such a group.
3579 @item C-c
3580 Toggle auto-exit after the next change (see below).
3581 If you are using expert mode, the first @kbd{C-c} will display the
3582 selection window.
3583 @end table
3585 @noindent
3586 This method lets you assign tags to a headline with very few keys.  With
3587 the above setup, you could clear the current tags and set @samp{@@HOME},
3588 @samp{Laptop} and @samp{PC} tags with just the following keys: @kbd{C-c
3589 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@HOME} to
3590 @samp{@@WORK} would be done with @kbd{C-c C-c w @key{RET}} or
3591 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
3592 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
3593 @key{RET} @key{RET}}.
3595 If you find that most of the time, you need only a single keypress to
3596 modify your list of tags, set the variable
3597 @code{org-fast-tag-selection-single-key}.  Then you no longer have to
3598 press @key{RET} to exit fast tag selection - it will immediately exit
3599 after the first change.  If you then occasionally need more keys, press
3600 @kbd{C-c} to turn off auto-exit for the current tag selection process
3601 (in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
3602 C-c}).  If you set the variable to the value @code{expert}, the special
3603 window is not even shown for single-key tag selection, it comes up only
3604 when you press an extra @kbd{C-c}.
3606 @node Tag searches,  , Setting tags, Tags
3607 @section Tag searches
3608 @cindex tag searches
3609 @cindex searching for tags
3611 Once a tags system has been set up, it can be used to collect related
3612 information into special lists.
3614 @table @kbd
3615 @kindex C-c \
3616 @item C-c \
3617 Create a sparse tree with all headlines matching a tags search.  With a
3618 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
3619 @kindex C-c a m
3620 @item C-c a m
3621 Create a global list of tag matches from all agenda files.
3622 @xref{Matching headline tags}.
3623 @kindex C-c a M
3624 @item C-c a M
3625 Create a global list of tag matches from all agenda files, but check
3626 only TODO items and force checking subitems (see variable
3627 @code{org-tags-match-list-sublevels}).
3628 @end table
3630 @cindex Boolean logic, for tag searches
3631 A @i{tags} search string can use Boolean operators @samp{&} for AND and
3632 @samp{|} for OR.  @samp{&} binds more strongly than @samp{|}.
3633 Parenthesis are currently not implemented.  A tag may also be preceded
3634 by @samp{-}, to select against it, and @samp{+} is syntactic sugar for
3635 positive selection.  The AND operator @samp{&} is optional when @samp{+}
3636 or @samp{-} is present.  Examples:
3638 @table @samp
3639 @item +WORK-BOSS
3640 Select headlines tagged @samp{:WORK:}, but discard those also tagged
3641 @samp{:BOSS:}.
3642 @item WORK|LAPTOP
3643 Selects lines tagged @samp{:WORK:} or @samp{:LAPTOP:}.
3644 @item WORK|LAPTOP&NIGHT
3645 Like before, but require the @samp{:LAPTOP:} lines to be tagged also
3646 @samp{NIGHT}.
3647 @end table
3649 @cindex TODO keyword matching, with tags search
3650 If you are using multi-state TODO keywords (@pxref{TODO extensions}), it
3651 can be useful to also match on the TODO keyword.  This can be done by
3652 adding a condition after a slash to a tags match.  The syntax is similar
3653 to the tag matches, but should be applied with consideration: For
3654 example, a positive selection on several TODO keywords can not
3655 meaningfully be combined with boolean AND.  However, @emph{negative
3656 selection} combined with AND can be meaningful.  To make sure that only
3657 lines are checked that actually have any TODO keyword, use @kbd{C-c a
3658 M}, or equivalently start the todo part after the slash with @samp{!}.
3659 Examples:
3661 @table @samp
3662 @item WORK/WAITING
3663 Select @samp{:WORK:}-tagged TODO lines with the specific TODO
3664 keyword @samp{WAITING}.
3665 @item WORK/!-WAITING-NEXT
3666 Select @samp{:WORK:}-tagged TODO lines that are neither @samp{WAITING}
3667 nor @samp{NEXT}
3668 @item WORK/+WAITING|+NEXT
3669 Select @samp{:WORK:}-tagged TODO lines that are either @samp{WAITING} or
3670 @samp{NEXT}.
3671 @end table
3673 @cindex regular expressions, with tags search
3674 Any element of the tag/todo match can be a regular expression - in this
3675 case it must be enclosed in curly braces.  For example,
3676 @samp{WORK+@{^BOSS.*@}} matches headlines that contain the tag
3677 @samp{WORK} and any tag @i{starting} with @samp{BOSS}.
3679 @cindex level, require for tags match
3680 You can also require a headline to be of a certain level, by writing
3681 instead of any TAG an expression like @samp{LEVEL=3}.  For example, a
3682 search @samp{+LEVEL=3+BOSS/-DONE} lists all level three headlines that
3683 have the tag BOSS and are @emph{not} marked with the todo keyword DONE.
3685 @node Agenda views, Embedded LaTeX, Tags, Top
3686 @chapter Agenda Views
3687 @cindex agenda views
3689 Due to the way Org-mode works, TODO items, time-stamped items, and
3690 tagged headlines can be scattered throughout a file or even a number of
3691 files.  To get an overview over open action items, or over events that
3692 are important for a particular date, this information must be collected,
3693 sorted and displayed in an organized way.
3695 Org-mode can select items based on various criteria, and display them
3696 in a separate buffer.  Six different view types are provided:
3698 @itemize @bullet
3699 @item
3700 an @emph{agenda} that is like a calendar and shows information
3701 for specific dates,
3702 @item
3703 a @emph{TODO list} that covers all unfinished
3704 action items,
3705 @item
3706 a @emph{tags view}, showings headlines based on
3707 the tags associated with them,
3708 @item
3709 a @emph{timeline view} that shows all events in a single Org-mode file,
3710 in time-sorted view,
3711 @item
3712 a @emph{stuck projects view} showing projects that currently don't move
3713 along, and
3714 @item
3715 @emph{custom views} that are special tag/keyword searches and
3716 combinations of different views.
3717 @end itemize
3719 @noindent
3720 The extracted information is displayed in a special @emph{agenda
3721 buffer}.  This buffer is read-only, but provides commands to visit the
3722 corresponding locations in the original Org-mode files, and even to
3723 edit these files remotely.  
3725 Two variables control how the agenda buffer is displayed and whether the
3726 window configuration is restored when the agenda exits:
3727 @code{org-agenda-window-setup} and
3728 @code{org-agenda-restore-windows-after-quit}.
3730 @menu
3731 * Agenda files::                Files being searched for agenda information
3732 * Agenda dispatcher::           Keyboard access to agenda views
3733 * Built-in agenda views::       What is available out of the box?
3734 * Presentation and sorting::    How agenda items are prepared for display
3735 * Agenda commands::             Remote editing of org trees
3736 * Custom agenda views::         Defining special searches and views
3737 @end menu
3739 @node Agenda files, Agenda dispatcher, Agenda views, Agenda views
3740 @section Agenda files
3741 @cindex agenda files
3742 @cindex files for agenda
3744 The information to be shown is collected from all @emph{agenda files},
3745 the files listed in the variable @code{org-agenda-files}@footnote{If the
3746 value of that variable is not a list, but a single file name, then the
3747 list of agenda files will be maintained in that external file.}.  Thus even
3748 if you only work with a single Org-mode file, this file should be put
3749 into that list@footnote{When using the dispatcher, pressing @kbd{1}
3750 before selecting a command will actually limit the command to the
3751 current file, and ignore @code{org-agenda-files} until the next
3752 dispatcher command.}.  You can customize @code{org-agenda-files}, but
3753 the easiest way to maintain it is through the following commands
3755 @cindex files, adding to agenda list
3756 @table @kbd
3757 @kindex C-c [
3758 @item C-c [
3759 Add current file to the list of agenda files.  The file is added to
3760 the front of the list.  If it was already in the list, it is moved to
3761 the front.  With prefix arg, file is added/moved to the end.
3762 @kindex C-c ]
3763 @item C-c ]
3764 Remove current file from the list of agenda files.
3765 @kindex C-,
3766 @kindex C-'
3767 @item C-,
3768 @itemx C-'
3769 Cycle through agenda file list, visiting one file after the other.
3770 @end table
3772 @noindent
3773 The Org menu contains the current list of files and can be used
3774 to visit any of them.
3776 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda views
3777 @section The agenda dispatcher
3778 @cindex agenda dispatcher
3779 @cindex dispatching agenda commands
3780 The views are created through a dispatcher that should be bound to a
3781 global key, for example @kbd{C-c a} (@pxref{Installation}).  In the
3782 following we will assume that @kbd{C-c a} is indeed how the dispatcher
3783 is accessed and list keyboard access to commands accordingly.  After
3784 pressing @kbd{C-c a}, an additional letter is required to execute a
3785 command.  The dispatcher offers the following default commands:
3786 @table @kbd
3787 @item a
3788 Create the calendar-like agenda (@pxref{Weekly/Daily agenda}).
3789 @item t @r{/} T
3790 Create a list of all TODO items (@pxref{Global TODO list}).
3791 @item m @r{/} M
3792 Create a list of headlines matching a TAGS expression (@pxref{Matching
3793 headline tags}).
3794 @item L
3795 Create the timeline view for the current buffer (@pxref{Timeline}).
3796 @item # @r{/} !
3797 Create a list of stuck projects (@pxref{Stuck projects}).
3798 @item 1
3799 Restrict an agenda command to the current buffer.  After pressing
3800 @kbd{1}, you still need to press the character selecting the command.
3801 @item 0
3802 If there is an active region, restrict the following agenda command to
3803 the region.  Otherwise, restrict it to the current subtree.  After
3804 pressing @kbd{0}, you still need to press the character selecting the
3805 command.
3806 @end table
3808 You can also define custom commands that will be accessible through the
3809 dispatcher, just like the default commands.  This includes the
3810 possibility to create extended agenda buffers that contain several
3811 blocks together, for example the weekly agenda, the global TODO list and
3812 a number of special tags matches.  @xref{Custom agenda views}.
3814 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda views
3815 @section The built-in agenda views
3817 In this section we describe the built-in views.
3819 @menu
3820 * Weekly/Daily agenda::         The calendar page with current tasks
3821 * Global TODO list::            All unfinished action items
3822 * Matching headline tags::      Structured information with fine-tuned search
3823 * Timeline::                    Time-sorted view for single file
3824 * Stuck projects::              Find projects you need to review
3825 @end menu
3827 @node Weekly/Daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
3828 @subsection The weekly/daily agenda
3829 @cindex agenda
3830 @cindex weekly agenda
3831 @cindex daily agenda
3833 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
3834 paper agenda, showing all the tasks for the current week or day.
3836 @table @kbd
3837 @cindex org-agenda, command
3838 @kindex C-c a a
3839 @item C-c a a
3840 Compile an agenda for the current week from a list of org files.  The
3841 agenda shows the entries for each day.  With a @kbd{C-u} prefix (or
3842 when the variable @code{org-agenda-include-all-todo} is @code{t}), all
3843 unfinished TODO items (including those without a date) are also listed at
3844 the beginning of the buffer, before the first date.@*
3845 @end table
3847 Remote editing from the agenda buffer means, for example, that you can
3848 change the dates of deadlines and appointments from the agenda buffer.
3849 The commands available in the Agenda buffer are listed in @ref{Agenda
3850 commands}.
3852 @subsubheading Calendar/Diary integration
3853 @cindex calendar integration
3854 @cindex diary integration
3856 Emacs contains the calendar and diary by Edward M. Reingold.  The
3857 calendar displays a three-month calendar with holidays from different
3858 countries and cultures.  The diary allows you to keep track of
3859 anniversaries, lunar phases, sunrise/set, recurrent appointments
3860 (weekly, monthly) and more.  In this way, it is quite complementary to
3861 Org-mode.  It can be very useful to combine output from Org-mode with
3862 the diary.
3864 In order to include entries from the Emacs diary into Org-mode's
3865 agenda, you only need to customize the variable
3867 @lisp
3868 (setq org-agenda-include-diary t)
3869 @end lisp
3871 @noindent After that, everything will happen automatically.  All diary
3872 entries including holidays, anniversaries etc will be included in the
3873 agenda buffer created by Org-mode.  @key{SPC}, @key{TAB}, and
3874 @key{RET} can be used from the agenda buffer to jump to the diary
3875 file in order to edit existing diary entries.  The @kbd{i} command to
3876 insert new entries for the current date works in the agenda buffer, as
3877 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
3878 Sunrise/Sunset times, show lunar phases and to convert to other
3879 calendars, respectively.  @kbd{c} can be used to switch back and forth
3880 between calendar and agenda.
3883 @node Global TODO list, Matching headline tags, Weekly/Daily agenda, Built-in agenda views
3884 @subsection The global TODO list
3885 @cindex global TODO list
3886 @cindex TODO list, global
3888 The global TODO list contains all unfinished TODO items, formatted and
3889 collected into a single place.
3891 @table @kbd
3892 @kindex C-c a t
3893 @item C-c a t
3894 Show the global TODO list.  This collects the TODO items from all
3895 agenda files (@pxref{Agenda views}) into a single buffer.  The buffer is in
3896 @code{agenda-mode}, so there are commands to examine and manipulate
3897 the TODO entries directly from that buffer (@pxref{Agenda commands}).
3898 @kindex C-c a T
3899 @item C-c a T
3900 @cindex TODO keyword matching
3901 Like the above, but allows selection of a specific TODO keyword.  You
3902 can also do this by specifying a prefix argument to @kbd{C-c a t}.  With
3903 a @kbd{C-u} prefix you are prompted for a keyword, and you may also
3904 specify several keywords by separating them with @samp{|} as boolean OR
3905 operator.  With a numeric prefix, the Nth keyword in
3906 @code{org-todo-keywords} is selected.
3907 @kindex r
3908 The @kbd{r} key in the agenda buffer regenerates it, and you can give
3909 a prefix argument to this command to change the selected TODO keyword,
3910 for example @kbd{3 r}.  If you often need a search for a specific
3911 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
3912 Matching specific TODO keywords can also be done as part of a tags
3913 search (@pxref{Tag searches}).
3914 @end table
3916 Remote editing of TODO items means that you can change the state of a
3917 TODO entry with a single key press.  The commands available in the
3918 TODO list are described in @ref{Agenda commands}.
3920 @cindex sublevels, inclusion into todo list
3921 Normally the global todo list simply shows all headlines with TODO
3922 keywords.  This list can become very long.  There are two ways to keep
3923 it more compact:
3924 @itemize @minus
3925 @item
3926 Some people view a TODO item that has been @emph{scheduled} for
3927 execution (@pxref{Time stamps}) as no longer @emph{open}.  Configure the
3928 variable @code{org-agenda-todo-ignore-scheduled} to exclude scheduled
3929 items from the global TODO list.
3930 @item
3931 TODO items may have sublevels to break up the task into subtasks.  In
3932 such cases it may be enough to list only the highest level TODO headline
3933 and omit the sublevels from the global list.  Configure the variable
3934 @code{org-agenda-todo-list-sublevels} to get this behavior.
3935 @end itemize
3937 @node Matching headline tags, Timeline, Global TODO list, Built-in agenda views
3938 @subsection Matching headline tags
3939 @cindex matching, of tags
3940 @cindex tags view
3942 If headlines in the agenda files are marked with @emph{tags}
3943 (@pxref{Tags}), you can select headlines based on the tags that apply
3944 to them and collect them into an agenda buffer.
3946 @table @kbd
3947 @kindex C-c a m
3948 @item C-c a m
3949 Produce a list of all headlines that match a given set of tags.  The
3950 command prompts for a selection criterion, which is a boolean logic
3951 expression with tags, like @samp{+WORK+URGENT-WITHBOSS} or
3952 @samp{WORK|HOME} (@pxref{Tags}).  If you often need a specific search,
3953 define a custom command for it (@pxref{Agenda dispatcher}).
3954 @kindex C-c a M
3955 @item C-c a M
3956 Like @kbd{C-c a m}, but only select headlines that are also TODO items
3957 and force checking subitems (see variable
3958 @code{org-tags-match-list-sublevels}).  Matching specific todo keywords
3959 together with a tags match is also possible, see @ref{Tag searches}.
3960 @end table
3962 The commands available in the tags list are described in @ref{Agenda
3963 commands}.
3965 @node Timeline, Stuck projects, Matching headline tags, Built-in agenda views
3966 @subsection Timeline for a single file
3967 @cindex timeline, single file
3968 @cindex time-sorted view
3970 The timeline summarizes all time-stamped items from a single Org-mode
3971 file in a @emph{time-sorted view}.  The main purpose of this command is
3972 to give an overview over events in a project.
3974 @table @kbd
3975 @kindex C-a a L
3976 @item C-c a L
3977 Show a time-sorted view of the org file, with all time-stamped items.
3978 When called with a @kbd{C-u} prefix, all unfinished TODO entries
3979 (scheduled or not) are also listed under the current date.
3980 @end table
3982 @noindent
3983 The commands available in the timeline buffer are listed in
3984 @ref{Agenda commands}.
3987 @node Stuck projects,  , Timeline, Built-in agenda views
3988 @subsection Stuck projects
3990 If you are following a system like David Allen's GTD to organize your
3991 work, one of the ``duties'' you have is a regular review to make sure
3992 that all projects move along.  A @emph{stuck} project is a project that
3993 has no defined next actions, so it will never show up in the TODO lists
3994 Org-mode produces.  During the review, you need to identify such
3995 projects and define next actions for them.
3997 @table @kbd
3998 @kindex C-c a #
3999 @item C-c a #
4000 List projects that are stuck.
4001 @kindex C-c a !
4002 @item C-c a !
4003 Customize the variable @code{org-stuck-projects} to define what a stuck
4004 project is and how to find it.
4005 @end table
4007 You almost certainly will have to configure this view before it will
4008 work for you.  The built-in default assumes that all your projects are
4009 level-2 headlines, and that a project is not stuck if it has at least
4010 one entry marked with a todo keyword TODO or NEXT or NEXTACTION.
4012 Lets assume that you, in your own way of using Org-mode, identify
4013 projects with a tag PROJECT, and that you use a todo keyword MAYBE to
4014 indicate a project that should not be considered yet.  Lets further
4015 assume that the todo keyword DONE marks finished projects, and that NEXT
4016 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
4017 is a next action even without the NEXT tag.  Finally, if the project
4018 contains the special word IGNORE anywhere, it should not be listed
4019 either.  In this case you would start by identifying eligible projects
4020 with a tags/todo match @samp{+PROJECT/-MAYBE-DONE}, and then check for
4021 TODO, NEXT, @@SHOP, and IGNORE in the subtree to identify projects that
4022 are not stuck.  The correct customization for this is
4024 @lisp
4025 (setq org-stuck-projects
4026       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
4027                                "\\<IGNORE\\>"))
4028 @end lisp
4031 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda views
4032 @section Presentation and sorting
4033 @cindex presentation, of agenda items
4035 Before displaying items in an agenda view, Org-mode visually prepares
4036 the items and sorts them.  Each item occupies a single line.  The line
4037 starts with a @emph{prefix} that contains the @emph{category}
4038 (@pxref{Categories}) of the item and other important information.  You can
4039 customize the prefix using the option @code{org-agenda-prefix-format}.
4040 The prefix is followed by a cleaned-up version of the outline headline
4041 associated with the item.
4043 @menu
4044 * Categories::                  Not all tasks are equal
4045 * Time-of-day specifications::  How the agenda knows the time
4046 * Sorting of agenda items::     The order of things
4047 @end menu
4049 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
4050 @subsection Categories
4052 @cindex category
4053 The category is a broad label assigned to each agenda item.  By default,
4054 the category is simply derived from the file name, but you can also
4055 specify it with a special line in the buffer, like this:
4057 @example
4058 #+CATEGORY: Thesis
4059 @end example
4061 If there are several such lines in a file, each specifies the category
4062 for the text below it (but the first category also applies to any text
4063 before the first CATEGORY line).  The display in the agenda buffer looks
4064 best if the category is not longer than 10 characters.
4066 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
4067 @subsection Time-of-Day Specifications
4068 @cindex time-of-day specification
4070 Org-mode checks each agenda item for a time-of-day specification.  The
4071 time can be part of the time stamp that triggered inclusion into the
4072 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
4073 ranges can be specified with two time stamps, like
4075 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
4077 In the headline of the entry itself, a time(range) may also appear as
4078 plain text (like @samp{12:45} or a @samp{8:30-1pm}.  If the agenda
4079 integrates the Emacs diary (@pxref{Weekly/Daily agenda}), time
4080 specifications in diary entries are recognized as well.
4082 For agenda display, Org-mode extracts the time and displays it in a
4083 standard 24 hour format as part of the prefix.  The example times in
4084 the previous paragraphs would end up in the agenda like this:
4086 @example
4087     8:30-13:00 Arthur Dent lies in front of the bulldozer
4088    12:45...... Ford Prefect arrives and takes Arthur to the pub
4089    19:00...... The Vogon reads his poem
4090    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
4091 @end example
4093 @cindex time grid
4094 If the agenda is in single-day mode, or for the display of today, the
4095 timed entries are embedded in a time grid, like
4097 @example
4098     8:00...... ------------------
4099     8:30-13:00 Arthur Dent lies in front of the bulldozer
4100    10:00...... ------------------
4101    12:00...... ------------------
4102    12:45...... Ford Prefect arrives and takes Arthur to the pub
4103    14:00...... ------------------
4104    16:00...... ------------------
4105    18:00...... ------------------
4106    19:00...... The Vogon reads his poem
4107    20:00...... ------------------
4108    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
4109 @end example
4111 The time grid can be turned on and off with the variable
4112 @code{org-agenda-use-time-grid}, and can be configured with
4113 @code{org-agenda-time-grid}.
4115 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
4116 @subsection Sorting of agenda items
4117 @cindex sorting, of agenda items
4118 @cindex priorities, of agenda items
4119 Before being inserted into a view, the items are sorted.  How this is
4120 done depends on the type of view.
4121 @itemize @bullet
4122 @item
4123 For the daily/weekly agenda, the items for each day are sorted.  The
4124 default order is to first collect all items containing an explicit
4125 time-of-day specification.  These entries will be shown at the beginning
4126 of the list, as a @emph{schedule} for the day.  After that, items remain
4127 grouped in categories, in the sequence given by @code{org-agenda-files}.
4128 Within each category, items are sorted by priority (@pxref{Priorities}),
4129 which is composed of the base priority (2000 for priority @samp{A}, 1000
4130 for @samp{B}, and 0 for @samp{C}), plus additional increments for
4131 overdue scheduled or deadline items.
4132 @item 
4133 For the TODO list, items remain in the order of categories, but within
4134 each category, sorting takes place according to priority
4135 (@pxref{Priorities}).
4136 @item
4137 For tags matches, items are not sorted at all, but just appear in the
4138 sequence in which they are found in the agenda files.
4139 @end itemize
4141 Sorting can be customized using the variable
4142 @code{org-agenda-sorting-strategy}.
4145 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda views
4146 @section Commands in the agenda buffer
4147 @cindex commands, in agenda buffer
4149 Entries in the agenda buffer are linked back to the org file or diary
4150 file where they originate.  You are not allowed to edit the agenda
4151 buffer itself, but commands are provided to show and jump to the
4152 original entry location, and to edit the org-files ``remotely'' from
4153 the agenda buffer.  In this way, all information is stored only once,
4154 removing the risk that your agenda and note files may diverge.
4156 Some commands can be executed with mouse clicks on agenda lines.  For
4157 the other commands, the cursor needs to be in the desired line.
4159 @table @kbd
4160 @tsubheading{Motion}
4161 @cindex motion commands in agenda
4162 @kindex n
4163 @item n
4164 Next line (same as @key{up}).
4165 @kindex p
4166 @item p
4167 Previous line (same as @key{down}).
4168 @tsubheading{View/GoTo org file}
4169 @kindex mouse-3
4170 @kindex @key{SPC}
4171 @item mouse-3
4172 @itemx @key{SPC}
4173 Display the original location of the item in another window.
4175 @kindex L
4176 @item L
4177 Display original location and recenter that window.
4179 @kindex mouse-2
4180 @kindex mouse-1
4181 @kindex @key{TAB}
4182 @item mouse-2
4183 @itemx mouse-1
4184 @itemx @key{TAB}
4185 Go to the original location of the item in another window.  Under Emacs
4186 22, @kbd{mouse-1} will also works for this.
4188 @kindex @key{RET}
4189 @itemx @key{RET}
4190 Go to the original location of the item and delete other windows.
4192 @kindex f
4193 @item f
4194 Toggle Follow mode.  In Follow mode, as you move the cursor through
4195 the agenda buffer, the other window always shows the corresponding
4196 location in the org file.  The initial setting for this mode in new
4197 agenda buffers can be set with the variable
4198 @code{org-agenda-start-with-follow-mode}.
4200 @kindex b
4201 @item b
4202 Display the entire subtree of the current item in an indirect buffer.
4203 With numerical prefix ARG, go up to this level and then take that tree.
4204 If ARG is negative, go up that many levels.  With @kbd{C-u} prefix, do
4205 not remove the previously used indirect buffer.
4207 @kindex l
4208 @item l
4209 Toggle Logbook mode.  In Logbook mode, entries that where marked DONE while
4210 logging was on (variable @code{org-log-done}) are shown in the agenda,
4211 as are entries that have been clocked on that day.
4213 @tsubheading{Change display}
4214 @cindex display changing, in agenda
4215 @kindex o
4216 @item o
4217 Delete other windows.
4219 @kindex w
4220 @item w
4221 Switch to weekly view (7 days displayed together).
4223 @kindex d
4224 @item d
4225 Switch to daily view (just one day displayed).
4227 @kindex D
4228 @item D
4229 Toggle the inclusion of diary entries.  See @ref{Weekly/Daily agenda}.
4231 @kindex g
4232 @item g
4233 Toggle the time grid on and off.  See also the variables
4234 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
4236 @kindex r
4237 @item r
4238 Recreate the agenda buffer, for example to reflect the changes
4239 after modification of the time stamps of items with S-@key{left} and
4240 S-@key{right}.  When the buffer is the global todo list, a prefix
4241 argument is interpreted to create a selective list for a specific TODO
4242 keyword.
4244 @kindex s
4245 @item s
4246 Save all Org-mode buffers in the current Emacs session.
4248 @kindex @key{right}
4249 @item @key{right}
4250 Display the following @code{org-agenda-ndays} days.  For example, if
4251 the display covers a week, switch to the following week.  With prefix
4252 arg, go forward that many times @code{org-agenda-ndays} days.
4254 @kindex @key{left}
4255 @item @key{left}
4256 Display the previous dates.
4258 @kindex .
4259 @item .
4260 Goto today.
4262 @tsubheading{Remote editing}
4263 @cindex remote editing, from agenda
4265 @item 0-9
4266 Digit argument.
4268 @cindex undoing remote-editing events
4269 @cindex remote editing, undo
4270 @kindex C-_
4271 @item C-_
4272 Undo a change due to a remote editing command.  The change is undone
4273 both in the agenda buffer and in the remote buffer.
4275 @kindex t
4276 @item t
4277 Change the TODO state of the item, both in the agenda and in the
4278 original org file.
4280 @kindex C-k
4281 @item C-k
4282 Delete the current agenda item along with the entire subtree belonging
4283 to it in the original Org-mode file.  If the text to be deleted remotely
4284 is longer than one line, the kill needs to be confirmed by the user.  See
4285 variable @code{org-agenda-confirm-kill}.
4287 @kindex $
4288 @item $
4289 Archive the subtree corresponding to the current headline.
4291 @kindex T
4292 @item T
4293 Show all tags associated with the current item.  Because of
4294 inheritance, this may be more than the tags listed in the line itself.
4296 @kindex :
4297 @item :
4298 Set tags for the current headline.
4300 @kindex a
4301 @item a
4302 Toggle the ARCHIVE tag for the current headline.
4304 @kindex ,
4305 @item ,
4306 Set the priority for the current item.  Org-mode prompts for the
4307 priority character. If you reply with @key{SPC}, the priority cookie
4308 is removed from the entry.
4310 @kindex P
4311 @item P
4312 Display weighted priority of current item.
4314 @kindex +
4315 @kindex S-@key{up}
4316 @item +
4317 @itemx S-@key{up}
4318 Increase the priority of the current item.  The priority is changed in
4319 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
4320 key for this.
4322 @kindex -
4323 @kindex S-@key{down}
4324 @item -
4325 @itemx S-@key{down}
4326 Decrease the priority of the current item.
4328 @kindex C-c C-s
4329 @item C-c C-s
4330 Schedule this item
4332 @kindex C-c C-d
4333 @item C-c C-d
4334 Set a deadline for this item.
4336 @kindex S-@key{right}
4337 @item S-@key{right}
4338 Change the time stamp associated with the current line by one day into
4339 the future.  With prefix argument, change it by that many days.  For
4340 example, @kbd{3 6 5 S-@key{right}} will change it by a year.  The
4341 stamp is changed in the original org file, but the change is not
4342 directly reflected in the agenda buffer.  Use the
4343 @kbd{r} key to update the buffer.
4345 @kindex S-@key{left}
4346 @item S-@key{left}
4347 Change the time stamp associated with the current line by one day
4348 into the past.
4350 @kindex >
4351 @item >
4352 Change the time stamp associated with the current line to today.
4353 The key @kbd{>} has been chosen, because it is the same as @kbd{S-.}
4354 on my keyboard.
4356 @kindex I
4357 @item I
4358 Start the clock on the current item.  If a clock is running already, it
4359 is stopped first.
4361 @kindex O
4362 @item O
4363 Stop the previously started clock.
4365 @kindex X
4366 @item X
4367 Cancel the currently running clock.
4369 @tsubheading{Calendar commands}
4370 @cindex calendar commands, from agenda
4371 @kindex c
4372 @item c
4373 Open the Emacs calendar and move to the date at the agenda cursor.
4375 @item c
4376 When in the calendar, compute and show the Org-mode agenda for the
4377 date at the cursor.
4379 @cindex diary entries, creating from agenda
4380 @kindex i
4381 @item i
4382 Insert a new entry into the diary.  Prompts for the type of entry
4383 (day, weekly, monthly, yearly, anniversary, cyclic) and creates a new
4384 entry in the diary, just as @kbd{i d} etc. would do in the calendar.
4385 The date is taken from the cursor position.
4387 @kindex M
4388 @item M
4389 Show the phases of the moon for the three months around current date.
4391 @kindex S
4392 @item S
4393 Show sunrise and sunset times.  The geographical location must be set
4394 with calendar variables, see documentation of the Emacs calendar.
4396 @kindex C
4397 @item C
4398 Convert the date at cursor into many other cultural and historic
4399 calendars.
4401 @kindex H
4402 @item H
4403 Show holidays for three month around the cursor date.
4405 @c FIXME:  This should be a different key.
4406 @kindex C-c C-x C-c
4407 @item C-c C-x C-c
4408 Export a single iCalendar file containing entries from all agenda files.
4410 @tsubheading{Exporting to a file}
4411 @kindex C-x C-w
4412 @item C-x C-w
4413 @cindex exporting agenda views
4414 @cindex agenda views, exporting
4415 Write the agenda view to a file.  Depending on the extension of the
4416 selected file name, the view will be exported as HTML (extension
4417 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}), or
4418 plain text (any other extension).  Use the variable
4419 @code{org-agenda-exporter-settings} to set options for @file{ps-print}
4420 and for @file{htmlize} to be used during export.
4422 @tsubheading{Quit and Exit}
4423 @kindex q
4424 @item q
4425 Quit agenda, remove the agenda buffer.
4427 @kindex x
4428 @cindex agenda files, removing buffers
4429 @item x
4430 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
4431 for the compilation of the agenda.  Buffers created by the user to
4432 visit org files will not be removed.
4433 @end table
4436 @node Custom agenda views,  , Agenda commands, Agenda views
4437 @section Custom agenda views
4438 @cindex custom agenda views
4439 @cindex agenda views, custom
4441 Custom agenda commands serve two purposes: to store and quickly access
4442 frequently used TODO and tags searches, and to create special composite
4443 agenda buffers.  Custom agenda commands will be accessible through the
4444 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
4446 @menu
4447 * Storing searches::            Type once, use often
4448 * Block agenda::                All the stuff you need in a single buffer
4449 * Setting Options::             Changing the rules
4450 * Exporting Agenda Views::      Writing agendas to files.
4451 * Extracting Agenda Information for other programs::  
4452 @end menu
4454 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
4455 @subsection Storing searches
4457 The first application of custom searches is the definition of keyboard
4458 shortcuts for frequently used searches, either creating an agenda
4459 buffer, or a sparse tree (the latter covering of course only the current
4460 buffer).
4461 @kindex C-c a C
4462 Custom commands are configured in the variable
4463 @code{org-agenda-custom-commands}.  You can customize this variable, for
4464 example by pressing @kbd{C-c a C}.  You can also directly set it with
4465 Emacs Lisp in @file{.emacs}.  The following example contains all valid
4466 search types:
4468 @lisp
4469 @group
4470 (setq org-agenda-custom-commands
4471       '(("w" todo "WAITING")
4472         ("W" todo-tree "WAITING")
4473         ("u" tags "+BOSS-URGENT")
4474         ("v" tags-todo "+BOSS-URGENT")
4475         ("U" tags-tree "+BOSS-URGENT")
4476         ("f" occur-tree "\\<FIXME\\>")))
4477 @end group
4478 @end lisp
4480 @noindent
4481 The initial single-character string in each entry defines the character
4482 you have to press after the dispatcher command @kbd{C-c a} in order to
4483 access the command.   The second parameter is the search type, followed
4484 by the string or regular expression to be used for the matching.  The
4485 example above will therefore define:
4487 @table @kbd
4488 @item C-c a w
4489 as a global search for TODO entries with @samp{WAITING} as the TODO
4490 keyword
4491 @item C-c a W
4492 as the same search, but only in the current buffer and displaying the
4493 results as a sparse tree
4494 @item C-c a u
4495 as a global tags search for headlines marked @samp{:BOSS:} but not
4496 @samp{:URGENT:}
4497 @item C-c a v
4498 as the same search as @kbd{C-c a u}, but limiting the search to
4499 headlines that are also TODO items
4500 @item C-c a U
4501 as the same search as @kbd{C-c a u}, but only in the current buffer and
4502 displaying the result as a sparse tree
4503 @item C-c a f
4504 to create a sparse tree (again: current buffer only) with all entries
4505 containing the word @samp{FIXME}.
4506 @end table
4508 @node Block agenda, Setting Options, Storing searches, Custom agenda views
4509 @subsection Block agenda
4510 @cindex block agenda
4511 @cindex agenda, with block views
4513 Another possibility is the construction of agenda views that comprise
4514 the results of @emph{several} commands, each of which creates a block in
4515 the agenda buffer.  The available commands include @code{agenda} for the
4516 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
4517 for the global todo list (as constructed with @kbd{C-c a t}), and the
4518 matching commands discussed above: @code{todo}, @code{tags}, and
4519 @code{tags-todo}.  Here are two examples:
4521 @lisp
4522 @group
4523 (setq org-agenda-custom-commands
4524       '(("h" "Agenda and Home-related tasks"
4525          ((agenda)
4526           (tags-todo "HOME")
4527           (tags "GARDEN")))
4528         ("o" "Agenda and Office-related tasks"
4529          ((agenda)
4530           (tags-todo "WORK")
4531           (tags "OFFICE")))))
4532 @end group
4533 @end lisp
4535 @noindent
4536 This will define @kbd{C-c a h} to create a multi-block view for stuff
4537 you need to attend to at home.  The resulting agenda buffer will contain
4538 your agenda for the current week, all TODO items that carry the tag
4539 @samp{HOME}, and also all lines tagged with @samp{GARDEN}.  Finally the
4540 command @kbd{C-c a o} provides a similar view for office tasks.
4543 @node Setting Options, Exporting Agenda Views, Block agenda, Custom agenda views
4544 @subsection Setting Options for custom commands
4545 @cindex options, for custom agenda views
4547 Org-mode contains a number of variables regulating agenda construction
4548 and display.  The global variables define the behavior for all agenda
4549 commands, including the custom commands.  However, if you want to change
4550 some settings just for a single custom view, you can do so.  Setting
4551 options requires inserting a list of variable names and values at the
4552 right spot in @code{org-agenda-custom-commands}.  For example:
4554 @lisp
4555 @group
4556 (setq org-agenda-custom-commands
4557       '(("w" todo "WAITING"
4558          ((org-agenda-sorting-strategy '(priority-down))
4559           (org-agenda-prefix-format "  Mixed: ")))
4560         ("U" tags-tree "+BOSS-URGENT"
4561          ((org-show-following-heading nil)
4562           (org-show-hierarchy-above nil)))))
4563 @end group
4564 @end lisp
4566 @noindent
4567 Now the @kbd{C-c a w} command will sort the collected entries only by
4568 priority, and the prefix format is modified to just say @samp{  Mixed:}
4569 instead of giving the category of the entry.  The sparse tags tree of
4570 @kbd{C-c a U} will now turn out ultra-compact, because neither the
4571 headline hierarchy above the match, nor the headline following the match
4572 will be shown.
4574 For command sets creating a block agenda,
4575 @code{org-agenda-custom-commands} has two separate spots for setting
4576 options.  You can add options that should be valid for just a single
4577 command in the set, and options that should be valid for all commands in
4578 the set.  The former are just added to the command entry, the latter
4579 must come after the list of command entries.  Going back to the block
4580 agenda example (@pxref{Block agenda}), let's change the sorting strategy
4581 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
4582 the results for GARDEN tags query in the opposite order,
4583 @code{priority-up}.  This would look like this:
4585 @lisp
4586 @group
4587 (setq org-agenda-custom-commands
4588       '(("h" "Agenda and Home-related tasks"
4589          ((agenda)
4590           (tags-todo "HOME")
4591           (tags "GARDEN"
4592                 ((org-agenda-sorting-strategy '(priority-up)))))
4593          ((org-agenda-sorting-strategy '(priority-down))))
4594         ("o" "Agenda and Office-related tasks"
4595          ((agenda)
4596           (tags-todo "WORK")
4597           (tags "OFFICE")))))
4598 @end group
4599 @end lisp
4601 As you see, the values and parenthesis setting is a little complex.
4602 When in doubt, use the customize interface to set this variable - it
4603 fully supports its structure.  Just one caveat: When setting options in
4604 this interface, the @emph{values} are just lisp expressions.  So if the
4605 value is a string, you need to add the double quotes around the value
4606 yourself.
4609 @node Exporting Agenda Views, Extracting Agenda Information for other programs, Setting Options, Custom agenda views
4610 @subsection Exporting Agenda Views
4611 @cindex agenda views, exporting
4613 If you are away from your computer, it can be very useful to have a
4614 printed version of some agenda views to carry around.  Org-mode can
4615 export custom agenda views as plain text, HTML@footnote{You need to
4616 install Hrvoje Niksic' @file{htmlize.el}.} and postscript.  If you want
4617 to do this only occasionally, use the commend
4619 @table @kbd
4620 @kindex C-x C-w
4621 @item C-x C-w
4622 @cindex exporting agenda views
4623 @cindex agenda views, exporting
4624 Write the agenda view to a file.  Depending on the extension of the
4625 selected file name, the view will be exported as HTML (extension
4626 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}), or
4627 plain text (any other extension).  Use the variable
4628 @code{org-agenda-exporter-settings} to set options for @file{ps-print}
4629 and for @file{htmlize} to be used during export, for example
4630 @lisp
4631 (setq org-agenda-exporter-settings
4632       '((ps-number-of-columns 2)
4633         (ps-landscape-mode t)
4634         (htmlize-output-type 'inline-css)))
4635 @end lisp
4636 @end table
4638 If you need to export certain agenda views frequently, you can associate
4639 any custom agenda command with a list of output file names
4640 @footnote{If you want to store standard views like the weekly agenda
4641 or the global TODO list as well, you need to define custom commands for
4642 them in order to be able to specify filenames.}.  Here is an example
4643 that first does define custom commands for the agenda and the global
4644 todo list, together with a number of files to which to export them.
4645 Then we define two block agenda commands and specify filenames for them
4646 as well.  File names can be relative to the current working directory,
4647 or absolute.
4649 @lisp
4650 @group
4651 (setq org-agenda-custom-commands
4652       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
4653         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
4654         ("h" "Agenda and Home-related tasks"
4655          ((agenda)
4656           (tags-todo "HOME")
4657           (tags "GARDEN"))
4658          nil
4659          ("~/views/home.html"))
4660         ("o" "Agenda and Office-related tasks"
4661          ((agenda)
4662           (tags-todo "WORK")
4663           (tags "OFFICE"))
4664          nil
4665          ("~/views/office.ps"))))
4666 @end group
4667 @end lisp
4669 The extension of the file name determines the type of export.  If it is
4670 @file{.html}, Org-mode will use the @file{htmlize.el} package to convert
4671 the buffer to HTML and save it to this file name.  If the extension is
4672 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
4673 postscript output.  Any other extension produces a plain ASCII file.
4675 The export files are @emph{not} created when you use one of those
4676 commands interactively.  Instead, there is a special command to produce
4677 @emph{all} specified files in one step:
4679 @table @kbd
4680 @kindex C-c a e
4681 @item C-c a e
4682 Export all agenda views that have export filenames associated with
4683 them.
4684 @end table
4686 You can use the options section of the custom agenda commands to also
4687 set options for the export commands.  For example:
4689 @lisp
4690 (setq org-agenda-custom-commands
4691       '(("X" agenda ""
4692          ((ps-number-of-columns 2)
4693           (ps-landscape-mode t)
4694           (org-agenda-prefix-format " [ ] ")
4695           (org-agenda-with-colors nil)
4696           (org-agenda-remove-tags t))
4697          ("theagenda.ps"))))
4698 @end lisp
4700 @noindent
4701 This command sets two options for the postscript exporter, to make it
4702 print in two columns in landscape format - the resulting page can be cut
4703 in two and then used in a paper agenda.  The remaining settings modify
4704 the agenda prefix to omit category and scheduling information, and
4705 instead include a checkbox to check off items.  We also remove the tags
4706 to make the lines compact, and we don't want to use colors for the
4707 black-and-white printer.  Settings specified in
4708 @code{org-agenda-exporter-settings} will also apply, but the settings
4709 in @code{org-agenda-custom-commands} take precedence.
4711 @noindent
4712 From the command line you may also use
4713 @example
4714 emacs -f org-batch-store-agenda-views -kill
4715 @end example
4716 @noindent
4717 or, if you need to modify some parameters
4718 @example
4719 emacs -eval '(org-batch-store-agenda-views                      \
4720               org-agenda-ndays 30                               \
4721               org-agenda-include-diary nil                      \
4722               org-agenda-files (quote ("~/org/project.org")))'  \
4723       -kill
4724 @end example
4725 @noindent
4726 which will create the agenda views restricted to the file
4727 @file{~/org/project.org}, without diary entries and with 30 days
4728 extent. 
4730 @node Extracting Agenda Information for other programs,  , Exporting Agenda Views, Custom agenda views
4731 @subsection Extracting Agenda Information for other programs
4732 @cindex agenda, pipe
4733 @cindex Scripts, for agenda processing
4735 Org-mode provides commands to access agenda information for the command
4736 line in emacs batch mode.  This extracted information can be sent
4737 directly to a printer, or it can be read by a program that does further
4738 processing of the data.  The first of these commands is the function
4739 @code{org-batch-agenda}, that produces an agenda view and sends it as
4740 ASCII text to STDOUT.  The command takes a single string as parameter.
4741 If the string has length 1, it is used as a key to one of the commands
4742 you have configured in @code{org-agenda-custom-commands}, basically any
4743 key you can use after @kbd{C-c a}.  For example, to directly print the
4744 current TODO list, you could use
4746 @example
4747 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
4748 @end example
4750 If the parameter is a string with 2 or more characters, it is used as a
4751 tags/todo match string.  For example, to print your local shopping list
4752 (all items with the tag @samp{shop}, but excluding the tag
4753 @samp{NewYork}), you could use
4755 @example
4756 emacs -batch -l ~/.emacs                                      \       
4757       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
4758 @end example
4760 @noindent
4761 You may also modify parameters on the fly like this:
4763 @example
4764 emacs -batch -l ~/.emacs                                      \
4765    -eval '(org-batch-agenda "a"                               \
4766             org-agenda-ndays 30                               \
4767             org-agenda-include-diary nil                      \
4768             org-agenda-files (quote ("~/org/project.org")))'  \
4769    | lpr
4770 @end example
4772 @noindent
4773 which will produce a 30 day agenda, fully restricted to the Org file
4774 @file{~/org/projects.org}, not even including the diary.
4776 If you want to process the agenda data in more sophisticated ways, you
4777 can use the command @code{org-batch-agenda-csv} to get a comma-separated
4778 list of values for each agenda item.  Each line in the output will
4779 contain a number of fields separated by commas.  The fields in a line
4780 are:
4782 @example
4783 category     @r{The category of the item}
4784 head         @r{The headline, without TODO kwd, TAGS and PRIORITY}
4785 type         @r{The type of the agenda entry, can be}
4786                 todo               @r{selected in TODO match}
4787                 tagsmatch          @r{selected in tags match}
4788                 diary              @r{imported from diary}
4789                 deadline           @r{a deadline}
4790                 scheduled          @r{scheduled}
4791                 timestamp          @r{appointment, selected by timestamp}
4792                 closed             @r{entry was closed on date}
4793                 upcoming-deadline  @r{warning about nearing deadline}
4794                 past-scheduled     @r{forwarded scheduled item}
4795                 block              @r{entry has date block including date}
4796 todo         @r{The todo keyword, if any}
4797 tags         @r{All tags including inherited ones, separated by colons}
4798 date         @r{The relevant date, like 2007-2-14}
4799 time         @r{The time, like 15:00-16:50}
4800 extra        @r{String with extra planning info}
4801 priority-l   @r{The priority letter if any was given}
4802 priority-n   @r{The computed numerical priority}
4803 @end example
4805 @noindent
4806 Time and date will only be given if a timestamp (or deadline/scheduled)
4807 lead to the selection of the item.
4809 A CSV list like this is very easy to use in a post processing script.
4810 For example, here is a Perl program that gets the TODO list from
4811 Emacs/org-mode and prints all the items, preceded by a checkbox:
4813 @example
4814 @group
4815 #!/usr/bin/perl
4817 # define the Emacs command to run
4818 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
4820 # run it and capture the output
4821 $agenda = qx@{$cmd 2>/dev/null@};
4823 # loop over all lines
4824 foreach $line (split(/\n/,$agenda)) @{
4826   # get the individual values
4827   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
4828    $priority_l,$priority_n) = split(/,/,$line);
4830   # proccess and print
4831   print "[ ] $head\n";
4833 @end group
4834 @end example
4836 @node Embedded LaTeX, Exporting, Agenda views, Top
4837 @chapter Embedded LaTeX
4838 @cindex @TeX{} interpretation
4839 @cindex La@TeX{} interpretation
4841 Plain ASCII is normally sufficient for almost all note taking.  One
4842 exception, however, are scientific notes which need to be able to
4843 contain mathematical symbols and the occasional formula.
4844 La@TeX{}@footnote{La@TeX{} is a macro system based on Donald E. Knuth's
4845 @TeX{} system.  Many of the features described here as ``La@TeX{}'' are
4846 really from @TeX{}, but for simplicity I am blurring this distinction.}
4847 is widely used to typeset scientific documents. Org-mode supports
4848 embedding La@TeX{} code into its files, because many academics are used
4849 to read La@TeX{} source code, and because it can be readily processed
4850 into images for HTML production.
4852 It is not necessary to mark La@TeX{} macros and code in any special way.
4853 If you observe a few conventions, Org-mode knows how to find it and what
4854 to do with it.
4856 @menu
4857 * Math symbols::                TeX macros for symbols and Greek letters
4858 * Subscripts and Superscripts::  Simple syntax for raising/lowering text
4859 * LaTeX fragments::             Complex formulas made easy
4860 * Processing LaTeX fragments::  Previewing LaTeX processing
4861 * CDLaTeX mode::                Speed up entering of formulas
4862 @end menu
4864 @node Math symbols, Subscripts and Superscripts, Embedded LaTeX, Embedded LaTeX
4865 @section Math symbols
4866 @cindex math symbols
4867 @cindex TeX macros
4869 You can use La@TeX{} macros to insert special symbols like @samp{\alpha}
4870 to indicate the Greek letter, or @samp{\to} to indicate an arrow.
4871 Completion for these macros is available, just type @samp{\} and maybe a
4872 few letters, and press @kbd{M-@key{TAB}} to see possible completions.
4873 Unlike La@TeX{} code, Org-mode allows these macros to be present
4874 without surrounding math delimiters, for example:
4876 @example
4877 Angles are written as Greek letters \alpha, \beta and \gamma.
4878 @end example
4880 During HTML export (@pxref{HTML export}), these symbols are translated
4881 into the proper syntax for HTML, for the above examples this is
4882 @samp{&alpha;} and @samp{&rarr;}, respectively.
4884 @node Subscripts and Superscripts, LaTeX fragments, Math symbols, Embedded LaTeX
4885 @section Subscripts and Superscripts
4886 @cindex subscript
4887 @cindex superscript
4889 Just like in La@TeX{}, @samp{^} and @samp{_} are used to indicate super-
4890 and subscripts.  Again, these can be used without embedding them in
4891 math-mode delimiters.  To increase the readability of ASCII text, it is
4892 not necessary (but OK) to surround multi-character sub- and superscripts
4893 with curly braces.  For example
4895 @example
4896 The mass if the sun is M_sun = 1.989 x 10^30 kg.  The radius of
4897 the sun is R_@{sun@} = 6.96 x 10^8 m.
4898 @end example
4900 To avoid interpretation as raised or lowered text, you can quote
4901 @samp{^} and @samp{_} with a backslash: @samp{\_} and @samp{\^}.
4903 During HTML export (@pxref{HTML export}), subscript and superscripts
4904 are surrounded with @code{<sub>} and @code{<sup>} tags, respectively.
4906 @node LaTeX fragments, Processing LaTeX fragments, Subscripts and Superscripts, Embedded LaTeX
4907 @section LaTeX fragments
4908 @cindex LaTeX fragments
4910 With symbols, sub- and superscripts, HTML is pretty much at its end when
4911 it comes to representing mathematical formulas@footnote{Yes, there is
4912 MathML, but that is not yet fully supported by many browsers, and there
4913 is no decent converter for turning LaTeX of ASCII representations of
4914 formulas into MathML.  So for the time being, converting formulas into
4915 images seems the way to go.}.  More complex
4916 expressions need a dedicated formula processor.  To this end, Org-mode
4917 can contain arbitrary La@TeX{} fragments.  It provides commands to
4918 preview the typeset result of these fragments, and upon export to HTML,
4919 all fragments will be converted to images and inlined into the HTML
4920 document.  For this to work you need to be on a system with a working
4921 La@TeX{} installation.  You also need the @file{dvipng} program,
4922 available at @url{http://sourceforge.net/projects/dvipng/}.  The LaTeX
4923 header that will be used when processing a fragment can be configured
4924 with the variable @code{org-format-latex-header}.
4926 La@TeX{} fragments don't need any special marking at all.  The following
4927 snippets will be identified as LaTeX source code:
4928 @itemize @bullet
4929 @item
4930 Environments of any kind.  The only requirement is that the
4931 @code{\begin} statement appears on a new line, preceded by only
4932 whitespace.
4933 @item
4934 Text within the usual La@TeX{} math delimiters.  To avoid conflicts with
4935 currency specifications, single @samp{$} characters are only recognized
4936 as math delimiters if the enclosed text contains at most two line breaks,
4937 is directly attached to the @samp{$} characters with no whitespace in
4938 between, and if the closing @samp{$} is followed by whitespace or
4939 punctuation.  For the other delimiters, there is no such restriction, so
4940 when in doubt, use @samp{\(...\)} as inline math delimiters.
4941 @end itemize
4943 @noindent For example:
4945 @example
4946 \begin@{equation@}                          % arbitrary environments,
4947 x=\sqrt@{b@}                                % even tables, figures
4948 \end@{equation@}                            % etc
4950 If $a^2=b$ and \( b=2 \), then the solution must be
4951 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
4952 @end example
4954 @noindent
4955 If you need any of the delimiter ASCII sequences for other purposes, you
4956 can configure the option @code{org-format-latex-options} to deselect the
4957 ones you do not wish to have interpreted by the La@TeX{} converter.
4959 @node Processing LaTeX fragments, CDLaTeX mode, LaTeX fragments, Embedded LaTeX
4960 @section Processing LaTeX fragments
4961 @cindex LaTeX fragments, preview
4963 La@TeX{} fragments can be processed to produce a preview images of the
4964 typeset expressions:
4966 @table @kbd
4967 @kindex C-c C-x C-l
4968 @item C-c C-x C-l
4969 Produce a preview image of the La@TeX{} fragment at point and overlay it
4970 over the source code.  If there is no fragment at point, process all
4971 fragments in the current entry (between two headlines).  When called
4972 with a prefix argument, process the entire subtree.  When called with
4973 two prefix arguments, or when the cursor is before the first headline,
4974 process the entire buffer.
4975 @kindex C-c C-c
4976 @item C-c C-c
4977 Remove the overlay preview images.
4978 @end table
4980 During HTML export (@pxref{HTML export}), all La@TeX{} fragments are
4981 converted into images and inlined into the document if the following
4982 setting is active:
4984 @lisp
4985 (setq org-export-with-LaTeX-fragments t)
4986 @end lisp
4988 @node CDLaTeX mode,  , Processing LaTeX fragments, Embedded LaTeX
4989 @section Using CDLaTeX to enter math
4990 @cindex CDLaTeX
4992 CDLaTeX-mode is a minor mode that is normally used in combination with a
4993 major LaTeX mode like AUCTeX in order to speed-up insertion of
4994 environments and math templates.  Inside Org-mode, you can make use of
4995 some of the features of cdlatex-mode.  You need to install
4996 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
4997 AUCTeX) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
4998 Don't turn cdlatex-mode itself under Org-mode, but use the light
4999 version @code{org-cdlatex-mode} that comes as part of Org-mode.  Turn it
5000 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
5001 Org-mode files with
5003 @lisp
5004 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
5005 @end lisp
5007 When this mode is enabled, the following features are present (for more
5008 details see the documentation of cdlatex-mode):
5009 @itemize @bullet
5010 @kindex C-c @{
5011 @item
5012 Environment templates can be inserted with @kbd{C-c @{}.
5013 @item
5014 @kindex @key{TAB}
5015 The @key{TAB} key will do template expansion if the cursor is inside a
5016 LaTeX fragment@footnote{Org-mode has a method to test if the cursor is
5017 inside such a fragment, see the documentation of the function
5018 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
5019 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
5020 correctly inside the first brace.  Another @key{TAB} will get you into
5021 the second brace.  Even outside fragments, @key{TAB} will expand
5022 environment abbreviations at the beginning of a line.  For example, if
5023 you write @samp{equ} at the beginning of a line and press @key{TAB},
5024 this abbreviation will be expanded to an @code{equation} environment.
5025 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
5026 @item
5027 @kindex _
5028 @kindex ^
5029 Pressing @kbd{_} and @kbd{^} inside a LaTeX fragment will insert these
5030 characters together with a pair of braces.  If you use @key{TAB} to move
5031 out of the braces, and if the braces surround only a single character or
5032 macro, they are removed again (depending on the variable
5033 @code{cdlatex-simplify-sub-super-scripts}).
5034 @item
5035 @kindex `
5036 Pressing the backquote @kbd{`} followed by a character inserts math
5037 macros, also outside LaTeX fragments.  If you wait more than 1.5 seconds
5038 after the backquote, a help window will pop up.
5039 @item
5040 @kindex '
5041 Pressing the normal quote @kbd{'} followed by another character modifies
5042 the symbol before point with an accent or a font.  If you wait more than
5043 1.5 seconds after the backquote, a help window will pop up.  Character
5044 modification will work only inside La@TeX{} fragments, outside the quote
5045 is normal.
5046 @end itemize
5048 @node Exporting, Publishing, Embedded LaTeX, Top
5049 @chapter Exporting
5050 @cindex exporting
5052 Org-mode documents can be exported into a variety of other formats.  For
5053 printing and sharing of notes, ASCII export produces a readable and
5054 simple version of an Org-mode file.  HTML export allows you to publish a
5055 notes file on the web, while the XOXO format provides a solid base for
5056 exchange with a broad range of other applications.  To incorporate
5057 entries with associated times like deadlines or appointments into a
5058 desktop calendar program like iCal, Org-mode can also produce extracts
5059 in the iCalendar format.  Currently Org-mode only supports export, not
5060 import of these different formats.
5062 When exporting, Org-mode uses special conventions to enrich the output
5063 produced.  @xref{Text interpretation}, for more details.
5065 @table @kbd
5066 @kindex C-c C-e
5067 @item C-c C-e
5068 Dispatcher for export and publishing commands.  Displays a help-window
5069 listing the additional key(s) needed to launch an export or publishing
5070 command.
5071 @end table
5073 @menu
5074 * ASCII export::                Exporting to plain ASCII
5075 * HTML export::                 Exporting to HTML
5076 * XOXO export::                 Exporting to XOXO
5077 * iCalendar export::            Exporting in iCalendar format
5078 * Text interpretation::         How the exporter looks at the file
5079 @end menu
5081 @node ASCII export, HTML export, Exporting, Exporting
5082 @section ASCII export
5083 @cindex ASCII export
5085 ASCII export produces a simple and very readable version of an Org-mode
5086 file.
5088 @cindex region, active
5089 @cindex active region
5090 @cindex transient-mark-mode
5091 @table @kbd
5092 @kindex C-c C-e a
5093 @item C-c C-e a
5094 Export as ASCII file.  If there is an active region, only the region
5095 will be exported.  For an org file @file{myfile.org}, the ASCII file
5096 will be @file{myfile.txt}.  The file will be overwritten without
5097 warning.
5098 @kindex C-c C-e v a
5099 @item C-c C-e v a
5100 Export only the visible part of the document.
5101 @end table
5103 @cindex headline levels, for exporting
5104 In the exported version, the first 3 outline levels will become
5105 headlines, defining a general document structure.  Additional levels
5106 will be exported as itemized lists.  If you want that transition to occur
5107 at a different level, specify it with a prefix argument.  For example,
5109 @example
5110 @kbd{C-1 C-c C-e a}
5111 @end example
5113 @noindent
5114 creates only top level headlines and does the rest as items.  When
5115 headlines are converted to items, the indentation of the text following
5116 the headline is changed to fit nicely under the item.  This is done with
5117 the assumption that the first bodyline indicates the base indentation of
5118 the body text.  Any indentation larger than this is adjusted to preserve
5119 the layout relative to the first line.  Should there be lines with less
5120 indentation than the first, these are left alone.
5122 @node HTML export, XOXO export, ASCII export, Exporting
5123 @section HTML export
5124 @cindex HTML export
5126 Org-mode contains an HTML (XHTML 1.0 strict) exporter with extensive
5127 HTML formatting, in ways similar to John Grubers @emph{markdown}
5128 language, but with additional support for tables.
5130 @menu
5131 * Export commands::             How to invoke HTML export
5132 * Quoting HTML tags::           Using direct HTML in Org-mode
5133 * Links::                       How hyperlinks get transferred to HTML
5134 * Images::                      To inline or not to inline?
5135 * CSS support::                 Style specifications
5136 @end menu
5138 @node Export commands, Quoting HTML tags, HTML export, HTML export
5139 @subsection HTML export commands
5141 @cindex region, active
5142 @cindex active region
5143 @cindex transient-mark-mode
5144 @table @kbd
5145 @kindex C-c C-e h
5146 @item C-c C-e h
5147 Export as HTML file @file{myfile.html}.
5148 @kindex C-c C-e b
5149 @item C-c C-e b
5150 Export as HTML file and open it with a browser.
5151 @kindex C-c C-e H
5152 @item C-c C-e H
5153 Export to a temporary buffer, do not create a file.
5154 @kindex C-c C-e v h
5155 @kindex C-c C-e v b
5156 @kindex C-c C-e v H
5157 @item C-c C-e v h
5158 @item C-c C-e v b
5159 @item C-c C-e v H
5160 Export only the visible part of the document.
5161 @end table
5163 @cindex headline levels, for exporting
5164 In the exported version, the first 3 outline levels will become
5165 headlines, defining a general document structure.  Additional levels
5166 will be exported as itemized lists.  If you want that transition to occur
5167 at a different level, specify it with a prefix argument.  For example,
5169 @example
5170 @kbd{C-2 C-c C-e b}
5171 @end example
5173 @noindent
5174 creates two levels of headings and does the rest as items.
5176 @node Quoting HTML tags, Links, Export commands, HTML export
5177 @subsection Quoting HTML tags
5179 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
5180 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
5181 which should be interpreted as such, mark them with @samp{@@} as in
5182 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
5183 simple tags.  For more extensive HTML that should be copied verbatim to
5184 the exported file use either
5186 @example
5187 #+HTML: Literal HTML code for export
5188 @end example
5190 @noindent or
5192 @example
5193 #+BEGIN_HTML
5194 All lines between these markers are exported literally
5195 #+END_HTML
5196 @end example
5199 @node Links, Images, Quoting HTML tags, HTML export
5200 @subsection Links
5202 @cindex links, in HTML export
5203 @cindex internal links, in HTML export
5204 @cindex external links, in HTML export
5205 Internal links (@pxref{Internal links}) will continue to work in HTML
5206 files only if they match a dedicated @samp{<<target>>}.  Automatic links
5207 created by radio targets (@pxref{Radio targets}) will also work in the
5208 HTML file.  Links to external files will still work if the HTML file is
5209 in the same directory as the Org-mode file.  Links to other @file{.org}
5210 files will be translated into HTML links under the assumption that an
5211 HTML version also exists of the linked file.  For information related to
5212 linking files while publishing them to a publishing directory see
5213 @ref{Publishing links}.
5215 @node Images, CSS support, Links, HTML export
5216 @subsection Images
5218 @cindex images, inline in HTML
5219 @cindex inlining images in HTML
5220 HTML export can inline images given as links in the Org-mode file, and
5221 it can make an image the clickable part of a link.  By
5222 default@footnote{but see the variable
5223 @code{org-export-html-inline-images}}, images are inlined if a link does
5224 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
5225 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
5226 @samp{the image} that points to the image.  If the description part
5227 itself is a @code{file:} link or a @code{http:} URL pointing to an
5228 image, this image will be inlined and activated so that clicking on the
5229 image will activate the link.  For example, to include a thumbnail that
5230 will link to a high resolution version of the image, you could use:
5232 @example
5233 [[file:highres.jpg][file:thumb.jpg]]
5234 @end example
5236 @noindent
5237 and you could use @code{http} addresses just as well.
5239 @node CSS support,  , Images, HTML export
5240 @subsection CSS support
5242 You can also give style information for the exported file.  The HTML
5243 exporter assigns the following CSS classes to appropriate parts of the
5244 document - your style specifications may change these:
5245 @example
5246 .todo           @r{TODO keywords}
5247 .done           @r{the DONE keyword}
5248 .timestamp      @r{time stamp}
5249 .timestamp-kwd  @r{keyword associated with a time stamp, like SCHEDULED}
5250 .tag            @r{tag in a headline}
5251 .target         @r{target for links}
5252 @end example
5254 The default style specification can be configured through the option
5255 @code{org-export-html-style}.  If you want to use a file-local style,
5256 you may use file variables, best wrapped into a COMMENT section at the
5257 end of the outline tree.  For example@footnote{Under Emacs 21, the
5258 continuation lines for a variable value should have no @samp{#} at the
5259 start of the line.}:
5261 @example
5262 * COMMENT html style specifications
5264 # Local Variables:
5265 # org-export-html-style: "   <style type=\"text/css\">
5266 #       p @{font-weight: normal; color: gray; @}
5267 #       h1 @{color: black; @}
5268 #   </style>"
5269 # End:
5270 @end example
5272 Remember to execute @kbd{M-x normal-mode} after changing this to make
5273 the new style visible to Emacs.  This command restarts org-mode for the
5274 current buffer and forces Emacs to re-evaluate the local variables
5275 section in the buffer.
5277 @c FIXME: More about header and footer styles
5278 @c FIXME: Talk about links and targets.
5280 @node XOXO export, iCalendar export, HTML export, Exporting
5281 @section XOXO export
5282 @cindex XOXO export
5284 Org-mode contains an exporter that produces XOXO-style output.
5285 Currently, this exporter only handles the general outline structure and
5286 does not interpret any additional Org-mode features.
5288 @table @kbd
5289 @kindex C-c C-e x
5290 @item C-c C-e x
5291 Export as XOXO file @file{myfile.html}.
5292 @kindex C-c C-e v
5293 @item C-c C-e v x
5294 Export only the visible part of the document.
5295 @end table
5297 @node iCalendar export, Text interpretation, XOXO export, Exporting
5298 @section iCalendar export
5299 @cindex iCalendar export
5301 Some people like to use Org-mode for keeping track of projects, but
5302 still prefer a standard calendar application for anniversaries and
5303 appointments.  In this case it can be useful to have deadlines and
5304 other time-stamped items in Org-mode files show up in the calendar
5305 application.  Org-mode can export calendar information in the standard
5306 iCalendar format.  If you also want to have TODO entries included in the
5307 export, configure the variable @code{org-icalendar-include-todo}.
5309 @table @kbd
5310 @kindex C-c C-e i
5311 @item C-c C-e i
5312 Create iCalendar entries for the current file and store them in the same
5313 directory, using a file extension @file{.ics}.
5314 @kindex C-c C-e I
5315 @item C-c C-e I
5316 Like @kbd{C-c C-e i}, but do this for all files in
5317 @code{org-agenda-files}.  For each of these files, a separate iCalendar
5318 file will be written.
5319 @kindex C-c C-e c
5320 @item C-c C-e c
5321 Create a single large iCalendar file from all files in
5322 @code{org-agenda-files} and write it to the file given by
5323 @code{org-combined-agenda-icalendar-file}.
5324 @end table
5326 How this calendar is best read and updated, depends on the application
5327 you are using.  The FAQ covers this issue.
5330 @node Text interpretation,  , iCalendar export, Exporting
5331 @section Text interpretation by the exporter
5333 The exporter backends interpret additional structure in the Org-mode file
5334 in order to produce better output.
5336 @menu
5337 * Comment lines::               Some lines will not be exported
5338 * Initial text::                Text before the first headline
5339 * Enhancing text::              Subscripts, symbols and more
5340 * Export options::              How to influence the export settings
5341 @end menu
5343 @node Comment lines, Initial text, Text interpretation, Text interpretation
5344 @subsection Comment lines
5345 @cindex comment lines
5346 @cindex exporting, not
5348 Lines starting with @samp{#} in column zero are treated as comments
5349 and will never be exported.  Also entire subtrees starting with the
5350 word @samp{COMMENT} will never be exported.
5352 @table @kbd
5353 @kindex C-c ;
5354 @item C-c ;
5355 Toggle the COMMENT keyword at the beginning of an entry.
5356 @end table
5358 @node Initial text, Enhancing text, Comment lines, Text interpretation
5359 @subsection Text before the first headline
5361 Org-mode normally ignores any text before the first headline when
5362 exporting, leaving this region for internal links to speed up navigation
5363 etc.  However, in publishing-oriented files, you might want to have some
5364 text before the first headline, like a small introduction, special HTML
5365 code with a navigation bar, etc.  You can ask to have this part of the
5366 file exported as well by setting the variable
5367 @code{org-export-skip-text-before-1st-heading} to @code{nil}.  On a
5368 per-file basis, you can get the same effect with
5370 @example
5371 #+OPTIONS: skip:nil
5372 @end example
5374 The text before the first headline will be fully processed
5375 (@pxref{Enhancing text}), and the first non-comment line becomes the
5376 title of the exported document.  If you need to include literal HTML,
5377 use the special constructs described in @ref{Quoting HTML tags}.  The
5378 table of contents is normally inserted directly before the first
5379 headline of the file.  If you would like to get it to a different
5380 location, insert the string @code{[TABLE-OF-CONTENTS]} on a line by
5381 itself at the desired location.
5383 Finally, if you want to use the space before the first headline for
5384 internal purposes, but @emph{still} want to place something before the
5385 first headline when exporting the file, you can use the @code{#+TEXT}
5386 construct:
5388 @example
5389 #+OPTIONS: skip:t
5390 #+TEXT: This text will go before the *first* headline.
5391 #+TEXT: We place the table of contents here:
5392 #+TEXT: [TABLE-OF-CONTENTS]
5393 #+TEXT: This goes between the table of contents and the first headline
5394 @end example
5396 @node Enhancing text, Export options, Initial text, Text interpretation
5397 @subsection Enhancing text for export
5398 @cindex enhancing text
5399 @cindex richer text
5401 Some of the export backends of Org-mode allow for sophisticated text
5402 formatting, this is true in particular for the HTML backend.  Org-mode
5403 has a number of typing conventions that allow to produce a richly
5404 formatted output.
5406 @itemize @bullet
5408 @cindex hand-formatted lists
5409 @cindex lists, hand-formatted
5410 @item
5411 Plain lists @samp{-}, @samp{*} or @samp{+} as bullet, or with @samp{1.}
5412 or @samp{2)} as enumerator will be recognized and transformed if the
5413 backend supports lists.  See @xref{Plain lists}.
5415 @cindex underlined text
5416 @cindex bold text
5417 @cindex italic text
5418 @item
5419 You can make words @b{*bold*}, @i{/italic/}, _underlined_,
5420 @code{=code=}, and even @samp{+strikethrough+}@footnote{but remember
5421 that strikethrough is typographically evil and should @i{never} be
5422 used.}.
5424 @cindex horizontal rules, in exported files
5425 @item
5426 A line consisting of only dashes, and at least 5 of them, will be
5427 exported as a horizontal line (@samp{<hr/>} in HTML).
5429 @cindex LaTeX fragments, export
5430 @cindex TeX macros, export
5431 @item
5432 Many @TeX{} macros and entire La@TeX{} fragments are converted into HTML
5433 entities or images (@pxref{Embedded LaTeX}).
5435 @cindex tables, export
5436 @item
5437 Tables are transformed into native tables under the exporter, if the
5438 export backend supports this. Data fields before the first horizontal
5439 separator line will be formatted as table header fields.
5441 @cindex fixed width
5442 @item
5443 If a headline starts with the word @samp{QUOTE}, the text below the
5444 headline will be typeset as fixed-width, to allow quoting of computer
5445 codes etc.  Lines starting with @samp{:} are also typeset in
5446 fixed-width font.
5447 @table @kbd
5448 @kindex C-c :
5449 @item C-c :
5450 Toggle fixed-width for entry (QUOTE) or region, see below.
5451 @end table
5453 @cindex linebreak, forced
5454 @item 
5455 A double backslash @emph{at the end of a line} enforces a line break at
5456 this position.
5457 @end itemize
5459 If these conversions conflict with your habits of typing ASCII text,
5460 they can all be turned off with corresponding variables.  See the
5461 customization group @code{org-export-general}, and the following section
5462 which explains how to set export options with special lines in a
5463 buffer.
5466 @node Export options,  , Enhancing text, Text interpretation
5467 @subsection Export options
5468 @cindex options, for export
5470 @cindex completion, of option keywords
5471 The exporter recognizes special lines in the buffer which provide
5472 additional information.  These lines may be put anywhere in the file.
5473 The whole set of lines can be inserted into the buffer with @kbd{C-c
5474 C-e t}.  For individual lines, a good way to make sure the keyword is
5475 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
5476 (@pxref{Completion}).
5478 @table @kbd
5479 @kindex C-c C-e t
5480 @item C-c C-e t
5481 Insert template with export options, see example below.
5482 @end table
5484 @example
5485 #+TITLE:     the title to be shown (default is the buffer name)
5486 #+AUTHOR:    the author (default taken from @code{user-full-name})
5487 #+EMAIL:     his/her email address (default from @code{user-mail-address})
5488 #+LANGUAGE:  language for HTML, e.g. @samp{en} (@code{org-export-default-language})
5489 #+TEXT:      Some descriptive text to be inserted at the beginning.
5490 #+TEXT:      Several lines may be given.
5491 #+OPTIONS:   H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t *:nil TeX:t LaTeX:t skip:t
5492 @end example
5494 @noindent
5495 The OPTIONS line is a compact form to specify export settings.  Here
5496 you can:
5497 @cindex headline levels
5498 @cindex section-numbers
5499 @cindex table of contents
5500 @cindex linebreak preservation
5501 @cindex quoted HTML tags
5502 @cindex fixed-width sections
5503 @cindex tables
5504 @cindex @TeX{}-like syntax for sub- and superscripts
5505 @cindex emphasized text
5506 @cindex @TeX{} macros
5507 @cindex La@TeX{} fragments
5508 @example
5509 H:      @r{set the number of headline levels for export}
5510 num:    @r{turn on/off section-numbers}
5511 toc:    @r{turn on/off table of contents, or set level limit (integer)}
5512 \n:     @r{turn on/off linebreak-preservation}
5513 @@:      @r{turn on/off quoted HTML tags}
5514 ::      @r{turn on/off fixed-width sections}
5515 |:      @r{turn on/off tables}
5516 ^:      @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
5517         @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
5518         @r{the simple @code{a_b} will be left as it is.}
5519 *:      @r{turn on/off emphasized text (bold, italic, underlined)}
5520 TeX:    @r{turn on/off simple @TeX{} macros in plain text}
5521 LaTeX:  @r{turn on/off La@TeX{} fragments}
5522 skip:   @r{turn on/off skipping the text before the first heading}
5523 @end example
5525 @node Publishing, Miscellaneous, Exporting, Top
5526 @chapter Publishing
5527 @cindex publishing
5529 Org-mode includes@footnote{@file{org-publish.el} is not yet part of
5530 Emacs, so if you are using @file{org.el} as it comes with Emacs, you
5531 need to download this file separately.  Also make sure org.el is at
5532 least version 4.27.} a publishing management system
5533 that allows you to configure automatic HTML conversion of
5534 @emph{projects} composed of interlinked org files.  This system is
5535 called @emph{org-publish}.  You can also configure org-publish to
5536 automatically upload your exported HTML pages and related attachments,
5537 such as images and source code files, to a web server.  Org-publish turns
5538 org-mode into a web-site authoring tool.
5540 Org-publish has been contributed to Org-mode by David O'Toole.
5542 @menu
5543 * Configuration::               Defining projects
5544 * Sample configuration::        Example projects
5545 * Triggering publication::      Publication commands
5546 @end menu
5548 @node Configuration, Sample configuration, Publishing, Publishing
5549 @section Configuration
5551 Publishing needs significant configuration to specify files, destination
5552 and many other properties of a project.
5554 @menu
5555 * Project alist::               The central configuration variable
5556 * Sources and destinations::    From here to there
5557 * Selecting files::             What files are part of the project?
5558 * Publishing action::           Setting the function doing the publishing
5559 * Publishing options::          Tweaking HTML export
5560 * Publishing links::            Which links keep working after publishing?
5561 * Project page index::          Publishing a list of project files
5562 @end menu
5564 @node Project alist, Sources and destinations, Configuration, Configuration
5565 @subsection The variable @code{org-publish-project-alist}
5566 @cindex org-publish-project-alist
5567 @cindex projects, for publishing
5569 Org-publish is configured almost entirely through setting the value of
5570 one variable, called @code{org-publish-project-alist}.
5571 Each element of the list configures one project, and may be in one of
5572 the two following forms:
5574 @lisp
5575 ("project-name"  :property value :property value ...)
5577 @r{or} 
5579 ("project-name"  :components ("project-name" "project-name" ...))
5581 @end lisp
5583 In both cases, projects are configured by specifying property values.
5584 A project defines the set of files that will be published, as well as
5585 the publishing configuration to use when publishing those files.  When
5586 a project takes the second form listed above, the individual members
5587 of the ``components'' property are taken to be components of the
5588 project, which group together files requiring different publishing
5589 options. When you publish such a ``meta-project'' all the components
5590 will also publish.
5592 @node Sources and destinations, Selecting files, Project alist, Configuration
5593 @subsection Sources and destinations for files
5594 @cindex directories, for publishing
5596 Most properties are optional, but some should always be set. In
5597 particular, org-publish needs to know where to look for source files,
5598 and where to put published files.
5600 @multitable @columnfractions 0.3 0.7
5601 @item @code{:base-directory}
5602 @tab Directory containing publishing source files
5603 @item @code{:publishing-directory}
5604 @tab Directory (possibly remote) where output files will be published.
5605 @item @code{:preparation-function}
5606 @tab Function called before starting publishing process, for example to
5607 run @code{make} for updating files to be published.
5608 @end multitable
5609 @noindent
5611 @node Selecting files, Publishing action, Sources and destinations, Configuration
5612 @subsection Selecting files
5613 @cindex files, selecting for publishing
5615 By default, all files with extension @file{.org} in the base directory
5616 are considered part of the project.  This can be modified by setting the
5617 properties 
5618 @multitable @columnfractions 0.25 0.75
5619 @item @code{:base-extension}
5620 @tab Extension (without the dot!) of source files.  This actually is a
5621 regular expression.
5623 @item @code{:exclude} 
5624 @tab Regular expression to match file names that should not be
5625 published, even though they have been selected on the basis of their
5626 extension.
5628 @item @code{:include}
5629 @tab List of files to be included regardless of @code{:base-extension}
5630 and @code{:exclude}.
5631 @end multitable
5633 @node Publishing action, Publishing options, Selecting files, Configuration
5634 @subsection Publishing Action
5635 @cindex action, for publishing
5637 Publishing means that a file is copied to the destination directory and
5638 possibly transformed in the process.  The default transformation is to
5639 export Org-mode files as HTML files, and this is done by the function
5640 @code{org-publish-org-to-html} which calls the HTML exporter
5641 (@pxref{HTML export}).  Other files like images only need to be copied
5642 to the publishing destination.  For non-Org-mode files, you need to
5643 specify the publishing function.
5645 @multitable @columnfractions 0.3 0.7
5646 @item @code{:publishing-function}
5647 @tab Function executing the publication of a file.  This may also be a
5648 list of functions, which will all be called in turn.
5649 @end multitable
5651 The function must accept two arguments: a property list containing at
5652 least a @code{:publishing-directory} property, and the name of the file
5653 to be published.  It should take the specified file, make the necessary
5654 transformation (if any) and place the result into the destination folder.
5655 You can write your own publishing function, but @code{org-publish}
5656 provides one for attachments (files that only need to be copied):
5657 @code{org-publish-attachment}.
5659 @node Publishing options, Publishing links, Publishing action, Configuration
5660 @subsection Options for the HTML exporter
5661 @cindex options, for publishing
5663 The property list can be used to set many export options for the HTML
5664 exporter.  In most cases, these properties correspond to user variables
5665 in Org-mode.  The table below lists these properties along with the
5666 variable they belong to.  See the documentation string for the
5667 respective variable for details.
5669 @multitable @columnfractions 0.3 0.7
5670 @item @code{:language}              @tab @code{org-export-default-language}
5671 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
5672 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
5673 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
5674 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
5675 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
5676 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
5677 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
5678 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
5679 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
5680 @item @code{:timestamps}           .@tab @code{org-export-with-timestamps}
5681 @item @code{:tags}                 .@tab @code{org-export-with-tags}
5682 @item @code{:tables}                @tab @code{org-export-with-tables}
5683 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
5684 @item @code{:style}                 @tab @code{org-export-html-style}
5685 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
5686 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
5687 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
5688 @item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
5689 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
5690 @item @code{:preamble}              @tab @code{org-export-html-preamble}
5691 @item @code{:postamble}             @tab @code{org-export-html-postamble}
5692 @item @code{:auto-preamble}         @tab @code{org-export-html-auto-preamble}
5693 @item @code{:auto-postamble}        @tab @code{org-export-html-auto-postamble}
5694 @item @code{:author}                @tab @code{user-full-name}
5695 @item @code{:email}                 @tab @code{user-mail-address}
5696 @end multitable
5698 When a property is given a value in org-publish-project-alist, its
5699 setting overrides the value of the corresponding user variable (if any)
5700 during publishing.  options set within a file (@pxref{Export
5701 options}), however, override everything.
5703 @node Publishing links, Project page index, Publishing options, Configuration
5704 @subsection Links between published files
5705 @cindex links, publishing
5707 To create a link from one Org-mode file to another, you would use
5708 something like @samp{[[file:foo.org][The foo]]} or simply
5709 @samp{file:foo.org.} (@pxref{Hyperlinks}).  Upon publishing this link
5710 becomes a link to @file{foo.html}.  In this way, you can interlink the
5711 pages of your "org web" project and the links will work as expected when
5712 you publish them to HTML.
5714 You may also link to related files, such as images. Provided you are
5715 careful with relative pathnames, and provided you have also configured
5716 org-publish to upload the related files, these links will work
5717 too. @ref{Complex example} for an example of this usage.
5719 Sometime an Org-mode file to be published may contain links that are
5720 only valid in your production environment, but not in the publishing
5721 location.  In this case, use the property 
5723 @multitable @columnfractions 0.4 0.6
5724 @item @code{:link-validation-function}
5725 @tab Function to validate links
5726 @end multitable
5728 @noindent
5729 to define a function for checking link validity.  This function must
5730 accept two arguments, the file name and a directory relative to which
5731 the file name is interpreted in the production environment.  If this
5732 function returns @code{nil}, then the HTML generator will only insert a
5733 description into the HTML file, but no link.  One option for this
5734 function is @code{org-publish-validate-link} which checks if the given
5735 file is part of any project in @code{org-publish-project-alist}.
5737 @node Project page index,  , Publishing links, Configuration
5738 @subsection Project page index
5739 @cindex index, of published pages
5741 The following properties may be used to control publishing of an
5742 index of files or summary page for a given project.
5744 @multitable @columnfractions 0.25 0.75
5745 @item @code{:auto-index}
5746 @tab When non-nil, publish an index during org-publish-current-project or
5747 org-publish-all.
5749 @item @code{:index-filename}
5750 @tab Filename for output of index. Defaults to @file{index.org} (which
5751 becomes @file{index.html}).
5753 @item @code{:index-title}
5754 @tab Title of index page. Defaults to name of file.
5756 @item @code{:index-function}
5757 @tab Plugin function to use for generation of index.
5758 Defaults to @code{org-publish-org-index}, which generates a plain list
5759 of links to all files in the project.
5760 @end multitable
5762 @node Sample configuration, Triggering publication, Configuration, Publishing
5763 @section Sample configuration
5765 Below we provide two example configurations.  The first one is a simple
5766 project publishing only a set of Org-mode files.  The second example is
5767 more complex, with a multi-component project.
5769 @menu
5770 * Simple example::              One-component publishing
5771 * Complex example::             A multi-component publishing example
5772 @end menu
5774 @node Simple example, Complex example, Sample configuration, Sample configuration
5775 @subsection Example: simple publishing configuration
5777 This example publishes a set of Org-mode files to the @file{public_html}
5778 directory on the local machine.
5780 @lisp
5781 (setq org-publish-project-alist
5782       '(("org" 
5783          :base-directory "~/org/"
5784          :publishing-directory "~/public_html"
5785          :section-numbers nil
5786          :table-of-contents nil
5787          :style "<link rel=stylesheet 
5788                 href=\"../other/mystyle.css\"
5789                 type=\"text/css\">")))
5790 @end lisp
5792 @node Complex example,  , Simple example, Sample configuration
5793 @subsection Example: complex publishing configuration
5795 This more complicated example publishes an entire website, including
5796 org files converted to HTML, image files, emacs lisp source code, and
5797 stylesheets. The publishing-directory is remote and private files are
5798 excluded.
5800 To ensure that links are preserved, care should be taken to replicate
5801 your directory structure on the web server, and to use relative file
5802 paths. For example, if your org files are kept in @file{~/org} and your
5803 publishable images in @file{~/images}, you'd link to an image with
5805 @example
5806 file:../images/myimage.png
5807 @end example
5809 On the web server, the relative path to the image should be the
5810 same. You can accomplish this by setting up an "images" folder in the
5811 right place on the webserver, and publishing images to it.
5813 @lisp
5814 (setq org-publish-project-alist
5815       '(("orgfiles"
5816           :base-directory "~/org/"
5817           :base-extension "org"
5818           :publishing-directory "/ssh:user@@host:~/html/notebook/"
5819           :publishing-function org-publish-org-to-html
5820           :exclude "PrivatePage.org"   ;; regexp
5821           :headline-levels 3
5822           :section-numbers nil
5823           :table-of-contents nil
5824           :style "<link rel=stylesheet 
5825                   href=\"../other/mystyle.css\" type=\"text/css\">"
5826           :auto-preamble t
5827           :auto-postamble nil)
5828          
5829          ("images"
5830           :base-directory "~/images/"
5831           :base-extension "jpg\\|gif\\|png"
5832           :publishing-directory "/ssh:user@@host:~/html/images/"
5833           :publishing-function org-publish-attachment)
5835          ("other"
5836           :base-directory "~/other/"
5837           :base-extension "css\\|el"
5838           :publishing-directory "/ssh:user@@host:~/html/other/"
5839           :publishing-function org-publish-attachment)
5840          ("website" :components ("orgfiles" "images" "other"))))
5841 @end lisp
5843 @node Triggering publication,  , Sample configuration, Publishing
5844 @section Triggering publication
5846 Once org-publish is properly configured, you can publish with the
5847 following functions: 
5849 @table @kbd
5850 @item C-c C-e C
5851 Prompt for a specific project and publish all files that belong to it.
5852 @item C-c C-e P
5853 Publish the project containing the current file.
5854 @item C-c C-e F
5855 Publish only the current file.
5856 @item C-c C-e A
5857 Publish all projects.
5858 @end table
5860 Org uses timestamps to track when a file has changed. The above
5861 functions normally only publish changed files. You can override this and
5862 force publishing of all files by giving a prefix argument.
5864 @node Miscellaneous, Extensions and Hacking, Publishing, Top
5865 @chapter Miscellaneous
5867 @menu
5868 * Completion::                  M-TAB knows what you need
5869 * Customization::               Adapting Org-mode to your taste
5870 * In-buffer settings::          Overview of the #+KEYWORDS
5871 * The very busy C-c C-c key::   When in doubt, press C-c C-c
5872 * Clean view::                  Getting rid of leading stars in the outline
5873 * TTY keys::                    Using Org-mode on a tty
5874 * Interaction::                 Other Emacs packages
5875 * Bugs::                        Things which do not work perfectly
5876 @end menu
5878 @node Completion, Customization, Miscellaneous, Miscellaneous
5879 @section Completion
5880 @cindex completion, of @TeX{} symbols
5881 @cindex completion, of TODO keywords
5882 @cindex completion, of dictionary words
5883 @cindex completion, of option keywords
5884 @cindex completion, of tags
5885 @cindex completion, of link abbreviations
5886 @cindex @TeX{} symbol completion
5887 @cindex TODO keywords completion
5888 @cindex dictionary word completion
5889 @cindex option keyword completion
5890 @cindex tag completion
5891 @cindex link abbreviations, completion of
5893 Org-mode supports in-buffer completion.  This type of completion does
5894 not make use of the minibuffer.  You simply type a few letters into
5895 the buffer and use the key to complete text right there.
5897 @table @kbd
5898 @kindex M-@key{TAB}
5899 @item M-@key{TAB}
5900 Complete word at point
5901 @itemize @bullet
5902 @item
5903 At the beginning of a headline, complete TODO keywords.
5904 @item
5905 After @samp{\}, complete @TeX{} symbols supported by the exporter.
5906 @item
5907 After @samp{*}, complete headlines in the current buffer so that they
5908 can be used in search links like @samp{[[*find this headline]]}.
5909 @item
5910 After @samp{:}, complete tags.  The list of tags is taken from the
5911 variable @code{org-tag-alist} (possibly set through the @samp{#+TAGS}
5912 in-buffer option, @pxref{Setting tags}), or it is created dynamically
5913 from all tags used in the current buffer.
5914 @item
5915 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
5916 @item
5917 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
5918 @samp{OPTIONS} which set file-specific options for Org-mode.  When the
5919 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
5920 will insert example settings for this keyword.
5921 @item
5922 In the line after @samp{#+STARTUP: }, complete startup keywords,
5923 i.e. valid keys for this line.
5924 @item
5925 Elsewhere, complete dictionary words using ispell.
5926 @end itemize
5927 @end table
5929 @node Customization, In-buffer settings, Completion, Miscellaneous
5930 @section Customization
5931 @cindex customization
5932 @cindex options, for customization
5933 @cindex variables, for customization
5935 There are more than 180 variables that can be used to customize
5936 Org-mode.  For the sake of compactness of the manual, I am not
5937 describing the variables here.  A structured overview of customization
5938 variables is available with @kbd{M-x org-customize}.  Or select
5939 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
5940 settings can also be activated on a per-file basis, by putting special
5941 lines into the buffer (@pxref{In-buffer settings}).
5943 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
5944 @section Summary of in-buffer settings
5945 @cindex in-buffer settings
5946 @cindex special keywords
5948 Org-mode uses special lines in the buffer to define settings on a
5949 per-file basis.  These lines start with a @samp{#+} followed by a
5950 keyword, a colon, and then individual words defining a setting.  Several
5951 setting words can be in the same line, but you can also have multiple
5952 lines for the keyword.  While these settings are described throughout
5953 the manual, here is a summary.  After changing any of those lines in the
5954 buffer, press @kbd{C-c C-c} with the cursor still in the line to
5955 activate the changes immediately.  Otherwise they become effective only
5956 when the file is visited again in a new Emacs session.
5958 @table @kbd
5959 @item #+STARTUP:
5960 This line sets options to be used at startup of org-mode, when an
5961 Org-mode file is being visited.  The first set of options deals with the
5962 initial visibility of the outline tree.  The corresponding variable for
5963 global default settings is @code{org-startup-folded}, with a default
5964 value @code{t}, which means @code{overview}.
5965 @cindex @code{overview}, STARTUP keyword
5966 @cindex @code{content}, STARTUP keyword
5967 @cindex @code{showall}, STARTUP keyword
5968 @example
5969 overview   @r{top-level headlines only}
5970 content    @r{all headlines}
5971 showall    @r{no folding at all, show everything}
5972 @end example
5973 Then there are options for aligning tables upon visiting a file.  This
5974 is useful in files containing narrowed table columns.  The corresponding
5975 variable is @code{org-startup-align-all-tables}, with a default value
5976 @code{nil}. 
5977 @cindex @code{align}, STARTUP keyword
5978 @cindex @code{noalign}, STARTUP keyword
5979 @example
5980 align      @r{align all tables}
5981 noalign    @r{don't align tables on startup}
5982 @end example
5983 Logging TODO state changes and clock intervals (variable
5984 @code{org-log-done}) can be configured using these options.
5985 @cindex @code{logdone}, STARTUP keyword
5986 @cindex @code{nologging}, STARTUP keyword
5987 @cindex @code{lognotedone}, STARTUP keyword
5988 @cindex @code{lognoteclock-out}, STARTUP keyword
5989 @cindex @code{lognotestate}, STARTUP keyword
5990 @cindex @code{logrepeat}, STARTUP keyword
5991 @cindex @code{nologrepeat}, STARTUP keyword
5992 @example
5993 logging          @r{record a timestamp when an item is marked DONE}
5994 nologging        @r{don't record when items are marked DONE}
5995 lognotedone      @r{record timestamp and a note when DONE}
5996 lognotestate     @r{record timestamp, note when TODO state changes}
5997 logrepeat        @r{record a not when re-instating a repeating item}
5998 nologrepeat      @r{do not record when re-instating repeating item}
5999 lognoteclock-out @r{record timestamp and a note when clocking out}
6000 @end example
6001 Here are the options for hiding leading stars in outline headings.  The
6002 corresponding variables are @code{org-hide-leading-stars} and
6003 @code{org-odd-levels-only}, both with a default setting @code{nil}
6004 (meaning @code{showstars} and @code{oddeven}).
6005 @cindex @code{hidestars}, STARTUP keyword
6006 @cindex @code{showstars}, STARTUP keyword
6007 @cindex @code{odd}, STARTUP keyword
6008 @cindex @code{even}, STARTUP keyword
6009 @example
6010 hidestars  @r{make all but one of the stars starting a headline invisible.}
6011 showstars  @r{show all stars starting a headline}
6012 odd        @r{allow only odd outline levels (1,3,...)}
6013 oddeven    @r{allow all outline levels}
6014 @end example
6015 To turn on custom format overlays over time stamps (variables
6016 @code{org-put-time-stamp-overlays} and
6017 @code{org-time-stamp-overlay-formats}), use
6018 @cindex @code{customtime}, STARTUP keyword
6019 @example
6020 customtime @r{overlay custom time format}
6021 @end example
6022 The following options influence the table spreadsheet (variable
6023 @code{constants-unit-system}).
6024 @cindex @code{constcgs}, STARTUP keyword
6025 @cindex @code{constSI}, STARTUP keyword
6026 @example
6027 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
6028 constSI    @r{@file{constants.el} should use the SI unit system}
6029 @end example
6030 @item #+SEQ_TODO:   #+TYP_TODO:
6031 These lines set the TODO keywords and their interpretation in the
6032 current file.  The corresponding variables are @code{org-todo-keywords}
6033 and @code{org-todo-interpretation}.
6034 @item #+TAGS:  TAG1(c1) TAG2(c2)
6035 These lines (several such lines are allowed) specify the legal tags in
6036 this file, and (potentially) the corresponding @emph{fast tag selection}
6037 keys.  The corresponding variable is @code{org-tag-alist}.
6038 @item #+LINK:  linkword replace
6039 These lines (several are allowed) specify link abbreviations.
6040 @xref{Link abbreviations}.  The corresponding variable is
6041 @code{org-link-abbrev-alist}.
6042 @item #+CATEGORY:
6043 This line sets the category for the agenda file.  The category applies
6044 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
6045 end of the file.  The first such line also applies to any entries before it.
6046 @item #+ARCHIVE: %s_done::
6047 This line sets the archive location for the agenda file.  It applies for
6048 all subsequent lines until the next @samp{#+CATEGORY} line, or the end
6049 of the file.  The first such line also applies to any entries before it.
6050 The corresponding variable is @code{org-archive-location}.
6051 @item #+TBLFM:
6052 This line contains the formulas for the table directly above the line.
6053 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+OPTIONS:
6054 These lines provide settings for exporting files.  For more details see
6055 @ref{Export options}.
6056 @end table
6058 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
6059 @section The very busy C-c C-c key
6060 @kindex C-c C-c
6061 @cindex C-c C-c, overview
6063 The key @kbd{C-c C-c} has many purposes in org-mode, which are all
6064 mentioned scattered throughout this manual.  One specific function of
6065 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
6066 other circumstances it means something like @emph{Hey Org-mode, look
6067 here and update according to what you see here}.  Here is a summary of
6068 what this means in different contexts.
6070 @itemize @minus
6071 @item
6072 If there are highlights in the buffer from the creation of a sparse
6073 tree, or from clock display, remove these highlights.
6074 @item
6075 If the cursor is in one of the special @code{#+KEYWORD} lines, this
6076 triggers scanning the buffer for these lines and updating the
6077 information. 
6078 @item
6079 If the cursor is inside a table, realign the table.  This command
6080 works even if the automatic table editor has been turned off.
6081 @item
6082 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
6083 the entire table.
6084 @item
6085 If the cursor is inside a table created by the @file{table.el} package,
6086 activate that table.
6087 @item
6088 If the current buffer is a remember buffer, close the note and file it.
6089 With a prefix argument, file it, without further interaction, to the
6090 default location.
6091 @item
6092 If the cursor is on a @code{<<<target>>>}, update radio targets and
6093 corresponding links in this buffer.
6094 @item
6095 If the cursor is in a plain list item with a checkbox, toggle the status
6096 of the checkbox.
6097 @item
6098 If the cursor is on a numbered item in a plain list, renumber the
6099 ordered list.
6100 @end itemize
6102 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
6103 @section A cleaner outline view
6104 @cindex hiding leading stars
6105 @cindex clean outline view
6107 Some people find it noisy and distracting that the Org-mode headlines
6108 are starting with a potentially large number of stars.  For example
6109 the tree from @ref{Headlines}:
6111 @example
6112 * Top level headline
6113 ** Second level
6114 *** 3rd level
6115     some text
6116 *** 3rd level
6117     more text
6118 * Another top level headline
6119 @end example
6121 @noindent
6122 Unfortunately this is deeply ingrained into the code of Org-mode and
6123 cannot be easily changed.  You can, however, modify the display in such
6124 a way that all leading stars become invisible and the outline more easy
6125 to read.  To do this, customize the variable
6126 @code{org-hide-leading-stars} like this:
6128 @lisp
6129 (setq org-hide-leading-stars t)
6130 @end lisp
6132 @noindent
6133 or change this on a per-file basis with one of the lines (anywhere in
6134 the buffer)
6136 @example
6137 #+STARTUP: showstars
6138 #+STARTUP: hidestars
6139 @end example
6141 @noindent
6142 Press @kbd{C-c C-c} with the cursor in a @samp{STARTUP} line to activate
6143 the modifications.
6145 With stars hidden, the tree becomes:
6147 @example
6148 * Top level headline
6149  * Second level
6150   * 3rd level
6151     some text
6152   * 3rd level
6153     more text
6154 * Another top level headline
6155 @end example
6157 @noindent
6158 Note that the leading stars are not truly replaced by whitespace, they
6159 are only fontified with the face @code{org-hide} that uses the
6160 background color as font color.  If you are not using either white or
6161 black background, you may have to customize this face to get the wanted
6162 effect.  Another possibility is to set this font such that the extra
6163 stars are @i{almost} invisible, for example using the color
6164 @code{grey90} on a white background.
6166 Things become cleaner still if you skip all the even levels and use only
6167 odd levels 1, 3, 5..., effectively adding two stars to go from one
6168 outline level to the next:
6170 @example
6171 * Top level headline
6172   * Second level
6173     * 3rd level
6174       some text
6175     * 3rd level
6176       more text
6177 * Another top level headline
6178 @end example
6180 @noindent
6181 In order to make the structure editing and export commands handle this
6182 convention correctly, use
6184 @lisp
6185 (setq org-odd-levels-only t)
6186 @end lisp
6188 @noindent
6189 or set this on a per-file basis with one of the following lines (don't
6190 forget to press @kbd{C-c C-c} with the cursor in the startup line to
6191 activate changes immediately).
6193 @example
6194 #+STARTUP: odd
6195 #+STARTUP: oddeven
6196 @end example
6198 You can convert an Org-mode file from single-star-per-level to the
6199 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
6200 RET} in that file.  The reverse operation is @kbd{M-x
6201 org-convert-to-oddeven-levels}.
6203 @node TTY keys, Interaction, Clean view, Miscellaneous
6204 @section Using org-mode on a tty
6205 @cindex tty keybindings
6207 Org-mode uses a number of keys that are not accessible on a tty.  This
6208 applies to most special keys like cursor keys, @key{TAB} and
6209 @key{RET}, when these are combined with modifier keys like @key{Meta}
6210 and/or @key{Shift}.  Org-mode uses these bindings because it needs to
6211 provide keys for a large number of commands, and because these keys
6212 appeared particularly easy to remember.  In order to still be able to
6213 access the core functionality of Org-mode on a tty, alternative
6214 bindings are provided.  Here is a complete list of these bindings,
6215 which are obviously more cumbersome to use.  Note that sometimes a
6216 work-around can be better.  For example changing a time stamp is
6217 really only fun with @kbd{S-@key{cursor}} keys.  On a tty you would
6218 rather use @kbd{C-c .}  to re-insert the timestamp.
6220 @multitable @columnfractions 0.15 0.2 0.2
6221 @item @b{Default} @tab @b{Alternative 1} @tab @b{Alternative 2}
6222 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab
6223 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{@key{Esc} @key{left}}
6224 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab
6225 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{@key{Esc} @key{right}}
6226 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab
6227 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{@key{Esc} @key{up}}
6228 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab
6229 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{@key{Esc} @key{down}}
6230 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab
6231 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab
6232 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{@key{Esc} @key{RET}}
6233 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab
6234 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab
6235 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab
6236 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab
6237 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab
6238 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab
6239 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab
6240 @end multitable
6242 @node Interaction, Bugs, TTY keys, Miscellaneous
6243 @section Interaction with other packages
6244 @cindex packages, interaction with other
6245 Org-mode lives in the world of GNU Emacs and interacts in various ways
6246 with other code out there.
6248 @menu
6249 * Cooperation::                 Packages Org-mode cooperates with
6250 * Conflicts::                   Packages that lead to conflicts
6251 @end menu
6253 @node Cooperation, Conflicts, Interaction, Interaction
6254 @subsection Packages that Org-mode cooperates with
6256 @table @asis
6257 @cindex @file{calc.el}
6258 @item @file{calc.el} by Dave Gillespie
6259 Org-mode uses the calc package for implementing spreadsheet
6260 functionality in its tables (@pxref{The spreadsheet}).  Org-mode
6261 checks for the availability of calc by looking for the function
6262 @code{calc-eval} which should be autoloaded in your setup if calc has
6263 been installed properly.  As of Emacs 22, calc is part of the Emacs
6264 distribution.  Another possibility for interaction between the two
6265 packages is using calc for embedded calculations. @xref{Embedded Mode,
6266 , Embedded Mode, calc, GNU Emacs Calc Manual}.
6267 @cindex @file{constants.el}
6268 @item @file{constants.el} by Carsten Dominik
6269 In a table formula (@pxref{The spreadsheet}), it is possible to use
6270 names for natural constants or units.  Instead of defining your own
6271 constants in the variable @code{org-table-formula-constants}, install
6272 the @file{constants} package which defines a large number of constants
6273 and units, and lets you use unit prefixes like @samp{M} for
6274 @samp{Mega} etc.  You will need version 2.0 of this package, available
6275 at @url{http://www.astro.uva.nl/~dominik/Tools}. Org-mode checks for
6276 the function @code{constants-get}, which has to be autoloaded in your
6277 setup.  See the installation instructions in the file
6278 @file{constants.el}.
6279 @item @file{cdlatex.el} by Carsten Dominik
6280 @cindex @file{cdlatex.el}
6281 Org-mode can make use of the cdlatex package to efficiently enter
6282 La@TeX{} fragments into Org-mode files. See @ref{CDLaTeX mode}.
6283 @item @file{remember.el} by John Wiegley
6284 @cindex @file{remember.el}
6285 Org mode cooperates with remember, see @ref{Remember}.
6286 @file{Remember.el} is not part of Emacs, find it on the web.
6287 @cindex @file{table.el}
6288 @item @file{table.el} by Takaaki Ota
6289 @kindex C-c C-c
6290 @cindex table editor, @file{table.el}
6291 @cindex @file{table.el}
6293 Complex ASCII tables with automatic line wrapping, column- and
6294 row-spanning, and alignment can be created using the Emacs table
6295 package by Takaaki Ota (@uref{http://sourceforge.net/projects/table},
6296 and also part of Emacs 22).
6297 When @key{TAB} or @kbd{C-c C-c} is pressed in such a table, Org-mode
6298 will call @command{table-recognize-table} and move the cursor into the
6299 table.  Inside a table, the keymap of Org-mode is inactive.  In order
6300 to execute Org-mode-related commands, leave the table.
6302 @table @kbd
6303 @kindex C-c C-c
6304 @item C-c C-c
6305 Recognize @file{table.el} table.  Works when the cursor is in a
6306 table.el table.
6308 @kindex C-c ~
6309 @item C-c ~
6310 Insert a table.el table.  If there is already a table at point, this
6311 command converts it between the table.el format and the Org-mode
6312 format.  See the documentation string of the command
6313 @code{org-convert-table} for the restrictions under which this is
6314 possible.
6315 @end table
6316 @file{table.el} is part of Emacs 22.
6317 @end table
6319 @node Conflicts,  , Cooperation, Interaction
6320 @subsection Packages that lead to conflicts with Org-mode
6322 @table @asis
6324 @cindex @file{allout.el}
6325 @item @file{allout.el} by Ken Manheimer
6326 Startup of Org-mode may fail with the error message
6327 @code{(wrong-type-argument keymapp nil)} when there is an outdated
6328 version @file{allout.el} on the load path, for example the version
6329 distributed with Emacs 21.x.  Upgrade to Emacs 22 and this problem will
6330 disappear.  If for some reason you cannot do this, make sure that org.el
6331 is loaded @emph{before} @file{allout.el}, for example by putting
6332 @code{(require 'org)} early enough into your @file{.emacs} file.
6334 @cindex @file{CUA.el}
6335 @item @file{CUA.el} by Kim. F. Storm
6336 Keybindings in Org-mode conflict with the @kbd{S-<cursor>} keys
6337 used by CUA-mode (as well as pc-select-mode and s-region-mode) to
6338 select and extend the region.  If you want to use one of these
6339 packages along with Org-mode, configure the variable
6340 @code{org-CUA-compatible}.  When set, Org-mode will move the following
6341 keybindings in org-mode files, and in the agenda buffer (but not
6342 during date selection).
6344 @example
6345 S-UP    -> M-p             S-DOWN  -> M-n
6346 S-LEFT  -> M--             S-RIGHT -> M-+
6347 @end example
6349 Yes, these are unfortunately more difficult to remember.  If you want
6350 to have other replacement keys, look at the variable
6351 @code{org-disputed-keys}.
6352 @item @file{windmove.el} by Hovav Shacham
6353 @cindex @file{windmove.el}
6354 Also this package uses the @kbd{S-<cursor>} keys, so everything written
6355 in the paragraph above about CUA mode also applies here.
6356 @end table
6358 @node Bugs,  , Interaction, Miscellaneous
6359 @section Bugs
6360 @cindex bugs
6362 Here is a list of things that should work differently, but which I
6363 have found too hard to fix.
6365 @itemize @bullet
6366 @item
6367 If a table field starts with a link, and if the corresponding table
6368 column is narrowed (@pxref{Narrow columns}) to a width too small to
6369 display the link, the field would look entirely empty even though it is
6370 not.  To prevent this, Org-mode throws an error.  The work-around is to
6371 make the column wide enough to fit the link, or to add some text (at
6372 least 2 characters) before the link in the same field.
6373 @item
6374 Narrowing table columns does not work on XEmacs, because the
6375 @code{format} function does not transport text properties.
6376 @item
6377 Text in an entry protected with the @samp{QUOTE} keyword should not
6378 autowrap.
6379 @item
6380 When the application called by @kbd{C-c C-o} to open a file link fails
6381 (for example because the application does not exist or refuses to open
6382 the file), it does so silently.  No error message is displayed.
6383 @item
6384 Recalculating a table line applies the formulas from left to right.
6385 If a formula uses @emph{calculated} fields further down the row,
6386 multiple recalculation may be needed to get all fields consistent.  You
6387 may use the command @code{org-table-iterate} (@kbd{C-u C-c *}) to
6388 recalculate until convergence.
6389 @item
6390 A single letter cannot be made bold, for example @samp{*a*}.
6391 @item
6392 The exporters work well, but could be made more efficient.
6393 @end itemize
6396 @node Extensions and Hacking, History and Acknowledgments, Miscellaneous, Top
6397 @appendix Extensions, Hooks and Hacking
6399 This appendix lists extensions for Org-mode written by other authors.
6400 It also covers some aspects where users can extend the functionality of
6401 Org-mode.
6403 @menu
6404 * Extensions::                  Existing 3rd-part extensions
6405 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
6406 * Dynamic blocks::              Automatically filled blocks
6407 * Special agenda views::        Customized views
6408 @end menu
6410 @node Extensions, Tables in arbitrary syntax, Extensions and Hacking, Extensions and Hacking
6411 @section Third-party extensions for Org-mode
6412 @cindex extension, third-party
6414 The following extensions for Org-mode have been written by other people:
6416 @table @asis
6417 @cindex @file{org-publish.el}
6418 @item @file{org-publish.el} by David O'Toole
6419 This package provides facilities for publishing related sets of Org-mode
6420 files together with linked files like images as webpages.  It is
6421 highly configurable and can be used for other publishing purposes as
6422 well.  As of Org-mode version 4.30, @file{org-publish.el} is part of the
6423 Org-mode distribution.  It is not yet part of Emacs, however, a delay
6424 caused by the preparations for the 22.1 release.  In the mean time,
6425 @file{org-publish.el} can be downloaded from David's site:
6426 @url{http://dto.freeshell.org/e/org-publish.el}.
6427 @cindex @file{org-mouse.el}
6428 @item @file{org-mouse.el} by Piotr Zielinski
6429 This package implements extended mouse functionality for Org-mode.  It
6430 allows you to cycle visibility and to edit the document structure with
6431 the mouse.  Best of all, it provides a context-sensitive menu on
6432 @key{mouse-3} that changes depending on the context of a mouse-click.
6433 As of Org-mode version 4.53, @file{org-mouse.el} is part of the
6434 Org-mode distribution.  It is not yet part of Emacs, however, a delay
6435 caused by the preparations for the 22.1 release.  In the mean time,
6436 @file{org-mouse.el} can be downloaded from Piotr's site:
6437 @url{http://www.cl.cam.ac.uk/~pz215/files/org-mouse.el}.
6438 @cindex @file{org-blog.el}
6439 @item @file{org-blog.el} by David O'Toole
6440 A blogging plug-in for @file{org-publish.el}.@*
6441 @url{http://dto.freeshell.org/notebook/OrgMode.html}.
6442 @cindex @file{blorg.el}
6443 @item @file{blorg.el} by Bastien Guerry
6444 Publish Org-mode files as
6445 blogs. @url{http://www.cognition.ens.fr/~guerry/blorg.html}.
6446 @cindex @file{org2rem.el}
6447 @item @file{org2rem.el} by Bastien Guerry
6448 Translates Org-mode files into something readable by
6449 Remind. @url{http://www.cognition.ens.fr/~guerry/u/org2rem.el}.
6450 @end table
6452 @page
6454 @node Tables in arbitrary syntax, Dynamic blocks, Extensions, Extensions and Hacking
6455 @section Tables in arbitrary syntax
6456 @cindex tables, in other modes
6457 @cindex orgtbl-mode
6459 Since Orgtbl-mode can be used as a minor mode in arbitrary buffers, a
6460 frequent feature request has been to make it work with native tables in
6461 specific languages, for example LaTeX.  However, this is extremely hard
6462 to do in a general way, would lead to a customization nightmare, and
6463 would take away much of the simplicity of the Orgtbl-mode table editor.
6465 This appendix describes a different approach.  We keep the Orgtbl-mode
6466 table in its native format (the @i{source table}), and use a custom
6467 function to @i{translate} the table to the correct syntax, and to
6468 @i{install} it in the right location (the @i{target table}).  This puts
6469 the burden of writing conversion functions on the user, but it allows
6470 for a very flexible system.
6472 @menu
6473 * Radio tables::                Sending and receiving
6474 * A LaTeX example::             Step by step, almost a tutorial
6475 * Translator functions::        Copy and modify
6476 @end menu
6478 @node Radio tables, A LaTeX example, Tables in arbitrary syntax, Tables in arbitrary syntax
6479 @subsection Radio tables
6480 @cindex radio tables
6482 To define the location of the target table, you first need to create two
6483 lines that are comments in the current mode, but contain magic words for
6484 Orgtbl-mode to find.  Orgtbl-mode will insert the translated table
6485 between these lines, replacing whatever was there before.  For example:
6487 @example
6488 /* BEGIN RECEIVE ORGTBL table_name */
6489 /* END RECEIVE ORGTBL table_name */
6490 @end example
6492 @noindent
6493 Just above the source table, we put a special line that tells
6494 Orgtbl-mode how to translate this table and where to install it.  For
6495 example:
6496 @example
6497 #+ORGTBL: SEND table_name translation_function arguments....
6498 @end example
6500 @noindent
6501 @code{table_name} is the reference name for the table that is also used
6502 in the receiver lines. @code{translation_function} is the Lisp function
6503 that does the translation.  Furthermore, the line can contain a list of
6504 arguments (alternating key and value) at the end.  The arguments will be
6505 passed as a property list to the translation function for
6506 interpretation.  A few standard parameters are already recognized and
6507 acted upon before the translation function is called:
6509 @table @code
6510 @item :skip N
6511 Skip the first N lines of the table. Hlines do count!
6512 @item :skipcols (n1 n2 ...)
6513 List of columns that should be skipped.  If the table has a column with
6514 calculation marks, that column is automatically discarded as well.
6515 Please note that the translator function sees the table @emph{after} the
6516 removal of these columns, the function never knows that there have been
6517 additional columns.
6518 @end table
6520 @noindent
6521 The one problem remaining is how to keep the source table in the buffer
6522 without disturbing the normal workings of the file, for example during
6523 compilation of a C file or processing of a LaTeX file.  There are a
6524 number of different solutions:
6526 @itemize @bullet
6527 @item
6528 The table could be placed in a block comment if that is supported by the
6529 language.  For example, in C-mode you could wrap the table between
6530 @samp{/*} and @samp{*/} lines.
6531 @item 
6532 Sometimes it is possible to put the table after some kind of @i{END}
6533 statement, for example @samp{\bye} in TeX and @samp{\end@{document@}}
6534 in LaTeX.
6535 @item
6536 You can just comment the table line by line whenever you want to process
6537 the file, and uncomment it whenever you need to edit the table.  This
6538 only sounds tedious - the command @kbd{M-x orgtbl-toggle-comment} does
6539 make this comment-toggling very easy, in particular if you bind it to a
6540 key.
6541 @end itemize
6543 @node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
6544 @subsection A LaTeX example
6545 @cindex LaTeX, and orgtbl-mode
6547 The best way to wrap the source table in LaTeX is to use the
6548 @code{comment} environment provided by @file{comment.sty}.  It has to be
6549 activated by placing @code{\usepackage@{comment@}} into the document
6550 header.  Orgtbl-mode can insert a radio table skeleton@footnote{By
6551 default this works only for LaTeX, HTML, and TeXInfo.  Configure the
6552 variable @code{orgtbl-radio-tables} to install templates for other
6553 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
6554 be prompted for a table name, lets say we use @samp{salesfigures}.  You
6555 will then get the following template:
6557 @example
6558 % BEGIN RECEIVE ORGTBL salesfigures
6559 % END RECEIVE ORGTBL salesfigures
6560 \begin@{comment@}
6561 #+ORGTBL: SEND salesfigures orgtbl-to-latex
6562 | | |
6563 \end@{comment@}
6564 @end example
6566 @noindent
6567 The @code{#+ORGTBL: SEND} line tells orgtbl-mode to use the function
6568 @code{orgtbl-to-latex} to convert the table into LaTeX and to put it
6569 into the receiver location with name @code{salesfigures}.  You may now
6570 fill in the table, feel free to use the spreadsheet features@footnote{If
6571 the @samp{#+TBLFM} line contains an odd number of dollar characters,
6572 this may cause problems with font-lock in latex-mode.  As shown in the
6573 example you can fix this by adding an extra line inside the
6574 @code{comment} environment that is used to balance the dollar
6575 expressions.  If you are using AUCTeX with the font-latex library, a
6576 much better solution is to add the @code{comment} environment to the
6577 variable @code{LaTeX-verbatim-environments}.}:
6579 @example
6580 % BEGIN RECEIVE ORGTBL salesfigures
6581 % END RECEIVE ORGTBL salesfigures
6582 \begin@{comment@}
6583 #+ORGTBL: SEND salesfigures orgtbl-to-latex
6584 | Month | Days | Nr sold | per day |
6585 |-------+------+---------+---------|
6586 | Jan   |   23 |      55 |     2.4 |
6587 | Feb   |   21 |      16 |     0.8 |
6588 | March |   22 |     278 |    12.6 |
6589 #+TBLFM: $4=$3/$2;%.1f
6590 % $ (optional extra dollar to keep font-lock happy, see footnote)
6591 \end@{comment@}
6592 @end example
6594 @noindent
6595 When you are done, press @kbd{C-c C-c} in the table to get the converted
6596 table inserted between the two marker lines.
6598 Now lets assume you want to make the table header by hand, because you
6599 want to control how columns are aligned etc.  In this case we make sure
6600 that the table translator does skip the first 2 lines of the source
6601 table, and tell the command to work as a @i{splice}, i.e. to not produce
6602 header and footer commands of the target table:
6604 @example
6605 \begin@{tabular@}@{lrrr@}
6606 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
6607 % BEGIN RECEIVE ORGTBL salesfigures
6608 % END RECEIVE ORGTBL salesfigures
6609 \end@{tabular@}
6611 \begin@{comment@}
6612 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
6613 | Month | Days | Nr sold | per day |
6614 |-------+------+---------+---------|
6615 | Jan   |   23 |      55 |     2.4 |
6616 | Feb   |   21 |      16 |     0.8 |
6617 | March |   22 |     278 |    12.6 |
6618 #+TBLFM: $4=$3/$2;%.1f
6619 \end@{comment@}
6620 @end example
6622 The LaTeX translator function @code{orgtbl-to-latex} is already part of
6623 Orgtbl-mode.  It uses a @code{tabular} environment to typeset the table
6624 and marks horizontal lines with @code{\hline}.  Furthermore, it
6625 interprets the following parameters:
6627 @table @code
6628 @item :splice nil/t
6629 When set to t, return only table body lines, don't wrap them into a
6630 tabular environment.  Default is nil.
6632 @item :fmt fmt
6633 A format to be used to wrap each field, should contain @code{%s} for the
6634 original field value.  For example, to wrap each field value in dollars,
6635 you could use @code{:fmt "$%s$"}.  This may also be a property list with
6636 column numbers and formats. for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
6638 @item :efmt efmt
6639 Use this format to print numbers with exponentials.  The format should
6640 have @code{%s} twice for inserting mantissa and exponent, for example
6641 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
6642 may also be a property list with column numbers and formats, for example
6643 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
6644 @code{efmt} has been applied to a value, @code{fmt} will also be
6645 applied.
6646 @end table
6648 @node Translator functions,  , A LaTeX example, Tables in arbitrary syntax
6649 @subsection Translator functions
6650 @cindex HTML, and orgtbl-mode
6651 @cindex translator function
6653 Orgtbl-mode has several translator functions built-in:
6654 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and
6655 @code{orgtbl-to-texinfo}.  Except for @code{orgtbl-to-html}@footnote{The
6656 HTML translator uses the same code that produces tables during HTML
6657 export.}, these all use a generic translator, @code{orgtbl-to-generic}.
6658 For example, @code{orgtbl-to-latex} itself is a very short function that
6659 computes the column definitions for the @code{tabular} environment,
6660 defines a few field and line separators and then hands over to the
6661 generic translator.  Here is the entire code:
6663 @lisp
6664 @group
6665 (defun orgtbl-to-latex (table params)
6666   "Convert the orgtbl-mode TABLE to LaTeX."
6667   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
6668                                org-table-last-alignment ""))
6669          (params2
6670           (list
6671            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
6672            :tend "\\end@{tabular@}"
6673            :lstart "" :lend " \\\\" :sep " & "
6674            :efmt "%s\\,(%s)" :hline "\\hline")))
6675     (orgtbl-to-generic table (org-combine-plists params2 params))))
6676 @end group
6677 @end lisp
6679 As you can see, the properties passed into the function (variable
6680 @var{PARAMS}) are combined with the ones newly defined in the function
6681 (variable @var{PARAMS2}).  The ones passed into the function (i.e. the
6682 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
6683 would like to use the LaTeX translator, but wanted the line endings to
6684 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
6685 overrule the default with
6687 @example
6688 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
6689 @end example
6691 For a new language, you can either write your own converter function in
6692 analogy with the LaTeX translator, or you can use the generic function
6693 directly.  For example, if you have a language where a table is started
6694 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
6695 started with @samp{!BL!}, ended with @samp{!EL!} and where the field
6696 separator is a TAB, you could call the generic translator like this (on
6697 a single line!):
6699 @example
6700 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
6701                               :lstart "!BL! " :lend " !EL!" :sep "\t"
6702 @end example
6704 @noindent
6705 Please check the documentation string of the function
6706 @code{orgtbl-to-generic} for a full list of parameters understood by
6707 that function and remember that you can pass each of them into
6708 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
6709 using the generic function.
6711 Of course you can also write a completely new function doing complicated
6712 things the generic translator cannot do.  A translator function takes
6713 two arguments.  The first argument is the table, a list of lines, each
6714 line either the symbol @code{hline} or a list of fields.  The second
6715 argument is the property list containing all parameters specified in the
6716 @samp{#+ORGTBL: SEND} line.  The function must return a single string
6717 containing the formatted table.  If you write a generally useful
6718 translator, please post it on @code{emacs-orgmode@@gnu.org} so that
6719 others can benefit from your work.
6721 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Extensions and Hacking
6722 @section Dynamic blocks
6723 @cindex dynamic blocks
6725 Org-mode documents can contain @emph{dynamic blocks}.  These are
6726 specially marked regions that are updated by some user-written function.
6727 A good example for such a block is the clock table inserted by the
6728 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
6730 Dynamic block are enclosed by a BEGIN-END structure that assigns a name
6731 to the block and can also specify parameters for the function producing
6732 the content of the block.
6734 @example
6735 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
6737 #+END:
6738 @end example
6740 Dynamic blocks are updated with the following commands
6742 @table @kbd
6743 @kindex C-c C-x C-u
6744 @item C-c C-x C-u
6745 Update dynamic block at point.
6746 @kindex C-u C-c C-x C-u
6747 @item C-u C-c C-x C-u
6748 Update all dynamic blocks in the current file.
6749 @end table
6751 Updating a dynamic block means to remove all the text between BEGIN and
6752 END, parse the BEGIN line for parameters and then call the specific
6753 writer function for this block to insert the new content.  For a block
6754 with name @code{myblock}, the writer function is
6755 @code{org-dblock-write:myblock} with as only parameter a property list
6756 with the parameters given in the begin line.  Here is a trivial example
6757 of a block that keeps track of when the block update function was last
6758 run:
6760 @example
6761 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
6763 #+END:
6764 @end example
6766 @noindent
6767 The corresponding block writer function could look like this:
6769 @lisp
6770 (defun org-dblock-write:block-update-time (params)
6771    (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
6772      (insert "Last block update at: "
6773              (format-time-string fmt (current-time)))))
6774 @end lisp
6776 If you want to make sure that all dynamic blocks are always up-to-date,
6777 you could add the function @code{org-update-all-dblocks} to a hook, for
6778 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
6779 written in a way that is does nothing in buffers that are not in Org-mode.
6781 @node Special agenda views,  , Dynamic blocks, Extensions and Hacking
6782 @section Special Agenda Views
6783 @cindex agenda views, user-defined
6785 Org-mode provides a special hook that can be used to narrow down the
6786 selection made by any of the agenda views.  You may specify a function
6787 that is used at each match to verify if the match should indeed be part
6788 of the agenda view, and if not, how much should be skipped.
6790 Let's say you want to produce a list of projects that contain a WAITING
6791 tag anywhere in the project tree.  Let's further assume that you have
6792 marked all tree headings that define a project with the todo keyword
6793 PROJECT.  In this case you would run a todo search for the keyword
6794 PROJECT, but skip the match unless there is a WAITING tag anywhere in
6795 the subtree belonging to the project line.
6797 To achieve this, you must write a function that searches the subtree for
6798 the tag.  If the tag is found, the function must return @code{nil} to
6799 indicate that this match should not be skipped.  If there is no such
6800 tag, return the location of the end of the subtree, to indicate that
6801 search should continue from there.
6803 @lisp
6804 (defun my-skip-unless-waiting ()
6805   "Skip trees that are not waiting"
6806   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
6807     (if (re-search-forward ":WAITING:" subtree-end t)
6808         nil          ; tag found, do not skip
6809       subtree-end))) ; tag not found, continue after end of subtree
6810 @end lisp
6812 Furthermore you must write a command that uses @code{let} to temporarily
6813 put this function into the variable @code{org-agenda-skip-function},
6814 sets the header string for the agenda buffer, and calls the todo-list
6815 generator while asking for the specific TODO keyword PROJECT.  The
6816 function must also accept one argument MATCH, but it can choose to
6817 ignore it@footnote{MATCH must be present in case you want to define a
6818 custom command for producing this special list.  Custom commands always
6819 supply the MATCH argument, but it can be empty if you do not specify it
6820 while defining the command(@pxref{Custom agenda
6821 views}).} (as we do in the example below).  Here is the example:
6823 @lisp
6824 (defun my-org-waiting-projects (&optional match)
6825   "Produce a list of projects that contain a WAITING tag.
6826 MATCH is being ignored."
6827   (interactive)
6828   (let ((org-agenda-skip-function 'my-skip-unless-waiting)
6829         (org-agenda-overriding-header "Projects waiting for something: "))
6830     ;; make the list
6831     (org-todo-list "PROJECT")))
6832 @end lisp
6835 @node History and Acknowledgments, Index, Extensions and Hacking, Top
6836 @appendix History and Acknowledgments
6837 @cindex acknowledgments
6838 @cindex history
6839 @cindex thanks
6841 Org-mode was borne in 2003, out of frustration over the user interface
6842 of the Emacs outline-mode.  I was trying to organize my notes and
6843 projects, and using Emacs seemed to be the natural way to go.  However,
6844 having to remember eleven different commands with two or three keys per
6845 command, only to hide and unhide parts of the outline tree, that seemed
6846 entirely unacceptable to me.  Also, when using outlines to take notes, I
6847 constantly want to restructure the tree, organizing it parallel to my
6848 thoughts and plans.  @emph{Visibility cycling} and @emph{structure
6849 editing} were originally implemented in the package
6850 @file{outline-magic.el}, but quickly moved to the more general
6851 @file{org.el}.  As this environment became comfortable for project
6852 planning, the next step was adding @emph{TODO entries}, basic @emph{time
6853 stamps}, and @emph{table support}.  These areas highlight the two main
6854 goals that Org-mode still has today: To create a new, outline-based,
6855 plain text mode with innovative and intuitive editing features, and to
6856 incorporate project planning functionality directly into a notes file.
6858 Since the first release, hundreds of emails to me or on
6859 @code{emacs-orgmode@@gnu.org} have provided a constant stream of bug
6860 reports, feedback, new ideas, and sometimes patches and add-on code.
6861 Many thanks to everyone who has helped to improve this package.  I am
6862 trying to keep here a list of the people who had significant influence
6863 in shaping one or more aspects of Org-mode.  The list may not be
6864 complete, if I have forgotten someone, please accept my apologies and
6865 let me know.
6867 @itemize @bullet
6869 @item
6870 @i{Thomas Baumann} contributed the code for links to the MH-E email
6871 system.
6872 @item
6873 @i{Alex Bochannek} provided a patch for rounding time stamps.
6874 @item
6875 @i{Charles Cave}'s suggestion sparked the implementation of templates
6876 for Remember.
6877 @item
6878 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
6879 specified time.
6880 @item
6881 @i{Gregory Chernov} patched support for lisp forms into table
6882 calculations and improved XEmacs compatibility, in particular by porting
6883 @file{nouline.el} to XEmacs.
6884 @item
6885 @i{Sacha Chua} suggested to copy some linking code from Planner.
6886 @item
6887 @i{Eddward DeVilla} proposed and tested checkbox statistics.
6888 @item
6889 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
6890 inspired some of the early development, including HTML export.  He also
6891 asked for a way to narrow wide table columns.
6892 @item
6893 @i{Christian Egli} converted the documentation into TeXInfo format,
6894 patched CSS formatting into the HTML exporter, and inspired the agenda.
6895 @item
6896 @i{Nic Ferrier} contributed mailcap and XOXO support.
6897 @item
6898 @i{John Foerch} figured out how to make incremental search show context
6899 around a match in a hidden outline tree.
6900 @item
6901 @i{Niels Giessen} had the idea to automatically archive DONE trees.
6902 @item
6903 @i{Bastien Guerry} provided extensive feedback and some patches, and
6904 translated David O'Toole's tutorial into French.
6905 @item
6906 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
6907 @item
6908 @i{Shidai Liu} ("Leo") asked for embedded LaTeX and tested it.  He also
6909 provided frequent feedback and some patches.
6910 @item
6911 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
6912 happy.
6913 @item
6914 @i{Rick Moynihan} proposed to allow multiple TODO sequences in a file.
6915 @item
6916 @i{Todd Neal} provided patches for links to Info files and elisp forms.
6917 @item
6918 @i{Tim O'Callaghan} suggested in-file links, search options for general
6919 file links, and TAGS.
6920 @item
6921 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
6922 into Japanese.
6923 @item
6924 @i{Oliver Oppitz} suggested multi-state TODO items.
6925 @item
6926 @i{Scott Otterson} sparked the introduction of descriptive text for
6927 links, among other things.
6928 @item
6929 @i{Pete Phillips} helped during the development of the TAGS feature, and
6930 provided frequent feedback.
6931 @item
6932 @i{T.V. Raman} reported bugs and suggested improvements.
6933 @item
6934 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
6935 control.
6936 @item
6937 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
6938 @item
6939 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
6940 conflict with @file{allout.el}.
6941 @item
6942 @i{Jason Riedy} sent a patch to fix a bug with export of TODO keywords.
6943 @item
6944 @i{Philip Rooke} created the Org-mode reference card and provided lots
6945 of feedback.
6946 @item
6947 @i{Christian Schlauer} proposed angular brackets around links, among
6948 other things.
6949 @item
6950 Linking to VM/BBDB/GNUS was inspired by @i{Tom Shannon}'s
6951 @file{organizer-mode.el}.
6952 @item
6953 @i{Daniel Sinder} came up with the idea of internal archiving by locking
6954 subtrees.
6955 @item
6956 @i{Dale Smith} proposed link abbreviations.
6957 @item
6958 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
6959 chapter about publishing.
6960 @item
6961 @i{J@"urgen Vollmer} contributed code generating the table of contents
6962 in HTML output.
6963 @item
6964 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
6965 keyword.
6966 @item
6967 @i{David Wainberg} suggested archiving, and improvements to the linking
6968 system.
6969 @item
6970 @i{John Wiegley} wrote @file{emacs-wiki.el} and @file{planner.el}.  The
6971 development of Org-mode was fully independent, and both systems are
6972 really different beasts in their basic ideas and implementation details.
6973 I later looked at John's code, however, and learned from his
6974 implementation of (i) links where the link itself is hidden and only a
6975 description is shown, and (ii) popping up a calendar to select a date.
6976 @item
6977 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
6978 linking to GNUS.
6979 @item
6980 @i{Roland Winkler} requested additional keybindings to make Org-mode
6981 work on a tty.
6982 @item
6983 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
6984 and contributed various ideas and code snippets.
6985 @end itemize
6988 @node Index, Key Index, History and Acknowledgments, Top
6989 @unnumbered Index
6991 @printindex cp
6993 @node Key Index,  , Index, Top
6994 @unnumbered Key Index
6996 @printindex ky
6998 @bye
7000 @ignore
7001    arch-tag: 7893d1fe-cc57-4d13-b5e5-f494a1bcc7ac
7002 @end ignore