Release 5.13
[org-mode.git] / org.texi
blob6ae14eb5f32512136da9010c6bacc27da7603304
1 \input texinfo
2 @c %**start of header
3 @setfilename ../info/org
4 @settitle Org Mode Manual
6 @set VERSION 5.13
7 @set DATE October 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://orgmode.org,maintainers webpage}
16 @set AUTHOR Carsten Dominik
17 @set MAINTAINER Carsten Dominik
18 @set MAINTAINEREMAIL @email{carsten at orgmode dot org}
19 @set MAINTAINERCONTACT @uref{mailto:carsten at orgmode dot org,contact the maintainer}
20 @c %**end of header
21 @finalout
23 @c Macro definitions
25 @c Subheadings inside a table.
26 @macro tsubheading{text}
27 @ifinfo
28 @subsubheading \text\
29 @end ifinfo
30 @ifnotinfo
31 @item @b{\text\}
32 @end ifnotinfo
33 @end macro
35 @copying
36 This manual is for Org-mode (version @value{VERSION}).
38 Copyright @copyright{} 2004, 2005, 2006, 2007 Free Software Foundation
40 @quotation
41 Permission is granted to copy, distribute and/or modify this document
42 under the terms of the GNU Free Documentation License, Version 1.1 or
43 any later version published by the Free Software Foundation; with no
44 Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
45 and with the Back-Cover Texts as in (a) below.  A copy of the
46 license is included in the section entitled ``GNU Free Documentation
47 License.''
49 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
50 this GNU Manual, like GNU software.  Copies published by the Free
51 Software Foundation raise funds for GNU development.''
52 @end quotation
53 @end copying
55 @titlepage
56 @title Org Mode Manual
58 @subtitle Release @value{VERSION}
59 @author by Carsten Dominik
61 @c The following two commands start the copyright page.
62 @page
63 @vskip 0pt plus 1filll
64 @insertcopying
65 @end titlepage
67 @c Output the table of contents at the beginning.
68 @contents
70 @ifnottex
71 @node Top, Introduction, (dir), (dir)
72 @top Org Mode Manual
74 @insertcopying
75 @end ifnottex
77 @menu
78 * Introduction::                Getting started
79 * Document structure::          A tree works like your brain
80 * Tables::                      Pure magic for quick formatting
81 * Hyperlinks::                  Notes in context
82 * TODO items::                  Every tree branch can be a TODO item
83 * Tags::                        Tagging headlines and matching sets of tags
84 * Properties and columns::      Storing information about an entry
85 * Timestamps::                  Assign date and time to items
86 * Remember::                    Quickly adding nodes to the outline tree
87 * Agenda views::                Collecting information into views
88 * Embedded LaTeX::              LaTeX fragments and formulas
89 * Exporting::                   Sharing and publishing of notes
90 * Publishing::                  Create a web site of linked Org-mode files
91 * Miscellaneous::               All the rest which did not fit elsewhere
92 * Extensions and Hacking::      It is possible to write add-on code
93 * History and Acknowledgments::  How Org-mode came into being 
94 * Index::                       The fast road to specific information
95 * Key Index::                   Key bindings and where they are described
97 @detailmenu
98  --- The Detailed Node Listing ---
100 Introduction
102 * Summary::                     Brief summary of what Org-mode does
103 * Installation::                How to install a downloaded version of Org-mode
104 * Activation::                  How to activate Org-mode for certain buffers.
105 * Feedback::                    Bug reports, ideas, patches etc.
107 Document Structure
109 * Outlines::                    Org-mode is based on outline-mode
110 * Headlines::                   How to typeset org-tree headlines
111 * Visibility cycling::          Show and hide, much simplified
112 * Motion::                      Jumping to other headlines
113 * Structure editing::           Changing sequence and level of headlines
114 * Archiving::                   Move done task trees to a different place
115 * Sparse trees::                Matches embedded in context
116 * Plain lists::                 Additional structure within an entry
117 * Drawers::                     Tucking stuff away
118 * orgstruct-mode::              Structure editing outside Org-mode
120 Archiving
122 * ARCHIVE tag::                 Marking a tree as inactive
123 * Moving subtrees::             Moving a tree to an archive file
125 Tables
127 * Built-in table editor::       Simple tables
128 * Narrow columns::              Stop wasting space in tables   
129 * Column groups::               Grouping to trigger vertical lines
130 * orgtbl-mode::                 The table editor as minor mode
131 * The spreadsheet::             The table editor has spreadsheet capabilities.
133 The spreadsheet
135 * References::                  How to refer to another field or range
136 * Formula syntax for Calc::     Using Calc to compute stuff
137 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
138 * Field formulas::              Formulas valid for a single field
139 * Column formulas::             Formulas valid for an entire column
140 * Editing and debugging formulas::  Fixing formulas
141 * Updating the table::          Recomputing all dependent fields
142 * Advanced features::           Field names, parameters and automatic recalc
144 Hyperlinks
146 * Link format::                 How links in Org-mode are formatted
147 * Internal links::              Links to other places in the current file
148 * External links::              URL-like links to the world
149 * Handling links::              Creating, inserting and following
150 * Using links outside Org-mode::  Linking from my C source code?
151 * Link abbreviations::          Shortcuts for writing complex links
152 * Search options::              Linking to a specific location
153 * Custom searches::             When the default search is not enough
155 Internal links
157 * Radio targets::               Make targets trigger links in plain text.
159 TODO items
161 * TODO basics::                 Marking and displaying TODO entries
162 * TODO extensions::             Workflow and assignments
163 * Progress logging::            Dates and notes for progress
164 * Priorities::                  Some things are more important than others
165 * Breaking down tasks::         Splitting a task into manageable pieces
166 * Checkboxes::                  Tick-off lists
168 Extended use of TODO keywords
170 * Workflow states::             From TODO to DONE in steps
171 * TODO types::                  I do this, Fred the rest
172 * Multiple sets in one file::   Mixing it all, and still finding your way
173 * Fast access to TODO states::  Single letter selection of a state
174 * Per file keywords::           Different files, different requirements
175 * Faces for TODO keywords::     Highlighting states
177 Progress Logging
179 * Closing items::               When was this entry marked DONE?
180 * Tracking TODO state changes::  When did the status change?
182 Tags
184 * Tag inheritance::             Tags use the tree structure of the outline
185 * Setting tags::                How to assign tags to a headline
186 * Tag searches::                Searching for combinations of tags
188 Properties and Columns
190 * Property syntax::             How properties are spelled out
191 * Special properties::          Access to other Org-mode features
192 * Property searches::           Matching property values
193 * Column view::                 Tabular viewing and editing
194 * Property API::                Properties for Lisp programmers
196 Column View
198 * Defining columns::            The COLUMNS format property
199 * Using column view::           How to create and use column view
200 * Capturing Column View::       A dynamic block for column view
202 Defining Columns
204 * Scope of column definitions::  Where defined, where valid?
205 * Column attributes::           Appearance and content of a column
207 Timestamps
209 * Time stamps::                 Assigning a time to a tree entry
210 * Creating timestamps::         Commands which insert timestamps
211 * Deadlines and scheduling::    Planning your work
212 * Clocking work time::          
214 Creating timestamps
216 * The date/time prompt::        How org-mode helps you entering date and time
217 * Custom time format::          Making dates look differently
219 Deadlines and Scheduling
221 * Inserting deadline/schedule::  Planning items
222 * Repeated tasks::              Items that show up again and again
224 Remember
226 * Setting up remember::         Some code for .emacs to get things going
227 * Remember templates::          Define the outline of different note types
228 * Storing notes::               Directly get the note to where it belongs
230 Agenda Views
232 * Agenda files::                Files being searched for agenda information
233 * Agenda dispatcher::           Keyboard access to agenda views
234 * Built-in agenda views::       What is available out of the box?
235 * Presentation and sorting::    How agenda items are prepared for display
236 * Agenda commands::             Remote editing of org trees
237 * Custom agenda views::         Defining special searches and views
239 The built-in agenda views
241 * Weekly/Daily agenda::         The calendar page with current tasks
242 * Global TODO list::            All unfinished action items
243 * Matching tags and properties::  Structured information with fine-tuned search
244 * Timeline::                    Time-sorted view for single file
245 * Stuck projects::              Find projects you need to review
247 Presentation and sorting
249 * Categories::                  Not all tasks are equal
250 * Time-of-day specifications::  How the agenda knows the time
251 * Sorting of agenda items::     The order of things
253 Custom agenda views
255 * Storing searches::            Type once, use often
256 * Block agenda::                All the stuff you need in a single buffer
257 * Setting Options::             Changing the rules
258 * Exporting Agenda Views::      Writing agendas to files.
259 * Extracting Agenda Information for other programs::  
261 Embedded LaTeX
263 * Math symbols::                TeX macros for symbols and Greek letters
264 * Subscripts and Superscripts::  Simple syntax for raising/lowering text
265 * LaTeX fragments::             Complex formulas made easy
266 * Processing LaTeX fragments::  Previewing LaTeX processing
267 * CDLaTeX mode::                Speed up entering of formulas
269 Exporting
271 * ASCII export::                Exporting to plain ASCII
272 * HTML export::                 Exporting to HTML
273 * LaTeX export::                Exporting to LaTeX
274 * XOXO export::                 Exporting to XOXO
275 * iCalendar export::            Exporting in iCalendar format
276 * Text interpretation::         How the exporter looks at the file
278 HTML export
280 * HTML Export commands::        How to invoke LaTeX export
281 * Quoting HTML tags::           Using direct HTML in Org-mode
282 * Links::                       Transformation of links for HTML
283 * Images::                      How to include images
284 * CSS support::                 Changing the appearence of the output
286 LaTeX export
288 * LaTeX export commands::       How to invoke LaTeX export
289 * Quoting LaTeX code::          Incorporating literal LaTeX code
291 Text interpretation by the exporter
293 * Comment lines::               Some lines will not be exported
294 * Initial text::                Text before the first headline
295 * Footnotes::                   Numbers like [1]
296 * Enhancing text::              Subscripts, symbols and more
297 * Export options::              How to influence the export settings
299 Publishing
301 * Configuration::               Defining projects
302 * Sample configuration::        Example projects
303 * Triggering publication::      Publication commands
305 Configuration
307 * Project alist::               The central configuration variable
308 * Sources and destinations::    From here to there
309 * Selecting files::             What files are part of the project?
310 * Publishing action::           Setting the function doing the publishing
311 * Publishing options::          Tweaking HTML export
312 * Publishing links::            Which links keep working after publishing?
313 * Project page index::          Publishing a list of project files
315 Sample configuration
317 * Simple example::              One-component publishing
318 * Complex example::             A multi-component publishing example
320 Miscellaneous
322 * Completion::                  M-TAB knows what you need
323 * Customization::               Adapting Org-mode to your taste
324 * In-buffer settings::          Overview of the #+KEYWORDS
325 * The very busy C-c C-c key::   When in doubt, press C-c C-c
326 * Clean view::                  Getting rid of leading stars in the outline
327 * TTY keys::                    Using Org-mode on a tty
328 * Interaction::                 Other Emacs packages
329 * Bugs::                        Things which do not work perfectly
331 Interaction with other packages
333 * Cooperation::                 Packages Org-mode cooperates with
334 * Conflicts::                   Packages that lead to conflicts
336 Extensions, Hooks and Hacking
338 * Extensions::                  Existing 3rd-part extensions
339 * Adding hyperlink types::      New custom link types
340 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
341 * Dynamic blocks::              Automatically filled blocks
342 * Special agenda views::        Customized views
343 * Using the property API::      Writing programs that use entry properties
345 Tables in arbitrary syntax
347 * Radio tables::                Sending and receiving
348 * A LaTeX example::             Step by step, almost a tutorial
349 * Translator functions::        Copy and modify
351 @end detailmenu
352 @end menu
354 @node Introduction, Document structure, Top, Top
355 @chapter Introduction
356 @cindex introduction
358 @menu
359 * Summary::                     Brief summary of what Org-mode does
360 * Installation::                How to install a downloaded version of Org-mode
361 * Activation::                  How to activate Org-mode for certain buffers.
362 * Feedback::                    Bug reports, ideas, patches etc.
363 @end menu
365 @node Summary, Installation, Introduction, Introduction
366 @section Summary
367 @cindex summary
369 Org-mode is a mode for keeping notes, maintaining TODO lists, and doing
370 project planning with a fast and effective plain-text system.
372 Org-mode develops organizational tasks around NOTES files that contain
373 lists or information about projects as plain text.  Org-mode is
374 implemented on top of outline-mode, which makes it possible to keep the
375 content of large files well structured.  Visibility cycling and
376 structure editing help to work with the tree.  Tables are easily created
377 with a built-in table editor.  Org-mode supports TODO items, deadlines,
378 time stamps, and scheduling.  It dynamically compiles entries into an
379 agenda that utilizes and smoothly integrates much of the Emacs calendar
380 and diary.  Plain text URL-like links connect to websites, emails,
381 Usenet messages, BBDB entries, and any files related to the projects.
382 For printing and sharing of notes, an Org-mode file can be exported as a
383 structured ASCII file, as HTML, or (todo and agenda items only) as an
384 iCalendar file.  It can also serve as a publishing tool for a set of
385 linked webpages.
387 An important design aspect that distinguishes Org-mode from for example
388 Planner/Muse is that it encourages to store every piece of information
389 only once.  In Planner, you have project pages, day pages and possibly
390 other files, duplicating some information such as tasks.  In Org-mode,
391 you only have notes files.  In your notes you mark entries as tasks,
392 label them with tags and timestamps.  All necessary lists like a
393 schedule for the day, the agenda for a meeting, tasks lists selected by
394 tags etc are created dynamically when you need them.
396 Org-mode keeps simple things simple.  When first fired up, it should
397 feel like a straightforward, easy to use outliner.  Complexity is not
398 imposed, but a large amount of functionality is available when you need
399 it.  Org-mode is a toolbox and can be used in different ways, for
400 example as:
402 @example
403 @r{@bullet{} outline extension with visibility cycling and structure editing}
404 @r{@bullet{} ASCII system and table editor for taking structured notes}
405 @r{@bullet{} ASCII table editor with spreadsheet-like capabilities}
406 @r{@bullet{} TODO list editor}
407 @r{@bullet{} full agenda and planner with deadlines and work scheduling}
408 @r{@bullet{} environment to implement David Allen's GTD system}
409 @r{@bullet{} a basic database application}
410 @r{@bullet{} simple hypertext system, with HTML export}
411 @r{@bullet{} publishing tool to create a set of interlinked webpages}
412 @end example
414 Org-mode's automatic, context sensitive table editor with spreadsheet
415 capabilities can be integrated into any major mode by activating the
416 minor Orgtbl-mode.  Using a translation step, it can be used to maintain
417 tables in arbitrary file types, for example in La@TeX{}.  The structure
418 editing and list creation capabilities can be used outside Org-mode with
419 the minor Orgstruct-mode.
421 @cindex FAQ
422 There is a website for Org-mode which provides links to the newest
423 version of Org-mode, as well as additional information, frequently asked
424 questions (FAQ), links to tutorials etc.  This page is located at
425 @uref{http://orgmode.org}.
427 @page
430 @node Installation, Activation, Summary, Introduction
431 @section Installation
432 @cindex installation
433 @cindex XEmacs
435 @b{Important:} @i{If Org-mode is part of the Emacs distribution or an
436 XEmacs package, please skip this section and go directly to
437 @ref{Activation}.}
439 If you have downloaded Org-mode from the Web, you must take the
440 following steps to install it: Go into the Org-mode distribution
441 directory and edit the top section of the file @file{Makefile}.  You
442 must set the name of the Emacs binary (likely either @file{emacs} or
443 @file{xemacs}), and the paths to the directories where local Lisp and
444 Info files are kept.  If you don't have access to the system-wide
445 directories, create your own two directories for these files, enter them
446 into the Makefile, and make sure Emacs finds the Lisp files by adding
447 the following line to @file{.emacs}:
449 @example
450 (setq load-path (cons "~/path/to/lispdir" load-path))
451 @end example
453 @b{XEmacs users now need to install the file @file{noutline.el} from
454 the @file{xemacs} subdirectory of the Org-mode distribution.  Use the
455 command:}
457 @example
458 @b{make install-noutline}
459 @end example
461 @noindent Now byte-compile and install the Lisp files with the shell
462 commands:
464 @example
465 make
466 make install
467 @end example
469 @noindent If you want to install the info documentation, use this command:
471 @example
472 make install-info
473 @end example
475 @noindent Then add to @file{.emacs}:
477 @lisp
478 ;; This line only if org-mode is not part of the X/Emacs distribution.
479 (require 'org-install)
480 @end lisp
482 @node Activation, Feedback, Installation, Introduction
483 @section Activation
484 @cindex activation
485 @cindex autoload
486 @cindex global keybindings
487 @cindex keybindings, global
489 @iftex
490 @b{Important:} @i{If you use copy-and-paste to copy lisp code from the
491 PDF documentation as viewed by Acrobat reader to your .emacs file, the
492 single quote character comes out incorrectly and the code will not work.
493 You need to fix the single quotes by hand, or copy from Info
494 documentation.}
495 @end iftex
497 Add the following lines to your @file{.emacs} file.  The last two lines
498 define @emph{global} keys for the commands @command{org-store-link} and
499 @command{org-agenda} - please choose suitable keys yourself.
501 @lisp
502 ;; The following lines are always needed.  Choose your own keys.
503 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
504 (global-set-key "\C-cl" 'org-store-link)
505 (global-set-key "\C-ca" 'org-agenda)
506 @end lisp
508 Furthermore, you must activate @code{font-lock-mode} in org-mode
509 buffers, because significant functionality depends on font-locking being
510 active.  You can do this with either one of the following two lines
511 (XEmacs user must use the second option):
512 @lisp
513 (global-font-lock-mode 1)                     ; for all buffers
514 (add-hook 'org-mode-hook 'turn-on-font-lock)  ; org-mode buffers only
515 @end lisp
517 @cindex org-mode, turning on
518 With this setup, all files with extension @samp{.org} will be put
519 into Org-mode.  As an alternative, make the first line of a file look
520 like this:
522 @example
523 MY PROJECTS    -*- mode: org; -*-
524 @end example
526 @noindent which will select Org-mode for this buffer no matter what
527 the file's name is.  See also the variable
528 @code{org-insert-mode-line-in-empty-file}.
530 @node Feedback,  , Activation, Introduction
531 @section Feedback
532 @cindex feedback
533 @cindex bug reports
534 @cindex maintainer
535 @cindex author
537 If you find problems with Org-mode, or if you have questions, remarks,
538 or ideas about it, please contact the maintainer @value{MAINTAINER} at
539 @value{MAINTAINEREMAIL}.
541 For bug reports, please provide as much information as possible,
542 including the version information of Emacs (@kbd{C-h v emacs-version
543 @key{RET}}) and Org-mode (@kbd{C-h v org-version @key{RET}}), as well as
544 the Org-mode related setup in @file{.emacs}.  If an error occurs, a
545 backtrace can be very useful (see below on how to create one).  Often a
546 small example file helps, along with clear information about:
548 @enumerate
549 @item What exactly did you do?
550 @item What did you expect to happen?
551 @item What happened instead?
552 @end enumerate
553 @noindent Thank you for helping to improve this mode.
555 @subsubheading How to create a useful backtrace
557 @cindex backtrace of an error
558 If working with Org-mode produces an error with a message you don't
559 understand, you may have hit a bug.  The best way to report this is by
560 providing, in addition to what was mentioned above, a @emph{Backtrace}.
561 This is information from the built-in debugger about where and how the
562 error occurred.  Here is how to produce a useful backtrace:
564 @enumerate
565 @item
566 Start a fresh Emacs or XEmacs, and make sure that it will load the
567 original Lisp code in @file{org.el} instead of the compiled version in
568 @file{org.elc}.  The backtrace contains much more information if it is
569 produced with uncompiled code.  To do this, either rename @file{org.elc}
570 to something else before starting Emacs, or ask Emacs explicitly to load
571 @file{org.el} by using the command line
572 @example
573 emacs -l /path/to/org.el
574 @end example
575 @item
576 Go to the @code{Options} menu and select @code{Enter Debugger on Error}
577 (XEmacs has this option in the @code{Troubleshooting} sub-menu).
578 @item
579 Do whatever you have to do to hit the error.  Don't forget to
580 document the steps you take.
581 @item
582 When you hit the error, a @file{*Backtrace*} buffer will appear on the
583 screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
584 attach it to your bug report.
585 @end enumerate
587 @node Document structure, Tables, Introduction, Top
588 @chapter Document Structure
589 @cindex document structure
590 @cindex structure of document
592 Org-mode is based on outline mode and provides flexible commands to
593 edit the structure of the document.
595 @menu
596 * Outlines::                    Org-mode is based on outline-mode
597 * Headlines::                   How to typeset org-tree headlines
598 * Visibility cycling::          Show and hide, much simplified
599 * Motion::                      Jumping to other headlines
600 * Structure editing::           Changing sequence and level of headlines
601 * Archiving::                   Move done task trees to a different place
602 * Sparse trees::                Matches embedded in context
603 * Plain lists::                 Additional structure within an entry
604 * Drawers::                     Tucking stuff away
605 * orgstruct-mode::              Structure editing outside Org-mode
606 @end menu
608 @node Outlines, Headlines, Document structure, Document structure
609 @section Outlines
610 @cindex outlines
611 @cindex outline-mode
613 Org-mode is implemented on top of outline-mode.  Outlines allow a
614 document to be organized in a hierarchical structure, which (at least
615 for me) is the best representation of notes and thoughts.  An overview
616 of this structure is achieved by folding (hiding) large parts of the
617 document to show only the general document structure and the parts
618 currently being worked on.  Org-mode greatly simplifies the use of
619 outlines by compressing the entire show/hide functionality into a single
620 command @command{org-cycle}, which is bound to the @key{TAB} key.
622 @node Headlines, Visibility cycling, Outlines, Document structure
623 @section Headlines
624 @cindex headlines
625 @cindex outline tree
627 Headlines define the structure of an outline tree.  The headlines in
628 Org-mode start with one or more stars, on the left margin@footnote{See
629 the variable @code{org-special-ctrl-a/e} to configure special behavior
630 of @kbd{C-a} and @kbd{C-e} in headlines.}.  For example:
632 @example
633 * Top level headline
634 ** Second level
635 *** 3rd level
636     some text
637 *** 3rd level
638     more text
640 * Another top level headline
641 @end example
643 @noindent Some people find the many stars too noisy and would prefer an
644 outline that has whitespace followed by a single star as headline
645 starters.  @ref{Clean view} describes a setup to realize this.
647 An empty line after the end of a subtree is considered part of it and
648 will be hidden when the subtree is folded.  However, if you leave at
649 least two empty lines, one empty line will remain visible after folding
650 the subtree, in order to structure the collapsed view.  See the
651 variable @code{org-cycle-separator-lines} to modify this behavior.
653 @node Visibility cycling, Motion, Headlines, Document structure
654 @section Visibility cycling
655 @cindex cycling, visibility
656 @cindex visibility cycling
657 @cindex trees, visibility
658 @cindex show hidden text
659 @cindex hide text
661 Outlines make it possible to hide parts of the text in the buffer.
662 Org-mode uses just two commands, bound to @key{TAB} and
663 @kbd{S-@key{TAB}} to change the visibility in the buffer.
665 @cindex subtree visibility states
666 @cindex subtree cycling
667 @cindex folded, subtree visibility state
668 @cindex children, subtree visibility state
669 @cindex subtree, subtree visibility state
670 @table @kbd
671 @kindex @key{TAB}
672 @item @key{TAB}
673 @emph{Subtree cycling}: Rotate current subtree among the states
675 @example
676 ,-> FOLDED -> CHILDREN -> SUBTREE --.
677 '-----------------------------------'
678 @end example
680 The cursor must be on a headline for this to work@footnote{see, however,
681 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
682 beginning of the buffer and the first line is not a headline, then
683 @key{TAB} actually runs global cycling (see below)@footnote{see the
684 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
685 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
687 @cindex global visibility states
688 @cindex global cycling
689 @cindex overview, global visibility state
690 @cindex contents, global visibility state
691 @cindex show all, global visibility state
692 @kindex S-@key{TAB}
693 @item S-@key{TAB}
694 @itemx C-u @key{TAB}
695 @emph{Global cycling}: Rotate the entire buffer among the states
697 @example
698 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
699 '--------------------------------------'
700 @end example
702 When @kbd{S-@key{TAB}} is called with a numerical prefix N, the CONTENTS
703 view up to headlines of level N will be shown.
704 Note that inside tables, @kbd{S-@key{TAB}} jumps to the previous field.
706 @cindex show all, command
707 @kindex C-c C-a
708 @item C-c C-a
709 Show all.
710 @kindex C-c C-r
711 @item C-c C-r
712 Reveal context around point, showing the current entry, the following
713 heading and the hierarchy above.  Useful for working near a location
714 exposed by a sparse tree command (@pxref{Sparse trees}) or an agenda
715 command (@pxref{Agenda commands}).  With prefix arg show, on each
716 level, all sibling headings.
717 @kindex C-c C-x b
718 @item C-c C-x b
719 Show the current subtree in an indirect buffer@footnote{The indirect
720 buffer
721 @ifinfo
722 (@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
723 @end ifinfo
724 @ifnotinfo
725 (see the Emacs manual for more information about indirect buffers)
726 @end ifnotinfo
727 will contain the entire buffer, but will be narrowed to the current
728 tree.  Editing the indirect buffer will also change the original buffer,
729 but without affecting visibility in that buffer.}.  With numerical
730 prefix ARG, go up to this level and then take that tree.  If ARG is
731 negative, go up that many levels.  With @kbd{C-u} prefix, do not remove
732 the previously used indirect buffer.
733 @end table
735 When Emacs first visits an Org-mode file, the global state is set to
736 OVERVIEW, i.e. only the top level headlines are visible.  This can be
737 configured through the variable @code{org-startup-folded}, or on a
738 per-file basis by adding one of the following lines anywhere in the
739 buffer:
741 @example
742 #+STARTUP: overview
743 #+STARTUP: content
744 #+STARTUP: showall
745 @end example
747 @node Motion, Structure editing, Visibility cycling, Document structure
748 @section Motion
749 @cindex motion, between headlines
750 @cindex jumping, to headlines
751 @cindex headline navigation
752 The following commands jump to other headlines in the buffer.
754 @table @kbd
755 @kindex C-c C-n
756 @item C-c C-n
757 Next heading.
758 @kindex C-c C-p
759 @item C-c C-p
760 Previous heading.
761 @kindex C-c C-f
762 @item C-c C-f
763 Next heading same level.
764 @kindex C-c C-b
765 @item C-c C-b
766 Previous heading same level.
767 @kindex C-c C-u
768 @item C-c C-u
769 Backward to higher level heading.
770 @kindex C-c C-j
771 @item C-c C-j
772 Jump to a different place without changing the current outline
773 visibility.  Shows the document structure in a temporary buffer, where
774 you can use the following keys to find your destination:
775 @example
776 @key{TAB}         @r{Cycle visibility.}
777 @key{down} / @key{up}   @r{Next/previous visible headline.}
778 n / p        @r{Next/previous visible headline.}
779 f / b        @r{Next/previous headline same level.}
780 u            @r{One level up.}
781 0-9          @r{Digit argument.}
782 @key{RET}         @r{Select this location.}
783 @end example
784 @end table
786 @node Structure editing, Archiving, Motion, Document structure
787 @section Structure editing
788 @cindex structure editing
789 @cindex headline, promotion and demotion
790 @cindex promotion, of subtrees
791 @cindex demotion, of subtrees
792 @cindex subtree, cut and paste
793 @cindex pasting, of subtrees
794 @cindex cutting, of subtrees
795 @cindex copying, of subtrees
796 @cindex subtrees, cut and paste
798 @table @kbd
799 @kindex M-@key{RET}
800 @item M-@key{RET}
801 Insert new heading with same level as current.  If the cursor is in a
802 plain list item, a new item is created (@pxref{Plain lists}).  To force
803 creation of a new headline, use a prefix arg, or first press @key{RET}
804 to get to the beginning of the next line.  When this command is used in
805 the middle of a line, the line is split and the rest of the line becomes
806 the new headline.  If the command is used at the beginning of a
807 headline, the new headline is created before the current line.  If at
808 the beginning of any other line, the content of that line is made the
809 new heading.  If the command is used at the end of a folded subtree
810 (i.e. behind the ellipses at the end of a headline), then a headline
811 like the current one will be inserted after the end of the subtree.
812 @kindex C-@key{RET}
813 @item C-@key{RET}
814 Insert a new heading after the current subtree, same level as the
815 current headline.  This command works from anywhere in the entry.
816 @kindex M-S-@key{RET}
817 @item M-S-@key{RET}
818 Insert new TODO entry with same level as current heading.
819 @kindex M-@key{left}
820 @item M-@key{left}
821 Promote current heading by one level.
822 @kindex M-@key{right}
823 @item M-@key{right}
824 Demote current heading by one level.
825 @kindex M-S-@key{left}
826 @item M-S-@key{left}
827 Promote the current subtree by one level.
828 @kindex M-S-@key{right}
829 @item M-S-@key{right}
830 Demote the current subtree by one level.
831 @kindex M-S-@key{up}
832 @item M-S-@key{up}
833 Move subtree up (swap with previous subtree of same
834 level).
835 @kindex M-S-@key{down}
836 @item M-S-@key{down}
837 Move subtree down (swap with next subtree of same level).
838 @kindex C-c C-x C-w
839 @kindex C-c C-x C-k
840 @item C-c C-x C-w
841 @itemx C-c C-x C-k
842 Kill subtree, i.e. remove it from buffer but save in kill ring.
843 With prefix arg, kill N sequential subtrees.
844 @kindex C-c C-x M-w
845 @item C-c C-x M-w
846 Copy subtree to kill ring.  With prefix arg, copy N sequential subtrees.
847 @kindex C-c C-x C-y
848 @item C-c C-x C-y
849 Yank subtree from kill ring.  This does modify the level of the subtree to
850 make sure the tree fits in nicely at the yank position.  The yank
851 level can also be specified with a prefix arg, or by yanking after a
852 headline marker like @samp{****}.
853 @kindex C-c ^
854 @item C-c ^
855 Sort same-level entries.  When there is an active region, all entries in
856 the region will be sorted.  Otherwise the children of the current
857 headline are sorted.  The command prompts for the sorting method, which
858 can be alphabetically, numerically, by time (using the first time stamp
859 in each entry), by priority, and each of these in reverse order.  You
860 can also supply your own function to extract the sorting key.  With a
861 @kbd{C-u} prefix, sorting will be case-sensitive.  With two @kbd{C-u
862 C-u} prefixes, duplicate entries will also be removed.
863 @end table
865 @cindex region, active
866 @cindex active region
867 @cindex transient-mark-mode
868 When there is an active region (transient-mark-mode), promotion and
869 demotion work on all headlines in the region.  To select a region of
870 headlines, it is best to place both point and mark at the beginning of a
871 line, mark at the beginning of the first headline, and point at the line
872 just after the last headline to change.  Note that when the cursor is
873 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
874 functionality.
876 @node Archiving, Sparse trees, Structure editing, Document structure
877 @section Archiving
878 @cindex archiving
880 When a project represented by a (sub)tree is finished, you may want
881 to move the tree out of the way and to stop it from contributing to the
882 agenda.  Org-mode knows two ways of archiving.  You can mark a tree with
883 the ARCHIVE tag, or you can move an entire (sub)tree to a different
884 location.
886 @menu
887 * ARCHIVE tag::                 Marking a tree as inactive
888 * Moving subtrees::             Moving a tree to an archive file
889 @end menu
891 @node ARCHIVE tag, Moving subtrees, Archiving, Archiving
892 @subsection The ARCHIVE tag
893 @cindex internal archiving
895 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
896 its location in the outline tree, but behaves in the following way:
897 @itemize @minus
898 @item
899 It does not open when you attempt to do so with a visibility cycling
900 command (@pxref{Visibility cycling}).  You can force cycling archived
901 subtrees with @kbd{C-@key{TAB}}, or by setting the option
902 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
903 @code{show-all} will open archived subtrees.
904 @item
905 During sparse tree construction (@pxref{Sparse trees}), matches in
906 archived subtrees are not exposed, unless you configure the option
907 @code{org-sparse-tree-open-archived-trees}.
908 @item
909 During agenda view construction (@pxref{Agenda views}), the content of
910 archived trees is ignored unless you configure the option
911 @code{org-agenda-skip-archived-trees}.
912 @item
913 Archived trees are not exported (@pxref{Exporting}), only the headline
914 is.  Configure the details using the variable
915 @code{org-export-with-archived-trees}.
916 @end itemize
918 The following commands help managing the ARCHIVE tag:
920 @table @kbd
921 @kindex C-c C-x C-a
922 @item C-c C-x C-a
923 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
924 the headline changes to a shadowish face, and the subtree below it is
925 hidden.
926 @kindex C-u C-c C-x C-a
927 @item C-u C-c C-x C-a
928 Check if any direct children of the current headline should be archived.
929 To do this, each subtree is checked for open TODO entries.  If none are
930 found, the command offers to set the ARCHIVE tag for the child.  If the
931 cursor is @emph{not} on a headline when this command is invoked, the
932 level 1 trees will be checked.
933 @kindex C-@kbd{TAB}
934 @item C-@kbd{TAB}
935 Cycle a tree even if it is tagged with ARCHIVE.
936 @end table
938 @node Moving subtrees,  , ARCHIVE tag, Archiving
939 @subsection Moving subtrees
940 @cindex external archiving
942 Once an entire project is finished, you may want to move it to a
943 different location, either in the current file, or even in a different
944 file, the archive file.
946 @table @kbd
947 @kindex C-c C-x C-s
948 @item C-c C-x C-s
949 Archive the subtree starting at the cursor position to the location
950 given by @code{org-archive-location}.  Context information that could be
951 lost like the file name, the category, inherited tags, and the todo
952 state will be store as properties in the entry.
953 @kindex C-u C-c C-x C-s
954 @item C-u C-c C-x C-s
955 Check if any direct children of the current headline could be moved to
956 the archive.  To do this, each subtree is checked for open TODO entries.
957 If none are found, the command offers to move it to the archive
958 location.  If the cursor is @emph{not} on a headline when this command
959 is invoked, the level 1 trees will be checked.
960 @end table
962 @cindex archive locations
963 The default archive location is a file in the same directory as the
964 current file, with the name derived by appending @file{_archive} to the
965 current file name.  For information and examples on how to change this,
966 see the documentation string of the variable
967 @code{org-archive-location}.  There is also an in-buffer option for
968 setting this variable, for example@footnote{If there are several such
969 lines in the buffer, each will be valid for the entries below it.  The
970 first will also apply to any text before it.  This method is only kept
971 for backward compatibility.  The preferred methods for setting multiple
972 archive locations is using a property.}:
974 @example
975 #+ARCHIVE: %s_done::
976 @end example
978 @noindent
979 If you would like to have a special ARCHIVE location for a single entry
980 or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
981 location as the value (@pxref{Properties and columns}).
983 @node Sparse trees, Plain lists, Archiving, Document structure
984 @section Sparse trees
985 @cindex sparse trees
986 @cindex trees, sparse
987 @cindex folding, sparse trees
988 @cindex occur, command
990 An important feature of Org-mode is the ability to construct
991 @emph{sparse trees} for selected information in an outline tree.  A
992 sparse tree means that the entire document is folded as much as
993 possible, but the selected information is made visible along with the
994 headline structure above it@footnote{See also the variables
995 @code{org-show-hierarchy-above}, @code{org-show-following-heading}, and
996 @code{org-show-siblings} for detailed control on how much context is
997 shown around each match.}.  Just try it out and you will see immediately
998 how it works.
1000 Org-mode contains several commands creating such trees, all these
1001 commands can be accessed through a dispatcher:
1003 @table @kbd
1004 @kindex C-c /
1005 @item C-c /
1006 This prompts for an extra key to select a sparse-tree creating command.
1007 @kindex C-c / r
1008 @item C-c / r
1009 Occur.  Prompts for a regexp and shows a sparse tree with all matches.
1010 If the match is in a headline, the headline is made visible.  If the
1011 match is in the body of an entry, headline and body are made visible.
1012 In order to provide minimal context, also the full hierarchy of
1013 headlines above the match is shown, as well as the headline following
1014 the match.  Each match is also highlighted; the highlights disappear
1015 when the buffer is changed by an editing command, or by pressing
1016 @kbd{C-c C-c}.  When called with a @kbd{C-u} prefix argument, previous
1017 highlights are kept, so several calls to this command can be stacked.
1018 @end table
1019 @noindent
1020 For frequently used sparse trees of specific search strings, you can
1021 use the variable @code{org-agenda-custom-commands} to define fast
1022 keyboard access to specific sparse trees.  These commands will then be
1023 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
1024 For example:
1026 @lisp
1027 (setq org-agenda-custom-commands
1028       '(("f" occur-tree "FIXME")))
1029 @end lisp
1031 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
1032 a sparse tree matching the string @samp{FIXME}.
1034 The other sparse tree commands select headings based on TODO keywords,
1035 tags, or properties and will be discussed later in this manual.
1037 @kindex C-c C-e v
1038 @cindex printing sparse trees
1039 @cindex visible text, printing
1040 To print a sparse tree, you can use the Emacs command
1041 @code{ps-print-buffer-with-faces} which does not print invisible parts
1042 of the document @footnote{This does not work under XEmacs, because
1043 XEmacs uses selective display for outlining, not text properties.}.
1044 Or you can use the command @kbd{C-c C-e v} to export only the visible
1045 part of the document and print the resulting file.
1047 @node Plain lists, Drawers, Sparse trees, Document structure
1048 @section Plain lists
1049 @cindex plain lists
1050 @cindex lists, plain
1051 @cindex lists, ordered
1052 @cindex ordered lists
1054 Within an entry of the outline tree, hand-formatted lists can provide
1055 additional structure.  They also provide a way to create lists of
1056 checkboxes (@pxref{Checkboxes}).  Org-mode supports editing such lists,
1057 and the HTML exporter (@pxref{Exporting}) does parse and format them.
1059 Org-mode knows ordered and unordered lists.  Unordered list items start
1060 with @samp{-}, @samp{+}, or @samp{*}@footnote{When using @samp{*} as a
1061 bullet, lines must be indented or they will be seen as top-level
1062 headlines.  Also, when you are hiding leading stars to get a clean
1063 outline view, plain list items starting with a star are visually
1064 indistinguishable from true headlines.  In short: even though @samp{*}
1065 is supported, it may be better not to use it for plain list items.} as
1066 bullets.  Ordered list items start with @samp{1.} or @samp{1)}.  Items
1067 belonging to the same list must have the same indentation on the first
1068 line.  In particular, if an ordered list reaches number @samp{10.}, then
1069 the 2--digit numbers must be written left-aligned with the other numbers
1070 in the list.  Indentation also determines the end of a list item.  It
1071 ends before the next line that is indented like the bullet/number, or
1072 less.  Empty lines are part of the previous item, so you can have
1073 several paragraphs in one item.  If you would like an empty line to
1074 terminate all currently open plain lists, configure the variable
1075 @code{org-empty-line-terminates-plain-lists}.  Here is an example:
1077 @example
1078 @group
1079 ** Lord of the Rings
1080    My favorite scenes are (in this order)
1081    1. The attack of the Rohirrim
1082    2. Eowyns fight with the witch king
1083       + this was already my favorite scene in the book
1084       + I really like Miranda Otto.
1085    3. Peter Jackson being shot by Legolas
1086        - on DVD only
1087       He makes a really funny face when it happens.
1088    But in the end, not individual scenes matter but the film as a whole.
1089 @end group
1090 @end example
1092 Org-mode supports these lists by tuning filling and wrapping commands to
1093 deal with them correctly@footnote{Org-mode only changes the filling
1094 settings for Emacs.  For XEmacs, you should use Kyle E. Jones'
1095 @file{filladapt.el}.  To turn this on,  put into @file{.emacs}:
1096 @code{(require 'filladapt)}}. 
1098 The following commands act on items when the cursor is in the first line
1099 of an item (the line with the bullet or number).
1101 @table @kbd
1102 @kindex @key{TAB}
1103 @item @key{TAB}
1104 Items can be folded just like headline levels if you set the variable
1105 @code{org-cycle-include-plain-lists}.  The level of an item is then
1106 given by the indentation of the bullet/number.  Items are always
1107 subordinate to real headlines, however; the hierarchies remain
1108 completely separated.
1110 If @code{org-cycle-include-plain-lists} has not been set, @key{TAB}
1111 fixes the indentation of the curent line in a heuristic way.
1112 @kindex M-@key{RET}
1113 @item M-@key{RET}
1114 Insert new item at current level.  With prefix arg, force a new heading
1115 (@pxref{Structure editing}).  If this command is used in the middle of a
1116 line, the line is @emph{split} and the rest of the line becomes the new
1117 item.  If this command is executed in the @emph{whitespace before a bullet or
1118 number}, the new item is created @emph{before} the current item.  If the
1119 command is executed in the white space before the text that is part of
1120 an item but does not contain the bullet, a bullet is added to the
1121 current line.
1122 @kindex M-S-@key{RET}
1123 @item M-S-@key{RET}
1124 Insert a new item with a checkbox (@pxref{Checkboxes}).
1125 @kindex S-@key{up}
1126 @kindex S-@key{down}
1127 @item S-@key{up}
1128 @itemx S-@key{down}
1129 Jump to the previous/next item in the current list.
1130 @kindex M-S-@key{up}
1131 @kindex M-S-@key{down}
1132 @item M-S-@key{up}
1133 @itemx M-S-@key{down}
1134 Move the item including subitems up/down (swap with previous/next item
1135 of same indentation).  If the list is ordered, renumbering is
1136 automatic.
1137 @kindex M-S-@key{left}
1138 @kindex M-S-@key{right}
1139 @item M-S-@key{left}
1140 @itemx M-S-@key{right}
1141 Decrease/increase the indentation of the item, including subitems.
1142 Initially, the item tree is selected based on current indentation.
1143 When these commands are executed several times in direct succession,
1144 the initially selected region is used, even if the new indentation
1145 would imply a different hierarchy.  To use the new hierarchy, break
1146 the command chain with a cursor motion or so.
1147 @kindex C-c C-c
1148 @item C-c C-c
1149 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1150 state of the checkbox.  If not, make this command makes sure that all
1151 the items on this list level use the same bullet.  Furthermore, if this
1152 is an ordered list, make sure the numbering is ok.
1153 @kindex C-c -
1154 @item C-c -
1155 Cycle the entire list level through the different itemize/enumerate
1156 bullets (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}).
1157 With prefix arg, select the nth bullet from this list.
1158 @end table
1160 @node Drawers, orgstruct-mode, Plain lists, Document structure
1161 @section Drawers
1162 @cindex drawers
1163 @cindex visibility cycling, drawers
1165 Sometimes you want to keep information associated with an entry, but you
1166 normally don't want to see it.  For this, Org-mode has @emph{drawers}.
1167 Drawers need to be configured with the variable
1168 @code{org-drawers}@footnote{You can define drawers on a per-file basis
1169 with a line like @code{#+DRAWERS: HIDDEN PROPPERTIES STATE}}, and
1170 look like this:
1172 @example
1173 ** This is a headline
1174    Still outside the drawer
1175    :DRAWERNAME:
1176       This is inside the drawer.
1177    :END:
1178    After the drawer.
1179 @end example
1181 Visibility cycling (@pxref{Visibility cycling}) on the headline will
1182 hide and show the entry, but keep the drawer collapsed to a single line.
1183 In order to look inside the drawer, you need to move the cursor to the
1184 drawer line and press @key{TAB} there.  Org-mode uses a drawer for
1185 storing properties (@pxref{Properties and columns}).
1187 @node orgstruct-mode,  , Drawers, Document structure
1188 @section The Orgstruct minor mode
1189 @cindex orgstruct-mode
1190 @cindex minor mode for structure editing
1192 If you like the intuitive way the Org-mode structure editing and list
1193 formatting works, you might want to use these commands in other modes
1194 like text-mode or mail-mode as well.  The minor mode Orgstruct-mode
1195 makes this possible.  You can always toggle the mode with @kbd{M-x
1196 orgstruct-mode}.  To turn it on by default, for example in mail mode,
1199 @lisp
1200 (add-hook 'mail-mode-hook 'turn-on-orgstruct)
1201 @end lisp
1203 When this mode is active and the cursor is on a line that looks to
1204 Org-mode like a headline of the first line of a list item, most
1205 structure editing commands will work, even if the same keys normally
1206 have different functionality in the major mode you are using.  If the
1207 cursor is not in one of those special lines, Orgstruct-mode lurks
1208 silently in the shadow.
1210 @node Tables, Hyperlinks, Document structure, Top
1211 @chapter Tables
1212 @cindex tables
1213 @cindex editing tables
1215 Org-mode has a very fast and intuitive table editor built-in.
1216 Spreadsheet-like calculations are supported in connection with the
1217 Emacs @file{calc} package.
1219 @menu
1220 * Built-in table editor::       Simple tables
1221 * Narrow columns::              Stop wasting space in tables   
1222 * Column groups::               Grouping to trigger vertical lines
1223 * orgtbl-mode::                 The table editor as minor mode
1224 * The spreadsheet::             The table editor has spreadsheet capabilities.
1225 @end menu
1227 @node Built-in table editor, Narrow columns, Tables, Tables
1228 @section The built-in table editor
1229 @cindex table editor, built-in
1231 Org-mode makes it easy to format tables in plain ASCII.  Any line with
1232 @samp{|} as the first non-whitespace character is considered part of a
1233 table.  @samp{|} is also the column separator.  A table might look like
1234 this:
1236 @example
1237 | Name  | Phone | Age |
1238 |-------+-------+-----|
1239 | Peter |  1234 |  17 |
1240 | Anna  |  4321 |  25 |
1241 @end example
1243 A table is re-aligned automatically each time you press @key{TAB} or
1244 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
1245 the next field (@key{RET} to the next row) and creates new table rows
1246 at the end of the table or before horizontal lines.  The indentation
1247 of the table is set by the first line.  Any line starting with
1248 @samp{|-} is considered as a horizontal separator line and will be
1249 expanded on the next re-align to span the whole table width.  So, to
1250 create the above table, you would only type
1252 @example
1253 |Name|Phone|Age|
1255 @end example
1257 @noindent and then press @key{TAB} to align the table and start filling in
1258 fields.
1260 When typing text into a field, Org-mode treats @key{DEL},
1261 @key{Backspace}, and all character keys in a special way, so that
1262 inserting and deleting avoids shifting other fields.  Also, when
1263 typing @emph{immediately after the cursor was moved into a new field
1264 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
1265 field is automatically made blank.  If this behavior is too
1266 unpredictable for you, configure the variables
1267 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
1269 @table @kbd
1270 @tsubheading{Creation and conversion}
1271 @kindex C-c |
1272 @item C-c |
1273 Convert the active region to table. If every line contains at least one
1274 TAB character, the function assumes that the material is tab separated.
1275 If every line contains a comma, comma-separated values (CSV) are assumed.
1276 If not, lines are split at whitespace into fields.  You can use a prefix
1277 argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
1278 C-u} forces TAB, and a numeric argument N indicates that at least N
1279 consequtive spaces, or alternatively a TAB will be the separator.
1280 @* 
1281 If there is no active region, this command creates an empty Org-mode
1282 table.  But it's easier just to start typing, like
1283 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
1285 @tsubheading{Re-aligning and field motion}
1286 @kindex C-c C-c
1287 @item C-c C-c
1288 Re-align the table without moving the cursor.
1290 @kindex @key{TAB}
1291 @item @key{TAB}
1292 Re-align the table, move to the next field.  Creates a new row if
1293 necessary.
1295 @kindex S-@key{TAB}
1296 @item S-@key{TAB}
1297 Re-align, move to previous field.
1299 @kindex @key{RET}
1300 @item @key{RET}
1301 Re-align the table and move down to next row.  Creates a new row if
1302 necessary.  At the beginning or end of a line, @key{RET} still does
1303 NEWLINE, so it can be used to split a table.
1305 @tsubheading{Column and row editing}
1306 @kindex M-@key{left}
1307 @kindex M-@key{right}
1308 @item M-@key{left}
1309 @itemx M-@key{right}
1310 Move the current column left/right.
1312 @kindex M-S-@key{left}
1313 @item M-S-@key{left}
1314 Kill the current column.
1316 @kindex M-S-@key{right}
1317 @item M-S-@key{right}
1318 Insert a new column to the left of the cursor position.
1320 @kindex M-@key{up}
1321 @kindex M-@key{down}
1322 @item M-@key{up}
1323 @itemx M-@key{down}
1324 Move the current row up/down.
1326 @kindex M-S-@key{up}
1327 @item M-S-@key{up}
1328 Kill the current row or horizontal line.
1330 @kindex M-S-@key{down}
1331 @item M-S-@key{down}
1332 Insert a new row above (with arg: below) the current row.
1334 @kindex C-c -
1335 @item C-c -
1336 Insert a horizontal line below current row. With prefix arg, the line
1337 is created above the current line.
1339 @kindex C-c ^
1340 @item C-c ^
1341 Sort the table lines in the region.  The position of point indicates the
1342 column to be used for sorting, and the range of lines is the range
1343 between the nearest horizontal separator lines, or the entire table.  If
1344 point is before the first column, you will be prompted for the sorting
1345 column.  If there is an active region, the mark specifies the first line
1346 and the sorting column, while point should be in the last line to be
1347 included into the sorting.  The command prompts for the sorting type
1348 (alphabetically, numerically, or by time).  When called with a prefix
1349 argument, alphabetic sorting will be case-sensitive.
1351 @tsubheading{Regions}
1352 @kindex C-c C-x M-w
1353 @item C-c C-x M-w
1354 Copy a rectangular region from a table to a special clipboard.  Point
1355 and mark determine edge fields of the rectangle.  The process ignores
1356 horizontal separator lines.
1358 @kindex C-c C-x C-w
1359 @item C-c C-x C-w
1360 Copy a rectangular region from a table to a special clipboard, and
1361 blank all fields in the rectangle.  So this is the ``cut'' operation.
1363 @kindex C-c C-x C-y
1364 @item C-c C-x C-y
1365 Paste a rectangular region into a table.
1366 The upper right corner ends up in the current field.  All involved fields
1367 will be overwritten.  If the rectangle does not fit into the present table,
1368 the table is enlarged as needed.  The process ignores horizontal separator
1369 lines.
1371 @kindex C-c C-q
1372 @item C-c C-q
1373 Wrap several fields in a column like a paragraph.  If there is an active
1374 region, and both point and mark are in the same column, the text in the
1375 column is wrapped to minimum width for the given number of lines.  A
1376 prefix ARG may be used to change the number of desired lines.  If there
1377 is no region, the current field is split at the cursor position and the
1378 text fragment to the right of the cursor is prepended to the field one
1379 line down. If there is no region, but you specify a prefix ARG, the
1380 current field is made blank, and the content is appended to the field
1381 above.
1383 @tsubheading{Calculations}
1384 @cindex formula, in tables
1385 @cindex calculations, in tables
1386 @cindex region, active
1387 @cindex active region
1388 @cindex transient-mark-mode
1389 @kindex C-c +
1390 @item C-c +
1391 Sum the numbers in the current column, or in the rectangle defined by
1392 the active region.  The result is shown in the echo area and can
1393 be inserted with @kbd{C-y}.
1395 @kindex S-@key{RET}
1396 @item S-@key{RET}
1397 When current field is empty, copy from first non-empty field above.
1398 When not empty, copy current field down to next row and move cursor
1399 along with it.  Depending on the variable
1400 @code{org-table-copy-increment}, integer field values will be
1401 incremented during copy.  This key is also used by CUA-mode
1402 (@pxref{Cooperation}).
1404 @tsubheading{Miscellaneous}
1405 @kindex C-c `
1406 @item C-c `
1407 Edit the current field in a separate window.  This is useful for fields
1408 that are not fully visible (@pxref{Narrow columns}).  When called with a
1409 @kbd{C-u} prefix, just make the full field visible, so that it can be
1410 edited in place.
1412 @kindex C-c @key{TAB}
1413 @item C-c @key{TAB}
1414 This is an alias for @kbd{C-u C-c `} to make the current field fully
1415 visible.
1417 @item M-x org-table-import
1418 Import a file as a table.  The table should be TAB- or whitespace
1419 separated.  Useful, for example, to import an Excel table or data from a
1420 database, because these programs generally can write TAB-separated text
1421 files.  This command works by inserting the file into the buffer and
1422 then converting the region to a table.  Any prefix argument is passed on
1423 to the converter, which uses it to determine the separator.
1424 @item C-c |
1425 Tables can also be imported by pasting tabular text into the org-mode
1426 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
1427 @kbd{C-c |} command (see above under @i{Creation and conversion}.
1429 @item M-x org-table-export
1430 Export the table as a TAB-separated file.  Useful for data exchange with,
1431 for example, Excel or database programs.
1432 @end table
1434 If you don't like the automatic table editor because it gets in your
1435 way on lines which you would like to start with @samp{|}, you can turn
1436 it off with
1438 @lisp
1439 (setq org-enable-table-editor nil)
1440 @end lisp
1442 @noindent Then the only table command that still works is
1443 @kbd{C-c C-c} to do a manual re-align.
1445 @node Narrow columns, Column groups, Built-in table editor, Tables
1446 @section Narrow columns
1447 @cindex narrow columns in tables
1449 The width of columns is automatically determined by the table editor.
1450 Sometimes a single field or a few fields need to carry more text,
1451 leading to inconveniently wide columns.  To limit@footnote{This feature
1452 does not work on XEmacs.} the width of a column, one field anywhere in
1453 the column may contain just the string @samp{<N>} where @samp{N} is an
1454 integer specifying the width of the column in characters.  The next
1455 re-align will then set the width of this column to no more than this
1456 value.
1458 @example
1459 @group
1460 |---+------------------------------|               |---+--------|
1461 |   |                              |               |   | <6>    |
1462 | 1 | one                          |               | 1 | one    |
1463 | 2 | two                          |     ----\     | 2 | two    |
1464 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
1465 | 4 | four                         |               | 4 | four   |
1466 |---+------------------------------|               |---+--------|
1467 @end group
1468 @end example
1470 @noindent
1471 Fields that are wider become clipped and end in the string @samp{=>}.
1472 Note that the full text is still in the buffer, it is only invisible.
1473 To see the full text, hold the mouse over the field - a tool-tip window
1474 will show the full content.  To edit such a field, use the command
1475 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
1476 open a new window with the full field.  Edit it and finish with @kbd{C-c
1477 C-c}.
1479 When visiting a file containing a table with narrowed columns, the
1480 necessary character hiding has not yet happened, and the table needs to
1481 be aligned before it looks nice.  Setting the option
1482 @code{org-startup-align-all-tables} will realign all tables in a file
1483 upon visiting, but also slow down startup.  You can also set this option
1484 on a per-file basis with:
1486 @example
1487 #+STARTUP: align
1488 #+STARTUP: noalign
1489 @end example
1491 @node Column groups, orgtbl-mode, Narrow columns, Tables
1492 @section Column groups
1493 @cindex grouping columns in tables
1495 When Org-mode exports tables, it does so by default without vertical
1496 lines because that is visually more satisfying in general.  Occasionally
1497 however, vertical lines can be useful to structure a table into groups
1498 of columns, much like horizontal lines can do for groups of rows.  In
1499 order to specify column groups, you can use a special row where the
1500 first field contains only @samp{/}.  The further fields can either
1501 contain @samp{<} to indicate that this column should start a group,
1502 @samp{>} to indicate the end of a column, or @samp{<>} to make a column
1503 a group of its own.  Boundaries between colum groups will upon export be
1504 marked with vertical lines.  Here is an example:
1506 @example
1507 |   |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1508 |---+----+-----+-----+-----+---------+------------|
1509 | / | <> |   < |     |   > |       < |          > |
1510 | # |  1 |   1 |   1 |   1 |       1 |          1 |
1511 | # |  2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
1512 | # |  3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
1513 |---+----+-----+-----+-----+---------+------------|
1514 #+TBLFM: $3=$2^2::$4=$2^3::$5=$2^4::$6=sqrt($2)::$7=sqrt(sqrt(($2))
1515 @end example
1517 It is also sufficient to just insert the colum group starters after
1518 every vertical line you'd like to have:
1520 @example
1521 |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1522 |----+-----+-----+-----+---------+------------|
1523 | /  | <   |     |     | <       |            |
1524 @end example
1526 @node orgtbl-mode, The spreadsheet, Column groups, Tables
1527 @section The Orgtbl minor mode
1528 @cindex orgtbl-mode
1529 @cindex minor mode for tables
1531 If you like the intuitive way the Org-mode table editor works, you
1532 might also want to use it in other modes like text-mode or mail-mode.
1533 The minor mode Orgtbl-mode makes this possible.  You can always toggle
1534 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
1535 example in mail mode, use
1537 @lisp
1538 (add-hook 'mail-mode-hook 'turn-on-orgtbl)
1539 @end lisp
1541 Furthermore, with some special setup, it is possible to maintain tables
1542 in arbitrary syntax with Orgtbl-mode.  For example, it is possible to
1543 construct La@TeX{} tables with the underlying ease and power of
1544 Orgtbl-mode, including spreadsheet capabilities.  For details, see
1545 @ref{Tables in arbitrary syntax}.
1547 @node The spreadsheet,  , orgtbl-mode, Tables
1548 @section The spreadsheet
1549 @cindex calculations, in tables
1550 @cindex spreadsheet capabilities
1551 @cindex @file{calc} package
1553 The table editor makes use of the Emacs @file{calc} package to implement
1554 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
1555 derive fields from other fields.  While fully featured, Org-mode's
1556 implementation is not identical to other spreadsheets.  For example,
1557 Org-mode knows the concept of a @emph{column formula} that will be
1558 applied to all non-header fields in a column without having to copy the
1559 formula to each relevant field.
1561 @menu
1562 * References::                  How to refer to another field or range
1563 * Formula syntax for Calc::     Using Calc to compute stuff
1564 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
1565 * Field formulas::              Formulas valid for a single field
1566 * Column formulas::             Formulas valid for an entire column
1567 * Editing and debugging formulas::  Fixing formulas
1568 * Updating the table::          Recomputing all dependent fields
1569 * Advanced features::           Field names, parameters and automatic recalc
1570 @end menu
1572 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
1573 @subsection References
1574 @cindex references
1576 To compute fields in the table from other fields, formulas must
1577 reference other fields or ranges.  In Org-mode, fields can be referenced
1578 by name, by absolute coordinates, and by relative coordinates.  To find
1579 out what the coordinates of a field are, press @kbd{C-c ?} in that
1580 field, or press @kbd{C-c @}} to toggle the display of a grid.
1582 @subsubheading Field references
1583 @cindex field references
1584 @cindex references, to fields
1586 Formulas can reference the value of another field in two ways.  Like in
1587 any other spreadsheet, you may reference fields with a letter/number
1588 combination like @code{B3}, meaning the 2nd field in the 3rd row.
1589 @c Such references are always fixed to that field, they don't change
1590 @c when you copy and paste a formula to a different field.  So
1591 @c Org-mode's @code{B3} behaves like @code{$B$3} in other spreadsheets.
1593 @noindent
1594 Org-mode also uses another, more general operator that looks like this:
1595 @example
1596 @@row$column
1597 @end example
1599 @noindent
1600 Column references can be absolute like @samp{1}, @samp{2},...@samp{N},
1601 or relative to the current column like @samp{+1} or @samp{-2}.
1603 The row specification only counts data lines and ignores horizontal
1604 separator lines (hlines).  You can use absolute row numbers
1605 @samp{1}...@samp{N}, and row numbers relative to the current row like
1606 @samp{+3} or @samp{-1}.  Or specify the row relative to one of the
1607 hlines: @samp{I} refers to the first hline, @samp{II} to the second etc.
1608 @samp{-I} refers to the first such line above the current line,
1609 @samp{+I} to the first such line below the current line.  You can also
1610 write @samp{III+2} which is the second data line after the third hline
1611 in the table.  Relative row numbers like @samp{-3} will not cross hlines
1612 if the current line is too close to the hline.  Instead, the value
1613 directly at the hline is used.
1615 @samp{0} refers to the current row and column.  Also, if you omit
1616 either the column or the row part of the reference, the current
1617 row/column is implied. 
1619 Org-mode's references with @emph{unsigned} numbers are fixed references
1620 in the sense that if you use the same reference in the formula for two
1621 different fields, the same field will be referenced each time.
1622 Org-mode's references with @emph{signed} numbers are floating
1623 references because the same reference operator can reference different
1624 fields depending on the field being calculated by the formula.
1626 Here are a few examples:
1628 @example
1629 @@2$3      @r{2nd row, 3rd column}
1630 C2        @r{same as previous}
1631 $5        @r{column 5 in the current row}
1632 E&        @r{same as previous}
1633 @@2        @r{current column, row 2}
1634 @@-1$-3    @r{the field one row up, three columns to the left}
1635 @@-I$2     @r{field just under hline above current row, column 2}
1636 @end example
1638 @subsubheading Range references
1639 @cindex range references
1640 @cindex references, to ranges
1642 You may reference a rectangular range of fields by specifying two field
1643 references connected by two dots @samp{..}.  If both fields are in the
1644 current row, you may simply use @samp{$2..$7}, but if at least one field
1645 is in a different row, you need to use the general @code{@@row$column}
1646 format at least for the first field (i.e the reference must start with
1647 @samp{@@} in order to be interpreted correctly).  Examples:
1649 @example
1650 $1..$3        @r{First three fields in the current row.}
1651 $P..$Q        @r{Range, using column names (see under Advanced)}
1652 @@2$1..@@4$3    @r{6 fields between these two fields.}
1653 A2..C4        @r{Same as above.}
1654 @@-1$-2..@@-1   @r{3 numbers from the column to the left, 2 up to current row}
1655 @end example
1657 @noindent Range references return a vector of values that can be fed
1658 into Calc vector functions.  Empty fields in ranges are normally
1659 suppressed, so that the vector contains only the non-empty fields (but
1660 see the @samp{E} mode switch below).  If there are no non-empty fields,
1661 @samp{[0]} is returned to avoid syntax errors in formulas.
1663 @subsubheading Named references
1664 @cindex named references
1665 @cindex references, named
1666 @cindex name, of column or field
1667 @cindex constants, in calculations
1669 @samp{$name} is interpreted as the name of a column, parameter or
1670 constant.  Constants are defined globally through the variable
1671 @code{org-table-formula-constants}, and locally (for the file) through a
1672 line like
1674 @example
1675 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
1676 @end example
1678 @noindent
1679 Also properties (@pxref{Properties and columns}) can be used as
1680 constants in table formulas: For a property @samp{:XYZ:} use the name
1681 @samp{$PROP_XYZ}, and the property will be searched in the current
1682 outline entry and in the hierarchy above it.  If you have the
1683 @file{constants.el} package, it will also be used to resolve constants,
1684 including natural constants like @samp{$h} for Planck's constant, and
1685 units like @samp{$km} for kilometers@footnote{@file{Constant.el} can
1686 supply the values of constants in two different unit systems, @code{SI}
1687 and @code{cgs}.  Which one is used depends on the value of the variable
1688 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
1689 @code{constSI} and @code{constcgs} to set this value for the current
1690 buffer.}.  Column names and parameters can be specified in special table
1691 lines.  These are described below, see @ref{Advanced features}.  All
1692 names must start with a letter, and further consist of letters and
1693 numbers.
1695 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
1696 @subsection Formula syntax for Calc
1697 @cindex formula syntax, Calc
1698 @cindex syntax, of formulas
1700 A formula can be any algebraic expression understood by the Emacs
1701 @file{Calc} package.  @b{Note that @file{calc} has the
1702 non-standard convention that @samp{/} has lower precedence than
1703 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
1704 evaluation by @code{calc-eval} (@pxref{Calling Calc from
1705 Your Programs,calc-eval,Calling calc from Your Lisp Programs,calc,GNU
1706 Emacs Calc Manual}),
1707 @c FIXME:  The link to the calc manual in HTML does not work.
1708 variable substitution takes place according to the rules described above.
1709 @cindex vectors, in table calculations
1710 The range vectors can be directly fed into the calc vector functions
1711 like @samp{vmean} and @samp{vsum}.
1713 @cindex format specifier
1714 @cindex mode, for @file{calc}
1715 A formula can contain an optional mode string after a semicolon.  This
1716 string consists of flags to influence Calc and other modes during
1717 execution.  By default, Org-mode uses the standard calc modes (precision
1718 12, angular units degrees, fraction and symbolic modes off.  The display
1719 format, however, has been changed to @code{(float 5)} to keep tables
1720 compact.  The default settings can be configured using the variable
1721 @code{org-calc-default-modes}.
1723 @example
1724 p20           @r{switch the internal precision to 20 digits}
1725 n3 s3 e2 f4   @r{normal, scientific, engineering, or fixed display format}
1726 D R           @r{angle modes: degrees, radians}
1727 F S           @r{fraction and symbolic modes}
1728 N             @r{interpret all fields as numbers, use 0 for non-numbers}
1729 T             @r{force text interpretation}
1730 E             @r{keep empty fields in ranges}
1731 @end example
1733 @noindent
1734 In addition, you may provide a @code{printf} format specifier to
1735 reformat the final result.  A few examples:
1737 @example
1738 $1+$2                @r{Sum of first and second field}
1739 $1+$2;%.2f           @r{Same, format result to two decimals}
1740 exp($2)+exp($1)      @r{Math functions can be used}
1741 $0;%.1f              @r{Reformat current cell to 1 decimal}
1742 ($3-32)*5/9          @r{Degrees F -> C conversion}
1743 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
1744 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
1745 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
1746 vmean($2..$7)        @r{Compute column range mean, using vector function}
1747 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
1748 taylor($3,x=7,2)     @r{taylor series of $3, at x=7, second degree}
1749 @end example
1751 Calc also contains a complete set of logical operations.  For example
1753 @example
1754 if($1<20,teen,string(""))  @r{``teen'' if age $1 less than 20, else empty}
1755 @end example
1757 @node Formula syntax for Lisp, Field formulas, Formula syntax for Calc, The spreadsheet
1758 @subsection Emacs Lisp forms as formulas
1759 @cindex Lisp forms, as table formulas
1761 It is also possible to write a formula in Emacs Lisp; this can be useful
1762 for string manipulation and control structures, if the Calc's
1763 functionality is not enough.  If a formula starts with a single quote
1764 followed by an opening parenthesis, then it is evaluated as a lisp form.
1765 The evaluation should return either a string or a number.  Just as with
1766 @file{calc} formulas, you can specify modes and a printf format after a
1767 semicolon.  With Emacs Lisp forms, you need to be concious about the way
1768 field references are interpolated into the form.  By default, a
1769 reference will be interpolated as a Lisp string (in double quotes)
1770 containing the field.  If you provide the @samp{N} mode switch, all
1771 referenced elements will be numbers (non-number fields will be zero) and
1772 interpolated as Lisp numbers, without quotes.  If you provide the
1773 @samp{L} flag, all fields will be interpolated literally, without quotes.
1774 I.e., if you want a reference to be interpreted as a string by the Lisp
1775 form, enclode the reference operator itself in double quotes, like
1776 @code{"$3"}.  Ranges are inserted as space-separated fields, so you can
1777 embed them in list or vector syntax.  A few examples, note how the
1778 @samp{N} mode is used when we do computations in lisp.
1780 @example
1781 @r{Swap the first two characters of the content of column 1}
1782   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
1783 @r{Add columns 1 and 2, equivalent to the Calc's @code{$1+$2}}
1784   '(+ $1 $2);N
1785 @r{Compute the sum of columns 1-4, like Calc's @code{vsum($1..$4)}}
1786   '(apply '+ '($1..$4));N
1787 @end example
1789 @node Field formulas, Column formulas, Formula syntax for Lisp, The spreadsheet
1790 @subsection Field formulas
1791 @cindex field formula
1792 @cindex formula, for individual table field
1794 To assign a formula to a particular field, type it directly into the
1795 field, preceded by @samp{:=}, for example @samp{:=$1+$2}.  When you
1796 press @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in
1797 the field, the formula will be stored as the formula for this field,
1798 evaluated, and the current field replaced with the result.
1800 Formulas are stored in a special line starting with @samp{#+TBLFM:}
1801 directly below the table.  If you typed the equation in the 4th field of
1802 the 3rd data line in the table, the formula will look like
1803 @samp{@@3$4=$1+$2}.  When inserting/deleting/swapping column and rows
1804 with the appropriate commands, @i{absolute references} (but not relative
1805 ones) in stored formulas are modified in order to still reference the
1806 same field.  Of cause this is not true if you edit the table structure
1807 with normal editing commands - then you must fix the equations yourself.
1809 Instead of typing an equation into the field, you may also use the
1810 following command
1812 @table @kbd
1813 @kindex C-u C-c =
1814 @item C-u C-c =
1815 Install a new formula for the current field.  The command prompts for a
1816 formula, with default taken from the @samp{#+TBLFM:} line, applies
1817 it to the current field and stores it.
1818 @end table
1820 @node Column formulas, Editing and debugging formulas, Field formulas, The spreadsheet
1821 @subsection Column formulas
1822 @cindex column formula
1823 @cindex formula, for table column
1825 Often in a table, the same formula should be used for all fields in a
1826 particular column.  Instead of having to copy the formula to all fields
1827 in that column, org-mode allows to assign a single formula to an entire
1828 column.  If the table contains horizontal separator hlines, everything
1829 before the first such line is considered part of the table @emph{header}
1830 and will not be modified by column formulas.
1832 To assign a formula to a column, type it directly into any field in the
1833 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
1834 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the
1835 field, the formula will be stored as the formula for the current column,
1836 evaluated and the current field replaced with the result.  If the field
1837 contains only @samp{=}, the previously stored formula for this column is
1838 used.  For each column, Org-mode will only remember the most recently
1839 used formula.  In the @samp{TBLFM:} line, column formulas will look like
1840 @samp{$4=$1+$2}.
1842 Instead of typing an equation into the field, you may also use the
1843 following command:
1845 @table @kbd
1846 @kindex C-c =
1847 @item C-c =
1848 Install a new formula for the current column and replace current field
1849 with the result of the formula.  The command prompts for a formula, with
1850 default taken from the @samp{#+TBLFM} line, applies it to the current
1851 field and stores it.  With a numerical prefix (e.g. @kbd{C-5 C-c =})
1852 will apply it to that many consecutive fields in the current column.
1853 @end table
1856 @node Editing and debugging formulas, Updating the table, Column formulas, The spreadsheet
1857 @subsection Editing and Debugging formulas
1858 @cindex formula editing
1859 @cindex editing, of table formulas
1861 You can edit individual formulas in the minibuffer or directly in the
1862 field.  Org-mode can also prepare a special buffer with all active
1863 formulas of a table.  When offering a formula for editing, Org-mode
1864 converts references to the standard format (like @code{B3} or @code{D&})
1865 if possible.  If you prefer to only work with the internal format (like
1866 @code{@@3$2} or @code{$4}), configure the variable
1867 @code{org-table-use-standard-references}.
1869 @table @kbd
1870 @kindex C-c =
1871 @kindex C-u C-c =
1872 @item C-c =
1873 @itemx C-u C-c =
1874 Edit the formula associated with the current column/field in the
1875 minibuffer.  See @ref{Column formulas} and @ref{Field formulas}.
1876 @kindex C-u C-u C-c =
1877 @item C-u C-u C-c =
1878 Re-insert the active formula (either a
1879 field formula, or a column formula) into the current field, so that you
1880 can edit it directly in the field.  The advantage over editing in the
1881 minibuffer is that you can use the command @kbd{C-c ?}.
1882 @kindex C-c ?
1883 @item C-c ?
1884 While editing a formula in a table field, highlight the field(s)
1885 referenced by the reference at the cursor position in the formula.
1886 @kindex C-c @}
1887 @item C-c @}
1888 Toggle the display of row and column numbers for a table, using
1889 overlays.  These are updated each time the table is aligned, you can
1890 force it with @kbd{C-c C-c}.
1891 @kindex C-c @{
1892 @item C-c @{
1893 Toggle the formula debugger on and off.  See below.
1894 @kindex C-c '
1895 @item C-c '
1896 Edit all formulas for the current table in a special buffer, where the
1897 formulas will be displayed one per line.  If the current field has an
1898 active formula, the cursor in the formula editor will mark it.
1899 While inside the special buffer, Org-mode will automatically highlight
1900 any field or range reference at the cursor position.  You may edit,
1901 remove and add formulas, and use the following commands:
1902 @table @kbd
1903 @kindex C-c C-c
1904 @kindex C-x C-s
1905 @item C-c C-c
1906 @itemx C-x C-s
1907 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
1908 prefix, also apply the new formulas to the entire table.
1909 @kindex C-c C-q
1910 @item C-c C-q
1911 Exit the formula editor without installing changes.
1912 @kindex C-c C-r
1913 @item C-c C-r
1914 Toggle all references in the formula editor between standard (like
1915 @code{B3}) and internal (like @code{@@3$2}).
1916 @kindex @key{TAB}
1917 @item @key{TAB}
1918 Pretty-print or indent lisp formula at point.  When in a line containing
1919 a lisp formula, format the formula according to Emacs Lisp rules.
1920 Another @key{TAB} collapses the formula back again.  In the open
1921 formula, @key{TAB} re-indents just like in Emacs-lisp-mode.
1922 @kindex M-@key{TAB}
1923 @item M-@key{TAB}
1924 Complete Lisp symbols, just like in Emacs-lisp-mode.
1925 @kindex S-@key{up}
1926 @kindex S-@key{down}
1927 @kindex S-@key{left}
1928 @kindex S-@key{right}
1929 @item S-@key{up}/@key{down}/@key{left}/@key{right}
1930 Shift the reference at point.  For example, if the reference is
1931 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
1932 This also works for relative references, and for hline references.
1933 @kindex M-S-@key{up}
1934 @kindex M-S-@key{down}
1935 @item M-S-@key{up}/@key{down}
1936 Move the test line for column formulas in the Org-mode buffer up and
1937 down.
1938 @kindex M-@key{up}
1939 @kindex M-@key{down}
1940 @item M-@key{up}/@key{down}
1941 Scroll the window displaying the table.
1942 @kindex C-c @}
1943 @item C-c @}
1944 Turn the coordinate grid in the table on and off.
1945 @end table
1946 @end table
1948 Making a table field blank does not remove the formula associated with
1949 the field, because that is stored in a different line (the @samp{TBLFM}
1950 line) - during the next recalculation the field will be filled again.
1951 To remove a formula from a field, you have to give an empty reply when
1952 prompted for the formula, or to edit the @samp{#+TBLFM} line.
1954 @kindex C-c C-c
1955 You may edit the @samp{#+TBLFM} directly and re-apply the changed
1956 equations with @kbd{C-c C-c} in that line, or with the normal
1957 recalculation commands in the table.
1959 @subsubheading Debugging formulas
1960 @cindex formula debugging
1961 @cindex debugging, of table formulas
1962 When the evaluation of a formula leads to an error, the field content
1963 becomes the string @samp{#ERROR}.  If you would like see what is going
1964 on during variable substitution and calculation in order to find a bug,
1965 turn on formula debugging in the @code{Tbl} menu and repeat the
1966 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
1967 field.  Detailed information will be displayed.
1969 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
1970 @subsection Updating the Table
1971 @cindex recomputing table fields
1972 @cindex updating, table
1974 Recalculation of a table is normally not automatic, but needs to be
1975 triggered by a command.  See @ref{Advanced features} for a way to make
1976 recalculation at least semi-automatically.
1978 In order to recalculate a line of a table or the entire table, use the
1979 following commands:
1981 @table @kbd
1982 @kindex C-c *
1983 @item C-c *
1984 Recalculate the current row by first applying the stored column formulas
1985 from left to right, and all field formulas in the current row.
1987 @kindex C-u C-c *
1988 @item C-u C-c *
1989 @kindex C-u C-c C-c
1990 @itemx C-u C-c C-c
1991 Recompute the entire table, line by line.  Any lines before the first
1992 hline are left alone, assuming that these are part of the table header.
1994 @kindex C-u C-u C-c *
1995 @kindex C-u C-u C-c C-c
1996 @item C-u C-u C-c *
1997 @itemx C-u C-u C-c C-c
1998 Iterate the table by recomputing it until no further changes occur.
1999 This may be necessary if some computed fields use the value of other
2000 fields that are computed @i{later} in the calculation sequence.
2001 @end table
2003 @node Advanced features,  , Updating the table, The spreadsheet
2004 @subsection Advanced features
2006 If you want the recalculation of fields to happen automatically, or if
2007 you want to be able to assign @i{names} to fields and columns, you need
2008 to reserve the first column of the table for special marking characters.
2009 @table @kbd
2010 @kindex C-#
2011 @item C-#
2012 Rotate the calculation mark in first column through the states @samp{},
2013 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  The meaning of these characters
2014 is discussed below.  When there is an active region, change all marks in
2015 the region.
2016 @end table
2018 Here is an example of a table that collects exam results of students and
2019 makes use of these features:
2021 @example
2022 @group
2023 |---+---------+--------+--------+--------+-------+------|
2024 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2025 |---+---------+--------+--------+--------+-------+------|
2026 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2027 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2028 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2029 |---+---------+--------+--------+--------+-------+------|
2030 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
2031 | # | Sara    |      6 |     14 |     19 |    39 |  7.8 |
2032 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
2033 |---+---------+--------+--------+--------+-------+------|
2034 |   | Average |        |        |        |  29.7 |      |
2035 | ^ |         |        |        |        |    at |      |
2036 | $ | max=50  |        |        |        |       |      |
2037 |---+---------+--------+--------+--------+-------+------|
2038 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
2039 @end group
2040 @end example
2042 @noindent @b{Important}: Please note that for these special tables,
2043 recalculating the table with @kbd{C-u C-c *} will only affect rows that
2044 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
2045 to the field itself.  The column formulas are not applied in rows with
2046 empty first field.
2048 @cindex marking characters, tables
2049 The marking characters have the following meaning:
2050 @table @samp
2051 @item !
2052 The fields in this line define names for the columns, so that you may
2053 refer to a column as @samp{$Tot} instead of @samp{$6}.
2054 @item ^
2055 This row defines names for the fields @emph{above} the row.  With such
2056 a definition, any formula in the table may use @samp{$m1} to refer to
2057 the value @samp{10}.  Also, if you assign a formula to a names field, it
2058 will be stored as @samp{$name=...}.
2059 @item _
2060 Similar to @samp{^}, but defines names for the fields in the row
2061 @emph{below}.
2062 @item $
2063 Fields in this row can define @emph{parameters} for formulas.  For
2064 example, if a field in a @samp{$} row contains @samp{max=50}, then
2065 formulas in this table can refer to the value 50 using @samp{$max}.
2066 Parameters work exactly like constants, only that they can be defined on
2067 a per-table basis.
2068 @item #
2069 Fields in this row are automatically recalculated when pressing
2070 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
2071 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
2072 lines will be left alone by this command.
2073 @item *
2074 Selects this line for global recalculation with @kbd{C-u C-c *}, but
2075 not for automatic recalculation.  Use this when automatic
2076 recalculation slows down editing too much.
2077 @item
2078 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
2079 All lines that should be recalculated should be marked with @samp{#}
2080 or @samp{*}.
2081 @item /
2082 Do not export this line.  Useful for lines that contain the narrowing
2083 @samp{<N>} markers.
2084 @end table
2086 Finally, just to whet your appetite on what can be done with the
2087 fantastic @file{calc} package, here is a table that computes the Taylor
2088 series of degree @code{n} at location @code{x} for a couple of functions
2089 (homework: try that with Excel :-)
2091 @example
2092 @group
2093 |---+-------------+---+-----+--------------------------------------|
2094 |   | Func        | n | x   | Result                               |
2095 |---+-------------+---+-----+--------------------------------------|
2096 | # | exp(x)      | 1 | x   | 1 + x                                |
2097 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
2098 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
2099 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
2100 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
2101 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
2102 |---+-------------+---+-----+--------------------------------------|
2103 #+TBLFM: $5=taylor($2,$4,$3);n3
2104 @end group
2105 @end example
2107 @node Hyperlinks, TODO items, Tables, Top
2108 @chapter Hyperlinks
2109 @cindex hyperlinks
2111 Just like HTML, Org-mode provides links inside a file, and external
2112 links to other files, Usenet articles, emails, and much more.
2114 @menu
2115 * Link format::                 How links in Org-mode are formatted
2116 * Internal links::              Links to other places in the current file
2117 * External links::              URL-like links to the world
2118 * Handling links::              Creating, inserting and following
2119 * Using links outside Org-mode::  Linking from my C source code?
2120 * Link abbreviations::          Shortcuts for writing complex links
2121 * Search options::              Linking to a specific location
2122 * Custom searches::             When the default search is not enough
2123 @end menu
2125 @node Link format, Internal links, Hyperlinks, Hyperlinks
2126 @section Link format
2127 @cindex link format
2128 @cindex format, of links
2130 Org-mode will recognize plain URL-like links and activate them as
2131 clickable links.  The general link format, however, looks like this:
2133 @example
2134 [[link][description]]       @r{or alternatively}           [[link]]  
2135 @end example
2137 Once a link in the buffer is complete (all brackets present), Org-mode
2138 will change the display so that @samp{description} is displayed instead
2139 of @samp{[[link][description]]} and @samp{link} is displayed instead of
2140 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
2141 which by default is an underlined face.  You can directly edit the
2142 visible part of a link.  Note that this can be either the @samp{link}
2143 part (if there is no description) or the @samp{description} part.  To
2144 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
2145 cursor on the link.
2147 If you place the cursor at the beginning or just behind the end of the
2148 displayed text and press @key{BACKSPACE}, you will remove the
2149 (invisible) bracket at that location.  This makes the link incomplete
2150 and the internals are again displayed as plain text.  Inserting the
2151 missing bracket hides the link internals again.  To show the
2152 internal structure of all links, use the menu entry
2153 @code{Org->Hyperlinks->Literal links}.
2155 @node Internal links, External links, Link format, Hyperlinks
2156 @section Internal links
2157 @cindex internal links
2158 @cindex links, internal
2159 @cindex targets, for links
2161 If the link does not look like a URL, it is considered to be internal in
2162 the current file.  Links such as @samp{[[My Target]]} or @samp{[[My
2163 Target][Find my target]]} lead to a text search in the current file.
2164 The link can be followed with @kbd{C-c C-o} when the cursor is on the
2165 link, or with a mouse click (@pxref{Handling links}).  The preferred
2166 match for such a link is a dedicated target: the same string in double
2167 angular brackets.  Targets may be located anywhere; sometimes it is
2168 convenient to put them into a comment line. For example
2170 @example
2171 # <<My Target>>
2172 @end example
2174 @noindent In HTML export (@pxref{HTML export}), such targets will become
2175 named anchors for direct access through @samp{http} links@footnote{Note
2176 that text before the first headline is usually not exported, so the
2177 first such target should be after the first headline.}.
2179 If no dedicated target exists, Org-mode will search for the words in the
2180 link.  In the above example the search would be for @samp{my target}.
2181 Links starting with a star like @samp{*My Target} restrict the search to
2182 headlines.  When searching, Org-mode will first try an exact match, but
2183 then move on to more and more lenient searches.  For example, the link
2184 @samp{[[*My Targets]]} will find any of the following:
2186 @example
2187 ** My targets
2188 ** TODO my targets are bright
2189 ** my 20 targets are
2190 @end example
2192 To insert a link targeting a headline, in-buffer completion can be used.
2193 Just type a star followed by a few optional letters into the buffer and
2194 press @kbd{M-@key{TAB}}.  All headlines in the current buffer will be
2195 offered as completions.  @xref{Handling links}, for more commands
2196 creating links.
2198 Following a link pushes a mark onto Org-mode's own mark ring.  You can
2199 return to the previous position with @kbd{C-c &}.  Using this command
2200 several times in direct succession goes back to positions recorded
2201 earlier.
2203 @menu
2204 * Radio targets::               Make targets trigger links in plain text.
2205 @end menu
2207 @node Radio targets,  , Internal links, Internal links
2208 @subsection Radio targets
2209 @cindex radio targets
2210 @cindex targets, radio
2211 @cindex links, radio targets
2213 Org-mode can automatically turn any occurrences of certain target names
2214 in normal text into a link.  So without explicitly creating a link, the
2215 text connects to the target radioing its position.  Radio targets are
2216 enclosed by triple angular brackets.  For example, a target @samp{<<<My
2217 Target>>>} causes each occurrence of @samp{my target} in normal text to
2218 become activated as a link.  The Org-mode file is scanned automatically
2219 for radio targets only when the file is first loaded into Emacs.  To
2220 update the target list during editing, press @kbd{C-c C-c} with the
2221 cursor on or at a target.
2223 @node External links, Handling links, Internal links, Hyperlinks
2224 @section External links
2225 @cindex links, external
2226 @cindex external links
2227 @cindex links, external
2228 @cindex GNUS links
2229 @cindex BBDB links
2230 @cindex URL links
2231 @cindex file links
2232 @cindex VM links
2233 @cindex RMAIL links
2234 @cindex WANDERLUST links
2235 @cindex MH-E links
2236 @cindex USENET links
2237 @cindex SHELL links
2238 @cindex Info links
2239 @cindex elisp links
2241 Org-mode supports links to files, websites, Usenet and email messages,
2242 and BBDB database entries.  External links are URL-like locators.  They
2243 start with a short identifying string followed by a colon.  There can be
2244 no space after the colon.  The following list shows examples for each
2245 link type.
2247 @example
2248 http://www.astro.uva.nl/~dominik          @r{on the web}
2249 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
2250 file:papers/last.pdf                      @r{file, relative path}
2251 news:comp.emacs                           @r{Usenet link}
2252 mailto:adent@@galaxy.net                   @r{Mail link}
2253 vm:folder                                 @r{VM folder link}
2254 vm:folder#id                              @r{VM message link}
2255 vm://myself@@some.where.org/folder#id      @r{VM on remote machine}
2256 wl:folder                                 @r{WANDERLUST folder link}
2257 wl:folder#id                              @r{WANDERLUST message link}
2258 mhe:folder                                @r{MH-E folder link}
2259 mhe:folder#id                             @r{MH-E message link}
2260 rmail:folder                              @r{RMAIL folder link}
2261 rmail:folder#id                           @r{RMAIL message link}
2262 gnus:group                                @r{GNUS group link}
2263 gnus:group#id                             @r{GNUS article link}
2264 bbdb:Richard Stallman                     @r{BBDB link}
2265 shell:ls *.org                            @r{A shell command}
2266 elisp:(find-file-other-frame "Elisp.org") @r{An elisp form to evaluate}
2267 @end example
2269 A link should be enclosed in double brackets and may contain a
2270 descriptive text to be displayed instead of the url (@pxref{Link
2271 format}), for example:
2273 @example
2274 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
2275 @end example
2277 @noindent
2278 If the description is a file name or URL that points to an image, HTML
2279 export (@pxref{HTML export}) will inline the image as a clickable
2280 button.  If there is no description at all and the link points to an
2281 image,
2282 that image will be inlined into the exported HTML file.
2284 @cindex angular brackets, around links
2285 @cindex plain text external links
2286 Org-mode also finds external links in the normal text and activates them
2287 as links.  If spaces must be part of the link (for example in
2288 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
2289 about the end of the link, enclose them in angular brackets.
2291 @node Handling links, Using links outside Org-mode, External links, Hyperlinks
2292 @section Handling links
2293 @cindex links, handling
2295 Org-mode provides methods to create a link in the correct syntax, to
2296 insert it into an org-mode file, and to follow the link.
2298 @table @kbd
2299 @kindex C-c l
2300 @cindex storing links
2301 @item C-c l
2302 Store a link to the current location.  This is a @emph{global} command
2303 which can be used in any buffer to create a link.  The link will be
2304 stored for later insertion into an Org-mode buffer (see below).  For
2305 Org-mode files, if there is a @samp{<<target>>} at the cursor, the link
2306 points to the target.  Otherwise it points to the current headline.  For
2307 VM, RMAIL, WANDERLUST, MH-E, GNUS and BBDB buffers, the link will
2308 indicate the current article/entry.  For W3 and W3M buffers, the link
2309 goes to the current URL.  For any other files, the link will point to
2310 the file, with a search string (@pxref{Search options}) pointing to the
2311 contents of the current line.  If there is an active region, the
2312 selected words will form the basis of the search string.  If the
2313 automatically created link is not working correctly or accurately
2314 enough, you can write custom functions to select the search string and
2315 to do the search for particular file types - see @ref{Custom searches}.
2316 The key binding @kbd{C-c l} is only a suggestion - see @ref{Installation}.
2318 @kindex C-c C-l
2319 @cindex link completion
2320 @cindex completion, of links
2321 @cindex inserting links
2322 @item C-c C-l
2323 Insert a link.  This prompts for a link to be inserted into the buffer.
2324 You can just type a link, using text for an internal link, or one of the
2325 link type prefixes mentioned in the examples above.  All links stored
2326 during the current session are part of the history for this prompt, so
2327 you can access them with @key{up} and @key{down} (or @kbd{M-p/n}).
2328 Completion, on the other hand, will help you to insert valid link
2329 prefixes like @samp{http:} or @samp{ftp:}, including the prefixes
2330 defined through link abbreviations (@pxref{Link abbreviations}).  The
2331 link will be inserted into the buffer@footnote{After insertion of a
2332 stored link, the link will be removed from the list of stored links.  To
2333 keep it in the list later use, use a triple @kbd{C-u} prefix to @kbd{C-c
2334 C-l}, or configure the option
2335 @code{org-keep-stored-link-after-insertion}.}, along with a descriptive
2336 text.  If some text was selected when this command is called, the
2337 selected text becomes the default description.@* Note that you don't
2338 have to use this command to insert a link.  Links in Org-mode are plain
2339 text, and you can type or paste them straight into the buffer.  By using
2340 this command, the links are automatically enclosed in double brackets,
2341 and you will be asked for the optional descriptive text.
2343 @c  If the link is a @samp{file:} link and
2344 @c the linked file is located in the same directory as the current file or
2345 @c a subdirectory of it, the path of the file will be inserted relative to
2346 @c the current directory.
2348 @kindex C-u C-c C-l
2349 @cindex file name completion
2350 @cindex completion, of file names
2351 @item C-u C-c C-l
2352 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
2353 a file will be inserted and you may use file name completion to select
2354 the name of the file.  The path to the file is inserted relative to the
2355 directory of the current org file, if the linked file is in the current
2356 directory or in a subdirectory of it, or if the path is written relative
2357 to the current directory using @samp{../}.  Otherwise an absolute path
2358 is used, if possible with @samp{~/} for your home directory.  You can
2359 force an absolute path with two @kbd{C-u} prefixes.
2361 @item C-c C-l @r{(with cursor on existing link)}
2362 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
2363 link and description parts of the link.
2365 @cindex following links
2366 @kindex C-c C-o
2367 @item C-c C-o
2368 Open link at point.  This will launch a web browser for URLs (using
2369 @command{browse-url-at-point}), run vm/mh-e/wanderlust/rmail/gnus/bbdb
2370 for the corresponding links, and execute the command in a shell link.
2371 When the cursor is on an internal link, this commands runs the
2372 corresponding search.  When the cursor is on a TAG list in a headline,
2373 it creates the corresponding TAGS view.  If the cursor is on a time
2374 stamp, it compiles the agenda for that date.  Furthermore, it will visit
2375 text and remote files in @samp{file:} links with Emacs and select a
2376 suitable application for local non-text files.  Classification of files
2377 is based on file extension only.  See option @code{org-file-apps}.  If
2378 you want to override the default application and visit the file with
2379 Emacs, use a @kbd{C-u} prefix.
2381 @kindex mouse-2
2382 @kindex mouse-1
2383 @item mouse-2
2384 @itemx mouse-1
2385 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
2386 would.  Under Emacs 22, also @kbd{mouse-1} will follow a link.
2388 @kindex mouse-3
2389 @item mouse-3
2390 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
2391 internal links to be displayed in another window@footnote{See the
2392 variable @code{org-display-internal-link-with-indirect-buffer}}.
2394 @cindex mark ring
2395 @kindex C-c %
2396 @item C-c %
2397 Push the current position onto the mark ring, to be able to return
2398 easily. Commands following an internal link do this automatically.
2400 @cindex links, returning to
2401 @kindex C-c &
2402 @item C-c &
2403 Jump back to a recorded position.  A position is recorded by the
2404 commands following internal links, and by @kbd{C-c %}.  Using this
2405 command several times in direct succession moves through a ring of
2406 previously recorded positions.
2408 @kindex C-c C-x C-n
2409 @kindex C-c C-x C-p
2410 @cindex links, finding next/previous
2411 @item C-c C-x C-n
2412 @itemx C-c C-x C-p
2413 Move forward/backward to the next link in the buffer.  At the limit of
2414 the buffer, the search fails once, and then wraps around.  The key
2415 bindings for this are really too long, you might want to bind this also
2416 to @kbd{C-n} and @kbd{C-p}
2417 @lisp
2418 (add-hook 'org-load-hook
2419   (lambda ()
2420     (define-key 'org-mode-map "\C-n" 'org-next-link)
2421     (define-key 'org-mode-map "\C-p" 'org-previous-link)))
2422 @end lisp
2423 @end table
2425 @node Using links outside Org-mode, Link abbreviations, Handling links, Hyperlinks
2426 @section Using links outside Org-mode
2428 You can insert and follow links that have Org-mode syntax not only in
2429 Org-mode, but in any Emacs buffer.  For this, you should create two
2430 global commands, like this (please select suitable global keys
2431 yourself):
2433 @lisp
2434 (global-set-key "\C-c L" 'org-insert-link-global)
2435 (global-set-key "\C-c o" 'org-open-at-point-global)
2436 @end lisp
2438 @node Link abbreviations, Search options, Using links outside Org-mode, Hyperlinks
2439 @section Link abbreviations
2440 @cindex link abbreviations
2441 @cindex abbreviation, links
2443 Long URLs can be cumbersome to type, and often many similar links are
2444 needed in a document.  For this you can use link abbreviations.  An
2445 abbreviated link looks like this
2447 @example
2448 [[linkword:tag][description]]
2449 @end example
2451 @noindent
2452 where the tag is optional.  Such abbreviations are resolved according to
2453 the information in the variable @code{org-link-abbrev-alist} that
2454 relates the linkwords to replacement text.  Here is an example:
2456 @lisp
2457 @group
2458 (setq org-link-abbrev-alist
2459   '(("bugzilla" . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
2460     ("google"   . "http://www.google.com/search?q=")
2461     ("ads"      . "http://adsabs.harvard.edu/cgi-bin/
2462                    nph-abs_connect?author=%s&db_key=AST")))
2463 @end group
2464 @end lisp
2466 If the replacement text contains the string @samp{%s}, it will be
2467 replaced with the tag.  Otherwise the tag will be appended to the string
2468 in order to create the link.  You may also specify a function that will
2469 be called with the tag as the only argument to create the link.
2471 With the above setting, you could link to a specific bug with
2472 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
2473 @code{[[google:OrgMode]]} and find out what the Org-mode author is
2474 doing besides Emacs hacking with @code{[[ads:Dominik,C]]}.
2476 If you need special abbreviations just for a single Org-mode buffer, you
2477 can define them in the file with
2479 @example
2480 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
2481 #+LINK: google    http://www.google.com/search?q=%s
2482 @end example
2484 @noindent
2485 In-buffer completion @pxref{Completion} can be used after @samp{[} to
2486 complete link abbreviations.
2488 @node Search options, Custom searches, Link abbreviations, Hyperlinks
2489 @section Search options in file links
2490 @cindex search option in file links
2491 @cindex file links, searching
2493 File links can contain additional information to make Emacs jump to a
2494 particular location in the file when following a link.  This can be a
2495 line number or a search option after a double@footnote{For backward
2496 compatibility, line numbers can also follow a single colon.} colon. For
2497 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
2498 links}) to a file, it encodes the words in the current line as a search
2499 string that can be used to find this line back later when following the
2500 link with @kbd{C-c C-o}. 
2502 Here is the syntax of the different ways to attach a search to a file
2503 link, together with an explanation:
2505 @example
2506 [[file:~/code/main.c::255]]
2507 [[file:~/xx.org::My Target]]
2508 [[file:~/xx.org::*My Target]]
2509 [[file:~/xx.org::/regexp/]]
2510 @end example
2512 @table @code
2513 @item 255
2514 Jump to line 255.
2515 @item My Target
2516 Search for a link target @samp{<<My Target>>}, or do a text search for
2517 @samp{my target}, similar to the search in internal links, see
2518 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
2519 link will become an HTML reference to the corresponding named anchor in
2520 the linked file.
2521 @item *My Target
2522 In an Org-mode file, restrict search to headlines.
2523 @item /regexp/
2524 Do a regular expression search for @code{regexp}.  This uses the Emacs
2525 command @code{occur} to list all matches in a separate window.  If the
2526 target file is in Org-mode, @code{org-occur} is used to create a
2527 sparse tree with the matches.
2528 @c If the target file is a directory,
2529 @c @code{grep} will be used to search all files in the directory.
2530 @end table
2532 As a degenerate case, a file link with an empty file name can be used
2533 to search the current file.  For example, @code{[[file:::find me]]} does
2534 a search for @samp{find me} in the current file, just as
2535 @samp{[[find me]]} would.
2537 @node Custom searches,  , Search options, Hyperlinks
2538 @section Custom Searches
2539 @cindex custom search strings
2540 @cindex search strings, custom
2542 The default mechanism for creating search strings and for doing the
2543 actual search related to a file link may not work correctly in all
2544 cases.  For example, BibTeX database files have many entries like
2545 @samp{year="1993"} which would not result in good search strings,
2546 because the only unique identification for a BibTeX entry is the
2547 citation key.
2549 If you come across such a problem, you can write custom functions to set
2550 the right search string for a particular file type, and to do the search
2551 for the string in the file.  Using @code{add-hook}, these functions need
2552 to be added to the hook variables
2553 @code{org-create-file-search-functions} and
2554 @code{org-execute-file-search-functions}.  See the docstring for these
2555 variables for more information.  Org-mode actually uses this mechanism
2556 for Bib@TeX{} database files, and you can use the corresponding code as
2557 an implementation example.  Search for @samp{BibTeX links} in the source
2558 file.
2562 @node TODO items, Tags, Hyperlinks, Top
2563 @chapter TODO items
2564 @cindex TODO items
2566 Org-mode does not maintain TODO lists as a separate document.  TODO
2567 items are an integral part of the notes file, because TODO items
2568 usually come up while taking notes!  With Org-mode, you simply mark
2569 any entry in a tree as being a TODO item.  In this way, the
2570 information is not duplicated, and the entire context from which the
2571 item emerged is always present when you check.
2573 Of course, this technique causes TODO items to be scattered throughout
2574 your file.  Org-mode provides methods to give you an overview over all
2575 things you have to do.
2577 @menu
2578 * TODO basics::                 Marking and displaying TODO entries
2579 * TODO extensions::             Workflow and assignments
2580 * Progress logging::            Dates and notes for progress
2581 * Priorities::                  Some things are more important than others
2582 * Breaking down tasks::         Splitting a task into manageable pieces
2583 * Checkboxes::                  Tick-off lists
2584 @end menu
2586 @node TODO basics, TODO extensions, TODO items, TODO items
2587 @section Basic TODO functionality
2589 Any headline can become a TODO item by starting it with the word TODO,
2590 for example:
2592 @example
2593 *** TODO Write letter to Sam Fortune
2594 @end example
2596 @noindent
2597 The most important commands to work with TODO entries are:
2599 @table @kbd
2600 @kindex C-c C-t
2601 @cindex cycling, of TODO states
2602 @item C-c C-t
2603 Rotate the TODO state of the current item among
2605 @example
2606 ,-> (unmarked) -> TODO -> DONE --.
2607 '--------------------------------'
2608 @end example
2610 The same rotation can also be done ``remotely'' from the timeline and
2611 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
2613 @kindex C-u C-c C-t
2614 @item C-u C-c C-t
2615 Select a specific keyword using completion of (if it has been set up)
2616 the fast selection interface.
2618 @kindex S-@key{right}
2619 @kindex S-@key{left}
2620 @item S-@key{right}
2621 @itemx S-@key{left}
2622 Select the following/preceding TODO state, similar to cycling.  Mostly
2623 useful if more than two TODO states are possible (@pxref{TODO
2624 extensions}).
2625 @kindex C-c C-c
2626 @item C-c C-c
2627 Use the fast tag interface to quickly and directly select a specific
2628 TODO state.  For this you need to assign keys to TODO state, like this:
2629 @example
2630 #+SEQ_TODO: TODO(t) STARTED(s) WAITING(w) | DONE(d)
2631 @end example
2632 @noindent See @ref{Per file keywords} and @ref{Setting tags} for more
2633 information.
2634 @kindex C-c C-v
2635 @kindex C-c / t
2636 @cindex sparse tree, for TODO
2637 @item C-c C-v
2638 @itemx C-c / t
2639 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds
2640 the entire buffer, but shows all TODO items and the headings hierarchy
2641 above them.  With prefix arg, search for a specific TODO.  You will be
2642 prompted for the keyword, and you can also give a list of keywords like
2643 @code{kwd1|kwd2|...}.  With numerical prefix N, show the tree for the
2644 Nth keyword in the variable @code{org-todo-keywords}.  With two prefix
2645 args, find all TODO and DONE entries.
2646 @kindex C-c a t
2647 @item C-c a t
2648 Show the global TODO list.  This collects the TODO items from all
2649 agenda files (@pxref{Agenda views}) into a single buffer.  The buffer is in
2650 @code{agenda-mode}, so there are commands to examine and manipulate
2651 the TODO entries directly from that buffer (@pxref{Agenda commands}).
2652 @xref{Global TODO list}, for more information.
2653 @kindex S-M-@key{RET}
2654 @item S-M-@key{RET}
2655 Insert a new TODO entry below the current one.
2656 @end table
2658 @node TODO extensions, Progress logging, TODO basics, TODO items
2659 @section Extended use of TODO keywords
2660 @cindex extended TODO keywords
2662 The default implementation of TODO entries is just two states: TODO and
2663 DONE.  You can use the TODO feature for more complicated things by
2664 configuring the variable @code{org-todo-keywords}.  With special setup,
2665 the TODO keyword system can work differently in different files.
2667 Note that @i{tags} are another way to classify headlines in general and
2668 TODO items in particular (@pxref{Tags}).
2670 @menu
2671 * Workflow states::             From TODO to DONE in steps
2672 * TODO types::                  I do this, Fred the rest
2673 * Multiple sets in one file::   Mixing it all, and still finding your way
2674 * Fast access to TODO states::  Single letter selection of a state
2675 * Per file keywords::           Different files, different requirements
2676 * Faces for TODO keywords::     Highlighting states
2677 @end menu
2679 @node Workflow states, TODO types, TODO extensions, TODO extensions
2680 @subsection TODO keywords as workflow states
2681 @cindex TODO workflow
2682 @cindex workflow states as TODO keywords
2684 You can use TODO keywords to indicate different @emph{sequential} states
2685 in the process of working on an item, for example@footnote{Changing
2686 this variable only becomes effective after restarting Org-mode in a
2687 buffer.}:
2689 @lisp
2690 (setq org-todo-keywords
2691   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
2692 @end lisp
2694 The vertical bar separates the TODO keywords (states that @emph{need
2695 action}) from the DONE states (which need @emph{no further action}.  If
2696 you don't provide the separator bar, the last state is used as the DONE
2697 state.
2698 @cindex completion, of TODO keywords
2699 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
2700 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED.  You may
2701 also use a prefix argument to quickly select a specific state.  For
2702 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY.
2703 If you define many keywords, you can use in-buffer completion (see
2704 @ref{Completion}) to insert these words into the buffer.  Changing a
2705 todo state can be logged with a timestamp, see @ref{Tracking TODO state
2706 changes} for more information.
2708 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
2709 @subsection TODO keywords as types
2710 @cindex TODO types
2711 @cindex names as TODO keywords
2712 @cindex types as TODO keywords
2714 The second possibility is to use TODO keywords to indicate different
2715 @emph{types} of action items.  For example, you might want to indicate
2716 that items are for ``work'' or ``home''.  Or, when you work with several
2717 people on a single project, you might want to assign action items
2718 directly to persons, by using their names as TODO keywords.  This would
2719 be set up like this:
2721 @lisp
2722 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
2723 @end lisp
2725 In this case, different keywords do not indicate a sequence, but rather
2726 different types.  So the normal work flow would be to assign a task to a
2727 person, and later to mark it DONE.  Org-mode supports this style by
2728 adapting the workings of the command @kbd{C-c C-t}@footnote{This is also
2729 true for the @kbd{t} command in the timeline and agenda buffers.}.  When
2730 used several times in succession, it will still cycle through all names,
2731 in order to first select the right type for a task.  But when you return
2732 to the item after some time and execute @kbd{C-c C-t} again, it will
2733 switch from any name directly to DONE.  Use prefix arguments or
2734 completion to quickly select a specific name.  You can also review the
2735 items of a specific TODO type in a sparse tree by using a numeric prefix
2736 to @kbd{C-c C-v}.  For example, to see all things Lucy has to do, you
2737 would use @kbd{C-3 C-c C-v}.  To collect Lucy's items from all agenda
2738 files into a single buffer, you would use the prefix arg as well when
2739 creating the global todo list: @kbd{C-3 C-c t}.
2741 @node Multiple sets in one file, Fast access to TODO states, TODO types, TODO extensions
2742 @subsection Multiple keyword sets in one file
2743 @cindex todo keyword sets
2745 Sometimes you may want to use different sets of TODO keywords in
2746 parallel.  For example, you may want to have the basic
2747 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
2748 separate state indicating that an item has been canceled (so it is not
2749 DONE, but also does not require action).  Your setup would then look
2750 like this:
2752 @lisp
2753 (setq org-todo-keywords
2754       '((sequence "TODO" "|" "DONE")
2755         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
2756         (sequence "|" "CANCELED")))
2757 @end lisp
2759 The keywords should all be different, this helps Org-mode to keep track
2760 of which subsequence should be used for a given entry.  In this setup,
2761 @kbd{C-c C-t} only operates within a subsequence, so it switches from
2762 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
2763 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
2764 select the correct sequence.  Besides the obvious ways like typing a
2765 keyword or using completion, you may also apply the following commands:
2767 @table @kbd
2768 @kindex C-S-@key{right}
2769 @kindex C-S-@key{left}
2770 @item C-S-@key{right}
2771 @itemx C-S-@key{left}
2772 These keys jump from one TODO subset to the next.  In the above example,
2773 @kbd{C-S-@key{right}} would jump from @code{TODO} or @code{DONE} to
2774 @code{REPORT}, and any of the words in the second row to @code{CANCELED}.
2775 @kindex S-@key{right}
2776 @kindex S-@key{left}
2777 @item S-@key{right}
2778 @itemx S-@key{left}
2779 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through
2780 @emph{all} keywords from all sets, so for example @kbd{S-@key{<right>}}
2781 would switch from @code{DONE} to @code{REPORT} in the example above.
2782 @end table
2784 @node Fast access to TODO states, Per file keywords, Multiple sets in one file, TODO extensions
2785 @subsection Fast access to TODO states
2787 If you would like to quickly change an entry to an arbitrary TODO state
2788 instead of cycling through the states, you can set up keys for
2789 single-letter access to the states.  This is done by adding the section
2790 key after each keyword, in parenthesis.  For example:
2792 @lisp
2793 (setq org-todo-keywords
2794       '((sequence "TODO(t)" "|" "DONE(d)")
2795         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
2796         (sequence "|" "CANCELED(c)")))
2797 @end lisp
2799 If you then press @code{C-u C-c C-t} followed by the selection key, the
2800 entry will be switched to this state.  @key{SPC} can be used to remove
2801 any TODO keyword from an entry.  Should you like this way of selecting
2802 TODO states a lot, you might want to set the variable
2803 @code{org-use-fast-todo-selection} to @code{t} and make this behavior
2804 the default.  Check also the variable
2805 @code{org-fast-tag-selection-include-todo}, it allows to change the TODO
2806 state through the tags interface (@pxref{Setting tags}).
2808 @node Per file keywords, Faces for TODO keywords, Fast access to TODO states, TODO extensions
2809 @subsection Setting up keywords for individual files
2810 @cindex keyword options
2811 @cindex per file keywords
2813 It can be very useful to use different aspects of the TODO mechanism in
2814 different files.  For file-local settings, you need to add special lines
2815 to the file which set the keywords and interpretation for that file
2816 only.  For example, to set one of the two examples discussed above, you
2817 need one of the following lines, starting in column zero anywhere in the
2818 file:
2820 @example
2821 #+SEQ_TODO: TODO FEEDBACK VERIFY | DONE CANCELED
2822 @end example
2824 @example
2825 #+TYP_TODO: Fred Sara Lucy Mike | DONE
2826 @end example
2828 A setup for using several sets in parallel would be:
2830 @example
2831 #+SEQ_TODO: TODO | DONE
2832 #+SEQ_TODO: REPORT BUG KNOWNCAUSE | FIXED
2833 #+SEQ_TODO: | CANCELED
2834 @end example
2836 @cindex completion, of option keywords
2837 @kindex M-@key{TAB}
2838 @noindent To make sure you are using the correct keyword, type
2839 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
2841 @cindex DONE, final TODO keyword
2842 Remember that the keywords after the vertical bar (or the last keyword
2843 if no bar is there) must always mean that the item is DONE (although you
2844 may use a different word).  After changing one of these lines, use
2845 @kbd{C-c C-c} with the cursor still in the line to make the changes
2846 known to Org-mode@footnote{Org-mode parses these lines only when
2847 Org-mode is activated after visiting a file.  @kbd{C-c C-c} with the
2848 cursor in a line starting with @samp{#+} is simply restarting Org-mode
2849 for the current buffer.}.
2851 @node Faces for TODO keywords,  , Per file keywords, TODO extensions
2852 @subsection Faces for TODO keywords
2853 @cindex faces, for TODO keywords
2855 Org-mode highlights TODO keywords with special faces: @code{org-todo}
2856 for keywords indicating that an item still has to be acted upon, and
2857 @code{org-done} for keywords indicating that an item is finished.  If
2858 you are using more than 2 different states, you might want to use
2859 special faces for some of them.  This can be done using the variable
2860 @code{org-todo-keyword-faces}.  For example:
2862 @lisp
2863 (setq org-todo-keyword-faces
2864       '(("TODO"      . org-warning)
2865         ("DEFERRED"  . shadow)
2866         ("CANCELED"  . (:foreground "blue" :weight bold))))
2867 @end lisp
2869 @page
2870 @node Progress logging, Priorities, TODO extensions, TODO items
2871 @section Progress Logging
2872 @cindex progress logging
2873 @cindex logging, of progress
2875 Org-mode can automatically record a time stamp and even a note when you
2876 mark a TODO item as DONE, or even each time you change the state of
2877 a TODO item.
2879 @menu
2880 * Closing items::               When was this entry marked DONE?
2881 * Tracking TODO state changes::  When did the status change?
2882 @end menu
2884 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
2885 @subsection Closing items
2887 If you want to keep track of @emph{when} a certain TODO item was
2888 finished, turn on logging with@footnote{The corresponding in-buffer
2889 setting is: @code{#+STARTUP: logdone}.  You may also set this for the
2890 scope of a subtree by adding a @code{LOGGING} property with one or more
2891 of the logging keywords in the value.}
2893 @lisp
2894 (setq org-log-done t)
2895 @end lisp
2897 @noindent
2898 Then each time you turn a TODO entry into DONE using either @kbd{C-c
2899 C-t} in the Org-mode buffer or @kbd{t} in the agenda buffer, a line
2900 @samp{CLOSED: [timestamp]} will be inserted just after the headline.  If
2901 you turn the entry back into a TODO item through further state cycling,
2902 that line will be removed again.  In the timeline (@pxref{Timeline}) and
2903 in the agenda (@pxref{Weekly/Daily agenda}), you can then use the
2904 @kbd{l} key to display the TODO items closed on each day, giving you an
2905 overview of what has been done on a day.  If you want to record a note
2906 along with the timestamp, use@footnote{The corresponding in-buffer
2907 setting is: @code{#+STARTUP: lognotedone}}
2909 @lisp
2910 (setq org-log-done '(done))
2911 @end lisp
2913 @node Tracking TODO state changes,  , Closing items, Progress logging
2914 @subsection Tracking TODO state changes
2916 When TODO keywords are used as workflow states (@pxref{Workflow
2917 states}), you might want to keep track of when a state change occurred
2918 and record a note about this change.  With the setting@footnote{The
2919 corresponding in-buffer setting is: @code{#+STARTUP: lognotestate}.}
2921 @lisp
2922 (setq org-log-done '(state))
2923 @end lisp
2925 @noindent
2926 each state change will prompt you for a note that will be attached to
2927 the current headline.  If you press @kbd{C-c C-c} without typing
2928 anything into the note buffer, only the time of the state change will be
2929 noted.  Very likely you do not want this verbose tracking all the time,
2930 so it is probably better to configure this behavior with in-buffer
2931 options.  For example, if you are tracking purchases, put these into a
2932 separate file that contains:
2934 @example
2935 #+SEQ_TODO: TODO(t) ORDERED(o) INVOICE(i) PAYED(p) | RECEIVED(r)
2936 #+STARTUP: lognotestate
2937 @end example
2939 If you only need to take a note for some of the states, mark those
2940 states with an additional @samp{@@}, like this:
2942 @example
2943 #+SEQ_TODO: TODO(t) ORDERED(o@@) INVOICE(i@@) PAYED(p) | RECEIVED(r)
2944 #+STARTUP: lognotestate
2945 @end example
2947 @node Priorities, Breaking down tasks, Progress logging, TODO items
2948 @section Priorities
2949 @cindex priorities
2951 If you use Org-mode extensively to organize your work, you may end up
2952 with a number of TODO entries so large that you'd like to prioritize
2953 them.  This can be done by placing a @emph{priority cookie} into the
2954 headline, like this
2956 @example
2957 *** TODO [#A] Write letter to Sam Fortune
2958 @end example
2960 @noindent
2961 With its standard setup, Org-mode supports priorities @samp{A},
2962 @samp{B}, and @samp{C}.  @samp{A} is the highest priority.  An entry
2963 without a cookie is treated as priority @samp{B}.  Priorities make a
2964 difference only in the agenda (@pxref{Weekly/Daily agenda}).
2966 @table @kbd
2967 @kindex @kbd{C-c ,}
2968 @item @kbd{C-c ,}
2969 Set the priority of the current headline.  The command prompts for a
2970 priority character @samp{A}, @samp{B} or @samp{C}.  When you press
2971 @key{SPC} instead, the priority cookie is removed from the headline.
2972 The priorities can also be changed ``remotely'' from the timeline and
2973 agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
2975 @kindex S-@key{up}
2976 @kindex S-@key{down}
2977 @item S-@key{up}
2978 @itemx S-@key{down}
2979 Increase/decrease priority of current headline@footnote{See also the
2980 option @code{org-priority-start-cycle-with-default'}.}.  Note that these
2981 keys are also used to modify time stamps (@pxref{Creating timestamps}).
2982 Furthermore, these keys are also used by CUA-mode (@pxref{Conflicts}).
2983 @end table
2985 You can change the range of allowed priorities by setting the variables
2986 @code{org-highest-priority}, @code{org-lowest-priority}, and
2987 @code{org-default-priority}.  For an individual buffer, you may set
2988 these values (highest, lowest, default) like this (please make sure that
2989 the highest priority is earlier in the alphabet than the lowest
2990 priority):
2992 @example
2993 #+PRIORITIES: A C B
2994 @end example
2996 @node Breaking down tasks, Checkboxes, Priorities, TODO items
2997 @section Breaking tasks down into subtasks
2998 @cindex tasks, breaking down
3000 It is often advisable to break down large tasks into smaller, manageable
3001 subtasks.  You can do this by creating an outline tree below a TODO
3002 item, with detailed subtasks on the tree@footnote{To keep subtasks out
3003 of the global TODO list, see the
3004 @code{org-agenda-todo-list-sublevels}.}.  Another possibility is the use
3005 of checkboxes to identify (a hierarchy of) a large number of subtasks
3006 (@pxref{Checkboxes}).
3009 @node Checkboxes,  , Breaking down tasks, TODO items
3010 @section Checkboxes
3011 @cindex checkboxes
3013 Every item in a plain list (@pxref{Plain lists}) can be made a checkbox
3014 by starting it with the string @samp{[ ]}.  This feature is similar to
3015 TODO items (@pxref{TODO items}), but more lightweight.  Checkboxes are
3016 not included into the global TODO list, so they are often great to split
3017 a task into a number of simple steps.  Or you can use them in a shopping
3018 list.  To toggle a checkbox, use @kbd{C-c C-c}, or try Piotr Zielinski's
3019 @file{org-mouse.el}.  Here is an example of a checkbox list.
3021 @example
3022 * TODO Organize party [3/6]
3023   - call people [1/3]
3024     - [ ] Peter
3025     - [X] Sarah
3026     - [ ] Sam
3027   - [X] order food
3028   - [ ] think about what music to play
3029   - [X] talk to the neighbors
3030 @end example
3032 @cindex statistics, for checkboxes
3033 @cindex checkbox statistics
3034 The @samp{[3/6]} and @samp{[1/3]} in the first and second line are
3035 cookies indicating how many checkboxes are present in this entry, and
3036 how many of them have been checked off.  This can give you an idea on
3037 how many checkboxes remain, even without opening a folded entry.  The
3038 cookies can be placed into a headline or into (the first line of) a
3039 plain list item. Each cookie covers all checkboxes structurally below
3040 that headline/item.  You have to insert the cookie yourself by typing
3041 either @samp{[/]} or @samp{[%]}.  In the first case you get an @samp{n
3042 out of m} result, in the second case you get information about the
3043 percentage of checkboxes checked (in the above example, this would be
3044 @samp{[50%]} and @samp{[33%], respectively}).
3046 @noindent The following commands work with checkboxes:
3048 @table @kbd
3049 @kindex C-c C-c
3050 @item C-c C-c
3051 Toggle checkbox at point.  With prefix argument, set it to @samp{[-]},
3052 which is considered to be an intermediate state.
3053 @kindex C-c C-x C-b
3054 @item C-c C-x C-b
3055 Toggle checkbox at point.
3056 @itemize @minus
3057 @item
3058 If there is an active region, toggle the first checkbox in the region
3059 and set all remaining boxes to the same status as the first.  If you
3060 want to toggle all boxes in the region independently, use a prefix
3061 argument.
3062 @item
3063 If the cursor is in a headline, toggle checkboxes in the region between
3064 this headline and the next (so @emph{not} the entire subtree).
3065 @item
3066 If there is no active region, just toggle the checkbox at point.
3067 @end itemize
3068 @kindex M-S-@key{RET}
3069 @item M-S-@key{RET}
3070 Insert a new item with a checkbox.
3071 This works only if the cursor is already in a plain list item
3072 (@pxref{Plain lists}).
3073 @kindex C-c #
3074 @item C-c #
3075 Update the checkbox statistics in the current outline entry.  When
3076 called with a @kbd{C-u} prefix, update the entire file.  Checkbox
3077 statistic cookies are updated automatically if you toggle checkboxes
3078 with @kbd{C-c C-c} and make new ones with @kbd{M-S-@key{RET}}.  If you
3079 delete boxes or add/change them by hand, use this command to get things
3080 back into synch.  Or simply toggle any checkbox twice with @kbd{C-c C-c}.
3081 @end table
3084 @node Tags, Properties and columns, TODO items, Top
3085 @chapter Tags
3086 @cindex tags
3087 @cindex headline tagging
3088 @cindex matching, tags
3089 @cindex sparse tree, tag based
3091 If you wish to implement a system of labels and contexts for
3092 cross-correlating information, an excellent way is to assign @i{tags} to
3093 headlines.  Org-mode has extensive support for using tags.
3095 Every headline can contain a list of tags, at the end of the headline.
3096 Tags are normal words containing letters, numbers, @samp{_}, and
3097 @samp{@@}.  Tags must be preceded and followed by a single colon; like
3098 @samp{:WORK:}.  Several tags can be specified like @samp{:WORK:URGENT:}.
3100 @menu
3101 * Tag inheritance::             Tags use the tree structure of the outline
3102 * Setting tags::                How to assign tags to a headline
3103 * Tag searches::                Searching for combinations of tags
3104 @end menu
3106 @node Tag inheritance, Setting tags, Tags, Tags
3107 @section Tag inheritance
3108 @cindex tag inheritance
3109 @cindex inheritance, of tags
3110 @cindex sublevels, inclusion into tags match
3112 @i{Tags} make use of the hierarchical structure of outline trees.  If a
3113 heading has a certain tag, all subheadings will inherit the tag as
3114 well.  For example, in the list
3116 @example
3117 * Meeting with the French group      :WORK:
3118 ** Summary by Frank                  :BOSS:NOTES:
3119 *** TODO Prepare slides for him      :ACTION:
3120 @end example
3122 @noindent
3123 the final heading will have the tags @samp{:WORK:}, @samp{:BOSS:},
3124 @samp{:NOTES:}, and @samp{:ACTION:}.  When executing tag searches and
3125 Org-mode finds that a certain headline matches the search criterion, it
3126 will not check any sublevel headline, assuming that these likely also
3127 match, and that the list of matches can become very long.  This may
3128 not be what you want, however, and you can influence inheritance and
3129 searching using the variables @code{org-use-tag-inheritance} and
3130 @code{org-tags-match-list-sublevels}.
3132 @node Setting tags, Tag searches, Tag inheritance, Tags
3133 @section Setting tags
3134 @cindex setting tags
3135 @cindex tags, setting
3137 @kindex M-@key{TAB}
3138 Tags can simply be typed into the buffer at the end of a headline.
3139 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
3140 also a special command for inserting tags:
3142 @table @kbd
3143 @kindex C-c C-c
3144 @item C-c C-c
3145 @cindex completion, of tags
3146 Enter new tags for the current headline.  Org-mode will either offer
3147 completion or a special single-key interface for setting tags, see
3148 below.  After pressing @key{RET}, the tags will be inserted and aligned
3149 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
3150 tags in the current buffer will be aligned to that column, just to make
3151 things look nice.  TAGS are automatically realigned after promotion,
3152 demotion, and TODO state changes (@pxref{TODO basics}).
3153 @end table
3155 Org will support tag insertion based on a @emph{list of tags}.  By
3156 default this list is constructed dynamically, containing all tags
3157 currently used in the buffer.  You may also globally specify a hard list
3158 of tags with the variable @code{org-tag-alist}.  Finally you can set
3159 the default tags for a given file with lines like
3161 @example
3162 #+TAGS: @@WORK @@HOME @@TENNISCLUB
3163 #+TAGS: Laptop Car PC Sailboat
3164 @end example
3166 If you have globally defined your preferred set of tags using the
3167 variable @code{org-tag-alist}, but would like to use a dynamic tag list
3168 in a specific file: Just add an empty TAGS option line to that file:
3170 @example
3171 #+TAGS:
3172 @end example
3174 The default support method for entering tags is minibuffer completion.
3175 However, Org-mode also implements a much better method: @emph{fast tag
3176 selection}.  This method allows to select and deselect tags with a
3177 single key per tag.  To function efficiently, you should assign unique
3178 keys to most tags.  This can be done globally with
3180 @lisp
3181 (setq org-tag-alist '(("@@WORK" . ?w) ("@@HOME" . ?h) ("Laptop" . ?l)))
3182 @end lisp
3184 @noindent or on a per-file basis with
3186 @example
3187 #+TAGS: @@WORK(w)  @@HOME(h)  @@TENNISCLUB(t)  Laptop(l)  PC(p)
3188 @end example
3190 @noindent
3191 You can also group together tags that are mutually exclusive.  With
3192 curly braces@footnote{In @code{org-mode-alist} use
3193 @code{'(:startgroup)} and @code{'(:endgroup)}, respectively.  Several
3194 groups are allowed.}
3196 @example
3197 #+TAGS: @{ @@WORK(w)  @@HOME(h)  @@TENNISCLUB(t) @}  Laptop(l)  PC(p)
3198 @end example
3200 @noindent you indicate that at most one of @samp{@@WORK}, @samp{@@HOME},
3201 and @samp{@@TENNISCLUB} should be selected.
3203 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
3204 these lines to activate any changes.
3206 If at least one tag has a selection key, pressing @kbd{C-c C-c} will
3207 automatically present you with a special interface, listing inherited
3208 tags, the tags of the current headline, and a list of all legal tags
3209 with corresponding keys@footnote{Keys will automatically be assigned to
3210 tags which have no configured keys.}.  In this interface, you can use
3211 the following keys:
3213 @table @kbd
3214 @item a-z...
3215 Pressing keys assigned to tags will add or remove them from the list of
3216 tags in the current line.  Selecting a tag in a group of mutually
3217 exclusive tags will turn off any other tags from that group.
3218 @kindex @key{TAB}
3219 @item @key{TAB}
3220 Enter a tag in the minibuffer, even if the tag is not in the predefined
3221 list.  You will be able to complete on all tags present in the buffer.
3222 @kindex @key{SPC}
3223 @item @key{SPC}
3224 Clear all tags for this line.
3225 @kindex @key{RET}
3226 @item @key{RET}
3227 Accept the modified set.
3228 @item C-g
3229 Abort without installing changes.
3230 @item q
3231 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
3232 @item !
3233 Turn off groups of mutually exclusive tags.  Use this to (as an
3234 exception) assign several tags from such a group.
3235 @item C-c
3236 Toggle auto-exit after the next change (see below).
3237 If you are using expert mode, the first @kbd{C-c} will display the
3238 selection window.
3239 @end table
3241 @noindent
3242 This method lets you assign tags to a headline with very few keys.  With
3243 the above setup, you could clear the current tags and set @samp{@@HOME},
3244 @samp{Laptop} and @samp{PC} tags with just the following keys: @kbd{C-c
3245 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@HOME} to
3246 @samp{@@WORK} would be done with @kbd{C-c C-c w @key{RET}} or
3247 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
3248 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
3249 @key{RET} @key{RET}}.
3251 If you find that most of the time, you need only a single keypress to
3252 modify your list of tags, set the variable
3253 @code{org-fast-tag-selection-single-key}.  Then you no longer have to
3254 press @key{RET} to exit fast tag selection - it will immediately exit
3255 after the first change.  If you then occasionally need more keys, press
3256 @kbd{C-c} to turn off auto-exit for the current tag selection process
3257 (in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
3258 C-c}).  If you set the variable to the value @code{expert}, the special
3259 window is not even shown for single-key tag selection, it comes up only
3260 when you press an extra @kbd{C-c}.
3262 @node Tag searches,  , Setting tags, Tags
3263 @section Tag searches
3264 @cindex tag searches
3265 @cindex searching for tags
3267 Once a tags system has been set up, it can be used to collect related
3268 information into special lists.
3270 @table @kbd
3271 @kindex C-c \
3272 @kindex C-c / T
3273 @item C-c \
3274 @itemx C-c / T
3275 Create a sparse tree with all headlines matching a tags search.  With a
3276 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
3277 @kindex C-c a m
3278 @item C-c a m
3279 Create a global list of tag matches from all agenda files.
3280 @xref{Matching tags and properties}.
3281 @kindex C-c a M
3282 @item C-c a M
3283 Create a global list of tag matches from all agenda files, but check
3284 only TODO items and force checking subitems (see variable
3285 @code{org-tags-match-list-sublevels}).
3286 @end table
3288 @cindex Boolean logic, for tag searches
3289 A @i{tags} search string can use Boolean operators @samp{&} for AND and
3290 @samp{|} for OR.  @samp{&} binds more strongly than @samp{|}.
3291 Parenthesis are currently not implemented.  A tag may also be preceded
3292 by @samp{-}, to select against it, and @samp{+} is syntactic sugar for
3293 positive selection.  The AND operator @samp{&} is optional when @samp{+}
3294 or @samp{-} is present.  Examples:
3296 @table @samp
3297 @item +WORK-BOSS
3298 Select headlines tagged @samp{:WORK:}, but discard those also tagged
3299 @samp{:BOSS:}.
3300 @item WORK|LAPTOP
3301 Selects lines tagged @samp{:WORK:} or @samp{:LAPTOP:}.
3302 @item WORK|LAPTOP&NIGHT
3303 Like before, but require the @samp{:LAPTOP:} lines to be tagged also
3304 @samp{NIGHT}.
3305 @end table
3307 @cindex TODO keyword matching, with tags search
3308 If you are using multi-state TODO keywords (@pxref{TODO extensions}), it
3309 can be useful to also match on the TODO keyword.  This can be done by
3310 adding a condition after a slash to a tags match.  The syntax is similar
3311 to the tag matches, but should be applied with consideration: For
3312 example, a positive selection on several TODO keywords can not
3313 meaningfully be combined with boolean AND.  However, @emph{negative
3314 selection} combined with AND can be meaningful.  To make sure that only
3315 lines are checked that actually have any TODO keyword, use @kbd{C-c a
3316 M}, or equivalently start the todo part after the slash with @samp{!}.
3317 Examples:
3319 @table @samp
3320 @item WORK/WAITING
3321 Select @samp{:WORK:}-tagged TODO lines with the specific TODO
3322 keyword @samp{WAITING}.
3323 @item WORK/!-WAITING-NEXT
3324 Select @samp{:WORK:}-tagged TODO lines that are neither @samp{WAITING}
3325 nor @samp{NEXT}
3326 @item WORK/+WAITING|+NEXT
3327 Select @samp{:WORK:}-tagged TODO lines that are either @samp{WAITING} or
3328 @samp{NEXT}.
3329 @end table
3331 @cindex regular expressions, with tags search
3332 Any element of the tag/todo match can be a regular expression - in this
3333 case it must be enclosed in curly braces.  For example,
3334 @samp{WORK+@{^BOSS.*@}} matches headlines that contain the tag
3335 @samp{WORK} and any tag @i{starting} with @samp{BOSS}.
3337 @cindex level, require for tags match
3338 You can also require a headline to be of a certain level, by writing
3339 instead of any TAG an expression like @samp{LEVEL=3}.  For example, a
3340 search @samp{+LEVEL=3+BOSS/-DONE} lists all level three headlines that
3341 have the tag BOSS and are @emph{not} marked with the todo keyword DONE.
3343 @node Properties and columns, Timestamps, Tags, Top
3344 @chapter Properties and Columns
3345 @cindex properties
3347 Properties are a set of key-value pairs associated with an entry.  There
3348 are two main applications for properties in Org-mode.  First, properties
3349 are like tags, but with a value.  For example, in a file where you
3350 document bugs and plan releases of a piece of software, instead of using
3351 tags like @code{:release_1:}, @code{:release_2:}, it can be more
3352 efficient to use a property @code{RELEASE} with a value @code{1.0} or
3353 @code{2.0}.  Second, you can use properties to implement (very basic)
3354 database capabilities in an Org-mode buffer, for example to create a
3355 list of Music CD's you own.  You can edit and view properties
3356 conveniently in column view (@pxref{Column view}).
3358 @menu
3359 * Property syntax::             How properties are spelled out
3360 * Special properties::          Access to other Org-mode features
3361 * Property searches::           Matching property values
3362 * Column view::                 Tabular viewing and editing
3363 * Property API::                Properties for Lisp programmers
3364 @end menu
3366 @node Property syntax, Special properties, Properties and columns, Properties and columns
3367 @section Property Syntax
3368 @cindex property syntax
3369 @cindex drawer, for properties
3371 Properties are key-value pairs.  They need to be inserted into a special
3372 drawer (@pxref{Drawers}) with the name @code{PROPERTIES}.  Each property
3373 is specified on a single line, with the key (surrounded by colons)
3374 first, and the value after it.  Here is an example:
3376 @example
3377 * CD collection
3378 ** Classic
3379 *** Goldberg Variations
3380     :PROPERTIES:
3381     :Title:     Goldberg Variations
3382     :Composer:  J.S. Bach
3383     :Artist:    Glen Gould 
3384     :Publisher: Deutsche Grammphon
3385     :NDisks:    1
3386     :END:       
3387 @end example
3389 You may define the allowed values for a particular property @samp{XYZ}
3390 by setting a property @samp{XYZ_ALL}.  This special property is
3391 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
3392 the entire tree.  When allowed values are defined, setting the
3393 corresponding property becomes easier and is less prone to typing
3394 errors.  For the example with the CD collection, we can predefine
3395 publishers and the number of disks in a box like this:
3397 @example
3398 * CD collection
3399   :PROPERTIES:
3400   :NDisks_ALL:  1 2 3 4
3401   :Publisher_ALL: "Deutsche Grammophon" Phillips EMI
3402   :END:
3403 @end example
3405 If you want to set properties that can be inherited by any entry in a
3406 file, use a line like
3408 @example
3409 #+PROPERTY: NDisks_ALL 1 2 3 4
3410 @end example
3412 Property values set with the global variable
3413 @code{org-global-properties} can be inherited by all entries in all
3414 Org-mode files.
3416 @noindent
3417 The following commands help to work with properties:
3419 @table @kbd
3420 @kindex M-@key{TAB}
3421 @item M-@key{TAB}
3422 After an initial colon in a line, complete property keys.  All keys used
3423 in the current file will be offered as possible completions.
3424 @kindex C-c C-x p
3425 @item C-c C-x p
3426 Set a property.  This prompts for a property name and a value.  If
3427 necessary, the property drawer is created as well.
3428 @item M-x org-insert-property-drawer
3429 Insert a property drawer into the current entry.  The drawer will be
3430 inserted early in the entry, but after the lines with planning
3431 information like deadlines.
3432 @kindex C-c C-c
3433 @item C-c C-c
3434 With the cursor in a property drawer, this executes property commands.
3435 @item C-c C-c s
3436 Set a property in the current entry.  Both the property and the value
3437 can be inserted using completion.
3438 @kindex S-@key{right}
3439 @kindex S-@key{left}
3440 @item S-@key{left}/@key{right}
3441 Switch property at point to the next/previous allowed value.
3442 @item C-c C-c d
3443 Remove a property from the current entry.
3444 @item C-c C-c D
3445 Globally remove a property, from all entries in the current file.
3446 @item C-c C-c c
3447 Compute the property at point, using the operator and scope from the
3448 nearest column format definition.
3449 @end table
3451 @node Special properties, Property searches, Property syntax, Properties and columns
3452 @section Special Properties
3453 @cindex properties, special
3455 Special properties provide alternative access method to Org-mode
3456 features discussed in the previous chapters, like the TODO state or the
3457 priority of an entry.  This interface exists so that you can include
3458 these states into columns view (@pxref{Column view}).  The following
3459 property names are special and should not be used as keys in the
3460 properties drawer:
3462 @example
3463 TODO         @r{The TODO keyword of the entry.}
3464 TAGS         @r{The tags defined directly in the headline.}
3465 ALLTAGS      @r{All tags, including inherited ones.}
3466 PRIORITY     @r{The priority of the entry, a string with a single letter.}
3467 DEADLINE     @r{The deadline time string, without the angular brackets.}
3468 SCHEDULED    @r{The scheduling time stamp, without the angular brackets.}
3469 @end example
3471 @node Property searches, Column view, Special properties, Properties and columns
3472 @section Property searches
3473 @cindex properties, searching
3474 @cindex properties, inheritance
3475 @cindex searching, of properties
3476 @cindex inheritance, of properties
3478 To create sparse trees and special lists with selection based on
3479 properties, the same commands are used as for tag searches (@pxref{Tag
3480 searches}), and the same logic applies.  For example, a search string
3482 @example
3483 +WORK-BOSS+PRIORITY="A"+coffee="unlimited"+with=@{Sarah\|Denny@}
3484 @end example
3486 @noindent
3487 finds entries tagged @samp{:WORK:} but not @samp{:BOSS:}, which
3488 also have a priority value @samp{A}, a @samp{:coffee:} property with the
3489 value @samp{unlimited}, and a @samp{:with:} property that is matched by
3490 the regular expression @samp{Sarah\|Denny}.
3492 During a search, properties will be inherited from parent entries only
3493 if you configure the variable @code{org-use-property-inheritance}.
3495 There is also a special command for creating sparse trees based on a
3496 single property:
3498 @table @kbd
3499 @kindex C-c / p
3500 @item C-c / p
3501 Create a sparse tree based on the value of a property.  This first
3502 prompts for the name of a property, and then for a value.  A sparse tree
3503 is created with all entries that define this property with the given
3504 value.  If you enclose the value into curly braces, it is interpreted as
3505 a regular expression and matched against the property values.
3506 @end table
3509 @node Column view, Property API, Property searches, Properties and columns
3510 @section Column View
3512 A great way to view and edit properties in an outline tree is
3513 @emph{column view}.  In column view, each outline item is turned into a
3514 table row.  Columns in this table provide access to properties of the
3515 entries.  Org-mode implements columns by overlaying a tabular structure
3516 over the headline of each item.  While the headlines have been turned
3517 into a table row, you can still change the visibility of the outline
3518 tree.  For example, you get a compact table by switching to CONTENTS
3519 view (@kbd{S-@key{TAB} S-@key{TAB}}, or simply @kbd{c} while column view
3520 is active), but you can still open, read, and edit the entry below each
3521 headline.  Or, you can switch to column view after executing a sparse
3522 tree command and in this way get a table only for the selected items.
3523 Column view also works in agenda buffers (@pxref{Agenda views}) where
3524 queries have collected selected items, possibly from a number of files.
3526 @menu
3527 * Defining columns::            The COLUMNS format property
3528 * Using column view::           How to create and use column view
3529 * Capturing Column View::       A dynamic block for column view
3530 @end menu
3532 @node Defining columns, Using column view, Column view, Column view
3533 @subsection Defining Columns
3534 @cindex column view, for properties
3535 @cindex properties, column view
3537 Setting up a column view first requires defining the columns.  This is
3538 done by defining a column format line.
3540 @menu
3541 * Scope of column definitions::  Where defined, where valid?
3542 * Column attributes::           Appearance and content of a column
3543 @end menu
3545 @node Scope of column definitions, Column attributes, Defining columns, Defining columns
3546 @subsubsection Scope of column definitions
3548 To define a column format for an entire file, use a line like
3550 @example
3551 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
3552 @end example
3554 To specify a format that only applies to a specific tree, add a COLUMNS
3555 property to the top node of that tree, for example
3556 @example
3557 ** Top node for columns view
3558    :PROPERTIES:
3559    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
3560    :END:
3561 @end example
3563 If a @code{COLUMNS} property is present in an entry, it defines columns
3564 for the entry itself, and for the entire subtree below it.  Since the
3565 column definition is part of the hierarchical structure of the document,
3566 you can define columns on level 1 that are general enough for all
3567 sublevels, and more specific columns further down, when you edit a
3568 deeper part of the tree.
3570 @node Column attributes,  , Scope of column definitions, Defining columns
3571 @subsubsection Column attributes
3572 A column definition sets the attributes of a column.  The general
3573 definition looks like this:
3575 @example
3576  %[width]property[(title)][@{summary-type@}]
3577 @end example
3579 @noindent
3580 Except for the percent sign and the property name, all items are
3581 optional.  The individual parts have the following meaning:
3583 @example
3584 width           @r{An integer specifying the width of the column in characters.}
3585                 @r{If omitted, the width will be determined automatically.}
3586 property        @r{The property that should be edited in this column.}
3587 (title)         @r{The header text for the column. If omitted, the}
3588                 @r{property name is used.}
3589 @{summary-type@}  @r{The summary type.  If specified, the column values for}
3590                 @r{parent nodes are computed from the children.}
3591                 @r{Supported summary types are:}
3592                 @{+@}  @r{Sum numbers in this column.}
3593                 @{:@}  @r{Sum times, HH:MM:SS, plain numbers are hours.}
3594                 @{X@}  @r{Checkbox status, [X] if all children are [X].}
3595 @end example
3597 @noindent
3598 Here is an example for a complete columns definition, along with allowed
3599 values.
3601 @example
3602 :COLUMNS:  %20ITEM %9Approved(Approved?)@{X@} %Owner %11Status %10Time_Spent@{:@}
3603 :Owner_ALL:    Tammy Mark Karl Lisa Don
3604 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
3605 :Approved_ALL: "[ ]" "[X]"
3606 @end example
3608 The first column, @samp{%25ITEM}, means the first 25 characters of the
3609 item itself, i.e. of the headline.  You probably always should start the
3610 column definition with the ITEM specifier.  The other specifiers create
3611 columns @samp{Owner} with a list of names as allowed values, for
3612 @samp{Status} with four different possible values, and for a checkbox
3613 field @samp{Approved}.  When no width is given after the @samp{%}
3614 character, the column will be exactly as wide as it needs to be in order
3615 to fully display all values.  The @samp{Approved} column does have a
3616 modified title (@samp{Approved?}, with a question mark).  Summaries will
3617 be created for the @samp{Time_Spent} column by adding time duration
3618 expressions like HH:MM, and for the @samp{Approved} column, by providing
3619 an @samp{[X]} status if all children have been checked.
3621 @node Using column view, Capturing Column View, Defining columns, Column view
3622 @subsection Using Column View
3624 @table @kbd
3625 @tsubheading{Turning column view on and off}
3626 @kindex C-c C-x C-c
3627 @item C-c C-x C-c
3628 Create the column view for the local environment.  This command searches
3629 the hierarchy, up from point, for a @code{COLUMNS} property that defines
3630 a format.  When one is found, the column view table is established for
3631 the entire tree, starting from the entry that contains the @code{COLUMNS}
3632 property.  If none is found, the format is taken from the @code{#+COLUMNS}
3633 line or from the variable @code{org-columns-default-format}, and column
3634 view is established for the current entry and its subtree.
3635 @kindex q
3636 @item q
3637 Exit column view.
3638 @tsubheading{Editing values}
3639 @item @key{left} @key{right} @key{up} @key{down}
3640 Move through the column view from field to field.
3641 @kindex S-@key{left}
3642 @kindex S-@key{right}
3643 @item  S-@key{left}/@key{right}
3644 Switch to the next/previous allowed value of the field.  For this, you
3645 have to have specified allowed values for a property.
3646 @kindex n
3647 @kindex p
3648 @itemx  n / p
3649 Same as @kbd{S-@key{left}/@key{right}}
3650 @kindex e
3651 @item e
3652 Edit the property at point.  For the special properties, this will
3653 invoke the same interface that you normally use to change that
3654 property.  For example, when editing a TAGS property, the tag completion
3655 or fast selection interface will pop up.
3656 @kindex C-c C-c
3657 @item C-c C-c
3658 When there is a checkbox at point, toggle it.
3659 @kindex v
3660 @item v
3661 View the full value of this property.  This is useful if the width of
3662 the column is smaller than that of the value.
3663 @kindex a
3664 @item a
3665 Edit the list of allowed values for this property.  If the list is found
3666 in the hierarchy, the modified values is stored there.  If no list is
3667 found, the new value is stored in the first entry that is part of the
3668 current column view.
3669 @tsubheading{Modifying the table structure}
3670 @kindex <
3671 @kindex >
3672 @item < / >
3673 Make the column narrower/wider by one character.
3674 @kindex S-M-@key{right}
3675 @item S-M-@key{right}
3676 Insert a new column, to the right of the current column.
3677 @kindex S-M-@key{left}
3678 @item S-M-@key{left}
3679 Delete the current column.
3680 @end table
3682 @node Capturing Column View,  , Using column view, Column view
3683 @subsection Capturing Column View
3685 Since column view is just an overlay over a buffer, it cannot be
3686 exported or printed directly.  If you want to capture a column view, use
3687 the dynamic block (@pxref{Dynamic blocks}).  The frame of this block
3688 looks like this:
3690 @example
3691 * The column view
3692 #+BEGIN: columnview :hlines 1 :id "label"
3694 #+END:
3695 @end example
3697 @noindent This dynamic block has the following parameters:
3699 @table @code
3700 @item :id
3701 This is most important parameter.  Column view is a feature that is
3702 often localized to a certain (sub)tree, and the capture block might be
3703 in a different location in the file.  To identify the tree whose view to
3704 capture, you can use 3 values:
3705 @example
3706 local     @r{use the tree in which the capture block is located}
3707 global    @r{make a global view, including all headings in the file}
3708 "label"   @r{call column view in the tree that has and @code{:ID:}}
3709           @r{property with the value @i{label}}
3710 @end example
3711 @item :hlines
3712 When @code{t}, insert a hline after every line.  When a number N, insert
3713 a hline before each headline with level @code{<= N}.
3714 @item :vlines
3715 When set to @code{t}, enforce column groups to get vertical lines.
3716 @end table
3718 @noindent
3719 The following commands insert or update the dynamic block:
3721 @table @kbd
3722 @kindex C-c C-x r
3723 @item C-c C-x r
3724 Insert a dynamic block capturing a column view.  You will be prompted
3725 for the scope or id of the view.
3726 @kindex C-c C-c
3727 @item C-c C-c
3728 @kindex C-c C-x C-u
3729 @itemx C-c C-x C-u
3730 Update dynamical block at point.  The cursor needs to be in the
3731 @code{#+BEGIN} line of the dynamic block.
3732 @kindex C-u C-c C-x C-u
3733 @item C-u C-c C-x C-u
3734 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
3735 you have several clocktable blocks in a buffer.
3736 @end table
3738 @node Property API,  , Column view, Properties and columns
3739 @section The Property API
3740 @cindex properties, API
3741 @cindex API, for properties
3743 There is a full API for accessing and changing properties.  This API can
3744 be used by Emacs Lisp programs to work with properties and to implement
3745 features based on them.  For more information see @ref{Using the
3746 property API}.
3748 @node Timestamps, Remember, Properties and columns, Top
3749 @chapter Timestamps
3750 @cindex time stamps
3751 @cindex date stamps
3753 Items can be labeled with timestamps to make them useful for project
3754 planning.
3756 @menu
3757 * Time stamps::                 Assigning a time to a tree entry
3758 * Creating timestamps::         Commands which insert timestamps
3759 * Deadlines and scheduling::    Planning your work
3760 * Clocking work time::          
3761 @end menu
3764 @node Time stamps, Creating timestamps, Timestamps, Timestamps
3765 @section Time stamps, deadlines and scheduling
3766 @cindex time stamps
3767 @cindex ranges, time
3768 @cindex date stamps
3769 @cindex deadlines
3770 @cindex scheduling
3772 A time stamp is a specification of a date (possibly with time or a range
3773 of times) in a special format, either @samp{<2003-09-16 Tue>} or
3774 @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16 Tue
3775 12:00-12:30>}@footnote{This is the standard ISO date/time format.  If
3776 you cannot get used to these, see @ref{Custom time format}}.  A time
3777 stamp can appear anywhere in the headline or body of an org-tree entry.
3778 Its presence causes entries to be shown on specific dates in the agenda
3779 (@pxref{Weekly/Daily agenda}).  We distinguish:
3781 @table @var
3782 @item Plain time stamp, Event, Appointment
3783 @cindex timestamp
3784 A simple time stamp just assigns a date/time to an item.  This is just
3785 like writing down an appointment or event in a paper agenda.  In the
3786 timeline and agenda displays, the headline of an entry associated with a
3787 plain time stamp will be shown exactly on that date.
3789 @example
3790 * Meet Peter at the movies <2006-11-01 Wed 19:15>
3791 * Discussion on climate change <2006-11-02 Thu 20:00-22:00>
3792 @end example
3794 @item Time stamp with repeater interval
3795 @cindex timestamp, with repeater interval
3796 A time stamp may contain a @emph{repeater interval}, indicating that it
3797 applies not only on the given date, but again and again after a certain
3798 interval of N days (d), weeks (w), months(m), or years(y).  The
3799 following will show up in the agenda every Wednesday:
3801 @example
3802 * Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
3803 @end example
3805 @item Diary-style sexp entries
3806 For more complex date specifications, Org-mode supports using the
3807 special sexp diary entries implemented in the Emacs calendar/diary
3808 package.  For example
3810 @example
3811 * The nerd meeting on every 2nd Thursday of the month
3812   <%%(diary-float t 4 2)>
3813 @end example
3815 @item Time/Date range
3816 @cindex timerange
3817 @cindex date range
3818 Two time stamps connected by @samp{--} denote a range.  The headline
3819 will be shown on the first and last day of the range, and on any dates
3820 that are displayed and fall in the range.  Here is an example:
3822 @example
3823 ** Meeting in Amsterdam
3824    <2004-08-23 Mon>--<2004-08-26 Thu>
3825 @end example
3827 @item Inactive time stamp
3828 @cindex timestamp, inactive
3829 @cindex inactive timestamp
3830 Just like a plain time stamp, but with square brackets instead of
3831 angular ones.  These time stamps are inactive in the sense that they do
3832 @emph{not} trigger an entry to show up in the agenda.
3834 @example
3835 * Gillian comes late for the fifth time [2006-11-01 Wed]
3836 @end example
3838 @end table
3840 @node Creating timestamps, Deadlines and scheduling, Time stamps, Timestamps
3841 @section Creating timestamps
3842 @cindex creating timestamps
3843 @cindex timestamps, creating
3845 For Org-mode to recognize time stamps, they need to be in the specific
3846 format.  All commands listed below produce time stamps in the correct
3847 format.
3849 @table @kbd
3850 @kindex C-c .
3851 @item C-c .
3852 Prompt for a date and insert a corresponding time stamp.  When the
3853 cursor is at a previously used time stamp, it is updated to NOW.  When
3854 this command is used twice in succession, a time range is inserted.
3856 @kindex C-u C-c .
3857 @item C-u C-c .
3858 Like @kbd{C-c .}, but use the alternative format which contains date
3859 and time.  The default time can be rounded to multiples of 5 minutes,
3860 see the option @code{org-time-stamp-rounding-minutes}.
3862 @kindex C-c !
3863 @item C-c !
3864 Like @kbd{C-c .}, but insert an inactive time stamp that will not cause
3865 an agenda entry.
3867 @kindex C-c <
3868 @item C-c <
3869 Insert a time stamp corresponding to the cursor date in the Calendar.
3871 @kindex C-c >
3872 @item C-c >
3873 Access the Emacs calendar for the current date.  If there is a
3874 timestamp in the current line, goto the corresponding date
3875 instead.
3877 @kindex C-c C-o
3878 @item C-c C-o
3879 Access the agenda for the date given by the time stamp or -range at
3880 point (@pxref{Weekly/Daily agenda}).
3882 @kindex S-@key{left}
3883 @kindex S-@key{right}
3884 @item S-@key{left}
3885 @itemx S-@key{right}
3886 Change date at cursor by one day.  These key bindings conflict with
3887 CUA-mode (@pxref{Conflicts}).
3889 @kindex S-@key{up}
3890 @kindex S-@key{down}
3891 @item S-@key{up}
3892 @itemx S-@key{down}
3893 Change the item under the cursor in a timestamp.  The cursor can be on a
3894 year, month, day, hour or minute.  Note that if the cursor is in a
3895 headline and not at a time stamp, these same keys modify the priority of
3896 an item.  (@pxref{Priorities}). The key bindings also conflict with
3897 CUA-mode (@pxref{Conflicts}).
3899 @kindex C-c C-y
3900 @cindex evaluate time range
3901 @item C-c C-y
3902 Evaluate a time range by computing the difference between start and
3903 end.  With prefix arg, insert result after the time range (in a table:
3904 into the following column).
3905 @end table
3908 @menu
3909 * The date/time prompt::        How org-mode helps you entering date and time
3910 * Custom time format::          Making dates look differently
3911 @end menu
3913 @node The date/time prompt, Custom time format, Creating timestamps, Creating timestamps
3914 @subsection The date/time prompt
3915 @cindex date, reading in minibuffer
3916 @cindex time, reading in minibuffer
3918 When Org-mode prompts for a date/time, the prompt suggests to enter an
3919 ISO date.  But it will in fact accept any string containing some date
3920 and/or time information.  You can, for example, use @kbd{C-y} to paste a
3921 (possibly multi-line) string copied from an email message.  Org-mode
3922 will find whatever information is in there and will replace anything not
3923 specified with the @emph{default date and time}.  The default is usually
3924 the current date and time, but when modifying an existing time stamp, or
3925 when entering the second stamp of a range, it is taken from the stamp in
3926 the buffer.  For example:
3928 @example
3929 3-2-5         --> 2003-02-05
3930 feb 15        --> defaultyear-02-15
3931 sep 12 9      --> 2009-09-12
3932 12:45         --> default-date 12:45
3933 22 sept 0:34  --> defaultyear-09-22 0:34
3934 12            --> defaultyear-defaultmonth-12
3935 Fri           --> nearest Friday (defaultdate or later)
3936 @end example
3938 Furthermore you can specify a relative date by giving, as the
3939 @emph{first} thing in the input: a plus/minus sign, a number and a
3940 letter [dwmy] to indicate change in days weeks, months, years.  With a
3941 single plus or minus, the date is always relative to today.  With a
3942 double plus or minus, it is relative to the default date.  E.g.
3944 @example
3945 +4d           --> four days from today
3946 +4            --> same as above
3947 +2w           --> two weeks from today
3948 ++5           --> five days from default date
3949 @end example
3951 The function understands English month and weekday abbreviations.  If
3952 you want to use unabbreviated names and/or other languages, configure
3953 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
3955 @cindex calendar, for selecting date
3956 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
3957 you don't need/want the calendar, configure the variable
3958 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
3959 prompt, either by clicking on a date in the calendar, or by pressing
3960 @key{RET}, the date selected in the calendar will be combined with the
3961 information entered at the prompt.  You can control the calendar fully
3962 from the minibuffer:
3964 @table @kbd
3965 @kindex <
3966 @item <
3967 Scroll calendar backwards by one month.
3968 @kindex >
3969 @item >
3970 Scroll calendar forwards by one month.
3971 @kindex mouse-1
3972 @item mouse-1
3973 Select date by clicking on it.
3974 @kindex S-@key{right}
3975 @item S-@key{right}
3976 One day forward.
3977 @kindex S-@key{left}
3978 @item S-@key{left}
3979 One day back.
3980 @kindex S-@key{down}
3981 @item S-@key{down}
3982 One week forward.
3983 @kindex S-@key{up}
3984 @item S-@key{up}
3985 One week back.
3986 @kindex M-S-@key{right}
3987 @item M-S-@key{right}
3988 One month forward.
3989 @kindex M-S-@key{left}
3990 @item M-S-@key{left}
3991 One month back.
3992 @kindex @key{RET}
3993 @item @key{RET}
3994 Choose date in calendar (only if nothing was typed into minibuffer).
3995 @end table
3997 @node Custom time format,  , The date/time prompt, Creating timestamps
3998 @subsection Custom time format
3999 @cindex custom date/time format
4000 @cindex time format, custom
4001 @cindex date format, custom
4003 Org-mode uses the standard ISO notation for dates and times as it is
4004 defined in ISO 8601.  If you cannot get used to this and require another
4005 representation of date and time to keep you happy, you can get it by
4006 customizing the variables @code{org-display-custom-times} and
4007 @code{org-time-stamp-custom-formats}.
4009 @table @kbd
4010 @kindex C-c C-x C-t
4011 @item C-c C-x C-t
4012 Toggle the display of custom formats for dates and times.
4013 @end table
4015 @noindent
4016 Org-mode needs the default format for scanning, so the custom date/time
4017 format does not @emph{replace} the default format - instead it is put
4018 @emph{over} the default format using text properties.  This has the
4019 following consequences:
4020 @itemize @bullet
4021 @item 
4022 You cannot place the cursor onto a time stamp anymore, only before or
4023 after.
4024 @item
4025 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
4026 each component of a time stamp.  If the cursor is at the beginning of
4027 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
4028 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
4029 time will be changed by one minute.
4030 @item
4031 If the time stamp contains a range of clock times or a repeater, these
4032 will not be overlayed, but remain in the buffer as they were.
4033 @item
4034 When you delete a time stamp character-by-character, it will only
4035 disappear from the buffer after @emph{all} (invisible) characters
4036 belonging to the ISO timestamp have been removed.
4037 @item
4038 If the custom time stamp format is longer than the default and you are
4039 using dates in tables, table alignment will be messed up.  If the custom
4040 format is shorter, things do work as expected.
4041 @end itemize
4044 @node Deadlines and scheduling, Clocking work time, Creating timestamps, Timestamps
4045 @section Deadlines and Scheduling
4047 A time stamp may be preceded by special keywords to facilitate planning
4048 of work:
4050 @table @var
4051 @item DEADLINE
4052 @cindex DEADLINE keyword
4053 The task (most likely a TODO item) is supposed to be finished on that
4054 date, and it will be listed then.  In addition, the compilation for
4055 @emph{today} will carry a warning about the approaching or missed
4056 deadline, starting @code{org-deadline-warning-days} before the due date,
4057 and continuing until the entry is marked DONE.  An example:
4059 @example
4060 *** TODO write article about the Earth for the Guide
4061     The editor in charge is [[bbdb:Ford Prefect]]
4062     DEADLINE: <2004-02-29 Sun>
4063 @end example
4065 You can specify a different lead time for warnings for a specific
4066 deadlines using the following syntax.  Here is an example with a warning
4067 period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.
4069 @item SCHEDULED
4070 @cindex SCHEDULED keyword
4071 You are planning to start working on that task on the given date. The
4072 headline will be listed under the given date@footnote{It will still be
4073 listed on that date after it has been marked DONE.  If you don't like
4074 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
4075 addition, a reminder that the scheduled date has passed will be present
4076 in the compilation for @emph{today}, until the entry is marked DONE.
4077 I.e., the task will automatically be forwarded until completed.
4079 @example
4080 *** TODO Call Trillian for a date on New Years Eve.
4081     SCHEDULED: <2004-12-25 Sat>
4082 @end example
4084 @noindent
4085 @b{Important:} Scheduling an item in Org-mode should @i{not} be
4086 understood like @i{Scheduling a meeting}.  Setting a date for a meeting
4087 is just a simple appointment, you should mark this entry with a simple
4088 plain time stamp, to get this item shown on the date where it applies.
4089 This is a frequent mis-understanding from Org-users.  In Org-mode,
4090 @i{Scheduling} means setting a date when you want to start working on an
4091 action item.
4092 @end table
4094 @menu
4095 * Inserting deadline/schedule::  Planning items
4096 * Repeated tasks::              Items that show up again and again
4097 @end menu
4099 @node Inserting deadline/schedule, Repeated tasks, Deadlines and scheduling, Deadlines and scheduling
4100 @subsection Inserting deadline/schedule
4102 The following commands allow to quickly insert a deadline or to schedule
4103 an item:
4105 @table @kbd
4107 @kindex C-c C-d
4108 @item C-c C-d
4109 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will
4110 happen in the line directly following the headline.  When called with a
4111 prefix arg, an existing deadline will be removed from the entry.
4112 @c FIXME Any CLOSED timestamp will be removed.????????
4114 @kindex C-c C-w
4115 @cindex sparse tree, for deadlines
4116 @item C-c C-w
4117 Create a sparse tree with all deadlines that are either past-due, or
4118 which will become due within @code{org-deadline-warning-days}.
4119 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
4120 prefix, check that many days.  For example, @kbd{C-1 C-c C-w} shows
4121 all deadlines due tomorrow.
4123 @kindex C-c C-s
4124 @item C-c C-s
4125 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
4126 happen in the line directly following the headline.  Any CLOSED
4127 timestamp will be removed.  When called with a prefix argument, remove
4128 the scheduling date from the entry.
4129 @end table
4131 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
4132 @subsection Repeated Tasks
4134 Some tasks need to be repeated again and again, and Org-mode therefore
4135 allows to use a repeater in a DEADLINE or SCHEDULED time stamp, for
4136 example:
4137 @example
4138 ** TODO Pay the rent
4139    DEADLINE: <2005-10-01 Sat +1m>
4140 @end example
4142 Deadlines and scheduled items produce entries in the agenda when they
4143 are over-due, so it is important to be able to mark such an entry as
4144 completed once you have done so.  When you mark a DEADLINE or a SCHEDULE
4145 with the todo keyword DONE, it will no longer produce entries in the
4146 agenda. The problem with this is, however, that then also the
4147 @emph{next} instance of the repeated entry will not be active.  Org-mode
4148 deals with this in the following way: When you try to mark such an entry
4149 DONE (using @kbd{C-c C-t}), it will shift the base date of the repeating
4150 time stamp by the repeater interval, and immediately set the entry state
4151 back to TODO.  In the example above, setting the state to DONE would
4152 actually switch the date like this:
4154 @example
4155 ** TODO Pay the rent
4156    DEADLINE: <2005-11-01 Tue +1m>
4157 @end example
4159 You will also be prompted for a note@footnote{You can change this using
4160 the option @code{org-log-repeat}, or the @code{#+STARTUP} options
4161 @code{logrepeat} and @code{nologrepeat}.} that will be put under the
4162 DEADLINE line to keep a record that you actually acted on the previous
4163 instance of this deadline.
4165 As a consequence of shifting the base date, this entry will no longer be
4166 visible in the agenda when checking past dates, but all future instances
4167 will be visible.
4169 You may have both scheduling and deadline information for a specific
4170 task - just make sure that the repeater intervals on both are the same.
4172 @node Clocking work time,  , Deadlines and scheduling, Timestamps
4173 @section Clocking work time
4175 Org-mode allows you to clock the time you spent on specific tasks in a
4176 project.  When you start working on an item, you can start the clock.
4177 When you stop working on that task, or when you mark the task done, the
4178 clock is stopped and the corresponding time interval is recorded.  It
4179 also computes the total time spent on each subtree of a project.
4181 @table @kbd
4182 @kindex C-c C-x C-i
4183 @item C-c C-x C-i
4184 Start the clock on the current item (clock-in).  This inserts the CLOCK
4185 keyword together with a timestamp.  If this is not the first clocking of
4186 this item, the multiple CLOCK lines will be wrapped into a
4187 @code{:CLOCK:} drawer (see also the variable
4188 @code{org-clock-into-drawer}.
4189 @kindex C-c C-x C-o
4190 @item C-c C-x C-o
4191 Stop the clock (clock-out).  The inserts another timestamp at the same
4192 location where the clock was last started.  It also directly computes
4193 the resulting time in inserts it after the time range as @samp{=>
4194 HH:MM}.  See the variable @code{org-log-done} for the possibility to
4195 record an additional note together with the clock-out time
4196 stamp@footnote{The corresponding in-buffer setting is: @code{#+STARTUP:
4197 lognoteclock-out}}.
4198 @kindex C-c C-y
4199 @item C-c C-y
4200 Recompute the time interval after changing one of the time stamps.  This
4201 is only necessary if you edit the time stamps directly.  If you change
4202 them with @kbd{S-@key{cursor}} keys, the update is automatic.
4203 @kindex C-c C-t
4204 @item C-c C-t
4205 Changing the TODO state of an item to DONE automatically stops the clock
4206 if it is running in this same item.
4207 @kindex C-c C-x C-x
4208 @item C-c C-x C-x
4209 Cancel the current clock.  This is useful if a clock was started by
4210 mistake, or if you ended up working on something else.
4211 @kindex C-c C-x C-j
4212 @item C-c C-x C-j
4213 Jump to the entry that contains the currently running clock, an another
4214 window.
4215 @kindex C-c C-x C-d
4216 @item C-c C-x C-d
4217 Display time summaries for each subtree in the current buffer.  This
4218 puts overlays at the end of each headline, showing the total time
4219 recorded under that heading, including the time of any subheadings. You
4220 can use visibility cycling to study the tree, but the overlays disappear
4221 when you change the buffer (see variable
4222 @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
4223 @kindex C-c C-x C-r
4224 @item C-c C-x C-r
4225 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
4226 report as an org-mode table into the current file.  When the cursor is
4227 at an existing clock table, just update it.  When called with a prefix
4228 argument, jump to the first clock report in the current document and
4229 update it.
4230 @example
4231 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
4233 #+END: clocktable
4234 @end example
4235 @noindent
4236 If such a block already exists at point, its content is replaced by the
4237 new table.  The @samp{BEGIN} line can specify options:
4238 @example
4239 :maxlevel    @r{Maximum level depth to which times are listed in the table.}
4240 :emphasize   @r{When @code{t}, emphasize level one and level two items}
4241 :scope       @r{The scope to consider.  This can be any of the following:}
4242              nil        @r{the current buffer or narrowed region}
4243              file       @r{the full current buffer}
4244              subtree    @r{the subtree where the clocktable is located}
4245              treeN      @r{the surrounding level N tree, for example @code{tree3}}
4246              tree       @r{the surrounding level 1 tree}
4247              agenda     @r{all agenda files}
4248              ("file"..) @r{scan these files}
4249 :block       @r{The time block to consider.  This block is specified relative}
4250              @r{to the current time and may be any of these keywords:}
4251              @r{@code{today}, @code{yesterday}, @code{thisweek}, @code{lastweek},}
4252              @r{@code{thismonth}, @code{lastmonth}, @code{thisyear}, or @code{lastyear}}.
4253 :tstart      @r{A time string specifying when to start considering times}
4254 :tend        @r{A time string specifying when to stop considering times}
4255 @end example
4256 So to get a clock summary of the current level 1 tree, for the current
4257 day, you could write
4258 @example
4259 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1
4261 #+END: clocktable
4262 @end example
4263 and to use a specific time range you could write@footnote{Note that all
4264 parameters must be specified in a single line - the line is broken here
4265 only to fit it onto the manual.}
4266 @example
4267 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>" 
4268                     :tend "<2006-08-10 Thu 12:00>"
4270 #+END: clocktable
4271 @end example
4272 @kindex C-c C-c
4273 @item C-c C-c
4274 @kindex C-c C-x C-u
4275 @itemx C-c C-x C-u
4276 Update dynamical block at point.  The cursor needs to be in the
4277 @code{#+BEGIN} line of the dynamic block.
4278 @kindex C-u C-c C-x C-u
4279 @item C-u C-c C-x C-u
4280 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
4281 you have several clocktable blocks in a buffer.
4282 @end table
4284 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
4285 the agenda (@pxref{Weekly/Daily agenda}) to show which tasks have been
4286 worked on or closed during a day.
4288 @node Remember, Agenda views, Timestamps, Top
4289 @chapter Remember
4290 @cindex @file{remember.el}
4292 The @i{Remember} package by John Wiegley lets you store quick notes with
4293 little interruption of your work flow.  See
4294 @uref{http://www.emacswiki.org/cgi-bin/wiki/RememberMode} for more
4295 information.  It is an excellent way to add new notes and TODO items to
4296 Org-mode files.  Org-mode significantly expands the possibilities of
4297 @i{remember}: You may define templates for different note types, and
4298 associate target files and headlines with specific templates.  It also
4299 allows you to select the location where a note should be stored
4300 interactively, on the fly.
4302 @menu
4303 * Setting up remember::         Some code for .emacs to get things going
4304 * Remember templates::          Define the outline of different note types
4305 * Storing notes::               Directly get the note to where it belongs
4306 @end menu
4308 @node Setting up remember, Remember templates, Remember, Remember
4309 @section Setting up remember
4311 The following customization will tell @i{remember} to use org files as
4312 target, and to create annotations compatible with Org-mode links.
4314 @example
4315 (setq org-directory "~/path/to/my/orgfiles/")
4316 (setq org-default-notes-file (concat org-directory "/notes.org"))
4317 (setq remember-annotation-functions '(org-remember-annotation))
4318 (setq remember-handler-functions '(org-remember-handler))
4319 (add-hook 'remember-mode-hook 'org-remember-apply-template)
4320 @end example
4323 @node Remember templates, Storing notes, Setting up remember, Remember
4324 @section Remember templates
4325 @cindex templates, for remember
4327 In combination with Org-mode, you can use templates to generate
4328 different types of @i{remember} notes.  For example, if you would like
4329 to use one template to create general TODO entries, another one for
4330 journal entries, and a third one for collecting random ideas, you could
4331 use:
4333 @example
4334 (setq org-remember-templates
4335  '(("Todo" ?t "* TODO %?\n  %i\n  %a" "~/org/TODO.org" "Tasks")
4336    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org")
4337    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
4338 @end example
4340 @noindent In these entries, the first string is just a name, and the
4341 character specifies how to select the template.  It is useful if the
4342 character is also the first letter of the name.  The next string
4343 specifies the template.  Two more (optional) strings give the file in
4344 which, and the headline under which the new note should be stored.  The
4345 file defaults (if not present or @code{nil}) to
4346 @code{org-default-notes-file}, the heading to
4347 @code{org-remember-default-headline}.  Both defaults help to get to the
4348 storing location quickly, but you can change the location interactively
4349 while storing the note.
4351 When you call @kbd{M-x remember} (or @kbd{M-x org-remember}) to remember
4352 something, org will prompt for a key to select the template (if you have
4353 more than one template) and then prepare the buffer like
4354 @example
4355 * TODO
4356   [[file:link to where you called remember]]
4357 @end example
4359 @noindent
4360 During expansion of the template, special @kbd{%}-escapes allow dynamic
4361 insertion of content:
4362 @example
4363 %^@{prompt@}  @r{prompt the user for a string and replace this sequence with it.}
4364 %t          @r{time stamp, date only}
4365 %T          @r{time stamp with date and time}
4366 %u, %U      @r{like the above, but inactive time stamps}
4367 %^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
4368             @r{You may define a prompt like @code{%^@{Birthday@}t}}
4369 %n          @r{user name (taken from @code{user-full-name})}
4370 %a          @r{annotation, normally the link created with @code{org-store-link}}
4371 %A          @r{like @code{%a}, but prompt for the description part}
4372 %i          @r{initial content, the region when remember is called with C-u.}
4373             @r{The entire text will be indented like @code{%i} itself.}
4374 %^g         @r{prompt for tags, with completion on tags in target file.}
4375 %^G         @r{prompt for tags, with completion all tags in all agenda files.}
4376 %:keyword   @r{specific information for certain link types, see below}
4377 @end example
4379 @noindent
4380 For specific link types, the following keywords will be
4381 defined@footnote{If you define your own link types (@pxref{Adding
4382 hyperlink types}), any property you store with
4383 @code{org-store-link-props} can be accessed in remember templates in a
4384 similar way.}:
4386 @example
4387 Link type          |  Available keywords
4388 -------------------+----------------------------------------------
4389 bbdb               |  %:name %:company
4390 vm, wl, mh, rmail  |  %:type %:subject %:message-id
4391                    |  %:from %:fromname %:fromaddress
4392                    |  %:to   %:toname   %:toaddress
4393                    |  %: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}.}}       
4394 gnus               |  %:group, @r{for messages also all email fields}
4395 w3, w3m            |  %:url
4396 info               |  %:file %:node
4397 calendar           |  %:date"
4398 @end example
4400 @noindent
4401 To place the cursor after template expansion use:
4403 @example
4404 %?          @r{After completing the template, position cursor here.}
4405 @end example
4407 @noindent
4408 If you change you mind about which template to use, call
4409 @code{org-remember} in the remember buffer.  You may then select a new
4410 template that will be filled with the previous context information.
4412 @node Storing notes,  , Remember templates, Remember
4413 @section Storing notes
4415 When you are finished preparing a note with @i{remember}, you have to press
4416 @kbd{C-c C-c} to file the note away.  The handler will store the note in
4417 the file and under the headline specified in the template, or it will
4418 use the default file and headlines.  The window configuration will be
4419 restored, and you are back in the working context before the call to
4420 @code{remember}.  To re-use the location found during the last call to
4421 @code{remember}, exit the remember buffer with @kbd{C-u C-u C-c C-c},
4422 i.e. specify a double prefix argument to @kbd{C-c C-c}.
4424 If you want to store the note to a different place, use @kbd{C-u C-c
4425 C-c} instead to exit remember@footnote{Configure the variable
4426 @code{org-remember-store-without-prompt} to make this behavior the
4427 default.}.  The handler will then first prompt for a target file - if you
4428 press @key{RET}, the value specified for the template is used.  Then the
4429 command offers the headings tree of the selected file, with the cursor
4430 position at the default headline (if you had specified one in the
4431 template).  You can either immediately press @key{RET} to get the note
4432 placed there.  Or you can use the following keys to find a different
4433 location:
4434 @example
4435 @key{TAB}         @r{Cycle visibility.}
4436 @key{down} / @key{up}   @r{Next/previous visible headline.}
4437 n / p        @r{Next/previous visible headline.}
4438 f / b        @r{Next/previous headline same level.}
4439 u            @r{One level up.}
4440 @c 0-9          @r{Digit argument.}
4441 @end example
4442 @noindent
4443 Pressing @key{RET} or @key{left} or @key{right}
4444 then leads to the following result.
4446 @multitable @columnfractions 0.2 0.15 0.65
4447 @item @b{Cursor position} @tab @b{Key} @tab @b{Note gets inserted}
4448 @item on headline     @tab @key{RET}              @tab as sublevel of the heading at cursor, first or last
4449 @item                 @tab                        @tab depending on @code{org-reverse-note-order}.
4450 @item                 @tab @key{left}/@key{right} @tab as same level, before/after current heading
4451 @item buffer-start    @tab @key{RET} @tab as level 2 heading at end of file or level 1 at beginning
4452 @item                 @tab @tab depending on @code{org-reverse-note-order}.
4453 @item not on headline @tab @key{RET}
4454       @tab at cursor position, level taken from context.
4455 @end multitable
4457 Before inserting the text into a tree, the function ensures that the
4458 text has a headline, i.e. a first line that starts with a @samp{*}.  If
4459 not, a headline is constructed from the current date and some additional
4460 data.  If you have indented the text of the note below the headline, the
4461 indentation will be adapted if inserting the note into the tree requires
4462 demotion from level 1.
4464 @node Agenda views, Embedded LaTeX, Remember, Top
4465 @chapter Agenda Views
4466 @cindex agenda views
4468 Due to the way Org-mode works, TODO items, time-stamped items, and
4469 tagged headlines can be scattered throughout a file or even a number of
4470 files.  To get an overview over open action items, or over events that
4471 are important for a particular date, this information must be collected,
4472 sorted and displayed in an organized way.
4474 Org-mode can select items based on various criteria, and display them
4475 in a separate buffer.  Six different view types are provided:
4477 @itemize @bullet
4478 @item
4479 an @emph{agenda} that is like a calendar and shows information
4480 for specific dates,
4481 @item
4482 a @emph{TODO list} that covers all unfinished
4483 action items,
4484 @item
4485 a @emph{tags view}, showings headlines based on
4486 the tags associated with them,
4487 @item
4488 a @emph{timeline view} that shows all events in a single Org-mode file,
4489 in time-sorted view,
4490 @item
4491 a @emph{stuck projects view} showing projects that currently don't move
4492 along, and
4493 @item
4494 @emph{custom views} that are special tag/keyword searches and
4495 combinations of different views.
4496 @end itemize
4498 @noindent
4499 The extracted information is displayed in a special @emph{agenda
4500 buffer}.  This buffer is read-only, but provides commands to visit the
4501 corresponding locations in the original Org-mode files, and even to
4502 edit these files remotely.  
4504 Two variables control how the agenda buffer is displayed and whether the
4505 window configuration is restored when the agenda exits:
4506 @code{org-agenda-window-setup} and
4507 @code{org-agenda-restore-windows-after-quit}.
4509 @menu
4510 * Agenda files::                Files being searched for agenda information
4511 * Agenda dispatcher::           Keyboard access to agenda views
4512 * Built-in agenda views::       What is available out of the box?
4513 * Presentation and sorting::    How agenda items are prepared for display
4514 * Agenda commands::             Remote editing of org trees
4515 * Custom agenda views::         Defining special searches and views
4516 @end menu
4518 @node Agenda files, Agenda dispatcher, Agenda views, Agenda views
4519 @section Agenda files
4520 @cindex agenda files
4521 @cindex files for agenda
4523 The information to be shown is collected from all @emph{agenda files},
4524 the files listed in the variable @code{org-agenda-files}@footnote{If the
4525 value of that variable is not a list, but a single file name, then the
4526 list of agenda files will be maintained in that external file.}.  Thus even
4527 if you only work with a single Org-mode file, this file should be put
4528 into that list@footnote{When using the dispatcher, pressing @kbd{1}
4529 before selecting a command will actually limit the command to the
4530 current file, and ignore @code{org-agenda-files} until the next
4531 dispatcher command.}.  You can customize @code{org-agenda-files}, but
4532 the easiest way to maintain it is through the following commands
4534 @cindex files, adding to agenda list
4535 @table @kbd
4536 @kindex C-c [
4537 @item C-c [
4538 Add current file to the list of agenda files.  The file is added to
4539 the front of the list.  If it was already in the list, it is moved to
4540 the front.  With prefix arg, file is added/moved to the end.
4541 @kindex C-c ]
4542 @item C-c ]
4543 Remove current file from the list of agenda files.
4544 @kindex C-,
4545 @kindex C-'
4546 @item C-,
4547 @itemx C-'
4548 Cycle through agenda file list, visiting one file after the other.
4549 @end table
4551 @noindent
4552 The Org menu contains the current list of files and can be used
4553 to visit any of them.
4555 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda views
4556 @section The agenda dispatcher
4557 @cindex agenda dispatcher
4558 @cindex dispatching agenda commands
4559 The views are created through a dispatcher that should be bound to a
4560 global key, for example @kbd{C-c a} (@pxref{Installation}).  In the
4561 following we will assume that @kbd{C-c a} is indeed how the dispatcher
4562 is accessed and list keyboard access to commands accordingly.  After
4563 pressing @kbd{C-c a}, an additional letter is required to execute a
4564 command.  The dispatcher offers the following default commands:
4565 @table @kbd
4566 @item a
4567 Create the calendar-like agenda (@pxref{Weekly/Daily agenda}).
4568 @item t @r{/} T
4569 Create a list of all TODO items (@pxref{Global TODO list}).
4570 @item m @r{/} M
4571 Create a list of headlines matching a TAGS expression (@pxref{Matching
4572 tags and properties}).
4573 @item L
4574 Create the timeline view for the current buffer (@pxref{Timeline}).
4575 @item # @r{/} !
4576 Create a list of stuck projects (@pxref{Stuck projects}).
4577 @item /
4578 Search for a regular expression in all agenda files and additionally in
4579 the files listed in @code{org-agenda-multi-occur-extra-files}.  This
4580 uses the Emacs command @code{multi-occur}.  A prefix argument can be
4581 used to specify the number of context lines for each match, default is
4583 @item <
4584 Restrict an agenda command to the current buffer@footnote{For backward
4585 compatibility, you can also press @kbd{1} to restrict to the current
4586 buffer.}.  After pressing @kbd{<}, you still need to press the character
4587 selecting the command.
4588 @item < <
4589 If there is an active region, restrict the following agenda command to
4590 the region.  Otherwise, restrict it to the current subtree@footnote{For
4591 backward compatibility, you can also press @kbd{0} to restrict to the
4592 current buffer.}.  After pressing @kbd{< <}, you still need to press the
4593 character selecting the command.
4594 @end table
4596 You can also define custom commands that will be accessible through the
4597 dispatcher, just like the default commands.  This includes the
4598 possibility to create extended agenda buffers that contain several
4599 blocks together, for example the weekly agenda, the global TODO list and
4600 a number of special tags matches.  @xref{Custom agenda views}.
4602 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda views
4603 @section The built-in agenda views
4605 In this section we describe the built-in views.
4607 @menu
4608 * Weekly/Daily agenda::         The calendar page with current tasks
4609 * Global TODO list::            All unfinished action items
4610 * Matching tags and properties::  Structured information with fine-tuned search
4611 * Timeline::                    Time-sorted view for single file
4612 * Stuck projects::              Find projects you need to review
4613 @end menu
4615 @node Weekly/Daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
4616 @subsection The weekly/daily agenda
4617 @cindex agenda
4618 @cindex weekly agenda
4619 @cindex daily agenda
4621 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
4622 paper agenda, showing all the tasks for the current week or day.
4624 @table @kbd
4625 @cindex org-agenda, command
4626 @kindex C-c a a
4627 @item C-c a a
4628 Compile an agenda for the current week from a list of org files.  The
4629 agenda shows the entries for each day.  With a @kbd{C-u} prefix (or
4630 when the variable @code{org-agenda-include-all-todo} is @code{t}), all
4631 unfinished TODO items (including those without a date) are also listed at
4632 the beginning of the buffer, before the first date.@*
4633 @end table
4635 Remote editing from the agenda buffer means, for example, that you can
4636 change the dates of deadlines and appointments from the agenda buffer.
4637 The commands available in the Agenda buffer are listed in @ref{Agenda
4638 commands}.
4640 @subsubheading Calendar/Diary integration
4641 @cindex calendar integration
4642 @cindex diary integration
4644 Emacs contains the calendar and diary by Edward M. Reingold.  The
4645 calendar displays a three-month calendar with holidays from different
4646 countries and cultures.  The diary allows you to keep track of
4647 anniversaries, lunar phases, sunrise/set, recurrent appointments
4648 (weekly, monthly) and more.  In this way, it is quite complementary to
4649 Org-mode.  It can be very useful to combine output from Org-mode with
4650 the diary.
4652 In order to include entries from the Emacs diary into Org-mode's
4653 agenda, you only need to customize the variable
4655 @lisp
4656 (setq org-agenda-include-diary t)
4657 @end lisp
4659 @noindent After that, everything will happen automatically.  All diary
4660 entries including holidays, anniversaries etc will be included in the
4661 agenda buffer created by Org-mode.  @key{SPC}, @key{TAB}, and
4662 @key{RET} can be used from the agenda buffer to jump to the diary
4663 file in order to edit existing diary entries.  The @kbd{i} command to
4664 insert new entries for the current date works in the agenda buffer, as
4665 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
4666 Sunrise/Sunset times, show lunar phases and to convert to other
4667 calendars, respectively.  @kbd{c} can be used to switch back and forth
4668 between calendar and agenda.
4670 If you are using the diary only for sexp entries and holidays, it is
4671 faster to not use the above setting, but instead to copy or even move
4672 the entries into an Org-mode file. Org-mode evaluates diary-style sexp
4673 entries, and does it faster because there is no overhead for first
4674 creating the diary display.  Note that the sexp entries must start at
4675 the left margin, no white space is allowed before them.  For example,
4676 the following segment of an Org-mode file will be processed and entries
4677 will be made in the agenda:
4679 @example
4680 * Birthdays and similar stuff
4681 #+CATEGORY: Holiday
4682 %%(org-calendar-holiday)   ; special function for holiday names
4683 #+CATEGORY: Ann
4684 %%(diary-anniversary 14  5 1956) Arthur Dent is %d years old
4685 %%(diary-anniversary  2 10 1869) Mahatma Gandhi would be %d years old
4686 @end example
4688 @subsubheading Appointment reminders
4689 @cindex @file{appt.el}
4690 @cindex appointment reminders
4692 Org can interact with Emacs appointments notification facility.
4694 To add all the appointments of your agenda files, use the command
4695 @code{org-agenda-to-appt}.  This commands also lets you filter through
4696 the list of your appointments and add only those belonging to a specific
4697 category or matching a regular expression. See the docstring for
4698 details.
4700 @node Global TODO list, Matching tags and properties, Weekly/Daily agenda, Built-in agenda views
4701 @subsection The global TODO list
4702 @cindex global TODO list
4703 @cindex TODO list, global
4705 The global TODO list contains all unfinished TODO items, formatted and
4706 collected into a single place.
4708 @table @kbd
4709 @kindex C-c a t
4710 @item C-c a t
4711 Show the global TODO list.  This collects the TODO items from all
4712 agenda files (@pxref{Agenda views}) into a single buffer.  The buffer is in
4713 @code{agenda-mode}, so there are commands to examine and manipulate
4714 the TODO entries directly from that buffer (@pxref{Agenda commands}).
4715 @kindex C-c a T
4716 @item C-c a T
4717 @cindex TODO keyword matching
4718 Like the above, but allows selection of a specific TODO keyword.  You
4719 can also do this by specifying a prefix argument to @kbd{C-c a t}.  With
4720 a @kbd{C-u} prefix you are prompted for a keyword, and you may also
4721 specify several keywords by separating them with @samp{|} as boolean OR
4722 operator.  With a numeric prefix, the Nth keyword in
4723 @code{org-todo-keywords} is selected.
4724 @kindex r
4725 The @kbd{r} key in the agenda buffer regenerates it, and you can give
4726 a prefix argument to this command to change the selected TODO keyword,
4727 for example @kbd{3 r}.  If you often need a search for a specific
4728 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
4729 Matching specific TODO keywords can also be done as part of a tags
4730 search (@pxref{Tag searches}).
4731 @end table
4733 Remote editing of TODO items means that you can change the state of a
4734 TODO entry with a single key press.  The commands available in the
4735 TODO list are described in @ref{Agenda commands}.
4737 @cindex sublevels, inclusion into todo list
4738 Normally the global todo list simply shows all headlines with TODO
4739 keywords.  This list can become very long.  There are two ways to keep
4740 it more compact:
4741 @itemize @minus
4742 @item
4743 Some people view a TODO item that has been @emph{scheduled} for
4744 execution (@pxref{Time stamps}) as no longer @emph{open}.  Configure the
4745 variable @code{org-agenda-todo-ignore-scheduled} to exclude scheduled
4746 items from the global TODO list.
4747 @item
4748 TODO items may have sublevels to break up the task into subtasks.  In
4749 such cases it may be enough to list only the highest level TODO headline
4750 and omit the sublevels from the global list.  Configure the variable
4751 @code{org-agenda-todo-list-sublevels} to get this behavior.
4752 @end itemize
4754 @node Matching tags and properties, Timeline, Global TODO list, Built-in agenda views
4755 @subsection Matching Tags and Properties
4756 @cindex matching, of tags
4757 @cindex matching, of properties
4758 @cindex tags view
4760 If headlines in the agenda files are marked with @emph{tags}
4761 (@pxref{Tags}), you can select headlines based on the tags that apply
4762 to them and collect them into an agenda buffer.
4764 @table @kbd
4765 @kindex C-c a m
4766 @item C-c a m
4767 Produce a list of all headlines that match a given set of tags.  The
4768 command prompts for a selection criterion, which is a boolean logic
4769 expression with tags, like @samp{+WORK+URGENT-WITHBOSS} or
4770 @samp{WORK|HOME} (@pxref{Tags}).  If you often need a specific search,
4771 define a custom command for it (@pxref{Agenda dispatcher}).
4772 @kindex C-c a M
4773 @item C-c a M
4774 Like @kbd{C-c a m}, but only select headlines that are also TODO items
4775 and force checking subitems (see variable
4776 @code{org-tags-match-list-sublevels}).  Matching specific todo keywords
4777 together with a tags match is also possible, see @ref{Tag searches}.
4778 @end table
4780 The commands available in the tags list are described in @ref{Agenda
4781 commands}.
4783 @node Timeline, Stuck projects, Matching tags and properties, Built-in agenda views
4784 @subsection Timeline for a single file
4785 @cindex timeline, single file
4786 @cindex time-sorted view
4788 The timeline summarizes all time-stamped items from a single Org-mode
4789 file in a @emph{time-sorted view}.  The main purpose of this command is
4790 to give an overview over events in a project.
4792 @table @kbd
4793 @kindex C-c a L
4794 @item C-c a L
4795 Show a time-sorted view of the org file, with all time-stamped items.
4796 When called with a @kbd{C-u} prefix, all unfinished TODO entries
4797 (scheduled or not) are also listed under the current date.
4798 @end table
4800 @noindent
4801 The commands available in the timeline buffer are listed in
4802 @ref{Agenda commands}.
4805 @node Stuck projects,  , Timeline, Built-in agenda views
4806 @subsection Stuck projects
4808 If you are following a system like David Allen's GTD to organize your
4809 work, one of the ``duties'' you have is a regular review to make sure
4810 that all projects move along.  A @emph{stuck} project is a project that
4811 has no defined next actions, so it will never show up in the TODO lists
4812 Org-mode produces.  During the review, you need to identify such
4813 projects and define next actions for them.
4815 @table @kbd
4816 @kindex C-c a #
4817 @item C-c a #
4818 List projects that are stuck.
4819 @kindex C-c a !
4820 @item C-c a !
4821 Customize the variable @code{org-stuck-projects} to define what a stuck
4822 project is and how to find it.
4823 @end table
4825 You almost certainly will have to configure this view before it will
4826 work for you.  The built-in default assumes that all your projects are
4827 level-2 headlines, and that a project is not stuck if it has at least
4828 one entry marked with a todo keyword TODO or NEXT or NEXTACTION.
4830 Lets assume that you, in your own way of using Org-mode, identify
4831 projects with a tag PROJECT, and that you use a todo keyword MAYBE to
4832 indicate a project that should not be considered yet.  Lets further
4833 assume that the todo keyword DONE marks finished projects, and that NEXT
4834 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
4835 is a next action even without the NEXT tag.  Finally, if the project
4836 contains the special word IGNORE anywhere, it should not be listed
4837 either.  In this case you would start by identifying eligible projects
4838 with a tags/todo match @samp{+PROJECT/-MAYBE-DONE}, and then check for
4839 TODO, NEXT, @@SHOP, and IGNORE in the subtree to identify projects that
4840 are not stuck.  The correct customization for this is
4842 @lisp
4843 (setq org-stuck-projects
4844       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
4845                                "\\<IGNORE\\>"))
4846 @end lisp
4849 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda views
4850 @section Presentation and sorting
4851 @cindex presentation, of agenda items
4853 Before displaying items in an agenda view, Org-mode visually prepares
4854 the items and sorts them.  Each item occupies a single line.  The line
4855 starts with a @emph{prefix} that contains the @emph{category}
4856 (@pxref{Categories}) of the item and other important information.  You can
4857 customize the prefix using the option @code{org-agenda-prefix-format}.
4858 The prefix is followed by a cleaned-up version of the outline headline
4859 associated with the item.
4861 @menu
4862 * Categories::                  Not all tasks are equal
4863 * Time-of-day specifications::  How the agenda knows the time
4864 * Sorting of agenda items::     The order of things
4865 @end menu
4867 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
4868 @subsection Categories
4870 @cindex category
4871 The category is a broad label assigned to each agenda item.  By default,
4872 the category is simply derived from the file name, but you can also
4873 specify it with a special line in the buffer, like this@footnote{If
4874 there are several such lines in a file, each specifies the category for
4875 the text below it.  The first category also applies to any text before
4876 the first CATEGORY line.  This method is only kept for backward
4877 compatibility.  The preferred method for setting multiple categories in
4878 a buffer is using a property.}:
4880 @example
4881 #+CATEGORY: Thesis
4882 @end example
4884 @noindent
4885 If you would like to have a special CATEGORY for a single entry or a
4886 (sub)tree, give the entry a @code{:CATEGORY:} property with the location
4887 as the value (@pxref{Properties and columns}).
4889 @noindent
4890 The display in the agenda buffer looks best if the category is not
4891 longer than 10 characters.
4893 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
4894 @subsection Time-of-Day Specifications
4895 @cindex time-of-day specification
4897 Org-mode checks each agenda item for a time-of-day specification.  The
4898 time can be part of the time stamp that triggered inclusion into the
4899 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
4900 ranges can be specified with two time stamps, like
4902 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
4904 In the headline of the entry itself, a time(range) may also appear as
4905 plain text (like @samp{12:45} or a @samp{8:30-1pm}.  If the agenda
4906 integrates the Emacs diary (@pxref{Weekly/Daily agenda}), time
4907 specifications in diary entries are recognized as well.
4909 For agenda display, Org-mode extracts the time and displays it in a
4910 standard 24 hour format as part of the prefix.  The example times in
4911 the previous paragraphs would end up in the agenda like this:
4913 @example
4914     8:30-13:00 Arthur Dent lies in front of the bulldozer
4915    12:45...... Ford Prefect arrives and takes Arthur to the pub
4916    19:00...... The Vogon reads his poem
4917    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
4918 @end example
4920 @cindex time grid
4921 If the agenda is in single-day mode, or for the display of today, the
4922 timed entries are embedded in a time grid, like
4924 @example
4925     8:00...... ------------------
4926     8:30-13:00 Arthur Dent lies in front of the bulldozer
4927    10:00...... ------------------
4928    12:00...... ------------------
4929    12:45...... Ford Prefect arrives and takes Arthur to the pub
4930    14:00...... ------------------
4931    16:00...... ------------------
4932    18:00...... ------------------
4933    19:00...... The Vogon reads his poem
4934    20:00...... ------------------
4935    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
4936 @end example
4938 The time grid can be turned on and off with the variable
4939 @code{org-agenda-use-time-grid}, and can be configured with
4940 @code{org-agenda-time-grid}.
4942 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
4943 @subsection Sorting of agenda items
4944 @cindex sorting, of agenda items
4945 @cindex priorities, of agenda items
4946 Before being inserted into a view, the items are sorted.  How this is
4947 done depends on the type of view.
4948 @itemize @bullet
4949 @item
4950 For the daily/weekly agenda, the items for each day are sorted.  The
4951 default order is to first collect all items containing an explicit
4952 time-of-day specification.  These entries will be shown at the beginning
4953 of the list, as a @emph{schedule} for the day.  After that, items remain
4954 grouped in categories, in the sequence given by @code{org-agenda-files}.
4955 Within each category, items are sorted by priority (@pxref{Priorities}),
4956 which is composed of the base priority (2000 for priority @samp{A}, 1000
4957 for @samp{B}, and 0 for @samp{C}), plus additional increments for
4958 overdue scheduled or deadline items.
4959 @item 
4960 For the TODO list, items remain in the order of categories, but within
4961 each category, sorting takes place according to priority
4962 (@pxref{Priorities}).
4963 @item
4964 For tags matches, items are not sorted at all, but just appear in the
4965 sequence in which they are found in the agenda files.
4966 @end itemize
4968 Sorting can be customized using the variable
4969 @code{org-agenda-sorting-strategy}.
4972 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda views
4973 @section Commands in the agenda buffer
4974 @cindex commands, in agenda buffer
4976 Entries in the agenda buffer are linked back to the org file or diary
4977 file where they originate.  You are not allowed to edit the agenda
4978 buffer itself, but commands are provided to show and jump to the
4979 original entry location, and to edit the org-files ``remotely'' from
4980 the agenda buffer.  In this way, all information is stored only once,
4981 removing the risk that your agenda and note files may diverge.
4983 Some commands can be executed with mouse clicks on agenda lines.  For
4984 the other commands, the cursor needs to be in the desired line.
4986 @table @kbd
4987 @tsubheading{Motion}
4988 @cindex motion commands in agenda
4989 @kindex n
4990 @item n
4991 Next line (same as @key{up} and @kbd{C-p}).
4992 @kindex p
4993 @item p
4994 Previous line (same as @key{down} and @kbd{C-n}).
4995 @tsubheading{View/GoTo org file}
4996 @kindex mouse-3
4997 @kindex @key{SPC}
4998 @item mouse-3
4999 @itemx @key{SPC}
5000 Display the original location of the item in another window.
5002 @kindex L
5003 @item L
5004 Display original location and recenter that window.
5006 @kindex mouse-2
5007 @kindex mouse-1
5008 @kindex @key{TAB}
5009 @item mouse-2
5010 @itemx mouse-1
5011 @itemx @key{TAB}
5012 Go to the original location of the item in another window.  Under Emacs
5013 22, @kbd{mouse-1} will also works for this.
5015 @kindex @key{RET}
5016 @itemx @key{RET}
5017 Go to the original location of the item and delete other windows.
5019 @kindex f
5020 @item f
5021 Toggle Follow mode.  In Follow mode, as you move the cursor through
5022 the agenda buffer, the other window always shows the corresponding
5023 location in the org file.  The initial setting for this mode in new
5024 agenda buffers can be set with the variable
5025 @code{org-agenda-start-with-follow-mode}.
5027 @kindex b
5028 @item b
5029 Display the entire subtree of the current item in an indirect buffer.
5030 With numerical prefix ARG, go up to this level and then take that tree.
5031 If ARG is negative, go up that many levels.  With @kbd{C-u} prefix, do
5032 not remove the previously used indirect buffer.
5034 @kindex l
5035 @item l
5036 Toggle Logbook mode.  In Logbook mode, entries that where marked DONE while
5037 logging was on (variable @code{org-log-done}) are shown in the agenda,
5038 as are entries that have been clocked on that day.
5040 @tsubheading{Change display}
5041 @cindex display changing, in agenda
5042 @kindex o
5043 @item o
5044 Delete other windows.
5046 @kindex d
5047 @kindex w
5048 @kindex m
5049 @kindex y
5050 @item d w m y
5051 Switch to day/week/month/year view.  When switching to day or week view,
5052 this setting becomes the default for subseqent agenda commands.  Since
5053 month and year views are slow to create, the do not become the default.
5055 @kindex D
5056 @item D
5057 Toggle the inclusion of diary entries.  See @ref{Weekly/Daily agenda}.
5059 @kindex g
5060 @item g
5061 Toggle the time grid on and off.  See also the variables
5062 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
5064 @kindex r
5065 @item r
5066 Recreate the agenda buffer, for example to reflect the changes
5067 after modification of the time stamps of items with S-@key{left} and
5068 S-@key{right}.  When the buffer is the global todo list, a prefix
5069 argument is interpreted to create a selective list for a specific TODO
5070 keyword.
5072 @kindex s
5073 @kindex C-x C-s
5074 @item s
5075 @itemx C-x C-s
5076 Save all Org-mode buffers in the current Emacs session.
5078 @kindex @key{right}
5079 @item @key{right}
5080 Display the following @code{org-agenda-ndays} days.  For example, if
5081 the display covers a week, switch to the following week.  With prefix
5082 arg, go forward that many times @code{org-agenda-ndays} days.
5084 @kindex @key{left}
5085 @item @key{left}
5086 Display the previous dates.
5088 @kindex .
5089 @item .
5090 Goto today.
5092 @tsubheading{Remote editing}
5093 @cindex remote editing, from agenda
5095 @item 0-9
5096 Digit argument.
5098 @cindex undoing remote-editing events
5099 @cindex remote editing, undo
5100 @kindex C-_
5101 @item C-_
5102 Undo a change due to a remote editing command.  The change is undone
5103 both in the agenda buffer and in the remote buffer.
5105 @kindex t
5106 @item t
5107 Change the TODO state of the item, both in the agenda and in the
5108 original org file.
5110 @kindex C-k
5111 @item C-k
5112 Delete the current agenda item along with the entire subtree belonging
5113 to it in the original Org-mode file.  If the text to be deleted remotely
5114 is longer than one line, the kill needs to be confirmed by the user.  See
5115 variable @code{org-agenda-confirm-kill}.
5117 @kindex $
5118 @item $
5119 Archive the subtree corresponding to the current headline.
5121 @kindex T
5122 @item T
5123 Show all tags associated with the current item.  Because of
5124 inheritance, this may be more than the tags listed in the line itself.
5126 @kindex :
5127 @item :
5128 Set tags for the current headline.  If there is an active region in the
5129 agenda, change a tag for all headings in the region.
5131 @kindex a
5132 @item a
5133 Toggle the ARCHIVE tag for the current headline.
5135 @kindex ,
5136 @item ,
5137 Set the priority for the current item.  Org-mode prompts for the
5138 priority character. If you reply with @key{SPC}, the priority cookie
5139 is removed from the entry.
5141 @kindex P
5142 @item P
5143 Display weighted priority of current item.
5145 @kindex +
5146 @kindex S-@key{up}
5147 @item +
5148 @itemx S-@key{up}
5149 Increase the priority of the current item.  The priority is changed in
5150 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
5151 key for this.
5153 @kindex -
5154 @kindex S-@key{down}
5155 @item -
5156 @itemx S-@key{down}
5157 Decrease the priority of the current item.
5159 @kindex C-c C-s
5160 @item C-c C-s
5161 Schedule this item
5163 @kindex C-c C-d
5164 @item C-c C-d
5165 Set a deadline for this item.
5167 @kindex S-@key{right}
5168 @item S-@key{right}
5169 Change the time stamp associated with the current line by one day into
5170 the future.  With prefix argument, change it by that many days.  For
5171 example, @kbd{3 6 5 S-@key{right}} will change it by a year.  The
5172 stamp is changed in the original org file, but the change is not
5173 directly reflected in the agenda buffer.  Use the
5174 @kbd{r} key to update the buffer.
5176 @kindex S-@key{left}
5177 @item S-@key{left}
5178 Change the time stamp associated with the current line by one day
5179 into the past.
5181 @kindex >
5182 @item >
5183 Change the time stamp associated with the current line to today.
5184 The key @kbd{>} has been chosen, because it is the same as @kbd{S-.}
5185 on my keyboard.
5187 @kindex I
5188 @item I
5189 Start the clock on the current item.  If a clock is running already, it
5190 is stopped first.
5192 @kindex O
5193 @item O
5194 Stop the previously started clock.
5196 @kindex X
5197 @item X
5198 Cancel the currently running clock.
5200 @kindex J
5201 @item J
5202 Jump to the running clock in another window.
5204 @tsubheading{Calendar commands}
5205 @cindex calendar commands, from agenda
5206 @kindex c
5207 @item c
5208 Open the Emacs calendar and move to the date at the agenda cursor.
5210 @item c
5211 When in the calendar, compute and show the Org-mode agenda for the
5212 date at the cursor.
5214 @cindex diary entries, creating from agenda
5215 @kindex i
5216 @item i
5217 Insert a new entry into the diary.  Prompts for the type of entry
5218 (day, weekly, monthly, yearly, anniversary, cyclic) and creates a new
5219 entry in the diary, just as @kbd{i d} etc. would do in the calendar.
5220 The date is taken from the cursor position.
5222 @kindex M
5223 @item M
5224 Show the phases of the moon for the three months around current date.
5226 @kindex S
5227 @item S
5228 Show sunrise and sunset times.  The geographical location must be set
5229 with calendar variables, see documentation of the Emacs calendar.
5231 @kindex C
5232 @item C
5233 Convert the date at cursor into many other cultural and historic
5234 calendars.
5236 @kindex H
5237 @item H
5238 Show holidays for three month around the cursor date.
5240 @c FIXME:  This should be a different key.
5241 @kindex C-c C-x C-c
5242 @item C-c C-x C-c
5243 Export a single iCalendar file containing entries from all agenda files.
5245 @tsubheading{Exporting to a file}
5246 @kindex C-x C-w
5247 @item C-x C-w
5248 @cindex exporting agenda views
5249 @cindex agenda views, exporting
5250 Write the agenda view to a file.  Depending on the extension of the
5251 selected file name, the view will be exported as HTML (extension
5252 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}), or
5253 plain text (any other extension).  Use the variable
5254 @code{org-agenda-exporter-settings} to set options for @file{ps-print}
5255 and for @file{htmlize} to be used during export.
5257 @tsubheading{Quit and Exit}
5258 @kindex q
5259 @item q
5260 Quit agenda, remove the agenda buffer.
5262 @kindex x
5263 @cindex agenda files, removing buffers
5264 @item x
5265 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
5266 for the compilation of the agenda.  Buffers created by the user to
5267 visit org files will not be removed.
5268 @end table
5271 @node Custom agenda views,  , Agenda commands, Agenda views
5272 @section Custom agenda views
5273 @cindex custom agenda views
5274 @cindex agenda views, custom
5276 Custom agenda commands serve two purposes: to store and quickly access
5277 frequently used TODO and tags searches, and to create special composite
5278 agenda buffers.  Custom agenda commands will be accessible through the
5279 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
5281 @menu
5282 * Storing searches::            Type once, use often
5283 * Block agenda::                All the stuff you need in a single buffer
5284 * Setting Options::             Changing the rules
5285 * Exporting Agenda Views::      Writing agendas to files.
5286 * Extracting Agenda Information for other programs::  
5287 @end menu
5289 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
5290 @subsection Storing searches
5292 The first application of custom searches is the definition of keyboard
5293 shortcuts for frequently used searches, either creating an agenda
5294 buffer, or a sparse tree (the latter covering of course only the current
5295 buffer).
5296 @kindex C-c a C
5297 Custom commands are configured in the variable
5298 @code{org-agenda-custom-commands}.  You can customize this variable, for
5299 example by pressing @kbd{C-c a C}.  You can also directly set it with
5300 Emacs Lisp in @file{.emacs}.  The following example contains all valid
5301 search types:
5303 @lisp
5304 @group
5305 (setq org-agenda-custom-commands
5306       '(("w" todo "WAITING")
5307         ("W" todo-tree "WAITING")
5308         ("u" tags "+BOSS-URGENT")
5309         ("v" tags-todo "+BOSS-URGENT")
5310         ("U" tags-tree "+BOSS-URGENT")
5311         ("f" occur-tree "\\<FIXME\\>")
5312         ("h" . "HOME+Name tags searches") ; description for "h" prefix
5313         ("hl" tags "+HOME+Lisa")
5314         ("hp" tags "+HOME+Peter")
5315         ("hk" tags "+HOME+Kim")))
5316 @end group
5317 @end lisp
5319 @noindent
5320 The initial string in each entry defines the keys you have to press
5321 after the dispatcher command @kbd{C-c a} in order to access the command.
5322 Usually this will be just a single character, but if you have many
5323 similar commands, you can also define two-letter combinations where the
5324 first character is the same in several combinations and serves as a
5325 prefix key@footnote{You can provide a description for a prefix key by
5326 inserting a cons cell with the prefix and the description.}.  The second
5327 parameter is the search type, followed by the string or regular
5328 expression to be used for the matching.  The example above will
5329 therefore define:
5331 @table @kbd
5332 @item C-c a w
5333 as a global search for TODO entries with @samp{WAITING} as the TODO
5334 keyword
5335 @item C-c a W
5336 as the same search, but only in the current buffer and displaying the
5337 results as a sparse tree
5338 @item C-c a u
5339 as a global tags search for headlines marked @samp{:BOSS:} but not
5340 @samp{:URGENT:}
5341 @item C-c a v
5342 as the same search as @kbd{C-c a u}, but limiting the search to
5343 headlines that are also TODO items
5344 @item C-c a U
5345 as the same search as @kbd{C-c a u}, but only in the current buffer and
5346 displaying the result as a sparse tree
5347 @item C-c a f
5348 to create a sparse tree (again: current buffer only) with all entries
5349 containing the word @samp{FIXME}
5350 @item C-c a h
5351 as a prefix command for a HOME tags search where you have to press an
5352 additional key (@kbd{l}, @kbd{p} or @kbd{k}) to select a name (Lisa,
5353 Peter, or Kim) as additional tag to match.
5354 @end table
5356 @node Block agenda, Setting Options, Storing searches, Custom agenda views
5357 @subsection Block agenda
5358 @cindex block agenda
5359 @cindex agenda, with block views
5361 Another possibility is the construction of agenda views that comprise
5362 the results of @emph{several} commands, each of which creates a block in
5363 the agenda buffer.  The available commands include @code{agenda} for the
5364 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
5365 for the global todo list (as constructed with @kbd{C-c a t}), and the
5366 matching commands discussed above: @code{todo}, @code{tags}, and
5367 @code{tags-todo}.  Here are two examples:
5369 @lisp
5370 @group
5371 (setq org-agenda-custom-commands
5372       '(("h" "Agenda and Home-related tasks"
5373          ((agenda)
5374           (tags-todo "HOME")
5375           (tags "GARDEN")))
5376         ("o" "Agenda and Office-related tasks"
5377          ((agenda)
5378           (tags-todo "WORK")
5379           (tags "OFFICE")))))
5380 @end group
5381 @end lisp
5383 @noindent
5384 This will define @kbd{C-c a h} to create a multi-block view for stuff
5385 you need to attend to at home.  The resulting agenda buffer will contain
5386 your agenda for the current week, all TODO items that carry the tag
5387 @samp{HOME}, and also all lines tagged with @samp{GARDEN}.  Finally the
5388 command @kbd{C-c a o} provides a similar view for office tasks.
5391 @node Setting Options, Exporting Agenda Views, Block agenda, Custom agenda views
5392 @subsection Setting Options for custom commands
5393 @cindex options, for custom agenda views
5395 Org-mode contains a number of variables regulating agenda construction
5396 and display.  The global variables define the behavior for all agenda
5397 commands, including the custom commands.  However, if you want to change
5398 some settings just for a single custom view, you can do so.  Setting
5399 options requires inserting a list of variable names and values at the
5400 right spot in @code{org-agenda-custom-commands}.  For example:
5402 @lisp
5403 @group
5404 (setq org-agenda-custom-commands
5405       '(("w" todo "WAITING"
5406          ((org-agenda-sorting-strategy '(priority-down))
5407           (org-agenda-prefix-format "  Mixed: ")))
5408         ("U" tags-tree "+BOSS-URGENT"
5409          ((org-show-following-heading nil)
5410           (org-show-hierarchy-above nil)))))
5411 @end group
5412 @end lisp
5414 @noindent
5415 Now the @kbd{C-c a w} command will sort the collected entries only by
5416 priority, and the prefix format is modified to just say @samp{  Mixed:}
5417 instead of giving the category of the entry.  The sparse tags tree of
5418 @kbd{C-c a U} will now turn out ultra-compact, because neither the
5419 headline hierarchy above the match, nor the headline following the match
5420 will be shown.
5422 For command sets creating a block agenda,
5423 @code{org-agenda-custom-commands} has two separate spots for setting
5424 options.  You can add options that should be valid for just a single
5425 command in the set, and options that should be valid for all commands in
5426 the set.  The former are just added to the command entry, the latter
5427 must come after the list of command entries.  Going back to the block
5428 agenda example (@pxref{Block agenda}), let's change the sorting strategy
5429 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
5430 the results for GARDEN tags query in the opposite order,
5431 @code{priority-up}.  This would look like this:
5433 @lisp
5434 @group
5435 (setq org-agenda-custom-commands
5436       '(("h" "Agenda and Home-related tasks"
5437          ((agenda)
5438           (tags-todo "HOME")
5439           (tags "GARDEN"
5440                 ((org-agenda-sorting-strategy '(priority-up)))))
5441          ((org-agenda-sorting-strategy '(priority-down))))
5442         ("o" "Agenda and Office-related tasks"
5443          ((agenda)
5444           (tags-todo "WORK")
5445           (tags "OFFICE")))))
5446 @end group
5447 @end lisp
5449 As you see, the values and parenthesis setting is a little complex.
5450 When in doubt, use the customize interface to set this variable - it
5451 fully supports its structure.  Just one caveat: When setting options in
5452 this interface, the @emph{values} are just lisp expressions.  So if the
5453 value is a string, you need to add the double quotes around the value
5454 yourself.
5457 @node Exporting Agenda Views, Extracting Agenda Information for other programs, Setting Options, Custom agenda views
5458 @subsection Exporting Agenda Views
5459 @cindex agenda views, exporting
5461 If you are away from your computer, it can be very useful to have a
5462 printed version of some agenda views to carry around.  Org-mode can
5463 export custom agenda views as plain text, HTML@footnote{You need to
5464 install Hrvoje Niksic' @file{htmlize.el}.} and postscript.  If you want
5465 to do this only occasionally, use the command
5467 @table @kbd
5468 @kindex C-x C-w
5469 @item C-x C-w
5470 @cindex exporting agenda views
5471 @cindex agenda views, exporting
5472 Write the agenda view to a file.  Depending on the extension of the
5473 selected file name, the view will be exported as HTML (extension
5474 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}), or
5475 plain text (any other extension).  Use the variable
5476 @code{org-agenda-exporter-settings} to set options for @file{ps-print}
5477 and for @file{htmlize} to be used during export, for example
5478 @lisp
5479 (setq org-agenda-exporter-settings
5480       '((ps-number-of-columns 2)
5481         (ps-landscape-mode t)
5482         (htmlize-output-type 'css)))
5483 @end lisp
5484 @end table
5486 If you need to export certain agenda views frequently, you can associate
5487 any custom agenda command with a list of output file names
5488 @footnote{If you want to store standard views like the weekly agenda
5489 or the global TODO list as well, you need to define custom commands for
5490 them in order to be able to specify filenames.}.  Here is an example
5491 that first does define custom commands for the agenda and the global
5492 todo list, together with a number of files to which to export them.
5493 Then we define two block agenda commands and specify filenames for them
5494 as well.  File names can be relative to the current working directory,
5495 or absolute.
5497 @lisp
5498 @group
5499 (setq org-agenda-custom-commands
5500       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
5501         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
5502         ("h" "Agenda and Home-related tasks"
5503          ((agenda)
5504           (tags-todo "HOME")
5505           (tags "GARDEN"))
5506          nil
5507          ("~/views/home.html"))
5508         ("o" "Agenda and Office-related tasks"
5509          ((agenda)
5510           (tags-todo "WORK")
5511           (tags "OFFICE"))
5512          nil
5513          ("~/views/office.ps"))))
5514 @end group
5515 @end lisp
5517 The extension of the file name determines the type of export.  If it is
5518 @file{.html}, Org-mode will use the @file{htmlize.el} package to convert
5519 the buffer to HTML and save it to this file name.  If the extension is
5520 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
5521 postscript output.  Any other extension produces a plain ASCII file.
5523 The export files are @emph{not} created when you use one of those
5524 commands interactively.  Instead, there is a special command to produce
5525 @emph{all} specified files in one step:
5527 @table @kbd
5528 @kindex C-c a e
5529 @item C-c a e
5530 Export all agenda views that have export filenames associated with
5531 them.
5532 @end table
5534 You can use the options section of the custom agenda commands to also
5535 set options for the export commands.  For example:
5537 @lisp
5538 (setq org-agenda-custom-commands
5539       '(("X" agenda ""
5540          ((ps-number-of-columns 2)
5541           (ps-landscape-mode t)
5542           (org-agenda-prefix-format " [ ] ")
5543           (org-agenda-with-colors nil)
5544           (org-agenda-remove-tags t))
5545          ("theagenda.ps"))))
5546 @end lisp
5548 @noindent
5549 This command sets two options for the postscript exporter, to make it
5550 print in two columns in landscape format - the resulting page can be cut
5551 in two and then used in a paper agenda.  The remaining settings modify
5552 the agenda prefix to omit category and scheduling information, and
5553 instead include a checkbox to check off items.  We also remove the tags
5554 to make the lines compact, and we don't want to use colors for the
5555 black-and-white printer.  Settings specified in
5556 @code{org-agenda-exporter-settings} will also apply, but the settings
5557 in @code{org-agenda-custom-commands} take precedence.
5559 @noindent
5560 From the command line you may also use
5561 @example
5562 emacs -f org-batch-store-agenda-views -kill
5563 @end example
5564 @noindent
5565 or, if you need to modify some parameters
5566 @example
5567 emacs -eval '(org-batch-store-agenda-views                      \
5568               org-agenda-ndays 30                               \
5569               org-agenda-include-diary nil                      \
5570               org-agenda-files (quote ("~/org/project.org")))'  \
5571       -kill
5572 @end example
5573 @noindent
5574 which will create the agenda views restricted to the file
5575 @file{~/org/project.org}, without diary entries and with 30 days
5576 extent. 
5578 @node Extracting Agenda Information for other programs,  , Exporting Agenda Views, Custom agenda views
5579 @subsection Extracting Agenda Information for other programs
5580 @cindex agenda, pipe
5581 @cindex Scripts, for agenda processing
5583 Org-mode provides commands to access agenda information for the command
5584 line in emacs batch mode.  This extracted information can be sent
5585 directly to a printer, or it can be read by a program that does further
5586 processing of the data.  The first of these commands is the function
5587 @code{org-batch-agenda}, that produces an agenda view and sends it as
5588 ASCII text to STDOUT.  The command takes a single string as parameter.
5589 If the string has length 1, it is used as a key to one of the commands
5590 you have configured in @code{org-agenda-custom-commands}, basically any
5591 key you can use after @kbd{C-c a}.  For example, to directly print the
5592 current TODO list, you could use
5594 @example
5595 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
5596 @end example
5598 If the parameter is a string with 2 or more characters, it is used as a
5599 tags/todo match string.  For example, to print your local shopping list
5600 (all items with the tag @samp{shop}, but excluding the tag
5601 @samp{NewYork}), you could use
5603 @example
5604 emacs -batch -l ~/.emacs                                      \       
5605       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
5606 @end example
5608 @noindent
5609 You may also modify parameters on the fly like this:
5611 @example
5612 emacs -batch -l ~/.emacs                                      \
5613    -eval '(org-batch-agenda "a"                               \
5614             org-agenda-ndays 30                               \
5615             org-agenda-include-diary nil                      \
5616             org-agenda-files (quote ("~/org/project.org")))'  \
5617    | lpr
5618 @end example
5620 @noindent
5621 which will produce a 30 day agenda, fully restricted to the Org file
5622 @file{~/org/projects.org}, not even including the diary.
5624 If you want to process the agenda data in more sophisticated ways, you
5625 can use the command @code{org-batch-agenda-csv} to get a comma-separated
5626 list of values for each agenda item.  Each line in the output will
5627 contain a number of fields separated by commas.  The fields in a line
5628 are:
5630 @example
5631 category     @r{The category of the item}
5632 head         @r{The headline, without TODO kwd, TAGS and PRIORITY}
5633 type         @r{The type of the agenda entry, can be}
5634                 todo               @r{selected in TODO match}
5635                 tagsmatch          @r{selected in tags match}
5636                 diary              @r{imported from diary}
5637                 deadline           @r{a deadline}
5638                 scheduled          @r{scheduled}
5639                 timestamp          @r{appointment, selected by timestamp}
5640                 closed             @r{entry was closed on date}
5641                 upcoming-deadline  @r{warning about nearing deadline}
5642                 past-scheduled     @r{forwarded scheduled item}
5643                 block              @r{entry has date block including date}
5644 todo         @r{The todo keyword, if any}
5645 tags         @r{All tags including inherited ones, separated by colons}
5646 date         @r{The relevant date, like 2007-2-14}
5647 time         @r{The time, like 15:00-16:50}
5648 extra        @r{String with extra planning info}
5649 priority-l   @r{The priority letter if any was given}
5650 priority-n   @r{The computed numerical priority}
5651 @end example
5653 @noindent
5654 Time and date will only be given if a timestamp (or deadline/scheduled)
5655 lead to the selection of the item.
5657 A CSV list like this is very easy to use in a post processing script.
5658 For example, here is a Perl program that gets the TODO list from
5659 Emacs/org-mode and prints all the items, preceded by a checkbox:
5661 @example
5662 @group
5663 #!/usr/bin/perl
5665 # define the Emacs command to run
5666 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
5668 # run it and capture the output
5669 $agenda = qx@{$cmd 2>/dev/null@};
5671 # loop over all lines
5672 foreach $line (split(/\n/,$agenda)) @{
5674   # get the individual values
5675   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
5676    $priority_l,$priority_n) = split(/,/,$line);
5678   # proccess and print
5679   print "[ ] $head\n";
5681 @end group
5682 @end example
5684 @node Embedded LaTeX, Exporting, Agenda views, Top
5685 @chapter Embedded LaTeX
5686 @cindex @TeX{} interpretation
5687 @cindex La@TeX{} interpretation
5689 Plain ASCII is normally sufficient for almost all note taking.  One
5690 exception, however, are scientific notes which need to be able to
5691 contain mathematical symbols and the occasional formula.
5692 La@TeX{}@footnote{La@TeX{} is a macro system based on Donald E. Knuth's
5693 @TeX{} system.  Many of the features described here as ``La@TeX{}'' are
5694 really from @TeX{}, but for simplicity I am blurring this distinction.}
5695 is widely used to typeset scientific documents. Org-mode supports
5696 embedding La@TeX{} code into its files, because many academics are used
5697 to read La@TeX{} source code, and because it can be readily processed
5698 into images for HTML production.
5700 It is not necessary to mark La@TeX{} macros and code in any special way.
5701 If you observe a few conventions, Org-mode knows how to find it and what
5702 to do with it.
5704 @menu
5705 * Math symbols::                TeX macros for symbols and Greek letters
5706 * Subscripts and Superscripts::  Simple syntax for raising/lowering text
5707 * LaTeX fragments::             Complex formulas made easy
5708 * Processing LaTeX fragments::  Previewing LaTeX processing
5709 * CDLaTeX mode::                Speed up entering of formulas
5710 @end menu
5712 @node Math symbols, Subscripts and Superscripts, Embedded LaTeX, Embedded LaTeX
5713 @section Math symbols
5714 @cindex math symbols
5715 @cindex TeX macros
5717 You can use La@TeX{} macros to insert special symbols like @samp{\alpha}
5718 to indicate the Greek letter, or @samp{\to} to indicate an arrow.
5719 Completion for these macros is available, just type @samp{\} and maybe a
5720 few letters, and press @kbd{M-@key{TAB}} to see possible completions.
5721 Unlike La@TeX{} code, Org-mode allows these macros to be present
5722 without surrounding math delimiters, for example:
5724 @example
5725 Angles are written as Greek letters \alpha, \beta and \gamma.
5726 @end example
5728 During HTML export (@pxref{HTML export}), these symbols are translated
5729 into the proper syntax for HTML, for the above examples this is
5730 @samp{&alpha;} and @samp{&rarr;}, respectively.
5732 @node Subscripts and Superscripts, LaTeX fragments, Math symbols, Embedded LaTeX
5733 @section Subscripts and Superscripts
5734 @cindex subscript
5735 @cindex superscript
5737 Just like in La@TeX{}, @samp{^} and @samp{_} are used to indicate super-
5738 and subscripts.  Again, these can be used without embedding them in
5739 math-mode delimiters.  To increase the readability of ASCII text, it is
5740 not necessary (but OK) to surround multi-character sub- and superscripts
5741 with curly braces.  For example
5743 @example
5744 The mass if the sun is M_sun = 1.989 x 10^30 kg.  The radius of
5745 the sun is R_@{sun@} = 6.96 x 10^8 m.
5746 @end example
5748 To avoid interpretation as raised or lowered text, you can quote
5749 @samp{^} and @samp{_} with a backslash: @samp{\_} and @samp{\^}.
5751 During HTML export (@pxref{HTML export}), subscript and superscripts
5752 are surrounded with @code{<sub>} and @code{<sup>} tags, respectively.
5754 @node LaTeX fragments, Processing LaTeX fragments, Subscripts and Superscripts, Embedded LaTeX
5755 @section LaTeX fragments
5756 @cindex LaTeX fragments
5758 With symbols, sub- and superscripts, HTML is pretty much at its end when
5759 it comes to representing mathematical formulas@footnote{Yes, there is
5760 MathML, but that is not yet fully supported by many browsers, and there
5761 is no decent converter for turning La@TeX{} or ASCII representations of
5762 formulas into MathML. So for the time being, converting formulas into
5763 images seems the way to go.}. More complex expressions need a dedicated
5764 formula processor. To this end, Org-mode can contain arbitrary La@TeX{}
5765 fragments. It provides commands to preview the typeset result of these
5766 fragments, and upon export to HTML, all fragments will be converted to
5767 images and inlined into the HTML document@footnote{The La@TeX{} export
5768 will not use images for displaying La@TeX{} fragments but include these
5769 fragments directly into the La@TeX{} code.}. For this to work you
5770 need to be on a system with a working La@TeX{} installation. You also
5771 need the @file{dvipng} program, available at
5772 @url{http://sourceforge.net/projects/dvipng/}. The La@TeX{} header that
5773 will be used when processing a fragment can be configured with the
5774 variable @code{org-format-latex-header}.
5776 La@TeX{} fragments don't need any special marking at all.  The following
5777 snippets will be identified as La@TeX{} source code:
5778 @itemize @bullet
5779 @item
5780 Environments of any kind.  The only requirement is that the
5781 @code{\begin} statement appears on a new line, preceded by only
5782 whitespace.
5783 @item
5784 Text within the usual La@TeX{} math delimiters.  To avoid conflicts with
5785 currency specifications, single @samp{$} characters are only recognized
5786 as math delimiters if the enclosed text contains at most two line breaks,
5787 is directly attached to the @samp{$} characters with no whitespace in
5788 between, and if the closing @samp{$} is followed by whitespace or
5789 punctuation.  For the other delimiters, there is no such restriction, so
5790 when in doubt, use @samp{\(...\)} as inline math delimiters.
5791 @end itemize
5793 @noindent For example:
5795 @example
5796 \begin@{equation@}                          % arbitrary environments,
5797 x=\sqrt@{b@}                                % even tables, figures
5798 \end@{equation@}                            % etc
5800 If $a^2=b$ and \( b=2 \), then the solution must be
5801 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
5802 @end example
5804 @noindent
5805 If you need any of the delimiter ASCII sequences for other purposes, you
5806 can configure the option @code{org-format-latex-options} to deselect the
5807 ones you do not wish to have interpreted by the La@TeX{} converter.
5809 @node Processing LaTeX fragments, CDLaTeX mode, LaTeX fragments, Embedded LaTeX
5810 @section Processing LaTeX fragments
5811 @cindex LaTeX fragments, preview
5813 La@TeX{} fragments can be processed to produce a preview images of the
5814 typeset expressions:
5816 @table @kbd
5817 @kindex C-c C-x C-l
5818 @item C-c C-x C-l
5819 Produce a preview image of the La@TeX{} fragment at point and overlay it
5820 over the source code.  If there is no fragment at point, process all
5821 fragments in the current entry (between two headlines).  When called
5822 with a prefix argument, process the entire subtree.  When called with
5823 two prefix arguments, or when the cursor is before the first headline,
5824 process the entire buffer.
5825 @kindex C-c C-c
5826 @item C-c C-c
5827 Remove the overlay preview images.
5828 @end table
5830 During HTML export (@pxref{HTML export}), all La@TeX{} fragments are
5831 converted into images and inlined into the document if the following
5832 setting is active:
5834 @lisp
5835 (setq org-export-with-LaTeX-fragments t)
5836 @end lisp
5838 @node CDLaTeX mode,  , Processing LaTeX fragments, Embedded LaTeX
5839 @section Using CDLaTeX to enter math
5840 @cindex CDLaTeX
5842 CDLaTeX-mode is a minor mode that is normally used in combination with a
5843 major La@TeX{} mode like AUCTeX in order to speed-up insertion of
5844 environments and math templates.  Inside Org-mode, you can make use of
5845 some of the features of cdlatex-mode.  You need to install
5846 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
5847 AUCTeX) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
5848 Don't turn cdlatex-mode itself under Org-mode, but use the light
5849 version @code{org-cdlatex-mode} that comes as part of Org-mode.  Turn it
5850 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
5851 Org-mode files with
5853 @lisp
5854 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
5855 @end lisp
5857 When this mode is enabled, the following features are present (for more
5858 details see the documentation of cdlatex-mode):
5859 @itemize @bullet
5860 @kindex C-c @{
5861 @item
5862 Environment templates can be inserted with @kbd{C-c @{}.
5863 @item
5864 @kindex @key{TAB}
5865 The @key{TAB} key will do template expansion if the cursor is inside a
5866 La@TeX{} fragment@footnote{Org-mode has a method to test if the cursor is
5867 inside such a fragment, see the documentation of the function
5868 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
5869 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
5870 correctly inside the first brace.  Another @key{TAB} will get you into
5871 the second brace.  Even outside fragments, @key{TAB} will expand
5872 environment abbreviations at the beginning of a line.  For example, if
5873 you write @samp{equ} at the beginning of a line and press @key{TAB},
5874 this abbreviation will be expanded to an @code{equation} environment.
5875 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
5876 @item
5877 @kindex _
5878 @kindex ^
5879 Pressing @kbd{_} and @kbd{^} inside a La@TeX{} fragment will insert these
5880 characters together with a pair of braces.  If you use @key{TAB} to move
5881 out of the braces, and if the braces surround only a single character or
5882 macro, they are removed again (depending on the variable
5883 @code{cdlatex-simplify-sub-super-scripts}).
5884 @item
5885 @kindex `
5886 Pressing the backquote @kbd{`} followed by a character inserts math
5887 macros, also outside La@TeX{} fragments.  If you wait more than 1.5 seconds
5888 after the backquote, a help window will pop up.
5889 @item
5890 @kindex '
5891 Pressing the normal quote @kbd{'} followed by another character modifies
5892 the symbol before point with an accent or a font.  If you wait more than
5893 1.5 seconds after the backquote, a help window will pop up.  Character
5894 modification will work only inside La@TeX{} fragments, outside the quote
5895 is normal.
5896 @end itemize
5898 @node Exporting, Publishing, Embedded LaTeX, Top
5899 @chapter Exporting
5900 @cindex exporting
5902 Org-mode documents can be exported into a variety of other formats.  For
5903 printing and sharing of notes, ASCII export produces a readable and
5904 simple version of an Org-mode file.  HTML export allows you to publish a
5905 notes file on the web, while the XOXO format provides a solid base for
5906 exchange with a broad range of other applications. La@TeX{} export lets
5907 you use Org-mode and its structured editing functions to easily create
5908 La@TeX{} files.  To incorporate entries with associated times like
5909 deadlines or appointments into a desktop calendar program like iCal,
5910 Org-mode can also produce extracts in the iCalendar format.  Currently
5911 Org-mode only supports export, not import of these different formats.
5913 When exporting, Org-mode uses special conventions to enrich the output
5914 produced.  @xref{Text interpretation}, for more details.
5916 @table @kbd
5917 @kindex C-c C-e
5918 @item C-c C-e
5919 Dispatcher for export and publishing commands.  Displays a help-window
5920 listing the additional key(s) needed to launch an export or publishing
5921 command.
5922 @end table
5924 @menu
5925 * ASCII export::                Exporting to plain ASCII
5926 * HTML export::                 Exporting to HTML
5927 * LaTeX export::                Exporting to LaTeX
5928 * XOXO export::                 Exporting to XOXO
5929 * iCalendar export::            Exporting in iCalendar format
5930 * Text interpretation::         How the exporter looks at the file
5931 @end menu
5933 @node ASCII export, HTML export, Exporting, Exporting
5934 @section ASCII export
5935 @cindex ASCII export
5937 ASCII export produces a simple and very readable version of an Org-mode
5938 file.
5940 @cindex region, active
5941 @cindex active region
5942 @cindex transient-mark-mode
5943 @table @kbd
5944 @kindex C-c C-e a
5945 @item C-c C-e a
5946 Export as ASCII file.  For an org file @file{myfile.org}, the ASCII file
5947 will be @file{myfile.txt}.  The file will be overwritten without
5948 warning.  If there is an active region, only the region will be
5949 exported. If the selected region is a single tree, the tree head will
5950 become the document title.  If the tree head entry has or inherits an
5951 EXPORT_FILE_NAME property, that name will be used for the export.
5952 @kindex C-c C-e v a
5953 @item C-c C-e v a
5954 Export only the visible part of the document.
5955 @end table
5957 @cindex headline levels, for exporting
5958 In the exported version, the first 3 outline levels will become
5959 headlines, defining a general document structure.  Additional levels
5960 will be exported as itemized lists.  If you want that transition to occur
5961 at a different level, specify it with a prefix argument.  For example,
5963 @example
5964 @kbd{C-1 C-c C-e a}
5965 @end example
5967 @noindent
5968 creates only top level headlines and does the rest as items.  When
5969 headlines are converted to items, the indentation of the text following
5970 the headline is changed to fit nicely under the item.  This is done with
5971 the assumption that the first bodyline indicates the base indentation of
5972 the body text.  Any indentation larger than this is adjusted to preserve
5973 the layout relative to the first line.  Should there be lines with less
5974 indentation than the first, these are left alone.
5976 @node HTML export, LaTeX export, ASCII export, Exporting
5977 @section HTML export
5978 @cindex HTML export
5980 Org-mode contains an HTML (XHTML 1.0 strict) exporter with extensive
5981 HTML formatting, in ways similar to John Grubers @emph{markdown}
5982 language, but with additional support for tables.
5984 @menu
5985 * HTML Export commands::        How to invoke LaTeX export
5986 * Quoting HTML tags::           Using direct HTML in Org-mode
5987 * Links::                       Transformation of links for HTML
5988 * Images::                      How to include images
5989 * CSS support::                 Changing the appearence of the output
5990 @end menu
5992 @node HTML Export commands, Quoting HTML tags, HTML export, HTML export
5993 @subsection HTML export commands
5995 @cindex region, active
5996 @cindex active region
5997 @cindex transient-mark-mode
5998 @table @kbd
5999 @kindex C-c C-e h
6000 @item C-c C-e h
6001 Export as HTML file @file{myfile.html}.  For an org file
6002 @file{myfile.org}, the ASCII file will be @file{myfile.html}.  The file
6003 will be overwritten without warning.  If there is an active region, only
6004 the region will be exported. If the selected region is a single tree,
6005 the tree head will become the document title.  If the tree head entry
6006 has or inherits an EXPORT_FILE_NAME property, that name will be used for
6007 the export.
6008 @kindex C-c C-e b
6009 @item C-c C-e b
6010 Export as HTML file and immediately open it with a browser.
6011 @kindex C-c C-e H
6012 @item C-c C-e H
6013 Export to a temporary buffer, do not create a file.
6014 @kindex C-c C-e R
6015 @item C-c C-e H
6016 Export the active region to a temporary buffer.  With prefix arg, do not
6017 produce file header and foot, but just the plain HTML section for the
6018 region.  This is good for cut-and-paste operations.
6019 @kindex C-c C-e v h
6020 @kindex C-c C-e v b
6021 @kindex C-c C-e v H
6022 @kindex C-c C-e v R
6023 @item C-c C-e v h
6024 @item C-c C-e v b
6025 @item C-c C-e v H
6026 @item C-c C-e v R
6027 Export only the visible part of the document.
6028 @item M-x org-export-region-as-html
6029 Convert the region to HTML under the assumption that it was org-mode
6030 syntax before.  This is a global command that can be invoked in any
6031 buffer.
6032 @item M-x org-replace-region-by-HTML
6033 Replace the active region (assumed to be in Org-mode syntax) by HTML
6034 code.
6035 @end table
6037 @cindex headline levels, for exporting
6038 In the exported version, the first 3 outline levels will become
6039 headlines, defining a general document structure.  Additional levels
6040 will be exported as itemized lists.  If you want that transition to occur
6041 at a different level, specify it with a prefix argument.  For example,
6043 @example
6044 @kbd{C-2 C-c C-e b}
6045 @end example
6047 @noindent
6048 creates two levels of headings and does the rest as items.
6050 @node Quoting HTML tags, Links, HTML Export commands, HTML export
6051 @subsection Quoting HTML tags
6053 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
6054 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
6055 which should be interpreted as such, mark them with @samp{@@} as in
6056 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
6057 simple tags.  For more extensive HTML that should be copied verbatim to
6058 the exported file use either
6060 @example
6061 #+HTML: Literal HTML code for export
6062 @end example
6064 @noindent or
6066 @example
6067 #+BEGIN_HTML
6068 All lines between these markers are exported literally
6069 #+END_HTML
6070 @end example
6073 @node Links, Images, Quoting HTML tags, HTML export
6074 @subsection Links
6076 @cindex links, in HTML export
6077 @cindex internal links, in HTML export
6078 @cindex external links, in HTML export
6079 Internal links (@pxref{Internal links}) will continue to work in HTML
6080 files only if they match a dedicated @samp{<<target>>}.  Automatic links
6081 created by radio targets (@pxref{Radio targets}) will also work in the
6082 HTML file.  Links to external files will still work if the HTML file is
6083 in the same directory as the Org-mode file.  Links to other @file{.org}
6084 files will be translated into HTML links under the assumption that an
6085 HTML version also exists of the linked file.  For information related to
6086 linking files while publishing them to a publishing directory see
6087 @ref{Publishing links}.
6089 @node Images, CSS support, Links, HTML export
6090 @subsection Images
6092 @cindex images, inline in HTML
6093 @cindex inlining images in HTML
6094 HTML export can inline images given as links in the Org-mode file, and
6095 it can make an image the clickable part of a link.  By
6096 default@footnote{but see the variable
6097 @code{org-export-html-inline-images}}, images are inlined if a link does
6098 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
6099 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
6100 @samp{the image} that points to the image.  If the description part
6101 itself is a @code{file:} link or a @code{http:} URL pointing to an
6102 image, this image will be inlined and activated so that clicking on the
6103 image will activate the link.  For example, to include a thumbnail that
6104 will link to a high resolution version of the image, you could use:
6106 @example
6107 [[file:highres.jpg][file:thumb.jpg]]
6108 @end example
6110 @noindent
6111 and you could use @code{http} addresses just as well.
6113 @node CSS support,  , Images, HTML export
6114 @subsection CSS support
6116 You can also give style information for the exported file.  The HTML
6117 exporter assigns the following CSS classes to appropriate parts of the
6118 document - your style specifications may change these:
6119 @example
6120 .todo           @r{TODO keywords}
6121 .done           @r{the DONE keyword}
6122 .timestamp      @r{time stamp}
6123 .timestamp-kwd  @r{keyword associated with a time stamp, like SCHEDULED}
6124 .tag            @r{tag in a headline}
6125 .target         @r{target for links}
6126 @end example
6128 The default style specification can be configured through the option
6129 @code{org-export-html-style}.  If you want to use a file-local style,
6130 you may use file variables, best wrapped into a COMMENT section at the
6131 end of the outline tree.  For example@footnote{Under Emacs 21, the
6132 continuation lines for a variable value should have no @samp{#} at the
6133 start of the line.}:
6135 @example
6136 * COMMENT html style specifications
6138 # Local Variables:
6139 # org-export-html-style: "   <style type=\"text/css\">
6140 #       p @{font-weight: normal; color: gray; @}
6141 #       h1 @{color: black; @}
6142 #   </style>"
6143 # End:
6144 @end example
6146 Remember to execute @kbd{M-x normal-mode} after changing this to make
6147 the new style visible to Emacs.  This command restarts org-mode for the
6148 current buffer and forces Emacs to re-evaluate the local variables
6149 section in the buffer.
6151 @c FIXME: More about header and footer styles
6152 @c FIXME: Talk about links and targets.
6154 @node LaTeX export, XOXO export, HTML export, Exporting
6155 @section LaTeX export
6156 @cindex LaTeX export
6158 Org-mode contains a La@TeX{} exporter written by Bastien Guerry.
6160 @menu
6161 * LaTeX export commands::       How to invoke LaTeX export
6162 * Quoting LaTeX code::          Incorporating literal LaTeX code
6163 @end menu
6165 @node LaTeX export commands, Quoting LaTeX code, LaTeX export, LaTeX export
6166 @subsection LaTeX export commands
6168 @table @kbd
6169 @kindex C-c C-e l
6170 @item C-c C-e l
6171 Export as La@TeX{} file @file{myfile.tex}.
6172 @kindex C-c C-e L
6173 @item C-c C-e L
6174 Export to a temporary buffer, do not create a file.
6175 @kindex C-c C-e v l
6176 @kindex C-c C-e v L
6177 @item C-c C-e v l
6178 @item C-c C-e v L
6179 Export only the visible part of the document.
6180 @item M-x org-export-region-as-latex
6181 Convert the region to La@TeX{} under the assumption that it was org-mode
6182 syntax before.  This is a global command that can be invoked in any
6183 buffer.
6184 @item M-x org-replace-region-by-latex
6185 Replace the active region (assumed to be in Org-mode syntax) by La@TeX{}
6186 code.
6187 @end table
6189 @cindex headline levels, for exporting
6190 In the exported version, the first 3 outline levels will become
6191 headlines, defining a general document structure.  Additional levels
6192 will be exported as description lists.  The exporter can ignore them or
6193 convert them to a custom string depending on
6194 @code{org-latex-low-levels}.
6196 If you want that transition to occur at a different level, specify it
6197 with a prefix argument. For example,
6199 @example
6200 @kbd{C-2 C-c C-e l}
6201 @end example
6203 @noindent
6204 creates two levels of headings and does the rest as items.
6206 @node Quoting LaTeX code,  , LaTeX export commands, LaTeX export
6207 @subsection Quoting LaTeX code
6209 Embedded La@TeX{} as described in @ref{Embedded LaTeX} will be correctly
6210 inserted into the La@TeX{} file.  Forthermore, you can add special code
6211 that should only be present in La@TeX{} export with the following
6212 constructs:
6214 @example
6215 #+LaTeX: Literal LaTeX code for export
6216 @end example
6218 @noindent or
6220 @example
6221 #+BEGIN_LaTeX
6222 All lines between these markers are exported literally
6223 #+END_LaTeX
6224 @end example
6225 @node XOXO export, iCalendar export, LaTeX export, Exporting
6226 @section XOXO export
6227 @cindex XOXO export
6229 Org-mode contains an exporter that produces XOXO-style output.
6230 Currently, this exporter only handles the general outline structure and
6231 does not interpret any additional Org-mode features.
6233 @table @kbd
6234 @kindex C-c C-e x
6235 @item C-c C-e x
6236 Export as XOXO file @file{myfile.html}.
6237 @kindex C-c C-e v
6238 @item C-c C-e v x
6239 Export only the visible part of the document.
6240 @end table
6242 @node iCalendar export, Text interpretation, XOXO export, Exporting
6243 @section iCalendar export
6244 @cindex iCalendar export
6246 Some people like to use Org-mode for keeping track of projects, but
6247 still prefer a standard calendar application for anniversaries and
6248 appointments.  In this case it can be useful to have deadlines and
6249 other time-stamped items in Org-mode files show up in the calendar
6250 application.  Org-mode can export calendar information in the standard
6251 iCalendar format.  If you also want to have TODO entries included in the
6252 export, configure the variable @code{org-icalendar-include-todo}.
6254 @table @kbd
6255 @kindex C-c C-e i
6256 @item C-c C-e i
6257 Create iCalendar entries for the current file and store them in the same
6258 directory, using a file extension @file{.ics}.
6259 @kindex C-c C-e I
6260 @item C-c C-e I
6261 Like @kbd{C-c C-e i}, but do this for all files in
6262 @code{org-agenda-files}.  For each of these files, a separate iCalendar
6263 file will be written.
6264 @kindex C-c C-e c
6265 @item C-c C-e c
6266 Create a single large iCalendar file from all files in
6267 @code{org-agenda-files} and write it to the file given by
6268 @code{org-combined-agenda-icalendar-file}.
6269 @end table
6271 The export will honor SUMMARY, DESCRIPTION and LOCATION properties if
6272 the selected entries have them.  If not, the summary will be derived
6273 from the headline, and the description from the body (limited to
6274 @code{org-icalendar-include-body} characters).  
6276 How this calendar is best read and updated, depends on the application
6277 you are using.  The FAQ covers this issue.
6280 @node Text interpretation,  , iCalendar export, Exporting
6281 @section Text interpretation by the exporter
6283 The exporter backends interpret additional structure in the Org-mode file
6284 in order to produce better output.
6286 @menu
6287 * Comment lines::               Some lines will not be exported
6288 * Initial text::                Text before the first headline
6289 * Footnotes::                   Numbers like [1]
6290 * Enhancing text::              Subscripts, symbols and more
6291 * Export options::              How to influence the export settings
6292 @end menu
6294 @node Comment lines, Initial text, Text interpretation, Text interpretation
6295 @subsection Comment lines
6296 @cindex comment lines
6297 @cindex exporting, not
6299 Lines starting with @samp{#} in column zero are treated as comments
6300 and will never be exported.  Also entire subtrees starting with the
6301 word @samp{COMMENT} will never be exported.
6303 @table @kbd
6304 @kindex C-c ;
6305 @item C-c ;
6306 Toggle the COMMENT keyword at the beginning of an entry.
6307 @end table
6309 @node Initial text, Footnotes, Comment lines, Text interpretation
6310 @subsection Text before the first headline
6312 Org-mode normally ignores any text before the first headline when
6313 exporting, leaving this region for internal links to speed up navigation
6314 etc.  However, in publishing-oriented files, you might want to have some
6315 text before the first headline, like a small introduction, special HTML
6316 code with a navigation bar, etc.  You can ask to have this part of the
6317 file exported as well by setting the variable
6318 @code{org-export-skip-text-before-1st-heading} to @code{nil}.  On a
6319 per-file basis, you can get the same effect with
6321 @example
6322 #+OPTIONS: skip:nil
6323 @end example
6325 The text before the first headline will be fully processed
6326 (@pxref{Enhancing text}), and the first non-comment line becomes the
6327 title of the exported document.  If you need to include literal HTML,
6328 use the special constructs described in @ref{Quoting HTML tags}.  The
6329 table of contents is normally inserted directly before the first
6330 headline of the file.  If you would like to get it to a different
6331 location, insert the string @code{[TABLE-OF-CONTENTS]} on a line by
6332 itself at the desired location.
6334 Finally, if you want to use the space before the first headline for
6335 internal purposes, but @emph{still} want to place something before the
6336 first headline when exporting the file, you can use the @code{#+TEXT}
6337 construct:
6339 @example
6340 #+OPTIONS: skip:t
6341 #+TEXT: This text will go before the *first* headline.
6342 #+TEXT: We place the table of contents here:
6343 #+TEXT: [TABLE-OF-CONTENTS]
6344 #+TEXT: This goes between the table of contents and the first headline
6345 @end example
6347 @node Footnotes, Enhancing text, Initial text, Text interpretation
6348 @subsection Footnotes
6349 @cindex footnotes
6350 @cindex @file{footnote.el}
6352 Numbers in square brackets are treated as footnotes, so that you can use
6353 the Emacs package @file{footnote.el} to create footnotes.  For example:
6355 @example
6356 The org-mode homepage[1] clearly needs help from
6357 a good web designer.
6359 [1] The link is: http://orgmode.org
6360 @end example
6362 @noindent
6363 @kindex C-c !
6364 Note that the @file{footnote} package uses @kbd{C-c !} to invoke its
6365 commands.  This binding conflicts with the org-mode command for
6366 inserting inactive time stamps.  You could use the variable
6367 @code{footnote-prefix} to switch footnotes commands to another key.  Or,
6368 if you are too used to this binding, you could use
6369 @code{org-replace-disputed-keys} and @code{org-disputed-keys} to change
6370 the settings in Org-mode.
6372 @node Enhancing text, Export options, Footnotes, Text interpretation
6373 @subsection Enhancing text for export
6374 @cindex enhancing text
6375 @cindex richer text
6377 Some of the export backends of Org-mode allow for sophisticated text
6378 formatting, this is true in particular for the HTML and La@TeX{}
6379 backends. Org-mode has a number of typing conventions that allow to
6380 produce a richly formatted output.
6382 @itemize @bullet
6384 @cindex hand-formatted lists
6385 @cindex lists, hand-formatted
6386 @item
6387 Plain lists @samp{-}, @samp{*} or @samp{+} as bullet, or with @samp{1.}
6388 or @samp{2)} as enumerator will be recognized and transformed if the
6389 backend supports lists.  See @xref{Plain lists}.
6391 @cindex underlined text
6392 @cindex bold text
6393 @cindex italic text
6394 @item
6395 You can make words @b{*bold*}, @i{/italic/}, _underlined_,
6396 @code{=code=}, and even @samp{+strikethrough+}@footnote{but remember
6397 that strikethrough is typographically evil and should @i{never} be
6398 used.}.
6400 @cindex horizontal rules, in exported files
6401 @item
6402 A line consisting of only dashes, and at least 5 of them, will be
6403 exported as a horizontal line (@samp{<hr/>} in HTML).
6405 @cindex LaTeX fragments, export
6406 @cindex TeX macros, export
6407 @item
6408 Many @TeX{} macros and entire La@TeX{} fragments are converted into HTML
6409 entities or images (@pxref{Embedded LaTeX}).
6411 @cindex tables, export
6412 @item
6413 Tables are transformed into native tables under the exporter, if the
6414 export backend supports this. Data fields before the first horizontal
6415 separator line will be formatted as table header fields.
6417 @cindex fixed width
6418 @item
6419 If a headline starts with the word @samp{QUOTE}, the text below the
6420 headline will be typeset as fixed-width, to allow quoting of computer
6421 codes etc.  Lines starting with @samp{:} are also typeset in fixed-width
6422 font. 
6423 @table @kbd
6424 @kindex C-c :
6425 @item C-c :
6426 Toggle fixed-width for entry (QUOTE) or region, see below.
6427 @end table
6429 @cindex linebreak, forced
6430 @item 
6431 A double backslash @emph{at the end of a line} enforces a line break at
6432 this position.
6433 @end itemize
6435 If these conversions conflict with your habits of typing ASCII text,
6436 they can all be turned off with corresponding variables.  See the
6437 customization group @code{org-export-general}, and the following section
6438 which explains how to set export options with special lines in a
6439 buffer.
6442 @node Export options,  , Enhancing text, Text interpretation
6443 @subsection Export options
6444 @cindex options, for export
6446 @cindex completion, of option keywords
6447 The exporter recognizes special lines in the buffer which provide
6448 additional information.  These lines may be put anywhere in the file.
6449 The whole set of lines can be inserted into the buffer with @kbd{C-c
6450 C-e t}.  For individual lines, a good way to make sure the keyword is
6451 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
6452 (@pxref{Completion}).
6454 @table @kbd
6455 @kindex C-c C-e t
6456 @item C-c C-e t
6457 Insert template with export options, see example below.
6458 @end table
6460 @example
6461 #+TITLE:     the title to be shown (default is the buffer name)
6462 #+AUTHOR:    the author (default taken from @code{user-full-name})
6463 #+DATE:      A date, fixed, of a format string for @code{format-time-string}
6464 #+EMAIL:     his/her email address (default from @code{user-mail-address})
6465 #+LANGUAGE:  language for HTML, e.g. @samp{en} (@code{org-export-default-language})
6466 #+TEXT:      Some descriptive text to be inserted at the beginning.
6467 #+TEXT:      Several lines may be given.
6468 #+OPTIONS:   H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
6469 @end example
6471 @noindent
6472 The OPTIONS line is a compact form to specify export settings.  Here
6473 you can:
6474 @cindex headline levels
6475 @cindex section-numbers
6476 @cindex table of contents
6477 @cindex linebreak preservation
6478 @cindex quoted HTML tags
6479 @cindex fixed-width sections
6480 @cindex tables
6481 @cindex @TeX{}-like syntax for sub- and superscripts
6482 @cindex footnotes
6483 @cindex emphasized text
6484 @cindex @TeX{} macros
6485 @cindex La@TeX{} fragments
6486 @cindex author info, in export
6487 @cindex time info, in export
6488 @example
6489 H:         @r{set the number of headline levels for export}
6490 num:       @r{turn on/off section-numbers}
6491 toc:       @r{turn on/off table of contents, or set level limit (integer)}
6492 \n:        @r{turn on/off linebreak-preservation}
6493 @@:         @r{turn on/off quoted HTML tags}
6494 ::         @r{turn on/off fixed-width sections}
6495 |:         @r{turn on/off tables}
6496 ^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
6497            @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
6498            @r{the simple @code{a_b} will be left as it is.}
6499 f:         @r{turn on/off foototes like this[1].}
6500 *:         @r{turn on/off emphasized text (bold, italic, underlined)}
6501 TeX:       @r{turn on/off simple @TeX{} macros in plain text}
6502 LaTeX:     @r{turn on/off La@TeX{} fragments}
6503 skip:      @r{turn on/off skipping the text before the first heading}
6504 author:    @r{turn on/off inclusion of author name/email into exported file}
6505 timestamp: @r{turn on/off inclusion creation time into exported file}
6506 d:         @r{turn on/off inclusion of drawers}
6507 @end example
6509 These options take effect in both the HTML and La@TeX{} export, except
6510 for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
6511 @code{nil} for the La@TeX{} export.
6513 @node Publishing, Miscellaneous, Exporting, Top
6514 @chapter Publishing
6515 @cindex publishing
6517 Org-mode includes@footnote{@file{org-publish.el} is not distributed with
6518 Emacs 21, if you are still using Emacs 21, you need you need to download
6519 this file separately.} a publishing management system that allows you to
6520 configure automatic HTML conversion of @emph{projects} composed of
6521 interlinked org files.  This system is called @emph{org-publish}.  You can
6522 also configure org-publish to automatically upload your exported HTML
6523 pages and related attachments, such as images and source code files, to
6524 a web server. Org-publish turns org-mode into a web-site authoring tool.
6526 You can also use Org-publish to convert files into La@TeX{}, or even
6527 combine HTML and La@TeX{} conversion so that files are available in both
6528 formats on the server@footnote{Since La@TeX{} files on a server are not
6529 that helpful, you surely want to perform further conversion on them --
6530 e.g. convert them to @code{PDF} format.}.
6532 Org-publish has been contributed to Org-mode by David O'Toole.
6534 @menu
6535 * Configuration::               Defining projects
6536 * Sample configuration::        Example projects
6537 * Triggering publication::      Publication commands
6538 @end menu
6540 @node Configuration, Sample configuration, Publishing, Publishing
6541 @section Configuration
6543 Publishing needs significant configuration to specify files, destination
6544 and many other properties of a project.
6546 @menu
6547 * Project alist::               The central configuration variable
6548 * Sources and destinations::    From here to there
6549 * Selecting files::             What files are part of the project?
6550 * Publishing action::           Setting the function doing the publishing
6551 * Publishing options::          Tweaking HTML export
6552 * Publishing links::            Which links keep working after publishing?
6553 * Project page index::          Publishing a list of project files
6554 @end menu
6556 @node Project alist, Sources and destinations, Configuration, Configuration
6557 @subsection The variable @code{org-publish-project-alist}
6558 @cindex org-publish-project-alist
6559 @cindex projects, for publishing
6561 Org-publish is configured almost entirely through setting the value of
6562 one variable, called @code{org-publish-project-alist}.
6563 Each element of the list configures one project, and may be in one of
6564 the two following forms:
6566 @lisp
6567 ("project-name"  :property value :property value ...)
6569 @r{or} 
6571 ("project-name"  :components ("project-name" "project-name" ...))
6573 @end lisp
6575 In both cases, projects are configured by specifying property values.
6576 A project defines the set of files that will be published, as well as
6577 the publishing configuration to use when publishing those files.  When
6578 a project takes the second form listed above, the individual members
6579 of the ``components'' property are taken to be components of the
6580 project, which group together files requiring different publishing
6581 options. When you publish such a ``meta-project'' all the components
6582 will also publish.
6584 @node Sources and destinations, Selecting files, Project alist, Configuration
6585 @subsection Sources and destinations for files
6586 @cindex directories, for publishing
6588 Most properties are optional, but some should always be set. In
6589 particular, org-publish needs to know where to look for source files,
6590 and where to put published files.
6592 @multitable @columnfractions 0.3 0.7
6593 @item @code{:base-directory}
6594 @tab Directory containing publishing source files
6595 @item @code{:publishing-directory}
6596 @tab Directory (possibly remote) where output files will be published.
6597 @item @code{:preparation-function}
6598 @tab Function called before starting publishing process, for example to
6599 run @code{make} for updating files to be published.
6600 @end multitable
6601 @noindent
6603 @node Selecting files, Publishing action, Sources and destinations, Configuration
6604 @subsection Selecting files
6605 @cindex files, selecting for publishing
6607 By default, all files with extension @file{.org} in the base directory
6608 are considered part of the project.  This can be modified by setting the
6609 properties 
6610 @multitable @columnfractions 0.25 0.75
6611 @item @code{:base-extension}
6612 @tab Extension (without the dot!) of source files.  This actually is a
6613 regular expression.
6615 @item @code{:exclude} 
6616 @tab Regular expression to match file names that should not be
6617 published, even though they have been selected on the basis of their
6618 extension.
6620 @item @code{:include}
6621 @tab List of files to be included regardless of @code{:base-extension}
6622 and @code{:exclude}.
6623 @end multitable
6625 @node Publishing action, Publishing options, Selecting files, Configuration
6626 @subsection Publishing Action
6627 @cindex action, for publishing
6629 Publishing means that a file is copied to the destination directory and
6630 possibly transformed in the process.  The default transformation is to
6631 export Org-mode files as HTML files, and this is done by the function
6632 @code{org-publish-org-to-html} which calls the HTML exporter
6633 (@pxref{HTML export}). But you also can publish your files in La@TeX{} by
6634 using the function @code{org-publish-org-to-latex} instead. Other files
6635 like images only need to be copied to the publishing destination. For
6636 non-Org-mode files, you need to specify the publishing function.
6639 @multitable @columnfractions 0.3 0.7
6640 @item @code{:publishing-function}
6641 @tab Function executing the publication of a file.  This may also be a
6642 list of functions, which will all be called in turn.
6643 @end multitable
6645 The function must accept two arguments: a property list containing at
6646 least a @code{:publishing-directory} property, and the name of the file
6647 to be published.  It should take the specified file, make the necessary
6648 transformation (if any) and place the result into the destination folder.
6649 You can write your own publishing function, but @code{org-publish}
6650 provides one for attachments (files that only need to be copied):
6651 @code{org-publish-attachment}.
6653 @node Publishing options, Publishing links, Publishing action, Configuration
6654 @subsection Options for the HTML/LaTeX exporters
6655 @cindex options, for publishing
6657 The property list can be used to set many export options for the HTML
6658 and La@TeX{} exporters.  In most cases, these properties correspond to user
6659 variables in Org-mode.  The table below lists these properties along
6660 with the variable they belong to.  See the documentation string for the
6661 respective variable for details.
6663 @multitable @columnfractions 0.3 0.7
6664 @item @code{:language}              @tab @code{org-export-default-language}
6665 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
6666 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
6667 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
6668 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
6669 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
6670 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
6671 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
6672 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
6673 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
6674 @item @code{:timestamps}           .@tab @code{org-export-with-timestamps}
6675 @item @code{:tags}                 .@tab @code{org-export-with-tags}
6676 @item @code{:tables}                @tab @code{org-export-with-tables}
6677 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
6678 @item @code{:style}                 @tab @code{org-export-html-style}
6679 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
6680 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
6681 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
6682 @item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
6683 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
6684 @item @code{:preamble}              @tab @code{org-export-html-preamble}
6685 @item @code{:postamble}             @tab @code{org-export-html-postamble}
6686 @item @code{:auto-preamble}         @tab @code{org-export-html-auto-preamble}
6687 @item @code{:auto-postamble}        @tab @code{org-export-html-auto-postamble}
6688 @item @code{:author}                @tab @code{user-full-name}
6689 @item @code{:email}                 @tab @code{user-mail-address}
6690 @end multitable
6692 Most of the @code{org-export-with-*} variables have the same effect in
6693 both HTML and La@TeX{} exporters, except for @code{:TeX-macros} and
6694 @code{:LaTeX-fragments}, respectively @code{nil} and @code{t} in the
6695 La@TeX{} export.
6697 When a property is given a value in org-publish-project-alist, its
6698 setting overrides the value of the corresponding user variable (if any)
6699 during publishing.  Options set within a file (@pxref{Export
6700 options}), however, override everything.
6702 @node Publishing links, Project page index, Publishing options, Configuration
6703 @subsection Links between published files
6704 @cindex links, publishing
6706 To create a link from one Org-mode file to another, you would use
6707 something like @samp{[[file:foo.org][The foo]]} or simply
6708 @samp{file:foo.org.} (@pxref{Hyperlinks}).  Upon publishing this link
6709 becomes a link to @file{foo.html}.  In this way, you can interlink the
6710 pages of your "org web" project and the links will work as expected when
6711 you publish them to HTML.
6713 You may also link to related files, such as images. Provided you are
6714 careful with relative pathnames, and provided you have also configured
6715 org-publish to upload the related files, these links will work
6716 too. @ref{Complex example} for an example of this usage.
6718 Sometime an Org-mode file to be published may contain links that are
6719 only valid in your production environment, but not in the publishing
6720 location.  In this case, use the property 
6722 @multitable @columnfractions 0.4 0.6
6723 @item @code{:link-validation-function}
6724 @tab Function to validate links
6725 @end multitable
6727 @noindent
6728 to define a function for checking link validity.  This function must
6729 accept two arguments, the file name and a directory relative to which
6730 the file name is interpreted in the production environment.  If this
6731 function returns @code{nil}, then the HTML generator will only insert a
6732 description into the HTML file, but no link.  One option for this
6733 function is @code{org-publish-validate-link} which checks if the given
6734 file is part of any project in @code{org-publish-project-alist}.
6736 @node Project page index,  , Publishing links, Configuration
6737 @subsection Project page index
6738 @cindex index, of published pages
6740 The following properties may be used to control publishing of an
6741 index of files or summary page for a given project.
6743 @multitable @columnfractions 0.25 0.75
6744 @item @code{:auto-index}
6745 @tab When non-nil, publish an index during org-publish-current-project or
6746 org-publish-all.
6748 @item @code{:index-filename}
6749 @tab Filename for output of index. Defaults to @file{index.org} (which
6750 becomes @file{index.html}).
6752 @item @code{:index-title}
6753 @tab Title of index page. Defaults to name of file.
6755 @item @code{:index-function}
6756 @tab Plugin function to use for generation of index.
6757 Defaults to @code{org-publish-org-index}, which generates a plain list
6758 of links to all files in the project.
6759 @end multitable
6761 @node Sample configuration, Triggering publication, Configuration, Publishing
6762 @section Sample configuration
6764 Below we provide two example configurations.  The first one is a simple
6765 project publishing only a set of Org-mode files.  The second example is
6766 more complex, with a multi-component project.
6768 @menu
6769 * Simple example::              One-component publishing
6770 * Complex example::             A multi-component publishing example
6771 @end menu
6773 @node Simple example, Complex example, Sample configuration, Sample configuration
6774 @subsection Example: simple publishing configuration
6776 This example publishes a set of Org-mode files to the @file{public_html}
6777 directory on the local machine.
6779 @lisp
6780 (setq org-publish-project-alist
6781       '(("org" 
6782          :base-directory "~/org/"
6783          :publishing-directory "~/public_html"
6784          :section-numbers nil
6785          :table-of-contents nil
6786          :style "<link rel=stylesheet 
6787                 href=\"../other/mystyle.css\"
6788                 type=\"text/css\">")))
6789 @end lisp
6791 @node Complex example,  , Simple example, Sample configuration
6792 @subsection Example: complex publishing configuration
6794 This more complicated example publishes an entire website, including
6795 org files converted to HTML, image files, emacs lisp source code, and
6796 stylesheets. The publishing-directory is remote and private files are
6797 excluded.
6799 To ensure that links are preserved, care should be taken to replicate
6800 your directory structure on the web server, and to use relative file
6801 paths. For example, if your org files are kept in @file{~/org} and your
6802 publishable images in @file{~/images}, you'd link to an image with
6804 @example
6805 file:../images/myimage.png
6806 @end example
6808 On the web server, the relative path to the image should be the
6809 same. You can accomplish this by setting up an "images" folder in the
6810 right place on the webserver, and publishing images to it.
6812 @lisp
6813 (setq org-publish-project-alist
6814       '(("orgfiles"
6815           :base-directory "~/org/"
6816           :base-extension "org"
6817           :publishing-directory "/ssh:user@@host:~/html/notebook/"
6818           :publishing-function org-publish-org-to-html
6819           :exclude "PrivatePage.org"   ;; regexp
6820           :headline-levels 3
6821           :section-numbers nil
6822           :table-of-contents nil
6823           :style "<link rel=stylesheet 
6824                   href=\"../other/mystyle.css\" type=\"text/css\">"
6825           :auto-preamble t
6826           :auto-postamble nil)
6827          
6828          ("images"
6829           :base-directory "~/images/"
6830           :base-extension "jpg\\|gif\\|png"
6831           :publishing-directory "/ssh:user@@host:~/html/images/"
6832           :publishing-function org-publish-attachment)
6834          ("other"
6835           :base-directory "~/other/"
6836           :base-extension "css\\|el"
6837           :publishing-directory "/ssh:user@@host:~/html/other/"
6838           :publishing-function org-publish-attachment)
6839          ("website" :components ("orgfiles" "images" "other"))))
6840 @end lisp
6842 @node Triggering publication,  , Sample configuration, Publishing
6843 @section Triggering publication
6845 Once org-publish is properly configured, you can publish with the
6846 following functions: 
6848 @table @kbd
6849 @item C-c C-e C
6850 Prompt for a specific project and publish all files that belong to it.
6851 @item C-c C-e P
6852 Publish the project containing the current file.
6853 @item C-c C-e F
6854 Publish only the current file.
6855 @item C-c C-e A
6856 Publish all projects.
6857 @end table
6859 Org uses timestamps to track when a file has changed. The above
6860 functions normally only publish changed files. You can override this and
6861 force publishing of all files by giving a prefix argument.
6863 @node Miscellaneous, Extensions and Hacking, Publishing, Top
6864 @chapter Miscellaneous
6866 @menu
6867 * Completion::                  M-TAB knows what you need
6868 * Customization::               Adapting Org-mode to your taste
6869 * In-buffer settings::          Overview of the #+KEYWORDS
6870 * The very busy C-c C-c key::   When in doubt, press C-c C-c
6871 * Clean view::                  Getting rid of leading stars in the outline
6872 * TTY keys::                    Using Org-mode on a tty
6873 * Interaction::                 Other Emacs packages
6874 * Bugs::                        Things which do not work perfectly
6875 @end menu
6877 @node Completion, Customization, Miscellaneous, Miscellaneous
6878 @section Completion
6879 @cindex completion, of @TeX{} symbols
6880 @cindex completion, of TODO keywords
6881 @cindex completion, of dictionary words
6882 @cindex completion, of option keywords
6883 @cindex completion, of tags
6884 @cindex completion, of property keys
6885 @cindex completion, of link abbreviations
6886 @cindex @TeX{} symbol completion
6887 @cindex TODO keywords completion
6888 @cindex dictionary word completion
6889 @cindex option keyword completion
6890 @cindex tag completion
6891 @cindex link abbreviations, completion of
6893 Org-mode supports in-buffer completion.  This type of completion does
6894 not make use of the minibuffer.  You simply type a few letters into
6895 the buffer and use the key to complete text right there.
6897 @table @kbd
6898 @kindex M-@key{TAB}
6899 @item M-@key{TAB}
6900 Complete word at point
6901 @itemize @bullet
6902 @item
6903 At the beginning of a headline, complete TODO keywords.
6904 @item
6905 After @samp{\}, complete @TeX{} symbols supported by the exporter.
6906 @item
6907 After @samp{*}, complete headlines in the current buffer so that they
6908 can be used in search links like @samp{[[*find this headline]]}.
6909 @item
6910 After @samp{:} in a headline, complete tags.  The list of tags is taken
6911 from the variable @code{org-tag-alist} (possibly set through the
6912 @samp{#+TAGS} in-buffer option, @pxref{Setting tags}), or it is created
6913 dynamically from all tags used in the current buffer.
6914 @item
6915 After @samp{:} and not in a headline, complete property keys.  The list
6916 of keys is constructed dynamically from all keys used in the current
6917 buffer.
6918 @item
6919 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
6920 @item
6921 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
6922 @samp{OPTIONS} which set file-specific options for Org-mode.  When the
6923 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
6924 will insert example settings for this keyword.
6925 @item
6926 In the line after @samp{#+STARTUP: }, complete startup keywords,
6927 i.e. valid keys for this line.
6928 @item
6929 Elsewhere, complete dictionary words using ispell.
6930 @end itemize
6931 @end table
6933 @node Customization, In-buffer settings, Completion, Miscellaneous
6934 @section Customization
6935 @cindex customization
6936 @cindex options, for customization
6937 @cindex variables, for customization
6939 There are more than 180 variables that can be used to customize
6940 Org-mode.  For the sake of compactness of the manual, I am not
6941 describing the variables here.  A structured overview of customization
6942 variables is available with @kbd{M-x org-customize}.  Or select
6943 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
6944 settings can also be activated on a per-file basis, by putting special
6945 lines into the buffer (@pxref{In-buffer settings}).
6947 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
6948 @section Summary of in-buffer settings
6949 @cindex in-buffer settings
6950 @cindex special keywords
6952 Org-mode uses special lines in the buffer to define settings on a
6953 per-file basis.  These lines start with a @samp{#+} followed by a
6954 keyword, a colon, and then individual words defining a setting.  Several
6955 setting words can be in the same line, but you can also have multiple
6956 lines for the keyword.  While these settings are described throughout
6957 the manual, here is a summary.  After changing any of those lines in the
6958 buffer, press @kbd{C-c C-c} with the cursor still in the line to
6959 activate the changes immediately.  Otherwise they become effective only
6960 when the file is visited again in a new Emacs session.
6962 @table @kbd
6963 @item #+ARCHIVE: %s_done::
6964 This line sets the archive location for the agenda file.  It applies for
6965 all subsequent lines until the next @samp{#+ARCHIVE} line, or the end
6966 of the file.  The first such line also applies to any entries before it.
6967 The corresponding variable is @code{org-archive-location}.
6968 @item #+CATEGORY:
6969 This line sets the category for the agenda file.  The category applies
6970 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
6971 end of the file.  The first such line also applies to any entries before it.
6972 @item #+COLUMNS: %25ITEM .....
6973 Set the default format for columns view.  This format applies when
6974 columns view is invoked in location where no COLUMNS property applies.
6975 @item #+CONSTANTS: name1=value1 ...
6976 Set file-local values for constants to be used in table formulas.  This
6977 line set the local variable @code{org-table-formula-constants-local}.
6978 The global version of this variable is
6979 @code{org-table-formula-constants}.
6980 @item #+DRAWERS: NAME1 .....
6981 Set the file-local set of drawers.  The corresponding global variable is
6982 @code{org-drawers}.
6983 @item #+LINK:  linkword replace
6984 These lines (several are allowed) specify link abbreviations.
6985 @xref{Link abbreviations}.  The corresponding variable is
6986 @code{org-link-abbrev-alist}.
6987 @item #+PRIORITIES: highest lowest default
6988 This line sets the limits and the default for the priorities.  All three
6989 must be either letters A-Z or numbers 0-9.  The highest priority must
6990 have a lower ASCII number that the lowest priority.
6991 @item #+PROPERTY: Property_Name Value
6992 This line sets a default inheritance value for entries in the current
6993 buffer, most useful for specifying the allowed values of a property.
6994 @item #+STARTUP:
6995 This line sets options to be used at startup of Org-mode, when an
6996 Org-mode file is being visited.  The first set of options deals with the
6997 initial visibility of the outline tree.  The corresponding variable for
6998 global default settings is @code{org-startup-folded}, with a default
6999 value @code{t}, which means @code{overview}.
7000 @cindex @code{overview}, STARTUP keyword
7001 @cindex @code{content}, STARTUP keyword
7002 @cindex @code{showall}, STARTUP keyword
7003 @example
7004 overview   @r{top-level headlines only}
7005 content    @r{all headlines}
7006 showall    @r{no folding at all, show everything}
7007 @end example
7008 Then there are options for aligning tables upon visiting a file.  This
7009 is useful in files containing narrowed table columns.  The corresponding
7010 variable is @code{org-startup-align-all-tables}, with a default value
7011 @code{nil}. 
7012 @cindex @code{align}, STARTUP keyword
7013 @cindex @code{noalign}, STARTUP keyword
7014 @example
7015 align      @r{align all tables}
7016 noalign    @r{don't align tables on startup}
7017 @end example
7018 Logging TODO state changes and clock intervals (variables
7019 @code{org-log-done} and @code{org-log-repeat}) can be configured using
7020 these options.
7021 @cindex @code{logdone}, STARTUP keyword
7022 @cindex @code{nologging}, STARTUP keyword
7023 @cindex @code{lognotedone}, STARTUP keyword
7024 @cindex @code{lognoteclock-out}, STARTUP keyword
7025 @cindex @code{lognotestate}, STARTUP keyword
7026 @cindex @code{logrepeat}, STARTUP keyword
7027 @cindex @code{nologrepeat}, STARTUP keyword
7028 @example
7029 logging          @r{record a timestamp when an item is marked DONE}
7030 nologging        @r{don't record when items are marked DONE}
7031 lognotedone      @r{record timestamp and a note when DONE}
7032 lognotestate     @r{record timestamp and a note when TODO state changes}
7033 logrepeat        @r{record a note when re-instating a repeating item}
7034 nologrepeat      @r{do not record when re-instating repeating item}
7035 lognoteclock-out @r{record timestamp and a note when clocking out}
7036 @end example
7037 Here are the options for hiding leading stars in outline headings.  The
7038 corresponding variables are @code{org-hide-leading-stars} and
7039 @code{org-odd-levels-only}, both with a default setting @code{nil}
7040 (meaning @code{showstars} and @code{oddeven}).
7041 @cindex @code{hidestars}, STARTUP keyword
7042 @cindex @code{showstars}, STARTUP keyword
7043 @cindex @code{odd}, STARTUP keyword
7044 @cindex @code{even}, STARTUP keyword
7045 @example
7046 hidestars  @r{make all but one of the stars starting a headline invisible.}
7047 showstars  @r{show all stars starting a headline}
7048 odd        @r{allow only odd outline levels (1,3,...)}
7049 oddeven    @r{allow all outline levels}
7050 @end example
7051 To turn on custom format overlays over time stamps (variables
7052 @code{org-put-time-stamp-overlays} and
7053 @code{org-time-stamp-overlay-formats}), use
7054 @cindex @code{customtime}, STARTUP keyword
7055 @example
7056 customtime @r{overlay custom time format}
7057 @end example
7058 The following options influence the table spreadsheet (variable
7059 @code{constants-unit-system}).
7060 @cindex @code{constcgs}, STARTUP keyword
7061 @cindex @code{constSI}, STARTUP keyword
7062 @example
7063 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
7064 constSI    @r{@file{constants.el} should use the SI unit system}
7065 @end example
7066 @item #+TAGS:  TAG1(c1) TAG2(c2)
7067 These lines (several such lines are allowed) specify the legal tags in
7068 this file, and (potentially) the corresponding @emph{fast tag selection}
7069 keys.  The corresponding variable is @code{org-tag-alist}.
7070 @item #+TBLFM:
7071 This line contains the formulas for the table directly above the line.
7072 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+OPTIONS, #+DATE:
7073 These lines provide settings for exporting files.  For more details see
7074 @ref{Export options}.
7075 @item #+SEQ_TODO:   #+TYP_TODO:
7076 These lines set the TODO keywords and their interpretation in the
7077 current file.  The corresponding variables are @code{org-todo-keywords}
7078 and @code{org-todo-interpretation}.
7079 @end table
7081 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
7082 @section The very busy C-c C-c key
7083 @kindex C-c C-c
7084 @cindex C-c C-c, overview
7086 The key @kbd{C-c C-c} has many purposes in org-mode, which are all
7087 mentioned scattered throughout this manual.  One specific function of
7088 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
7089 other circumstances it means something like @emph{Hey Org-mode, look
7090 here and update according to what you see here}.  Here is a summary of
7091 what this means in different contexts.
7093 @itemize @minus
7094 @item
7095 If there are highlights in the buffer from the creation of a sparse
7096 tree, or from clock display, remove these highlights.
7097 @item
7098 If the cursor is in one of the special @code{#+KEYWORD} lines, this
7099 triggers scanning the buffer for these lines and updating the
7100 information. 
7101 @item
7102 If the cursor is inside a table, realign the table.  This command
7103 works even if the automatic table editor has been turned off.
7104 @item
7105 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
7106 the entire table.
7107 @item
7108 If the cursor is inside a table created by the @file{table.el} package,
7109 activate that table.
7110 @item
7111 If the current buffer is a remember buffer, close the note and file it.
7112 With a prefix argument, file it, without further interaction, to the
7113 default location.
7114 @item
7115 If the cursor is on a @code{<<<target>>>}, update radio targets and
7116 corresponding links in this buffer.
7117 @item
7118 If the cursor is in a property line or at the start or end of a property
7119 drawer, offer property commands.
7120 @item
7121 If the cursor is in a plain list item with a checkbox, toggle the status
7122 of the checkbox.
7123 @item
7124 If the cursor is on a numbered item in a plain list, renumber the
7125 ordered list.
7126 @item
7127 If the cursor is on the @code{#+BEGIN} line of a dynamical block, the
7128 block is updated.
7129 @end itemize
7131 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
7132 @section A cleaner outline view
7133 @cindex hiding leading stars
7134 @cindex clean outline view
7136 Some people find it noisy and distracting that the Org-mode headlines
7137 are starting with a potentially large number of stars.  For example
7138 the tree from @ref{Headlines}:
7140 @example
7141 * Top level headline
7142 ** Second level
7143 *** 3rd level
7144     some text
7145 *** 3rd level
7146     more text
7147 * Another top level headline
7148 @end example
7150 @noindent
7151 Unfortunately this is deeply ingrained into the code of Org-mode and
7152 cannot be easily changed.  You can, however, modify the display in such
7153 a way that all leading stars become invisible and the outline more easy
7154 to read.  To do this, customize the variable
7155 @code{org-hide-leading-stars} like this:
7157 @lisp
7158 (setq org-hide-leading-stars t)
7159 @end lisp
7161 @noindent
7162 or change this on a per-file basis with one of the lines (anywhere in
7163 the buffer)
7165 @example
7166 #+STARTUP: showstars
7167 #+STARTUP: hidestars
7168 @end example
7170 @noindent
7171 Press @kbd{C-c C-c} with the cursor in a @samp{STARTUP} line to activate
7172 the modifications.
7174 With stars hidden, the tree becomes:
7176 @example
7177 * Top level headline
7178  * Second level
7179   * 3rd level
7180     some text
7181   * 3rd level
7182     more text
7183 * Another top level headline
7184 @end example
7186 @noindent
7187 Note that the leading stars are not truly replaced by whitespace, they
7188 are only fontified with the face @code{org-hide} that uses the
7189 background color as font color.  If you are not using either white or
7190 black background, you may have to customize this face to get the wanted
7191 effect.  Another possibility is to set this font such that the extra
7192 stars are @i{almost} invisible, for example using the color
7193 @code{grey90} on a white background.
7195 Things become cleaner still if you skip all the even levels and use only
7196 odd levels 1, 3, 5..., effectively adding two stars to go from one
7197 outline level to the next:
7199 @example
7200 * Top level headline
7201   * Second level
7202     * 3rd level
7203       some text
7204     * 3rd level
7205       more text
7206 * Another top level headline
7207 @end example
7209 @noindent
7210 In order to make the structure editing and export commands handle this
7211 convention correctly, use
7213 @lisp
7214 (setq org-odd-levels-only t)
7215 @end lisp
7217 @noindent
7218 or set this on a per-file basis with one of the following lines (don't
7219 forget to press @kbd{C-c C-c} with the cursor in the startup line to
7220 activate changes immediately).
7222 @example
7223 #+STARTUP: odd
7224 #+STARTUP: oddeven
7225 @end example
7227 You can convert an Org-mode file from single-star-per-level to the
7228 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
7229 RET} in that file.  The reverse operation is @kbd{M-x
7230 org-convert-to-oddeven-levels}.
7232 @node TTY keys, Interaction, Clean view, Miscellaneous
7233 @section Using org-mode on a tty
7234 @cindex tty keybindings
7236 Org-mode uses a number of keys that are not accessible on a tty.  This
7237 applies to most special keys like cursor keys, @key{TAB} and
7238 @key{RET}, when these are combined with modifier keys like @key{Meta}
7239 and/or @key{Shift}.  Org-mode uses these bindings because it needs to
7240 provide keys for a large number of commands, and because these keys
7241 appeared particularly easy to remember.  In order to still be able to
7242 access the core functionality of Org-mode on a tty, alternative
7243 bindings are provided.  Here is a complete list of these bindings,
7244 which are obviously more cumbersome to use.  Note that sometimes a
7245 work-around can be better.  For example changing a time stamp is
7246 really only fun with @kbd{S-@key{cursor}} keys.  On a tty you would
7247 rather use @kbd{C-c .}  to re-insert the timestamp.
7249 @multitable @columnfractions 0.15 0.2 0.2
7250 @item @b{Default} @tab @b{Alternative 1} @tab @b{Alternative 2}
7251 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab
7252 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{@key{Esc} @key{left}}
7253 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab
7254 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{@key{Esc} @key{right}}
7255 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab
7256 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{@key{Esc} @key{up}}
7257 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab
7258 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{@key{Esc} @key{down}}
7259 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab
7260 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab
7261 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{@key{Esc} @key{RET}}
7262 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab
7263 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab
7264 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab
7265 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab
7266 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab
7267 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab
7268 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab
7269 @end multitable
7271 @node Interaction, Bugs, TTY keys, Miscellaneous
7272 @section Interaction with other packages
7273 @cindex packages, interaction with other
7274 Org-mode lives in the world of GNU Emacs and interacts in various ways
7275 with other code out there.
7277 @menu
7278 * Cooperation::                 Packages Org-mode cooperates with
7279 * Conflicts::                   Packages that lead to conflicts
7280 @end menu
7282 @node Cooperation, Conflicts, Interaction, Interaction
7283 @subsection Packages that Org-mode cooperates with
7285 @table @asis
7286 @cindex @file{calc.el}
7287 @item @file{calc.el} by Dave Gillespie
7288 Org-mode uses the calc package for implementing spreadsheet
7289 functionality in its tables (@pxref{The spreadsheet}).  Org-mode
7290 checks for the availability of calc by looking for the function
7291 @code{calc-eval} which should be autoloaded in your setup if calc has
7292 been installed properly.  As of Emacs 22, calc is part of the Emacs
7293 distribution.  Another possibility for interaction between the two
7294 packages is using calc for embedded calculations. @xref{Embedded Mode,
7295 , Embedded Mode, calc, GNU Emacs Calc Manual}.
7296 @cindex @file{constants.el}
7297 @item @file{constants.el} by Carsten Dominik
7298 In a table formula (@pxref{The spreadsheet}), it is possible to use
7299 names for natural constants or units.  Instead of defining your own
7300 constants in the variable @code{org-table-formula-constants}, install
7301 the @file{constants} package which defines a large number of constants
7302 and units, and lets you use unit prefixes like @samp{M} for
7303 @samp{Mega} etc.  You will need version 2.0 of this package, available
7304 at @url{http://www.astro.uva.nl/~dominik/Tools}. Org-mode checks for
7305 the function @code{constants-get}, which has to be autoloaded in your
7306 setup.  See the installation instructions in the file
7307 @file{constants.el}.
7308 @item @file{cdlatex.el} by Carsten Dominik
7309 @cindex @file{cdlatex.el}
7310 Org-mode can make use of the cdlatex package to efficiently enter
7311 La@TeX{} fragments into Org-mode files. See @ref{CDLaTeX mode}.
7312 @item @file{remember.el} by John Wiegley
7313 @cindex @file{remember.el}
7314 Org mode cooperates with remember, see @ref{Remember}.
7315 @file{Remember.el} is not part of Emacs, find it on the web.
7316 @cindex @file{table.el}
7317 @item @file{table.el} by Takaaki Ota
7318 @kindex C-c C-c
7319 @cindex table editor, @file{table.el}
7320 @cindex @file{table.el}
7322 Complex ASCII tables with automatic line wrapping, column- and
7323 row-spanning, and alignment can be created using the Emacs table
7324 package by Takaaki Ota (@uref{http://sourceforge.net/projects/table},
7325 and also part of Emacs 22).
7326 When @key{TAB} or @kbd{C-c C-c} is pressed in such a table, Org-mode
7327 will call @command{table-recognize-table} and move the cursor into the
7328 table.  Inside a table, the keymap of Org-mode is inactive.  In order
7329 to execute Org-mode-related commands, leave the table.
7331 @table @kbd
7332 @kindex C-c C-c
7333 @item C-c C-c
7334 Recognize @file{table.el} table.  Works when the cursor is in a
7335 table.el table.
7337 @kindex C-c ~
7338 @item C-c ~
7339 Insert a table.el table.  If there is already a table at point, this
7340 command converts it between the table.el format and the Org-mode
7341 format.  See the documentation string of the command
7342 @code{org-convert-table} for the restrictions under which this is
7343 possible.
7344 @end table
7345 @file{table.el} is part of Emacs 22.
7346 @cindex @file{footnote.el}
7347 @item @file{footnote.el} by Steven L. Baur
7348 Org-mode recognizes numerical footnotes as provided by this package
7349 (@pxref{Footnotes}).
7350 @end table
7352 @node Conflicts,  , Cooperation, Interaction
7353 @subsection Packages that lead to conflicts with Org-mode
7355 @table @asis
7357 @cindex @file{allout.el}
7358 @item @file{allout.el} by Ken Manheimer
7359 Startup of Org-mode may fail with the error message
7360 @code{(wrong-type-argument keymapp nil)} when there is an outdated
7361 version @file{allout.el} on the load path, for example the version
7362 distributed with Emacs 21.x.  Upgrade to Emacs 22 and this problem will
7363 disappear.  If for some reason you cannot do this, make sure that org.el
7364 is loaded @emph{before} @file{allout.el}, for example by putting
7365 @code{(require 'org)} early enough into your @file{.emacs} file.
7367 @cindex @file{CUA.el}
7368 @item @file{CUA.el} by Kim. F. Storm
7369 Keybindings in Org-mode conflict with the @kbd{S-<cursor>} keys
7370 used by CUA-mode (as well as pc-select-mode and s-region-mode) to
7371 select and extend the region.  If you want to use one of these
7372 packages along with Org-mode, configure the variable
7373 @code{org-CUA-compatible}.  When set, Org-mode will move the following
7374 keybindings in Org-mode files, and in the agenda buffer (but not
7375 during date selection).
7377 @example
7378 S-UP    -> M-p             S-DOWN  -> M-n
7379 S-LEFT  -> M--             S-RIGHT -> M-+
7380 @end example
7382 Yes, these are unfortunately more difficult to remember.  If you want
7383 to have other replacement keys, look at the variable
7384 @code{org-disputed-keys}.
7385 @item @file{windmove.el} by Hovav Shacham
7386 @cindex @file{windmove.el}
7387 Also this package uses the @kbd{S-<cursor>} keys, so everything written
7388 in the paragraph above about CUA mode also applies here.
7390 @cindex @file{footnote.el}
7391 @item @file{footnote.el} by Steven L. Baur
7392 Org-mode supports the syntax of the footnote package, but only the
7393 numerical footnote markers.  Also, the default key for footnote
7394 commands, @kbd{C-c !} is already used by Org-mode.  You could use the
7395 variable @code{footnote-prefix} to switch footnotes commands to another
7396 key.  Or, you could use @code{org-replace-disputed-keys} and
7397 @code{org-disputed-keys} to change the settings in Org-mode.
7399 @end table
7402 @node Bugs,  , Interaction, Miscellaneous
7403 @section Bugs
7404 @cindex bugs
7406 Here is a list of things that should work differently, but which I
7407 have found too hard to fix.
7409 @itemize @bullet
7410 @item
7411 If a table field starts with a link, and if the corresponding table
7412 column is narrowed (@pxref{Narrow columns}) to a width too small to
7413 display the link, the field would look entirely empty even though it is
7414 not.  To prevent this, Org-mode throws an error.  The work-around is to
7415 make the column wide enough to fit the link, or to add some text (at
7416 least 2 characters) before the link in the same field.
7417 @item
7418 Narrowing table columns does not work on XEmacs, because the
7419 @code{format} function does not transport text properties.
7420 @item
7421 Text in an entry protected with the @samp{QUOTE} keyword should not
7422 autowrap.
7423 @item
7424 When the application called by @kbd{C-c C-o} to open a file link fails
7425 (for example because the application does not exist or refuses to open
7426 the file), it does so silently.  No error message is displayed.
7427 @item
7428 Recalculating a table line applies the formulas from left to right.
7429 If a formula uses @emph{calculated} fields further down the row,
7430 multiple recalculation may be needed to get all fields consistent.  You
7431 may use the command @code{org-table-iterate} (@kbd{C-u C-c *}) to
7432 recalculate until convergence.
7433 @item
7434 A single letter cannot be made bold, for example @samp{*a*}.
7435 @item
7436 The exporters work well, but could be made more efficient.
7437 @end itemize
7440 @node Extensions and Hacking, History and Acknowledgments, Miscellaneous, Top
7441 @appendix Extensions, Hooks and Hacking
7443 This appendix lists extensions for Org-mode written by other authors.
7444 It also covers some aspects where users can extend the functionality of
7445 Org-mode.
7447 @menu
7448 * Extensions::                  Existing 3rd-part extensions
7449 * Adding hyperlink types::      New custom link types
7450 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
7451 * Dynamic blocks::              Automatically filled blocks
7452 * Special agenda views::        Customized views
7453 * Using the property API::      Writing programs that use entry properties
7454 @end menu
7456 @node Extensions, Adding hyperlink types, Extensions and Hacking, Extensions and Hacking
7457 @section Third-party extensions for Org-mode
7458 @cindex extension, third-party
7460 The following extensions for Org-mode have been written by other people:
7462 @table @asis
7463 @cindex @file{org-publish.el}
7464 @item @file{org-publish.el} by David O'Toole
7465 This package provides facilities for publishing related sets of Org-mode
7466 files together with linked files like images as webpages.  It is
7467 highly configurable and can be used for other publishing purposes as
7468 well.  As of Org-mode version 4.30, @file{org-publish.el} is part of the
7469 Org-mode distribution.  It is not yet part of Emacs, however, a delay
7470 caused by the preparations for the 22.1 release.  In the mean time,
7471 @file{org-publish.el} can be downloaded from David's site:
7472 @url{http://dto.freeshell.org/e/org-publish.el}.
7473 @cindex @file{org-mouse.el}
7474 @item @file{org-mouse.el} by Piotr Zielinski
7475 This package implements extended mouse functionality for Org-mode.  It
7476 allows you to cycle visibility and to edit the document structure with
7477 the mouse.  Best of all, it provides a context-sensitive menu on
7478 @key{mouse-3} that changes depending on the context of a mouse-click.
7479 As of Org-mode version 4.53, @file{org-mouse.el} is part of the
7480 Org-mode distribution.  It is not yet part of Emacs, however, a delay
7481 caused by the preparations for the 22.1 release.  In the mean time,
7482 @file{org-mouse.el} can be downloaded from Piotr's site:
7483 @url{http://www.cl.cam.ac.uk/~pz215/files/org-mouse.el}.
7484 @cindex @file{org-blog.el}
7485 @item @file{org-blog.el} by David O'Toole
7486 A blogging plug-in for @file{org-publish.el}.@*
7487 @url{http://dto.freeshell.org/notebook/OrgMode.html}.
7488 @cindex @file{blorg.el}
7489 @item @file{blorg.el} by Bastien Guerry
7490 Publish Org-mode files as
7491 blogs. @url{http://www.cognition.ens.fr/~guerry/blorg.html}.
7492 @cindex @file{org2rem.el}
7493 @item @file{org2rem.el} by Bastien Guerry
7494 Translates Org-mode files into something readable by
7495 Remind. @url{http://www.cognition.ens.fr/~guerry/u/org2rem.el}.
7496 @item @file{org-toc.el} by Bastien Guerry
7497 Produces a simple table of contents of an Org-mode file, for easy
7498 navigation. @url{http://www.cognition.ens.fr/~guerry/u/org2rem.el}.
7499 @item @file{org-registry.el} by Bastien Guerry
7500 Find which Org-file link to a certain document.
7501 @url{http://www.cognition.ens.fr/~guerry/u/org2rem.el}.
7502 @end table
7504 @page
7506 @node Adding hyperlink types, Tables in arbitrary syntax, Extensions, Extensions and Hacking
7507 @section Adding hyperlink types
7508 @cindex hyperlinks, adding new types
7510 Org-mode has a large number of hyperlink types built-in
7511 (@pxref{Hyperlinks}).  If you would like to add new link types, it
7512 provides an interface for doing so.  Lets look at an example file
7513 @file{org-man.el} that will add support for creating links like
7514 @samp{[[man:printf][The printf manpage]]} to show unix manual pages inside
7515 emacs:
7517 @lisp
7518 ;;; org-man.el - Support for links to manpages in Org-mode
7520 (require 'org)
7522 (org-add-link-type "man" 'org-man-open)
7523 (add-hook 'org-store-link-functions 'org-man-store-link)
7525 (defcustom org-man-command 'man
7526   "The Emacs command to be used to display a man page."
7527   :group 'org-link
7528   :type '(choice (const man) (const woman)))
7530 (defun org-man-open (path)
7531   "Visit the manpage on PATH.
7532 PATH should be a topic that can be thrown at the man command."
7533   (funcall org-man-command path))
7535 (defun org-man-store-link ()
7536   "Store a link to a manpage."
7537   (when (memq major-mode '(Man-mode woman-mode))
7538     ;; This is a man page, we do make this link
7539     (let* ((page (org-man-get-page-name))
7540            (link (concat "man:" page))
7541            (description (format "Manpage for %s" page)))
7542       (org-store-link-props
7543        :type "man"
7544        :link link
7545        :description description))))
7547 (defun org-man-get-page-name ()
7548   "Extract the page name from the buffer name."
7549   ;; This works for both `Man-mode' and `woman-mode'.
7550   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
7551       (match-string 1 (buffer-name))
7552     (error "Cannot create link to this man page")))
7554 (provide 'org-man)
7556 ;;; org-man.el ends here
7557 @end lisp
7559 @noindent
7560 You would activate this new link type in @file{.emacs} with
7562 @lisp
7563 (require 'org-man)
7564 @end lisp
7566 @noindent
7567 Lets go through the file and see what it does.
7568 @enumerate
7569 @item 
7570 It does @code{(require 'org)} to make sure that @file{org.el} has been
7571 loaded.
7572 @item
7573 The next line calls @code{org-add-link-type} to define a new link type
7574 with prefix @samp{man}.  The call also contains the name of a function
7575 that will be called to follow such a link.
7576 @item
7577 The next line adds a function to @code{org-store-link-functions}, in
7578 order to allow the command @kbd{C-c l} to record a useful link in a
7579 buffer displaying a man page.
7580 @end enumerate
7582 The rest of the file defines the necessary variables and functions.
7583 First there is a customization variable that determines which emacs
7584 command should be used to display manpages.  There are two options,
7585 @code{man} and @code{woman}.  Then the function to follow a link is
7586 defined.  It gets the link path as an argument - in this case the link
7587 path is just a topic for the manual command.  The function calls the
7588 value of @code{org-man-command} to display the man page.
7590 Finally the function @code{org-man-store-link} is defined.  When you try
7591 to store a link with @kbd{C-c l}, also this function will be called to
7592 try to make a link.  The function must first decide if it is supposed to
7593 create the link for this buffer type, we do this by checking the value
7594 of the variable @code{major-mode}.  If not, the function must exit and
7595 retunr the value @code{nil}.  If yes, the link is created by getting the
7596 manual tpoic from the buffer name and prefixing it with the string
7597 @samp{man:}.  Then it must call the command @code{org-store-link-props}
7598 and set the @code{:type} and @code{:link} properties.  Optionally you
7599 can also set the @code{:description} property to provide a default for
7600 the link description when the link is later inserted into tan Org-mode
7601 buffer with @kbd{C-c C-l}.
7603 @node Tables in arbitrary syntax, Dynamic blocks, Adding hyperlink types, Extensions and Hacking
7604 @section Tables in arbitrary syntax
7605 @cindex tables, in other modes
7606 @cindex orgtbl-mode
7608 Since Orgtbl-mode can be used as a minor mode in arbitrary buffers, a
7609 frequent feature request has been to make it work with native tables in
7610 specific languages, for example La@TeX{}.  However, this is extremely hard
7611 to do in a general way, would lead to a customization nightmare, and
7612 would take away much of the simplicity of the Orgtbl-mode table editor.
7614 This appendix describes a different approach.  We keep the Orgtbl-mode
7615 table in its native format (the @i{source table}), and use a custom
7616 function to @i{translate} the table to the correct syntax, and to
7617 @i{install} it in the right location (the @i{target table}).  This puts
7618 the burden of writing conversion functions on the user, but it allows
7619 for a very flexible system.
7621 @menu
7622 * Radio tables::                Sending and receiving
7623 * A LaTeX example::             Step by step, almost a tutorial
7624 * Translator functions::        Copy and modify
7625 @end menu
7627 @node Radio tables, A LaTeX example, Tables in arbitrary syntax, Tables in arbitrary syntax
7628 @subsection Radio tables
7629 @cindex radio tables
7631 To define the location of the target table, you first need to create two
7632 lines that are comments in the current mode, but contain magic words for
7633 Orgtbl-mode to find.  Orgtbl-mode will insert the translated table
7634 between these lines, replacing whatever was there before.  For example:
7636 @example
7637 /* BEGIN RECEIVE ORGTBL table_name */
7638 /* END RECEIVE ORGTBL table_name */
7639 @end example
7641 @noindent
7642 Just above the source table, we put a special line that tells
7643 Orgtbl-mode how to translate this table and where to install it.  For
7644 example:
7645 @example
7646 #+ORGTBL: SEND table_name translation_function arguments....
7647 @end example
7649 @noindent
7650 @code{table_name} is the reference name for the table that is also used
7651 in the receiver lines. @code{translation_function} is the Lisp function
7652 that does the translation.  Furthermore, the line can contain a list of
7653 arguments (alternating key and value) at the end.  The arguments will be
7654 passed as a property list to the translation function for
7655 interpretation.  A few standard parameters are already recognized and
7656 acted upon before the translation function is called:
7658 @table @code
7659 @item :skip N
7660 Skip the first N lines of the table. Hlines do count!
7661 @item :skipcols (n1 n2 ...)
7662 List of columns that should be skipped.  If the table has a column with
7663 calculation marks, that column is automatically discarded as well.
7664 Please note that the translator function sees the table @emph{after} the
7665 removal of these columns, the function never knows that there have been
7666 additional columns.
7667 @end table
7669 @noindent
7670 The one problem remaining is how to keep the source table in the buffer
7671 without disturbing the normal workings of the file, for example during
7672 compilation of a C file or processing of a La@TeX{} file.  There are a
7673 number of different solutions:
7675 @itemize @bullet
7676 @item
7677 The table could be placed in a block comment if that is supported by the
7678 language.  For example, in C-mode you could wrap the table between
7679 @samp{/*} and @samp{*/} lines.
7680 @item 
7681 Sometimes it is possible to put the table after some kind of @i{END}
7682 statement, for example @samp{\bye} in TeX and @samp{\end@{document@}}
7683 in La@TeX{}.
7684 @item
7685 You can just comment the table line by line whenever you want to process
7686 the file, and uncomment it whenever you need to edit the table.  This
7687 only sounds tedious - the command @kbd{M-x orgtbl-toggle-comment} does
7688 make this comment-toggling very easy, in particular if you bind it to a
7689 key.
7690 @end itemize
7692 @node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
7693 @subsection A LaTeX example
7694 @cindex LaTeX, and orgtbl-mode
7696 The best way to wrap the source table in La@TeX{} is to use the
7697 @code{comment} environment provided by @file{comment.sty}.  It has to be
7698 activated by placing @code{\usepackage@{comment@}} into the document
7699 header.  Orgtbl-mode can insert a radio table skeleton@footnote{By
7700 default this works only for La@TeX{}, HTML, and TeXInfo.  Configure the
7701 variable @code{orgtbl-radio-tables} to install templates for other
7702 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
7703 be prompted for a table name, lets say we use @samp{salesfigures}.  You
7704 will then get the following template:
7706 @example
7707 % BEGIN RECEIVE ORGTBL salesfigures
7708 % END RECEIVE ORGTBL salesfigures
7709 \begin@{comment@}
7710 #+ORGTBL: SEND salesfigures orgtbl-to-latex
7711 | | |
7712 \end@{comment@}
7713 @end example
7715 @noindent
7716 The @code{#+ORGTBL: SEND} line tells orgtbl-mode to use the function
7717 @code{orgtbl-to-latex} to convert the table into La@TeX{} and to put it
7718 into the receiver location with name @code{salesfigures}.  You may now
7719 fill in the table, feel free to use the spreadsheet features@footnote{If
7720 the @samp{#+TBLFM} line contains an odd number of dollar characters,
7721 this may cause problems with font-lock in latex-mode.  As shown in the
7722 example you can fix this by adding an extra line inside the
7723 @code{comment} environment that is used to balance the dollar
7724 expressions.  If you are using AUCTeX with the font-latex library, a
7725 much better solution is to add the @code{comment} environment to the
7726 variable @code{LaTeX-verbatim-environments}.}:
7728 @example
7729 % BEGIN RECEIVE ORGTBL salesfigures
7730 % END RECEIVE ORGTBL salesfigures
7731 \begin@{comment@}
7732 #+ORGTBL: SEND salesfigures orgtbl-to-latex
7733 | Month | Days | Nr sold | per day |
7734 |-------+------+---------+---------|
7735 | Jan   |   23 |      55 |     2.4 |
7736 | Feb   |   21 |      16 |     0.8 |
7737 | March |   22 |     278 |    12.6 |
7738 #+TBLFM: $4=$3/$2;%.1f
7739 % $ (optional extra dollar to keep font-lock happy, see footnote)
7740 \end@{comment@}
7741 @end example
7743 @noindent
7744 When you are done, press @kbd{C-c C-c} in the table to get the converted
7745 table inserted between the two marker lines.
7747 Now lets assume you want to make the table header by hand, because you
7748 want to control how columns are aligned etc.  In this case we make sure
7749 that the table translator does skip the first 2 lines of the source
7750 table, and tell the command to work as a @i{splice}, i.e. to not produce
7751 header and footer commands of the target table:
7753 @example
7754 \begin@{tabular@}@{lrrr@}
7755 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
7756 % BEGIN RECEIVE ORGTBL salesfigures
7757 % END RECEIVE ORGTBL salesfigures
7758 \end@{tabular@}
7760 \begin@{comment@}
7761 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
7762 | Month | Days | Nr sold | per day |
7763 |-------+------+---------+---------|
7764 | Jan   |   23 |      55 |     2.4 |
7765 | Feb   |   21 |      16 |     0.8 |
7766 | March |   22 |     278 |    12.6 |
7767 #+TBLFM: $4=$3/$2;%.1f
7768 \end@{comment@}
7769 @end example
7771 The La@TeX{} translator function @code{orgtbl-to-latex} is already part of
7772 Orgtbl-mode.  It uses a @code{tabular} environment to typeset the table
7773 and marks horizontal lines with @code{\hline}.  Furthermore, it
7774 interprets the following parameters:
7776 @table @code
7777 @item :splice nil/t
7778 When set to t, return only table body lines, don't wrap them into a
7779 tabular environment.  Default is nil.
7781 @item :fmt fmt
7782 A format to be used to wrap each field, should contain @code{%s} for the
7783 original field value.  For example, to wrap each field value in dollars,
7784 you could use @code{:fmt "$%s$"}.  This may also be a property list with
7785 column numbers and formats. for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
7787 @item :efmt efmt
7788 Use this format to print numbers with exponentials.  The format should
7789 have @code{%s} twice for inserting mantissa and exponent, for example
7790 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
7791 may also be a property list with column numbers and formats, for example
7792 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
7793 @code{efmt} has been applied to a value, @code{fmt} will also be
7794 applied.
7795 @end table
7797 @node Translator functions,  , A LaTeX example, Tables in arbitrary syntax
7798 @subsection Translator functions
7799 @cindex HTML, and orgtbl-mode
7800 @cindex translator function
7802 Orgtbl-mode has several translator functions built-in:
7803 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and
7804 @code{orgtbl-to-texinfo}.  Except for @code{orgtbl-to-html}@footnote{The
7805 HTML translator uses the same code that produces tables during HTML
7806 export.}, these all use a generic translator, @code{orgtbl-to-generic}.
7807 For example, @code{orgtbl-to-latex} itself is a very short function that
7808 computes the column definitions for the @code{tabular} environment,
7809 defines a few field and line separators and then hands over to the
7810 generic translator.  Here is the entire code:
7812 @lisp
7813 @group
7814 (defun orgtbl-to-latex (table params)
7815   "Convert the orgtbl-mode TABLE to LaTeX."
7816   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
7817                                org-table-last-alignment ""))
7818          (params2
7819           (list
7820            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
7821            :tend "\\end@{tabular@}"
7822            :lstart "" :lend " \\\\" :sep " & "
7823            :efmt "%s\\,(%s)" :hline "\\hline")))
7824     (orgtbl-to-generic table (org-combine-plists params2 params))))
7825 @end group
7826 @end lisp
7828 As you can see, the properties passed into the function (variable
7829 @var{PARAMS}) are combined with the ones newly defined in the function
7830 (variable @var{PARAMS2}).  The ones passed into the function (i.e. the
7831 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
7832 would like to use the La@TeX{} translator, but wanted the line endings to
7833 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
7834 overrule the default with
7836 @example
7837 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
7838 @end example
7840 For a new language, you can either write your own converter function in
7841 analogy with the La@TeX{} translator, or you can use the generic function
7842 directly.  For example, if you have a language where a table is started
7843 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
7844 started with @samp{!BL!}, ended with @samp{!EL!} and where the field
7845 separator is a TAB, you could call the generic translator like this (on
7846 a single line!):
7848 @example
7849 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
7850                               :lstart "!BL! " :lend " !EL!" :sep "\t"
7851 @end example
7853 @noindent
7854 Please check the documentation string of the function
7855 @code{orgtbl-to-generic} for a full list of parameters understood by
7856 that function and remember that you can pass each of them into
7857 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
7858 using the generic function.
7860 Of course you can also write a completely new function doing complicated
7861 things the generic translator cannot do.  A translator function takes
7862 two arguments.  The first argument is the table, a list of lines, each
7863 line either the symbol @code{hline} or a list of fields.  The second
7864 argument is the property list containing all parameters specified in the
7865 @samp{#+ORGTBL: SEND} line.  The function must return a single string
7866 containing the formatted table.  If you write a generally useful
7867 translator, please post it on @code{emacs-orgmode@@gnu.org} so that
7868 others can benefit from your work.
7870 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Extensions and Hacking
7871 @section Dynamic blocks
7872 @cindex dynamic blocks
7874 Org-mode documents can contain @emph{dynamic blocks}.  These are
7875 specially marked regions that are updated by some user-written function.
7876 A good example for such a block is the clock table inserted by the
7877 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
7879 Dynamic block are enclosed by a BEGIN-END structure that assigns a name
7880 to the block and can also specify parameters for the function producing
7881 the content of the block.
7883 @example
7884 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
7886 #+END:
7887 @end example
7889 Dynamic blocks are updated with the following commands
7891 @table @kbd
7892 @kindex C-c C-x C-u
7893 @item C-c C-x C-u
7894 Update dynamic block at point.
7895 @kindex C-u C-c C-x C-u
7896 @item C-u C-c C-x C-u
7897 Update all dynamic blocks in the current file.
7898 @end table
7900 Updating a dynamic block means to remove all the text between BEGIN and
7901 END, parse the BEGIN line for parameters and then call the specific
7902 writer function for this block to insert the new content.  For a block
7903 with name @code{myblock}, the writer function is
7904 @code{org-dblock-write:myblock} with as only parameter a property list
7905 with the parameters given in the begin line.  Here is a trivial example
7906 of a block that keeps track of when the block update function was last
7907 run:
7909 @example
7910 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
7912 #+END:
7913 @end example
7915 @noindent
7916 The corresponding block writer function could look like this:
7918 @lisp
7919 (defun org-dblock-write:block-update-time (params)
7920    (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
7921      (insert "Last block update at: "
7922              (format-time-string fmt (current-time)))))
7923 @end lisp
7925 If you want to make sure that all dynamic blocks are always up-to-date,
7926 you could add the function @code{org-update-all-dblocks} to a hook, for
7927 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
7928 written in a way that is does nothing in buffers that are not in Org-mode.
7930 @node Special agenda views, Using the property API, Dynamic blocks, Extensions and Hacking
7931 @section Special Agenda Views
7932 @cindex agenda views, user-defined
7934 Org-mode provides a special hook that can be used to narrow down the
7935 selection made by any of the agenda views.  You may specify a function
7936 that is used at each match to verify if the match should indeed be part
7937 of the agenda view, and if not, how much should be skipped.
7939 Let's say you want to produce a list of projects that contain a WAITING
7940 tag anywhere in the project tree.  Let's further assume that you have
7941 marked all tree headings that define a project with the todo keyword
7942 PROJECT.  In this case you would run a todo search for the keyword
7943 PROJECT, but skip the match unless there is a WAITING tag anywhere in
7944 the subtree belonging to the project line.
7946 To achieve this, you must write a function that searches the subtree for
7947 the tag.  If the tag is found, the function must return @code{nil} to
7948 indicate that this match should not be skipped.  If there is no such
7949 tag, return the location of the end of the subtree, to indicate that
7950 search should continue from there.
7952 @lisp
7953 (defun my-skip-unless-waiting ()
7954   "Skip trees that are not waiting"
7955   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
7956     (if (re-search-forward ":WAITING:" subtree-end t)
7957         nil          ; tag found, do not skip
7958       subtree-end))) ; tag not found, continue after end of subtree
7959 @end lisp
7961 Now you may use this function in an agenda custom command, for example
7962 like this:
7964 @lisp
7965 (org-add-agenda-custom-command
7966  '("b" todo "PROJECT"
7967    ((org-agenda-skip-function 'my-org-waiting-projects)
7968     (org-agenda-overriding-header "Projects waiting for something: "))))
7969 @end lisp
7971 Note that this also binds @code{org-agenda-overriding-header} to get a
7972 meaningful header in the agenda view.
7974 You may also put a Lisp form into @code{org-agenda-skip-function}.  In
7975 particular, you may use the functions @code{org-agenda-skip-entry-if}
7976 and @code{org-agenda-skip-subtree-if} in this form, for example:
7978 @table @code
7979 @item '(org-agenda-skip-entry-if 'scheduled)
7980 Skip current entry if it has been scheduled.
7981 @item '(org-agenda-skip-entry-if 'notscheduled)
7982 Skip current entry if it has not been scheduled.
7983 @item '(org-agenda-skip-entry-if 'deadline)
7984 Skip current entry if it has a deadline.
7985 @item '(org-agenda-skip-entry-if 'scheduled 'deadline)
7986 Skip current entry if it has a deadline, or if it is scheduled.
7987 @item '(org-agenda-skip-entry 'regexp "regular expression")
7988 Skip current entry if the regular expression matches in the entry.
7989 @item '(org-agenda-skip-entry 'notregexp "regular expression")
7990 Skip current entry unless the regular expression matches.
7991 @item '(org-agenda-skip-subtree-if 'regexp "regular expression")
7992 Same as above, but check and skip the entire subtree.
7993 @end table
7995 Therefore we could also have written the search for WAITING projects
7996 like this, even without defining a special function:
7998 @lisp
7999 (org-add-agenda-custom-command
8000  '("b" todo "PROJECT"
8001    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
8002                                 'regexp ":WAITING:"))
8003     (org-agenda-overriding-header "Projects waiting for something: "))))
8004 @end lisp
8007 @node Using the property API,  , Special agenda views, Extensions and Hacking
8008 @section Using the property API
8009 @cindex API, for properties
8010 @cindex properties, API
8012 Here is a description of the functions that can be used to work with
8013 properties.
8015 @defun org-entry-properties &optional pom which
8016 Get all properties of the entry at point-or-marker POM.
8017 This includes the TODO keyword, the tags, time strings for deadline,
8018 scheduled, and clocking, and any additional properties defined in the
8019 entry.  The return value is an alist, keys may occur multiple times
8020 if the property key was used several times.
8021 POM may also be nil, in which case the current entry is used.
8022 If WHICH is nil or `all', get all properties.  If WHICH is
8023 `special' or `standard', only get that subclass.
8024 @end defun
8025 @defun org-entry-get pom property &optional inherit
8026 Get value of PROPERTY for entry at point-or-marker POM.
8027 If INHERIT is non-nil and the entry does not have the property,
8028 then also check higher levels of the hierarchy.
8029 @end defun
8031 @defun org-entry-delete pom property
8032 Delete the property PROPERTY from entry at point-or-marker POM.
8033 @end defun
8035 @defun org-entry-put pom property value
8036 Set PROPERTY to VALUE for entry at point-or-marker POM.
8037 @end defun
8039 @defun org-buffer-property-keys &optional include-specials
8040 Get all property keys in the current buffer.
8041 @end defun
8043 @defun org-insert-property-drawer
8044 Insert a property drawer at point.
8045 @end defun
8047 @node History and Acknowledgments, Index, Extensions and Hacking, Top
8048 @appendix History and Acknowledgments
8049 @cindex acknowledgments
8050 @cindex history
8051 @cindex thanks
8053 Org-mode was borne in 2003, out of frustration over the user interface
8054 of the Emacs outline-mode.  I was trying to organize my notes and
8055 projects, and using Emacs seemed to be the natural way to go.  However,
8056 having to remember eleven different commands with two or three keys per
8057 command, only to hide and unhide parts of the outline tree, that seemed
8058 entirely unacceptable to me.  Also, when using outlines to take notes, I
8059 constantly want to restructure the tree, organizing it parallel to my
8060 thoughts and plans.  @emph{Visibility cycling} and @emph{structure
8061 editing} were originally implemented in the package
8062 @file{outline-magic.el}, but quickly moved to the more general
8063 @file{org.el}.  As this environment became comfortable for project
8064 planning, the next step was adding @emph{TODO entries}, basic @emph{time
8065 stamps}, and @emph{table support}.  These areas highlight the two main
8066 goals that Org-mode still has today: To create a new, outline-based,
8067 plain text mode with innovative and intuitive editing features, and to
8068 incorporate project planning functionality directly into a notes file.
8070 Since the first release, literally thousands of emails to me or on
8071 @code{emacs-orgmode@@gnu.org} have provided a constant stream of bug
8072 reports, feedback, new ideas, and sometimes patches and add-on code.
8073 Many thanks to everyone who has helped to improve this package.  I am
8074 trying to keep here a list of the people who had significant influence
8075 in shaping one or more aspects of Org-mode.  The list may not be
8076 complete, if I have forgotten someone, please accept my apologies and
8077 let me know.
8079 @itemize @bullet
8081 @item
8082 @i{Russel Adams} came up with the idea for drawers.
8083 @item
8084 @i{Thomas Baumann} contributed the code for links to the MH-E email
8085 system.
8086 @item
8087 @i{Alex Bochannek} provided a patch for rounding time stamps.
8088 @item
8089 @i{Charles Cave}'s suggestion sparked the implementation of templates
8090 for Remember.
8091 @item
8092 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
8093 specified time.
8094 @item
8095 @i{Gregory Chernov} patched support for lisp forms into table
8096 calculations and improved XEmacs compatibility, in particular by porting
8097 @file{nouline.el} to XEmacs.
8098 @item
8099 @i{Sacha Chua} suggested to copy some linking code from Planner.
8100 @item
8101 @i{Eddward DeVilla} proposed and tested checkbox statistics.  He also
8102 came up with the idea of properties, and that there should be an API for
8103 them.
8104 @item
8105 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
8106 inspired some of the early development, including HTML export.  He also
8107 asked for a way to narrow wide table columns.
8108 @item
8109 @i{Christian Egli} converted the documentation into TeXInfo format,
8110 patched CSS formatting into the HTML exporter, and inspired the agenda.
8111 @item
8112 @i{David Emery} provided a patch for custom CSS support in exported
8113 HTML agendas.
8114 @item
8115 @i{Nic Ferrier} contributed mailcap and XOXO support.
8116 @item
8117 @i{John Foerch} figured out how to make incremental search show context
8118 around a match in a hidden outline tree.
8119 @item
8120 @i{Niels Giesen} had the idea to automatically archive DONE trees.
8121 @item
8122 @i{Bastien Guerry} wrote the La@TeX{} exporter and has been prolific
8123 with patches, ideas, and bug reports.
8124 @item
8125 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
8126 @item
8127 @i{Scott Jaderholm} proposed footnotes, control over whitespace between
8128 folded entries, and column view for properties.
8129 @item
8130 @i{Shidai Liu} ("Leo") asked for embedded La@TeX{} and tested it.  He also
8131 provided frequent feedback and some patches.
8132 @item
8133 @i{Jason F. McBrayer} suggested agenda export to CSV format.
8134 @item
8135 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
8136 basis.
8137 @item
8138 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
8139 happy.
8140 @item
8141 @i{Rick Moynihan} proposed to allow multiple TODO sequences in a file.
8142 @item
8143 @i{Todd Neal} provided patches for links to Info files and elisp forms.
8144 @item
8145 @i{Tim O'Callaghan} suggested in-file links, search options for general
8146 file links, and TAGS.
8147 @item
8148 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
8149 into Japanese.
8150 @item
8151 @i{Oliver Oppitz} suggested multi-state TODO items.
8152 @item
8153 @i{Scott Otterson} sparked the introduction of descriptive text for
8154 links, among other things.
8155 @item
8156 @i{Pete Phillips} helped during the development of the TAGS feature, and
8157 provided frequent feedback.
8158 @item
8159 @i{T.V. Raman} reported bugs and suggested improvements.
8160 @item
8161 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
8162 control.
8163 @item
8164 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
8165 @item
8166 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
8167 conflict with @file{allout.el}.
8168 @item
8169 @i{Jason Riedy} sent a patch to fix a bug with export of TODO keywords.
8170 @item
8171 @i{Philip Rooke} created the Org-mode reference card and provided lots
8172 of feedback.
8173 @item
8174 @i{Christian Schlauer} proposed angular brackets around links, among
8175 other things.
8176 @item
8177 Linking to VM/BBDB/GNUS was inspired by @i{Tom Shannon}'s
8178 @file{organizer-mode.el}.
8179 @item
8180 @i{Daniel Sinder} came up with the idea of internal archiving by locking
8181 subtrees.
8182 @item
8183 @i{Dale Smith} proposed link abbreviations.
8184 @item
8185 @i{Adam Spiers} asked for global linking commands and inspired the link
8186 extension system.  support mairix.
8187 @item
8188 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
8189 chapter about publishing.
8190 @item
8191 @i{J@"urgen Vollmer} contributed code generating the table of contents
8192 in HTML output.
8193 @item
8194 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
8195 keyword.
8196 @item
8197 @i{David Wainberg} suggested archiving, and improvements to the linking
8198 system.
8199 @item
8200 @i{John Wiegley} wrote @file{emacs-wiki.el} and @file{planner.el}.  The
8201 development of Org-mode was fully independent, and both systems are
8202 really different beasts in their basic ideas and implementation details.
8203 I later looked at John's code, however, and learned from his
8204 implementation of (i) links where the link itself is hidden and only a
8205 description is shown, and (ii) popping up a calendar to select a date.
8206 John has also contributed a number of great ideas directly to Org-mode.
8207 @item
8208 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
8209 linking to GNUS.
8210 @item
8211 @i{Roland Winkler} requested additional keybindings to make Org-mode
8212 work on a tty.
8213 @item
8214 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
8215 and contributed various ideas and code snippets.
8216 @end itemize
8219 @node Index, Key Index, History and Acknowledgments, Top
8220 @unnumbered Index
8222 @printindex cp
8224 @node Key Index,  , Index, Top
8225 @unnumbered Key Index
8227 @printindex ky
8229 @bye
8231 @ignore
8232    arch-tag: 7893d1fe-cc57-4d13-b5e5-f494a1bcc7ac
8233 @end ignore