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