Another bug fix in org-publish, related to the FORCE argument.
[org-mode/org-tableheadings.git] / org.texi
blob0daa1102509c5ce84e14016dee26e55fe1ecbec0
1 \input texinfo
2 @c %**start of header
3 @setfilename ../../info/org
4 @settitle Org Mode Manual
6 @set VERSION 5.22a
7 @set DATE February 2008
9 @dircategory Emacs
10 @direntry
11 * Org Mode: (org).      Outline-based notes management and organizer
12 @end direntry
14 @c Version and Contact Info
15 @set MAINTAINERSITE @uref{http://orgmode.org,maintainers webpage}
16 @set AUTHOR Carsten Dominik
17 @set MAINTAINER Carsten Dominik
18 @set MAINTAINEREMAIL @email{carsten at orgmode dot org}
19 @set MAINTAINERCONTACT @uref{mailto:carsten at orgmode dot org,contact the maintainer}
20 @c %**end of header
21 @finalout
23 @c Macro definitions
25 @c Subheadings inside a table.
26 @macro tsubheading{text}
27 @ifinfo
28 @subsubheading \text\
29 @end ifinfo
30 @ifnotinfo
31 @item @b{\text\}
32 @end ifnotinfo
33 @end macro
35 @copying
36 This manual is for Org-mode (version @value{VERSION}).
38 Copyright @copyright{} 2004, 2005, 2006, 2007, 2008 Free Software Foundation
40 @quotation
41 Permission is granted to copy, distribute and/or modify this document
42 under the terms of the GNU Free Documentation License, Version 1.1 or
43 any later version published by the Free Software Foundation; with no
44 Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
45 and with the Back-Cover Texts as in (a) below.  A copy of the
46 license is included in the section entitled ``GNU Free Documentation
47 License.''
49 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
50 this GNU Manual, like GNU software.  Copies published by the Free
51 Software Foundation raise funds for GNU development.''
52 @end quotation
53 @end copying
55 @titlepage
56 @title Org Mode Manual
58 @subtitle Release @value{VERSION}
59 @author by Carsten Dominik
61 @c The following two commands start the copyright page.
62 @page
63 @vskip 0pt plus 1filll
64 @insertcopying
65 @end titlepage
67 @c Output the table of contents at the beginning.
68 @contents
70 @ifnottex
71 @node Top, Introduction, (dir), (dir)
72 @top Org Mode Manual
74 @insertcopying
75 @end ifnottex
77 @menu
78 * Introduction::                Getting started
79 * Document structure::          A tree works like your brain
80 * Tables::                      Pure magic for quick formatting
81 * Hyperlinks::                  Notes in context
82 * TODO items::                  Every tree branch can be a TODO item
83 * Tags::                        Tagging headlines and matching sets of tags
84 * Properties and columns::      Storing information about an entry
85 * Dates and times::             Making items useful for planning
86 * Remember::                    Quickly adding nodes to the outline tree
87 * Agenda views::                Collecting information into views
88 * Embedded LaTeX::              LaTeX fragments and formulas
89 * Exporting::                   Sharing and publishing of notes
90 * Publishing::                  Create a web site of linked Org-mode files
91 * Miscellaneous::               All the rest which did not fit elsewhere
92 * Extensions and Hacking::      It is possible to write add-on code
93 * History and Acknowledgments::  How Org-mode came into being 
94 * Main Index::                  
95 * Key Index::                   Key bindings and where they are described
97 @detailmenu
98  --- The Detailed Node Listing ---
100 Introduction
102 * Summary::                     Brief summary of what Org-mode does
103 * Installation::                How to install a downloaded version of Org-mode
104 * Activation::                  How to activate Org-mode for certain buffers.
105 * Feedback::                    Bug reports, ideas, patches etc.
106 * Conventions::                 Type-setting conventions in the manual
108 Document Structure
110 * Outlines::                    Org-mode is based on outline-mode
111 * Headlines::                   How to typeset org-tree headlines
112 * Visibility cycling::          Show and hide, much simplified
113 * Motion::                      Jumping to other headlines
114 * Structure editing::           Changing sequence and level of headlines
115 * Archiving::                   Move done task trees to a different place
116 * Sparse trees::                Matches embedded in context
117 * Plain lists::                 Additional structure within an entry
118 * Drawers::                     Tucking stuff away
119 * orgstruct-mode::              Structure editing outside Org-mode
121 Archiving
123 * ARCHIVE tag::                 Marking a tree as inactive
124 * Moving subtrees::             Moving a tree to an archive file
126 Tables
128 * Built-in table editor::       Simple tables
129 * Narrow columns::              Stop wasting space in tables   
130 * Column groups::               Grouping to trigger vertical lines
131 * orgtbl-mode::                 The table editor as minor mode
132 * The spreadsheet::             The table editor has spreadsheet capabilities.
134 The spreadsheet
136 * References::                  How to refer to another field or range
137 * Formula syntax for Calc::     Using Calc to compute stuff
138 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
139 * Field formulas::              Formulas valid for a single field
140 * Column formulas::             Formulas valid for an entire column
141 * Editing and debugging formulas::  Fixing formulas
142 * Updating the table::          Recomputing all dependent fields
143 * Advanced features::           Field names, parameters and automatic recalc
145 Hyperlinks
147 * Link format::                 How links in Org-mode are formatted
148 * Internal links::              Links to other places in the current file
149 * External links::              URL-like links to the world
150 * Handling links::              Creating, inserting and following
151 * Using links outside Org-mode::  Linking from my C source code?
152 * Link abbreviations::          Shortcuts for writing complex links
153 * Search options::              Linking to a specific location
154 * Custom searches::             When the default search is not enough
156 Internal links
158 * Radio targets::               Make targets trigger links in plain text.
160 TODO items
162 * TODO basics::                 Marking and displaying TODO entries
163 * TODO extensions::             Workflow and assignments
164 * Progress logging::            Dates and notes for progress
165 * Priorities::                  Some things are more important than others
166 * Breaking down tasks::         Splitting a task into manageable pieces
167 * Checkboxes::                  Tick-off lists
169 Extended use of TODO keywords
171 * Workflow states::             From TODO to DONE in steps
172 * TODO types::                  I do this, Fred does the rest
173 * Multiple sets in one file::   Mixing it all, and still finding your way
174 * Fast access to TODO states::  Single letter selection of a state
175 * Per-file keywords::           Different files, different requirements
176 * Faces for TODO keywords::     Highlighting states
178 Progress Logging
180 * Closing items::               When was this entry marked DONE?
181 * Tracking TODO state changes::  When did the status change?
183 Tags
185 * Tag inheritance::             Tags use the tree structure of the outline
186 * Setting tags::                How to assign tags to a headline
187 * Tag searches::                Searching for combinations of tags
189 Properties and Columns
191 * Property syntax::             How properties are spelled out
192 * Special properties::          Access to other Org-mode features
193 * Property searches::           Matching property values
194 * Property inheritance::        Passing values down the tree
195 * Column view::                 Tabular viewing and editing
196 * Property API::                Properties for Lisp programmers
198 Column View
200 * Defining columns::            The COLUMNS format property
201 * Using column view::           How to create and use column view
202 * Capturing Column View::       A dynamic block for column view
204 Defining Columns
206 * Scope of column definitions::  Where defined, where valid?
207 * Column attributes::           Appearance and content of a column
209 Dates and Times
211 * Time stamps::                 Assigning a time to a tree entry
212 * Creating timestamps::         Commands which insert timestamps
213 * Deadlines and scheduling::    Planning your work
214 * Clocking work time::          
216 Creating timestamps
218 * The date/time prompt::        How org-mode helps you entering date and time
219 * Custom time format::          Making dates look differently
221 Deadlines and Scheduling
223 * Inserting deadline/schedule::  Planning items
224 * Repeated tasks::              Items that show up again and again
226 Remember
228 * Setting up remember::         Some code for .emacs to get things going
229 * Remember templates::          Define the outline of different note types
230 * Storing notes::               Directly get the note to where it belongs
231 * Refiling notes::              Moving a note or task to a project
233 Agenda Views
235 * Agenda files::                Files being searched for agenda information
236 * Agenda dispatcher::           Keyboard access to agenda views
237 * Built-in agenda views::       What is available out of the box?
238 * Presentation and sorting::    How agenda items are prepared for display
239 * Agenda commands::             Remote editing of org trees
240 * Custom agenda views::         Defining special searches and views
242 The built-in agenda views
244 * Weekly/Daily agenda::         The calendar page with current tasks
245 * Global TODO list::            All unfinished action items
246 * Matching tags and properties::  Structured information with fine-tuned search
247 * Timeline::                    Time-sorted view for single file
248 * Stuck projects::              Find projects you need to review
250 Presentation and sorting
252 * Categories::                  Not all tasks are equal
253 * Time-of-day specifications::  How the agenda knows the time
254 * Sorting of agenda items::     The order of things
256 Custom agenda views
258 * Storing searches::            Type once, use often
259 * Block agenda::                All the stuff you need in a single buffer
260 * Setting Options::             Changing the rules
261 * Exporting Agenda Views::      Writing agendas to files.
262 * Extracting Agenda Information for other programs::  
264 Embedded LaTeX
266 * Math symbols::                TeX macros for symbols and Greek letters
267 * Subscripts and Superscripts::  Simple syntax for raising/lowering text
268 * LaTeX fragments::             Complex formulas made easy
269 * Processing LaTeX fragments::  Previewing LaTeX processing
270 * CDLaTeX mode::                Speed up entering of formulas
272 Exporting
274 * ASCII export::                Exporting to plain ASCII
275 * HTML export::                 Exporting to HTML
276 * LaTeX export::                Exporting to LaTeX
277 * XOXO export::                 Exporting to XOXO
278 * iCalendar export::            Exporting in iCalendar format
279 * Text interpretation::         How the exporter looks at the file
281 HTML export
283 * HTML Export commands::        How to invoke LaTeX export
284 * Quoting HTML tags::           Using direct HTML in Org-mode
285 * Links::                       Transformation of links for HTML
286 * Images::                      How to include images
287 * CSS support::                 Changing the appearence of the output
289 LaTeX export
291 * LaTeX export commands::       How to invoke LaTeX export
292 * Quoting LaTeX code::          Incorporating literal LaTeX code
293 * Sectioning structure::        
295 Text interpretation by the exporter
297 * Comment lines::               Some lines will not be exported
298 * Initial text::                Text before the first headline
299 * Footnotes::                   Numbers like [1]
300 * Quoted examples::             Inserting quoted chnuks of text            
301 * Enhancing text::              Subscripts, symbols and more
302 * Export options::              How to influence the export settings
304 Publishing
306 * Configuration::               Defining projects
307 * Sample configuration::        Example projects
308 * Triggering publication::      Publication commands
310 Configuration
312 * Project alist::               The central configuration variable
313 * Sources and destinations::    From here to there
314 * Selecting files::             What files are part of the project?
315 * Publishing action::           Setting the function doing the publishing
316 * Publishing options::          Tweaking HTML export
317 * Publishing links::            Which links keep working after publishing?
318 * Project page index::          Publishing a list of project files
320 Sample configuration
322 * Simple example::              One-component publishing
323 * Complex example::             A multi-component publishing example
325 Miscellaneous
327 * Completion::                  M-TAB knows what you need
328 * Customization::               Adapting Org-mode to your taste
329 * In-buffer settings::          Overview of the #+KEYWORDS
330 * The very busy C-c C-c key::   When in doubt, press C-c C-c
331 * Clean view::                  Getting rid of leading stars in the outline
332 * TTY keys::                    Using Org-mode on a tty
333 * Interaction::                 Other Emacs packages
334 * Bugs::                        Things which do not work perfectly
336 Interaction with other packages
338 * Cooperation::                 Packages Org-mode cooperates with
339 * Conflicts::                   Packages that lead to conflicts
341 Extensions, Hooks and Hacking
343 * Extensions::                  Existing 3rd-part extensions
344 * Adding hyperlink types::      New custom link types
345 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
346 * Dynamic blocks::              Automatically filled blocks
347 * Special agenda views::        Customized views
348 * Using the property API::      Writing programs that use entry properties
350 Tables and Lists in arbitrary syntax
352 * Radio tables::                Sending and receiving
353 * A LaTeX example::             Step by step, almost a tutorial
354 * Translator functions::        Copy and modify
355 * Radio lists::                 Doing the same for lists.
357 @end detailmenu
358 @end menu
360 @node Introduction, Document structure, Top, Top
361 @chapter Introduction
362 @cindex introduction
364 @menu
365 * Summary::                     Brief summary of what Org-mode does
366 * Installation::                How to install a downloaded version of Org-mode
367 * Activation::                  How to activate Org-mode for certain buffers.
368 * Feedback::                    Bug reports, ideas, patches etc.
369 * Conventions::                 Type-setting conventions in the manual
370 @end menu
372 @node Summary, Installation, Introduction, Introduction
373 @section Summary
374 @cindex summary
376 Org-mode is a mode for keeping notes, maintaining TODO lists, and doing
377 project planning with a fast and effective plain-text system.
379 Org-mode develops organizational tasks around NOTES files that contain
380 lists or information about projects as plain text.  Org-mode is
381 implemented on top of outline-mode, which makes it possible to keep the
382 content of large files well structured.  Visibility cycling and
383 structure editing help to work with the tree.  Tables are easily created
384 with a built-in table editor.  Org-mode supports TODO items, deadlines,
385 time stamps, and scheduling.  It dynamically compiles entries into an
386 agenda that utilizes and smoothly integrates much of the Emacs calendar
387 and diary.  Plain text URL-like links connect to websites, emails,
388 Usenet messages, BBDB entries, and any files related to the projects.
389 For printing and sharing of notes, an Org-mode file can be exported as a
390 structured ASCII file, as HTML, or (TODO and agenda items only) as an
391 iCalendar file.  It can also serve as a publishing tool for a set of
392 linked webpages.
394 An important design aspect that distinguishes Org-mode from for example
395 Planner/Muse is that it encourages to store every piece of information
396 only once.  In Planner, you have project pages, day pages and possibly
397 other files, duplicating some information such as tasks.  In Org-mode,
398 you only have notes files.  In your notes you mark entries as tasks,
399 label them with tags and timestamps.  All necessary lists like a
400 schedule for the day, the agenda for a meeting, tasks lists selected by
401 tags etc are created dynamically when you need them.
403 Org-mode keeps simple things simple.  When first fired up, it should
404 feel like a straightforward, easy to use outliner.  Complexity is not
405 imposed, but a large amount of functionality is available when you need
406 it.  Org-mode is a toolbox and can be used in different ways, for
407 example as:
409 @example
410 @r{@bullet{} outline extension with visibility cycling and structure editing}
411 @r{@bullet{} ASCII system and table editor for taking structured notes}
412 @r{@bullet{} ASCII table editor with spreadsheet-like capabilities}
413 @r{@bullet{} TODO list editor}
414 @r{@bullet{} full agenda and planner with deadlines and work scheduling}
415 @r{@bullet{} environment to implement David Allen's GTD system}
416 @r{@bullet{} a basic database application}
417 @r{@bullet{} simple hypertext system, with HTML and LaTeX export}
418 @r{@bullet{} publishing tool to create a set of interlinked webpages}
419 @end example
421 Org-mode's automatic, context sensitive table editor with spreadsheet
422 capabilities can be integrated into any major mode by activating the
423 minor Orgtbl-mode.  Using a translation step, it can be used to maintain
424 tables in arbitrary file types, for example in La@TeX{}.  The structure
425 editing and list creation capabilities can be used outside Org-mode with
426 the minor Orgstruct-mode.
428 @cindex FAQ
429 There is a website for Org-mode which provides links to the newest
430 version of Org-mode, as well as additional information, frequently asked
431 questions (FAQ), links to tutorials etc.  This page is located at
432 @uref{http://orgmode.org}.
434 @page
437 @node Installation, Activation, Summary, Introduction
438 @section Installation
439 @cindex installation
440 @cindex XEmacs
442 @b{Important:} @i{If Org-mode is part of the Emacs distribution or an
443 XEmacs package, please skip this section and go directly to
444 @ref{Activation}.}
446 If you have downloaded Org-mode from the Web, you must take the
447 following steps to install it: Go into the Org-mode distribution
448 directory and edit the top section of the file @file{Makefile}.  You
449 must set the name of the Emacs binary (likely either @file{emacs} or
450 @file{xemacs}), and the paths to the directories where local Lisp and
451 Info files are kept.  If you don't have access to the system-wide
452 directories, create your own two directories for these files, enter them
453 into the Makefile, and make sure Emacs finds the Lisp files by adding
454 the following line to @file{.emacs}:
456 @example
457 (setq load-path (cons "~/path/to/lispdir" load-path))
458 @end example
460 @b{XEmacs users now need to install the file @file{noutline.el} from
461 the @file{xemacs} subdirectory of the Org-mode distribution.  Use the
462 command:}
464 @example
465 @b{make install-noutline}
466 @end example
468 @noindent Now byte-compile and install the Lisp files with the shell
469 commands:
471 @example
472 make
473 make install
474 @end example
476 @noindent If you want to install the info documentation, use this command:
478 @example
479 make install-info
480 @end example
482 @noindent Then add to @file{.emacs}:
484 @lisp
485 ;; This line only if org-mode is not part of the X/Emacs distribution.
486 (require 'org-install)
487 @end lisp
489 @node Activation, Feedback, Installation, Introduction
490 @section Activation
491 @cindex activation
492 @cindex autoload
493 @cindex global keybindings
494 @cindex keybindings, global
496 @iftex
497 @b{Important:} @i{If you use copy-and-paste to copy lisp code from the
498 PDF documentation as viewed by Acrobat reader to your .emacs file, the
499 single quote character comes out incorrectly and the code will not work.
500 You need to fix the single quotes by hand, or copy from Info
501 documentation.}
502 @end iftex
504 Add the following lines to your @file{.emacs} file.  The last two lines
505 define @emph{global} keys for the commands @command{org-store-link} and
506 @command{org-agenda} - please choose suitable keys yourself.
508 @lisp
509 ;; The following lines are always needed.  Choose your own keys.
510 (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
511 (global-set-key "\C-cl" 'org-store-link)
512 (global-set-key "\C-ca" 'org-agenda)
513 @end lisp
515 Furthermore, you must activate @code{font-lock-mode} in org-mode
516 buffers, because significant functionality depends on font-locking being
517 active.  You can do this with either one of the following two lines
518 (XEmacs user must use the second option):
519 @lisp
520 (global-font-lock-mode 1)                     ; for all buffers
521 (add-hook 'org-mode-hook 'turn-on-font-lock)  ; org-mode buffers only
522 @end lisp
524 @cindex org-mode, turning on
525 With this setup, all files with extension @samp{.org} will be put
526 into Org-mode.  As an alternative, make the first line of a file look
527 like this:
529 @example
530 MY PROJECTS    -*- mode: org; -*-
531 @end example
533 @noindent which will select Org-mode for this buffer no matter what
534 the file's name is.  See also the variable
535 @code{org-insert-mode-line-in-empty-file}.
537 @node Feedback, Conventions, Activation, Introduction
538 @section Feedback
539 @cindex feedback
540 @cindex bug reports
541 @cindex maintainer
542 @cindex author
544 If you find problems with Org-mode, or if you have questions, remarks,
545 or ideas about it, please contact the maintainer @value{MAINTAINER} at
546 @value{MAINTAINEREMAIL}.
548 For bug reports, please provide as much information as possible,
549 including the version information of Emacs (@kbd{C-h v emacs-version
550 @key{RET}}) and Org-mode (@kbd{C-h v org-version @key{RET}}), as well as
551 the Org-mode related setup in @file{.emacs}.  If an error occurs, a
552 backtrace can be very useful (see below on how to create one).  Often a
553 small example file helps, along with clear information about:
555 @enumerate
556 @item What exactly did you do?
557 @item What did you expect to happen?
558 @item What happened instead?
559 @end enumerate
560 @noindent Thank you for helping to improve this mode.
562 @subsubheading How to create a useful backtrace
564 @cindex backtrace of an error
565 If working with Org-mode produces an error with a message you don't
566 understand, you may have hit a bug.  The best way to report this is by
567 providing, in addition to what was mentioned above, a @emph{Backtrace}.
568 This is information from the built-in debugger about where and how the
569 error occurred.  Here is how to produce a useful backtrace:
571 @enumerate
572 @item
573 Start a fresh Emacs or XEmacs, and make sure that it will load the
574 original Lisp code in @file{org.el} instead of the compiled version in
575 @file{org.elc}.  The backtrace contains much more information if it is
576 produced with uncompiled code.  To do this, either rename @file{org.elc}
577 to something else before starting Emacs, or ask Emacs explicitly to load
578 @file{org.el} by using the command line
579 @example
580 emacs -l /path/to/org.el
581 @end example
582 @item
583 Go to the @code{Options} menu and select @code{Enter Debugger on Error}
584 (XEmacs has this option in the @code{Troubleshooting} sub-menu).
585 @item
586 Do whatever you have to do to hit the error.  Don't forget to
587 document the steps you take.
588 @item
589 When you hit the error, a @file{*Backtrace*} buffer will appear on the
590 screen.  Save this buffer to a file (for example using @kbd{C-x C-w}) and
591 attach it to your bug report.
592 @end enumerate
594 @node Conventions,  , Feedback, Introduction
595 @section Typesetting conventions used in this manual
597 Org-mode uses three types of keywords: TODO keywords, tags, and property
598 names.  In this manual we use the following conventions:
600 @table @code
601 @item TODO
602 @itemx WAITING
603 TODO keywords are written with all capitals, even if they are
604 user-defined.
605 @item boss
606 @itemx ARCHIVE
607 User-defined tags are written in lowercase; built-in tags with special
608 meaning are written with all capitals.
609 @item Release
610 @itemx PRIORITY
611 User-defined properties are capitalized; built-in properties with
612 special meaning are written with all capitals.
613 @end table
615 @node Document structure, Tables, Introduction, Top
616 @chapter Document Structure
617 @cindex document structure
618 @cindex structure of document
620 Org-mode is based on outline mode and provides flexible commands to
621 edit the structure of the document.
623 @menu
624 * Outlines::                    Org-mode is based on outline-mode
625 * Headlines::                   How to typeset org-tree headlines
626 * Visibility cycling::          Show and hide, much simplified
627 * Motion::                      Jumping to other headlines
628 * Structure editing::           Changing sequence and level of headlines
629 * Archiving::                   Move done task trees to a different place
630 * Sparse trees::                Matches embedded in context
631 * Plain lists::                 Additional structure within an entry
632 * Drawers::                     Tucking stuff away
633 * orgstruct-mode::              Structure editing outside Org-mode
634 @end menu
636 @node Outlines, Headlines, Document structure, Document structure
637 @section Outlines
638 @cindex outlines
639 @cindex outline-mode
641 Org-mode is implemented on top of outline-mode.  Outlines allow a
642 document to be organized in a hierarchical structure, which (at least
643 for me) is the best representation of notes and thoughts.  An overview
644 of this structure is achieved by folding (hiding) large parts of the
645 document to show only the general document structure and the parts
646 currently being worked on.  Org-mode greatly simplifies the use of
647 outlines by compressing the entire show/hide functionality into a single
648 command @command{org-cycle}, which is bound to the @key{TAB} key.
650 @node Headlines, Visibility cycling, Outlines, Document structure
651 @section Headlines
652 @cindex headlines
653 @cindex outline tree
655 Headlines define the structure of an outline tree.  The headlines in
656 Org-mode start with one or more stars, on the left margin@footnote{See
657 the variable @code{org-special-ctrl-a/e} to configure special behavior
658 of @kbd{C-a} and @kbd{C-e} in headlines.}.  For example:
660 @example
661 * Top level headline
662 ** Second level
663 *** 3rd level
664     some text
665 *** 3rd level
666     more text
668 * Another top level headline
669 @end example
671 @noindent Some people find the many stars too noisy and would prefer an
672 outline that has whitespace followed by a single star as headline
673 starters.  @ref{Clean view} describes a setup to realize this.
675 An empty line after the end of a subtree is considered part of it and
676 will be hidden when the subtree is folded.  However, if you leave at
677 least two empty lines, one empty line will remain visible after folding
678 the subtree, in order to structure the collapsed view.  See the
679 variable @code{org-cycle-separator-lines} to modify this behavior.
681 @node Visibility cycling, Motion, Headlines, Document structure
682 @section Visibility cycling
683 @cindex cycling, visibility
684 @cindex visibility cycling
685 @cindex trees, visibility
686 @cindex show hidden text
687 @cindex hide text
689 Outlines make it possible to hide parts of the text in the buffer.
690 Org-mode uses just two commands, bound to @key{TAB} and
691 @kbd{S-@key{TAB}} to change the visibility in the buffer.
693 @cindex subtree visibility states
694 @cindex subtree cycling
695 @cindex folded, subtree visibility state
696 @cindex children, subtree visibility state
697 @cindex subtree, subtree visibility state
698 @table @kbd
699 @kindex @key{TAB}
700 @item @key{TAB}
701 @emph{Subtree cycling}: Rotate current subtree among the states
703 @example
704 ,-> FOLDED -> CHILDREN -> SUBTREE --.
705 '-----------------------------------'
706 @end example
708 The cursor must be on a headline for this to work@footnote{see, however,
709 the option @code{org-cycle-emulate-tab}.}.  When the cursor is at the
710 beginning of the buffer and the first line is not a headline, then
711 @key{TAB} actually runs global cycling (see below)@footnote{see the
712 option @code{org-cycle-global-at-bob}.}.  Also when called with a prefix
713 argument (@kbd{C-u @key{TAB}}), global cycling is invoked.
715 @cindex global visibility states
716 @cindex global cycling
717 @cindex overview, global visibility state
718 @cindex contents, global visibility state
719 @cindex show all, global visibility state
720 @kindex S-@key{TAB}
721 @item S-@key{TAB}
722 @itemx C-u @key{TAB}
723 @emph{Global cycling}: Rotate the entire buffer among the states
725 @example
726 ,-> OVERVIEW -> CONTENTS -> SHOW ALL --.
727 '--------------------------------------'
728 @end example
730 When @kbd{S-@key{TAB}} is called with a numerical prefix N, the CONTENTS
731 view up to headlines of level N will be shown.
732 Note that inside tables, @kbd{S-@key{TAB}} jumps to the previous field.
734 @cindex show all, command
735 @kindex C-c C-a
736 @item C-c C-a
737 Show all.
738 @kindex C-c C-r
739 @item C-c C-r
740 Reveal context around point, showing the current entry, the following
741 heading and the hierarchy above.  Useful for working near a location
742 that has been exposed by a sparse tree command (@pxref{Sparse trees}) or
743 an agenda command (@pxref{Agenda commands}).  With prefix arg show, on
744 each
746 level, all sibling headings.
747 @kindex C-c C-x b
748 @item C-c C-x b
749 Show the current subtree in an indirect buffer@footnote{The indirect
750 buffer
751 @ifinfo
752 (@pxref{Indirect Buffers,,,emacs,GNU Emacs Manual})
753 @end ifinfo
754 @ifnotinfo
755 (see the Emacs manual for more information about indirect buffers)
756 @end ifnotinfo
757 will contain the entire buffer, but will be narrowed to the current
758 tree.  Editing the indirect buffer will also change the original buffer,
759 but without affecting visibility in that buffer.}.  With numerical
760 prefix ARG, go up to this level and then take that tree.  If ARG is
761 negative, go up that many levels.  With @kbd{C-u} prefix, do not remove
762 the previously used indirect buffer.
763 @end table
765 When Emacs first visits an Org-mode file, the global state is set to
766 OVERVIEW, i.e. only the top level headlines are visible.  This can be
767 configured through the variable @code{org-startup-folded}, or on a
768 per-file basis by adding one of the following lines anywhere in the
769 buffer:
771 @example
772 #+STARTUP: overview
773 #+STARTUP: content
774 #+STARTUP: showall
775 @end example
777 @node Motion, Structure editing, Visibility cycling, Document structure
778 @section Motion
779 @cindex motion, between headlines
780 @cindex jumping, to headlines
781 @cindex headline navigation
782 The following commands jump to other headlines in the buffer.
784 @table @kbd
785 @kindex C-c C-n
786 @item C-c C-n
787 Next heading.
788 @kindex C-c C-p
789 @item C-c C-p
790 Previous heading.
791 @kindex C-c C-f
792 @item C-c C-f
793 Next heading same level.
794 @kindex C-c C-b
795 @item C-c C-b
796 Previous heading same level.
797 @kindex C-c C-u
798 @item C-c C-u
799 Backward to higher level heading.
800 @kindex C-c C-j
801 @item C-c C-j
802 Jump to a different place without changing the current outline
803 visibility.  Shows the document structure in a temporary buffer, where
804 you can use the following keys to find your destination:
805 @example
806 @key{TAB}         @r{Cycle visibility.}
807 @key{down} / @key{up}   @r{Next/previous visible headline.}
808 n / p        @r{Next/previous visible headline.}
809 f / b        @r{Next/previous headline same level.}
810 u            @r{One level up.}
811 0-9          @r{Digit argument.}
812 @key{RET}         @r{Select this location.}
813 @end example
814 @end table
816 @node Structure editing, Archiving, Motion, Document structure
817 @section Structure editing
818 @cindex structure editing
819 @cindex headline, promotion and demotion
820 @cindex promotion, of subtrees
821 @cindex demotion, of subtrees
822 @cindex subtree, cut and paste
823 @cindex pasting, of subtrees
824 @cindex cutting, of subtrees
825 @cindex copying, of subtrees
826 @cindex subtrees, cut and paste
828 @table @kbd
829 @kindex M-@key{RET}
830 @item M-@key{RET}
831 Insert new heading with same level as current.  If the cursor is in a
832 plain list item, a new item is created (@pxref{Plain lists}).  To force
833 creation of a new headline, use a prefix arg, or first press @key{RET}
834 to get to the beginning of the next line.  When this command is used in
835 the middle of a line, the line is split and the rest of the line becomes
836 the new headline@footnote{If you do not want the line to be split,
837 customize the variable @code{org-M-RET-may-split-line}.}.  If the
838 command is used at the beginning of a headline, the new headline is
839 created before the current line.  If at the beginning of any other line,
840 the content of that line is made the new heading.  If the command is
841 used at the end of a folded subtree (i.e. behind the ellipses at the end
842 of a headline), then a headline like the current one will be inserted
843 after the end of the subtree.
844 @kindex C-@key{RET}
845 @item C-@key{RET}
846 Insert a new heading after the current subtree, same level as the
847 current headline.  This command works from anywhere in the entry.
848 @kindex M-S-@key{RET}
849 @item M-S-@key{RET}
850 Insert new TODO entry with same level as current heading.
851 @kindex M-@key{left}
852 @item M-@key{left}
853 Promote current heading by one level.
854 @kindex M-@key{right}
855 @item M-@key{right}
856 Demote current heading by one level.
857 @kindex M-S-@key{left}
858 @item M-S-@key{left}
859 Promote the current subtree by one level.
860 @kindex M-S-@key{right}
861 @item M-S-@key{right}
862 Demote the current subtree by one level.
863 @kindex M-S-@key{up}
864 @item M-S-@key{up}
865 Move subtree up (swap with previous subtree of same
866 level).
867 @kindex M-S-@key{down}
868 @item M-S-@key{down}
869 Move subtree down (swap with next subtree of same level).
870 @kindex C-c C-x C-w
871 @kindex C-c C-x C-k
872 @item C-c C-x C-w
873 @itemx C-c C-x C-k
874 Kill subtree, i.e. remove it from buffer but save in kill ring.
875 With prefix arg, kill N sequential subtrees.
876 @kindex C-c C-x M-w
877 @item C-c C-x M-w
878 Copy subtree to kill ring.  With prefix arg, copy N sequential subtrees.
879 @kindex C-c C-x C-y
880 @item C-c C-x C-y
881 Yank subtree from kill ring.  This does modify the level of the subtree to
882 make sure the tree fits in nicely at the yank position.  The yank
883 level can also be specified with a prefix arg, or by yanking after a
884 headline marker like @samp{****}.
885 @kindex C-c C-w
886 @item C-c C-w
887 Refile entry to a different location.  @xref{Refiling notes}.
888 @kindex C-c ^
889 @item C-c ^
890 Sort same-level entries.  When there is an active region, all entries in
891 the region will be sorted.  Otherwise the children of the current
892 headline are sorted.  The command prompts for the sorting method, which
893 can be alphabetically, numerically, by time (using the first time stamp
894 in each entry), by priority, and each of these in reverse order.  You
895 can also supply your own function to extract the sorting key.  With a
896 @kbd{C-u} prefix, sorting will be case-sensitive.  With two @kbd{C-u
897 C-u} prefixes, duplicate entries will also be removed.
898 @end table
900 @cindex region, active
901 @cindex active region
902 @cindex transient-mark-mode
903 When there is an active region (transient-mark-mode), promotion and
904 demotion work on all headlines in the region.  To select a region of
905 headlines, it is best to place both point and mark at the beginning of a
906 line, mark at the beginning of the first headline, and point at the line
907 just after the last headline to change.  Note that when the cursor is
908 inside a table (@pxref{Tables}), the Meta-Cursor keys have different
909 functionality.
911 @node Archiving, Sparse trees, Structure editing, Document structure
912 @section Archiving
913 @cindex archiving
915 When a project represented by a (sub)tree is finished, you may want
916 to move the tree out of the way and to stop it from contributing to the
917 agenda.  Org-mode knows two ways of archiving.  You can mark a tree with
918 the ARCHIVE tag, or you can move an entire (sub)tree to a different
919 location.
921 @menu
922 * ARCHIVE tag::                 Marking a tree as inactive
923 * Moving subtrees::             Moving a tree to an archive file
924 @end menu
926 @node ARCHIVE tag, Moving subtrees, Archiving, Archiving
927 @subsection The ARCHIVE tag
928 @cindex internal archiving
930 A headline that is marked with the ARCHIVE tag (@pxref{Tags}) stays at
931 its location in the outline tree, but behaves in the following way:
932 @itemize @minus
933 @item
934 It does not open when you attempt to do so with a visibility cycling
935 command (@pxref{Visibility cycling}).  You can force cycling archived
936 subtrees with @kbd{C-@key{TAB}}, or by setting the option
937 @code{org-cycle-open-archived-trees}.  Also normal outline commands like
938 @code{show-all} will open archived subtrees.
939 @item
940 During sparse tree construction (@pxref{Sparse trees}), matches in
941 archived subtrees are not exposed, unless you configure the option
942 @code{org-sparse-tree-open-archived-trees}.
943 @item
944 During agenda view construction (@pxref{Agenda views}), the content of
945 archived trees is ignored unless you configure the option
946 @code{org-agenda-skip-archived-trees}.
947 @item
948 Archived trees are not exported (@pxref{Exporting}), only the headline
949 is.  Configure the details using the variable
950 @code{org-export-with-archived-trees}.
951 @end itemize
953 The following commands help managing the ARCHIVE tag:
955 @table @kbd
956 @kindex C-c C-x C-a
957 @item C-c C-x C-a
958 Toggle the ARCHIVE tag for the current headline.  When the tag is set,
959 the headline changes to a shadowish face, and the subtree below it is
960 hidden.
961 @kindex C-u C-c C-x C-a
962 @item C-u C-c C-x C-a
963 Check if any direct children of the current headline should be archived.
964 To do this, each subtree is checked for open TODO entries.  If none are
965 found, the command offers to set the ARCHIVE tag for the child.  If the
966 cursor is @emph{not} on a headline when this command is invoked, the
967 level 1 trees will be checked.
968 @kindex C-@kbd{TAB}
969 @item C-@kbd{TAB}
970 Cycle a tree even if it is tagged with ARCHIVE.
971 @end table
973 @node Moving subtrees,  , ARCHIVE tag, Archiving
974 @subsection Moving subtrees
975 @cindex external archiving
977 Once an entire project is finished, you may want to move it to a
978 different location, either in the current file, or even in a different
979 file, the archive file.
981 @table @kbd
982 @kindex C-c C-x C-s
983 @item C-c C-x C-s
984 Archive the subtree starting at the cursor position to the location
985 given by @code{org-archive-location}.  Context information that could be
986 lost like the file name, the category, inherited tags, and the todo
987 state will be store as properties in the entry.
988 @kindex C-u C-c C-x C-s
989 @item C-u C-c C-x C-s
990 Check if any direct children of the current headline could be moved to
991 the archive.  To do this, each subtree is checked for open TODO entries.
992 If none are found, the command offers to move it to the archive
993 location.  If the cursor is @emph{not} on a headline when this command
994 is invoked, the level 1 trees will be checked.
995 @end table
997 @cindex archive locations
998 The default archive location is a file in the same directory as the
999 current file, with the name derived by appending @file{_archive} to the
1000 current file name.  For information and examples on how to change this,
1001 see the documentation string of the variable
1002 @code{org-archive-location}.  There is also an in-buffer option for
1003 setting this variable, for example@footnote{For backward compatibility,
1004 the following also works: If there are several such lines in a file,
1005 each specifies the archive location for the text below it.  The first
1006 such line also applies to any text before its definition.  However,
1007 using this method is @emph{strongly} deprecated as it is incompatible
1008 with the outline structure of the document.  The correct method for
1009 setting multiple archive locations in a buffer is using a property.}:
1011 @example
1012 #+ARCHIVE: %s_done::
1013 @end example
1015 @noindent
1016 If you would like to have a special ARCHIVE location for a single entry
1017 or a (sub)tree, give the entry an @code{:ARCHIVE:} property with the
1018 location as the value (@pxref{Properties and columns}).
1020 When a subtree is moved, it receives a number of special properties that
1021 record context information like the file from where the entry came, it's
1022 outline path the archiving time etc.  Configure the variable
1023 @code{org-archive-save-context-info} to adjust the amount of information
1024 added.
1026 @node Sparse trees, Plain lists, Archiving, Document structure
1027 @section Sparse trees
1028 @cindex sparse trees
1029 @cindex trees, sparse
1030 @cindex folding, sparse trees
1031 @cindex occur, command
1033 An important feature of Org-mode is the ability to construct
1034 @emph{sparse trees} for selected information in an outline tree, so that
1035 the entire document is folded as much as possible, but the selected
1036 information is made visible along with the headline structure above
1037 it@footnote{See also the variables @code{org-show-hierarchy-above},
1038 @code{org-show-following-heading}, and @code{org-show-siblings} for
1039 detailed control on how much context is shown around each match.}.  Just
1040 try it out and you will see immediately how it works.
1042 Org-mode contains several commands creating such trees, all these
1043 commands can be accessed through a dispatcher:
1045 @table @kbd
1046 @kindex C-c /
1047 @item C-c /
1048 This prompts for an extra key to select a sparse-tree creating command.
1049 @kindex C-c / r
1050 @item C-c / r
1051 Occur.  Prompts for a regexp and shows a sparse tree with all matches.
1052 If the match is in a headline, the headline is made visible.  If the
1053 match is in the body of an entry, headline and body are made visible.
1054 In order to provide minimal context, also the full hierarchy of
1055 headlines above the match is shown, as well as the headline following
1056 the match.  Each match is also highlighted; the highlights disappear
1057 when the buffer is changed by an editing command, or by pressing
1058 @kbd{C-c C-c}.  When called with a @kbd{C-u} prefix argument, previous
1059 highlights are kept, so several calls to this command can be stacked.
1060 @end table
1062 @noindent
1063 For frequently used sparse trees of specific search strings, you can
1064 use the variable @code{org-agenda-custom-commands} to define fast
1065 keyboard access to specific sparse trees.  These commands will then be
1066 accessible through the agenda dispatcher (@pxref{Agenda dispatcher}).
1067 For example:
1069 @lisp
1070 (setq org-agenda-custom-commands
1071       '(("f" occur-tree "FIXME")))
1072 @end lisp
1074 @noindent will define the key @kbd{C-c a f} as a shortcut for creating
1075 a sparse tree matching the string @samp{FIXME}.
1077 The other sparse tree commands select headings based on TODO keywords,
1078 tags, or properties and will be discussed later in this manual.
1080 @kindex C-c C-e v
1081 @cindex printing sparse trees
1082 @cindex visible text, printing
1083 To print a sparse tree, you can use the Emacs command
1084 @code{ps-print-buffer-with-faces} which does not print invisible parts
1085 of the document @footnote{This does not work under XEmacs, because
1086 XEmacs uses selective display for outlining, not text properties.}.
1087 Or you can use the command @kbd{C-c C-e v} to export only the visible
1088 part of the document and print the resulting file.
1090 @node Plain lists, Drawers, Sparse trees, Document structure
1091 @section Plain lists
1092 @cindex plain lists
1093 @cindex lists, plain
1094 @cindex lists, ordered
1095 @cindex ordered lists
1097 Within an entry of the outline tree, hand-formatted lists can provide
1098 additional structure.  They also provide a way to create lists of
1099 checkboxes (@pxref{Checkboxes}).  Org-mode supports editing such lists,
1100 and the HTML exporter (@pxref{Exporting}) parses and formats them.
1102 Org-mode knows ordered and unordered lists.  Unordered list items start
1103 with @samp{-}, @samp{+}, or @samp{*}@footnote{When using @samp{*} as a
1104 bullet, lines must be indented or they will be seen as top-level
1105 headlines.  Also, when you are hiding leading stars to get a clean
1106 outline view, plain list items starting with a star are visually
1107 indistinguishable from true headlines.  In short: even though @samp{*}
1108 is supported, it may be better to not use it for plain list items.} as
1109 bullets.  Ordered list items start with a numeral followed by either a
1110 period or a right parenthesis, such as @samp{1.} or @samp{1)}.  Items
1111 belonging to the same list must have the same indentation on the first
1112 line.  In particular, if an ordered list reaches number @samp{10.}, then
1113 the 2--digit numbers must be written left-aligned with the other numbers
1114 in the list.  Indentation also determines the end of a list item.  It
1115 ends before the next line that is indented like the bullet/number, or
1116 less.  Empty lines are part of the previous item, so you can have
1117 several paragraphs in one item.  If you would like an empty line to
1118 terminate all currently open plain lists, configure the variable
1119 @code{org-empty-line-terminates-plain-lists}.  Here is an example:
1121 @example
1122 @group
1123 ** Lord of the Rings
1124    My favorite scenes are (in this order)
1125    1. The attack of the Rohirrim
1126    2. Eowyns fight with the witch king
1127       + this was already my favorite scene in the book
1128       + I really like Miranda Otto.
1129    3. Peter Jackson being shot by Legolas
1130        - on DVD only
1131       He makes a really funny face when it happens.
1132    But in the end, not individual scenes matter but the film as a whole.
1133 @end group
1134 @end example
1136 Org-mode supports these lists by tuning filling and wrapping commands to
1137 deal with them correctly@footnote{Org-mode only changes the filling
1138 settings for Emacs.  For XEmacs, you should use Kyle E. Jones'
1139 @file{filladapt.el}.  To turn this on,  put into @file{.emacs}:
1140 @code{(require 'filladapt)}}. 
1142 The following commands act on items when the cursor is in the first line
1143 of an item (the line with the bullet or number).
1145 @table @kbd
1146 @kindex @key{TAB}
1147 @item @key{TAB}
1148 Items can be folded just like headline levels if you set the variable
1149 @code{org-cycle-include-plain-lists}.  The level of an item is then
1150 given by the indentation of the bullet/number.  Items are always
1151 subordinate to real headlines, however; the hierarchies remain
1152 completely separated.
1154 If @code{org-cycle-include-plain-lists} has not been set, @key{TAB}
1155 fixes the indentation of the curent line in a heuristic way.
1156 @kindex M-@key{RET}
1157 @item M-@key{RET}
1158 Insert new item at current level.  With prefix arg, force a new heading
1159 (@pxref{Structure editing}).  If this command is used in the middle of a
1160 line, the line is @emph{split} and the rest of the line becomes the new
1161 item@footnote{If you do not want the line to be split, customize the
1162 variable @code{org-M-RET-may-split-line}.}.  If this command is executed
1163 in the @emph{whitespace before a bullet or number}, the new item is
1164 created @emph{before} the current item.  If the command is executed in
1165 the white space before the text that is part of an item but does not
1166 contain the bullet, a bullet is added to the current line.
1167 @kindex M-S-@key{RET}
1168 @item M-S-@key{RET}
1169 Insert a new item with a checkbox (@pxref{Checkboxes}).
1170 @kindex S-@key{up}
1171 @kindex S-@key{down}
1172 @item S-@key{up}
1173 @itemx S-@key{down}
1174 Jump to the previous/next item in the current list.
1175 @kindex M-S-@key{up}
1176 @kindex M-S-@key{down}
1177 @item M-S-@key{up}
1178 @itemx M-S-@key{down}
1179 Move the item including subitems up/down (swap with previous/next item
1180 of same indentation).  If the list is ordered, renumbering is
1181 automatic.
1182 @kindex M-S-@key{left}
1183 @kindex M-S-@key{right}
1184 @item M-S-@key{left}
1185 @itemx M-S-@key{right}
1186 Decrease/increase the indentation of the item, including subitems.
1187 Initially, the item tree is selected based on current indentation.
1188 When these commands are executed several times in direct succession,
1189 the initially selected region is used, even if the new indentation
1190 would imply a different hierarchy.  To use the new hierarchy, break
1191 the command chain with a cursor motion or so.
1192 @kindex C-c C-c
1193 @item C-c C-c
1194 If there is a checkbox (@pxref{Checkboxes}) in the item line, toggle the
1195 state of the checkbox.  If not, this command makes sure that all the
1196 items on this list level use the same bullet.  Furthermore, if this is
1197 an ordered list, make sure the numbering is ok.
1198 @kindex C-c -
1199 @item C-c -
1200 Cycle the entire list level through the different itemize/enumerate
1201 bullets (@samp{-}, @samp{+}, @samp{*}, @samp{1.}, @samp{1)}).
1202 With prefix arg, select the nth bullet from this list.
1203 @end table
1205 @node Drawers, orgstruct-mode, Plain lists, Document structure
1206 @section Drawers
1207 @cindex drawers
1208 @cindex visibility cycling, drawers
1210 Sometimes you want to keep information associated with an entry, but you
1211 normally don't want to see it.  For this, Org-mode has @emph{drawers}.
1212 Drawers need to be configured with the variable
1213 @code{org-drawers}@footnote{You can define drawers on a per-file basis
1214 with a line like @code{#+DRAWERS: HIDDEN PROPERTIES STATE}}.  Drawers
1215 look like this:
1217 @example
1218 ** This is a headline
1219    Still outside the drawer
1220    :DRAWERNAME:
1221       This is inside the drawer.
1222    :END:
1223    After the drawer.
1224 @end example
1226 Visibility cycling (@pxref{Visibility cycling}) on the headline will
1227 hide and show the entry, but keep the drawer collapsed to a single line.
1228 In order to look inside the drawer, you need to move the cursor to the
1229 drawer line and press @key{TAB} there.  Org-mode uses a drawer for
1230 storing properties (@pxref{Properties and columns}).
1232 @node orgstruct-mode,  , Drawers, Document structure
1233 @section The Orgstruct minor mode
1234 @cindex orgstruct-mode
1235 @cindex minor mode for structure editing
1237 If you like the intuitive way the Org-mode structure editing and list
1238 formatting works, you might want to use these commands in other modes
1239 like text-mode or mail-mode as well.  The minor mode Orgstruct-mode
1240 makes this possible.  You can always toggle the mode with @kbd{M-x
1241 orgstruct-mode}.  To turn it on by default, for example in mail mode,
1244 @lisp
1245 (add-hook 'mail-mode-hook 'turn-on-orgstruct)
1246 @end lisp
1248 When this mode is active and the cursor is on a line that looks to
1249 Org-mode like a headline of the first line of a list item, most
1250 structure editing commands will work, even if the same keys normally
1251 have different functionality in the major mode you are using.  If the
1252 cursor is not in one of those special lines, Orgstruct-mode lurks
1253 silently in the shadow.
1255 @node Tables, Hyperlinks, Document structure, Top
1256 @chapter Tables
1257 @cindex tables
1258 @cindex editing tables
1260 Org-mode comes with a fast and intuitive table editor.  Spreadsheet-like
1261 calculations are supported in connection with the Emacs @file{calc}
1262 package 
1263 @ifinfo
1264 (@pxref{Top,Calc,,calc,Gnu Emacs Calculator Manual}).
1265 @end ifinfo
1266 @ifnotinfo
1267 (see the Emacs Calculator manual for more information about the Emacs
1268 calculator).
1269 @end ifnotinfo
1271 @menu
1272 * Built-in table editor::       Simple tables
1273 * Narrow columns::              Stop wasting space in tables   
1274 * Column groups::               Grouping to trigger vertical lines
1275 * orgtbl-mode::                 The table editor as minor mode
1276 * The spreadsheet::             The table editor has spreadsheet capabilities.
1277 @end menu
1279 @node Built-in table editor, Narrow columns, Tables, Tables
1280 @section The built-in table editor
1281 @cindex table editor, built-in
1283 Org-mode makes it easy to format tables in plain ASCII.  Any line with
1284 @samp{|} as the first non-whitespace character is considered part of a
1285 table.  @samp{|} is also the column separator.  A table might look like
1286 this:
1288 @example
1289 | Name  | Phone | Age |
1290 |-------+-------+-----|
1291 | Peter |  1234 |  17 |
1292 | Anna  |  4321 |  25 |
1293 @end example
1295 A table is re-aligned automatically each time you press @key{TAB} or
1296 @key{RET} or @kbd{C-c C-c} inside the table.  @key{TAB} also moves to
1297 the next field (@key{RET} to the next row) and creates new table rows
1298 at the end of the table or before horizontal lines.  The indentation
1299 of the table is set by the first line.  Any line starting with
1300 @samp{|-} is considered as a horizontal separator line and will be
1301 expanded on the next re-align to span the whole table width.  So, to
1302 create the above table, you would only type
1304 @example
1305 |Name|Phone|Age|
1307 @end example
1309 @noindent and then press @key{TAB} to align the table and start filling in
1310 fields.
1312 When typing text into a field, Org-mode treats @key{DEL},
1313 @key{Backspace}, and all character keys in a special way, so that
1314 inserting and deleting avoids shifting other fields.  Also, when
1315 typing @emph{immediately after the cursor was moved into a new field
1316 with @kbd{@key{TAB}}, @kbd{S-@key{TAB}} or @kbd{@key{RET}}}, the
1317 field is automatically made blank.  If this behavior is too
1318 unpredictable for you, configure the variables
1319 @code{org-enable-table-editor} and @code{org-table-auto-blank-field}.
1321 @table @kbd
1322 @tsubheading{Creation and conversion}
1323 @kindex C-c |
1324 @item C-c |
1325 Convert the active region to table. If every line contains at least one
1326 TAB character, the function assumes that the material is tab separated.
1327 If every line contains a comma, comma-separated values (CSV) are assumed.
1328 If not, lines are split at whitespace into fields.  You can use a prefix
1329 argument to force a specific separator: @kbd{C-u} forces CSV, @kbd{C-u
1330 C-u} forces TAB, and a numeric argument N indicates that at least N
1331 consequtive spaces, or alternatively a TAB will be the separator.
1332 @* 
1333 If there is no active region, this command creates an empty Org-mode
1334 table.  But it's easier just to start typing, like
1335 @kbd{|Name|Phone|Age @key{RET} |- @key{TAB}}.
1337 @tsubheading{Re-aligning and field motion}
1338 @kindex C-c C-c
1339 @item C-c C-c
1340 Re-align the table without moving the cursor.
1342 @kindex @key{TAB}
1343 @item @key{TAB}
1344 Re-align the table, move to the next field.  Creates a new row if
1345 necessary.
1347 @kindex S-@key{TAB}
1348 @item S-@key{TAB}
1349 Re-align, move to previous field.
1351 @kindex @key{RET}
1352 @item @key{RET}
1353 Re-align the table and move down to next row.  Creates a new row if
1354 necessary.  At the beginning or end of a line, @key{RET} still does
1355 NEWLINE, so it can be used to split a table.
1357 @tsubheading{Column and row editing}
1358 @kindex M-@key{left}
1359 @kindex M-@key{right}
1360 @item M-@key{left}
1361 @itemx M-@key{right}
1362 Move the current column left/right.
1364 @kindex M-S-@key{left}
1365 @item M-S-@key{left}
1366 Kill the current column.
1368 @kindex M-S-@key{right}
1369 @item M-S-@key{right}
1370 Insert a new column to the left of the cursor position.
1372 @kindex M-@key{up}
1373 @kindex M-@key{down}
1374 @item M-@key{up}
1375 @itemx M-@key{down}
1376 Move the current row up/down.
1378 @kindex M-S-@key{up}
1379 @item M-S-@key{up}
1380 Kill the current row or horizontal line.
1382 @kindex M-S-@key{down}
1383 @item M-S-@key{down}
1384 Insert a new row above (with arg: below) the current row.
1386 @kindex C-c -
1387 @item C-c -
1388 Insert a horizontal line below current row. With prefix arg, the line
1389 is created above the current line.
1391 @kindex C-c ^
1392 @item C-c ^
1393 Sort the table lines in the region.  The position of point indicates the
1394 column to be used for sorting, and the range of lines is the range
1395 between the nearest horizontal separator lines, or the entire table.  If
1396 point is before the first column, you will be prompted for the sorting
1397 column.  If there is an active region, the mark specifies the first line
1398 and the sorting column, while point should be in the last line to be
1399 included into the sorting.  The command prompts for the sorting type
1400 (alphabetically, numerically, or by time).  When called with a prefix
1401 argument, alphabetic sorting will be case-sensitive.
1403 @tsubheading{Regions}
1404 @kindex C-c C-x M-w
1405 @item C-c C-x M-w
1406 Copy a rectangular region from a table to a special clipboard.  Point
1407 and mark determine edge fields of the rectangle.  The process ignores
1408 horizontal separator lines.
1410 @kindex C-c C-x C-w
1411 @item C-c C-x C-w
1412 Copy a rectangular region from a table to a special clipboard, and
1413 blank all fields in the rectangle.  So this is the ``cut'' operation.
1415 @kindex C-c C-x C-y
1416 @item C-c C-x C-y
1417 Paste a rectangular region into a table.
1418 The upper right corner ends up in the current field.  All involved fields
1419 will be overwritten.  If the rectangle does not fit into the present table,
1420 the table is enlarged as needed.  The process ignores horizontal separator
1421 lines.
1423 @kindex C-c C-q
1424 @kindex M-@key{RET}
1425 @item C-c C-q
1426 @itemx M-@kbd{RET}
1427 Wrap several fields in a column like a paragraph.  If there is an active
1428 region, and both point and mark are in the same column, the text in the
1429 column is wrapped to minimum width for the given number of lines.  A
1430 prefix ARG may be used to change the number of desired lines.  If there
1431 is no region, the current field is split at the cursor position and the
1432 text fragment to the right of the cursor is prepended to the field one
1433 line down. If there is no region, but you specify a prefix ARG, the
1434 current field is made blank, and the content is appended to the field
1435 above.
1437 @tsubheading{Calculations}
1438 @cindex formula, in tables
1439 @cindex calculations, in tables
1440 @cindex region, active
1441 @cindex active region
1442 @cindex transient-mark-mode
1443 @kindex C-c +
1444 @item C-c +
1445 Sum the numbers in the current column, or in the rectangle defined by
1446 the active region.  The result is shown in the echo area and can
1447 be inserted with @kbd{C-y}.
1449 @kindex S-@key{RET}
1450 @item S-@key{RET}
1451 When current field is empty, copy from first non-empty field above.
1452 When not empty, copy current field down to next row and move cursor
1453 along with it.  Depending on the variable
1454 @code{org-table-copy-increment}, integer field values will be
1455 incremented during copy.  This key is also used by CUA-mode
1456 (@pxref{Cooperation}).
1458 @tsubheading{Miscellaneous}
1459 @kindex C-c `
1460 @item C-c `
1461 Edit the current field in a separate window.  This is useful for fields
1462 that are not fully visible (@pxref{Narrow columns}).  When called with a
1463 @kbd{C-u} prefix, just make the full field visible, so that it can be
1464 edited in place.
1466 @item M-x org-table-import
1467 Import a file as a table.  The table should be TAB- or whitespace
1468 separated.  Useful, for example, to import a spreadsheet table or data
1469 from a database, because these programs generally can write
1470 TAB-separated text files.  This command works by inserting the file into
1471 the buffer and then converting the region to a table.  Any prefix
1472 argument is passed on to the converter, which uses it to determine the
1473 separator.
1474 @item C-c |
1475 Tables can also be imported by pasting tabular text into the org-mode
1476 buffer, selecting the pasted text with @kbd{C-x C-x} and then using the
1477 @kbd{C-c |} command (see above under @i{Creation and conversion}.
1479 @item M-x org-table-export
1480 Export the table as a TAB-separated file.  Useful for data exchange with,
1481 for example, spreadsheet or database programs.
1482 @end table
1484 If you don't like the automatic table editor because it gets in your
1485 way on lines which you would like to start with @samp{|}, you can turn
1486 it off with
1488 @lisp
1489 (setq org-enable-table-editor nil)
1490 @end lisp
1492 @noindent Then the only table command that still works is
1493 @kbd{C-c C-c} to do a manual re-align.
1495 @node Narrow columns, Column groups, Built-in table editor, Tables
1496 @section Narrow columns
1497 @cindex narrow columns in tables
1499 The width of columns is automatically determined by the table editor.
1500 Sometimes a single field or a few fields need to carry more text,
1501 leading to inconveniently wide columns.  To limit@footnote{This feature
1502 does not work on XEmacs.} the width of a column, one field anywhere in
1503 the column may contain just the string @samp{<N>} where @samp{N} is an
1504 integer specifying the width of the column in characters.  The next
1505 re-align will then set the width of this column to no more than this
1506 value.
1508 @example
1509 @group
1510 |---+------------------------------|               |---+--------|
1511 |   |                              |               |   | <6>    |
1512 | 1 | one                          |               | 1 | one    |
1513 | 2 | two                          |     ----\     | 2 | two    |
1514 | 3 | This is a long chunk of text |     ----/     | 3 | This=> |
1515 | 4 | four                         |               | 4 | four   |
1516 |---+------------------------------|               |---+--------|
1517 @end group
1518 @end example
1520 @noindent
1521 Fields that are wider become clipped and end in the string @samp{=>}.
1522 Note that the full text is still in the buffer, it is only invisible.
1523 To see the full text, hold the mouse over the field - a tool-tip window
1524 will show the full content.  To edit such a field, use the command
1525 @kbd{C-c `} (that is @kbd{C-c} followed by the backquote).  This will
1526 open a new window with the full field.  Edit it and finish with @kbd{C-c
1527 C-c}.
1529 When visiting a file containing a table with narrowed columns, the
1530 necessary character hiding has not yet happened, and the table needs to
1531 be aligned before it looks nice.  Setting the option
1532 @code{org-startup-align-all-tables} will realign all tables in a file
1533 upon visiting, but also slow down startup.  You can also set this option
1534 on a per-file basis with:
1536 @example
1537 #+STARTUP: align
1538 #+STARTUP: noalign
1539 @end example
1541 @node Column groups, orgtbl-mode, Narrow columns, Tables
1542 @section Column groups
1543 @cindex grouping columns in tables
1545 When Org-mode exports tables, it does so by default without vertical
1546 lines because that is visually more satisfying in general.  Occasionally
1547 however, vertical lines can be useful to structure a table into groups
1548 of columns, much like horizontal lines can do for groups of rows.  In
1549 order to specify column groups, you can use a special row where the
1550 first field contains only @samp{/}.  The further fields can either
1551 contain @samp{<} to indicate that this column should start a group,
1552 @samp{>} to indicate the end of a column, or @samp{<>} to make a column
1553 a group of its own.  Boundaries between colum groups will upon export be
1554 marked with vertical lines.  Here is an example:
1556 @example
1557 |   |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1558 |---+----+-----+-----+-----+---------+------------|
1559 | / | <> |   < |     |   > |       < |          > |
1560 | # |  1 |   1 |   1 |   1 |       1 |          1 |
1561 | # |  2 |   4 |   8 |  16 |  1.4142 |     1.1892 |
1562 | # |  3 |   9 |  27 |  81 |  1.7321 |     1.3161 |
1563 |---+----+-----+-----+-----+---------+------------|
1564 #+TBLFM: $3=$2^2::$4=$2^3::$5=$2^4::$6=sqrt($2)::$7=sqrt(sqrt(($2))
1565 @end example
1567 It is also sufficient to just insert the colum group starters after
1568 every vertical line you'd like to have:
1570 @example
1571 |  N | N^2 | N^3 | N^4 | sqrt(n) | sqrt[4](N) |
1572 |----+-----+-----+-----+---------+------------|
1573 | /  | <   |     |     | <       |            |
1574 @end example
1576 @node orgtbl-mode, The spreadsheet, Column groups, Tables
1577 @section The Orgtbl minor mode
1578 @cindex orgtbl-mode
1579 @cindex minor mode for tables
1581 If you like the intuitive way the Org-mode table editor works, you
1582 might also want to use it in other modes like text-mode or mail-mode.
1583 The minor mode Orgtbl-mode makes this possible.  You can always toggle
1584 the mode with @kbd{M-x orgtbl-mode}.  To turn it on by default, for
1585 example in mail mode, use
1587 @lisp
1588 (add-hook 'mail-mode-hook 'turn-on-orgtbl)
1589 @end lisp
1591 Furthermore, with some special setup, it is possible to maintain tables
1592 in arbitrary syntax with Orgtbl-mode.  For example, it is possible to
1593 construct La@TeX{} tables with the underlying ease and power of
1594 Orgtbl-mode, including spreadsheet capabilities.  For details, see
1595 @ref{Tables in arbitrary syntax}.
1597 @node The spreadsheet,  , orgtbl-mode, Tables
1598 @section The spreadsheet
1599 @cindex calculations, in tables
1600 @cindex spreadsheet capabilities
1601 @cindex @file{calc} package
1603 The table editor makes use of the Emacs @file{calc} package to implement
1604 spreadsheet-like capabilities.  It can also evaluate Emacs Lisp forms to
1605 derive fields from other fields.  While fully featured, Org-mode's
1606 implementation is not identical to other spreadsheets.  For example,
1607 Org-mode knows the concept of a @emph{column formula} that will be
1608 applied to all non-header fields in a column without having to copy the
1609 formula to each relevant field.
1611 @menu
1612 * References::                  How to refer to another field or range
1613 * Formula syntax for Calc::     Using Calc to compute stuff
1614 * Formula syntax for Lisp::     Writing formulas in Emacs Lisp
1615 * Field formulas::              Formulas valid for a single field
1616 * Column formulas::             Formulas valid for an entire column
1617 * Editing and debugging formulas::  Fixing formulas
1618 * Updating the table::          Recomputing all dependent fields
1619 * Advanced features::           Field names, parameters and automatic recalc
1620 @end menu
1622 @node References, Formula syntax for Calc, The spreadsheet, The spreadsheet
1623 @subsection References
1624 @cindex references
1626 To compute fields in the table from other fields, formulas must
1627 reference other fields or ranges.  In Org-mode, fields can be referenced
1628 by name, by absolute coordinates, and by relative coordinates.  To find
1629 out what the coordinates of a field are, press @kbd{C-c ?} in that
1630 field, or press @kbd{C-c @}} to toggle the display of a grid.
1632 @subsubheading Field references
1633 @cindex field references
1634 @cindex references, to fields
1636 Formulas can reference the value of another field in two ways.  Like in
1637 any other spreadsheet, you may reference fields with a letter/number
1638 combination like @code{B3}, meaning the 2nd field in the 3rd row.
1639 @c Such references are always fixed to that field, they don't change
1640 @c when you copy and paste a formula to a different field.  So
1641 @c Org-mode's @code{B3} behaves like @code{$B$3} in other spreadsheets.
1643 @noindent
1644 Org-mode also uses another, more general operator that looks like this:
1645 @example
1646 @@row$column
1647 @end example
1649 @noindent
1650 Column references can be absolute like @samp{1}, @samp{2},...@samp{N},
1651 or relative to the current column like @samp{+1} or @samp{-2}.
1653 The row specification only counts data lines and ignores horizontal
1654 separator lines (hlines).  You can use absolute row numbers
1655 @samp{1}...@samp{N}, and row numbers relative to the current row like
1656 @samp{+3} or @samp{-1}.  Or specify the row relative to one of the
1657 hlines: @samp{I} refers to the first hline@footnote{Note that only
1658 hlines are counted that @emph{separate} table lines.  If the table
1659 starts with a hline above the header, it does not count.}, @samp{II} to
1660 the second etc.  @samp{-I} refers to the first such line above the
1661 current line, @samp{+I} to the first such line below the current line.
1662 You can also write @samp{III+2} which is the second data line after the
1663 third hline in the table.  Relative row numbers like @samp{-3} will not
1664 cross hlines if the current line is too close to the hline.  Instead,
1665 the value directly at the hline is used.
1667 @samp{0} refers to the current row and column.  Also, if you omit
1668 either the column or the row part of the reference, the current
1669 row/column is implied. 
1671 Org-mode's references with @emph{unsigned} numbers are fixed references
1672 in the sense that if you use the same reference in the formula for two
1673 different fields, the same field will be referenced each time.
1674 Org-mode's references with @emph{signed} numbers are floating
1675 references because the same reference operator can reference different
1676 fields depending on the field being calculated by the formula.
1678 Here are a few examples:
1680 @example
1681 @@2$3      @r{2nd row, 3rd column}
1682 C2        @r{same as previous}
1683 $5        @r{column 5 in the current row}
1684 E&        @r{same as previous}
1685 @@2        @r{current column, row 2}
1686 @@-1$-3    @r{the field one row up, three columns to the left}
1687 @@-I$2     @r{field just under hline above current row, column 2}
1688 @end example
1690 @subsubheading Range references
1691 @cindex range references
1692 @cindex references, to ranges
1694 You may reference a rectangular range of fields by specifying two field
1695 references connected by two dots @samp{..}.  If both fields are in the
1696 current row, you may simply use @samp{$2..$7}, but if at least one field
1697 is in a different row, you need to use the general @code{@@row$column}
1698 format at least for the first field (i.e the reference must start with
1699 @samp{@@} in order to be interpreted correctly).  Examples:
1701 @example
1702 $1..$3        @r{First three fields in the current row.}
1703 $P..$Q        @r{Range, using column names (see under Advanced)}
1704 @@2$1..@@4$3    @r{6 fields between these two fields.}
1705 A2..C4        @r{Same as above.}
1706 @@-1$-2..@@-1   @r{3 numbers from the column to the left, 2 up to current row}
1707 @end example
1709 @noindent Range references return a vector of values that can be fed
1710 into Calc vector functions.  Empty fields in ranges are normally
1711 suppressed, so that the vector contains only the non-empty fields (but
1712 see the @samp{E} mode switch below).  If there are no non-empty fields,
1713 @samp{[0]} is returned to avoid syntax errors in formulas.
1715 @subsubheading Named references
1716 @cindex named references
1717 @cindex references, named
1718 @cindex name, of column or field
1719 @cindex constants, in calculations
1721 @samp{$name} is interpreted as the name of a column, parameter or
1722 constant.  Constants are defined globally through the variable
1723 @code{org-table-formula-constants}, and locally (for the file) through a
1724 line like
1726 @example
1727 #+CONSTANTS: c=299792458. pi=3.14 eps=2.4e-6
1728 @end example
1730 @noindent
1731 Also properties (@pxref{Properties and columns}) can be used as
1732 constants in table formulas: For a property @samp{:Xyz:} use the name
1733 @samp{$PROP_Xyz}, and the property will be searched in the current
1734 outline entry and in the hierarchy above it.  If you have the
1735 @file{constants.el} package, it will also be used to resolve constants,
1736 including natural constants like @samp{$h} for Planck's constant, and
1737 units like @samp{$km} for kilometers@footnote{@file{Constant.el} can
1738 supply the values of constants in two different unit systems, @code{SI}
1739 and @code{cgs}.  Which one is used depends on the value of the variable
1740 @code{constants-unit-system}.  You can use the @code{#+STARTUP} options
1741 @code{constSI} and @code{constcgs} to set this value for the current
1742 buffer.}.  Column names and parameters can be specified in special table
1743 lines.  These are described below, see @ref{Advanced features}.  All
1744 names must start with a letter, and further consist of letters and
1745 numbers.
1747 @node Formula syntax for Calc, Formula syntax for Lisp, References, The spreadsheet
1748 @subsection Formula syntax for Calc
1749 @cindex formula syntax, Calc
1750 @cindex syntax, of formulas
1752 A formula can be any algebraic expression understood by the Emacs
1753 @file{Calc} package.  @b{Note that @file{calc} has the
1754 non-standard convention that @samp{/} has lower precedence than
1755 @samp{*}, so that @samp{a/b*c} is interpreted as @samp{a/(b*c)}.}  Before
1756 evaluation by @code{calc-eval} (@pxref{Calling Calc from
1757 Your Programs,calc-eval,Calling calc from Your Lisp Programs,calc,GNU
1758 Emacs Calc Manual}),
1759 @c FIXME:  The link to the calc manual in HTML does not work.
1760 variable substitution takes place according to the rules described above.
1761 @cindex vectors, in table calculations
1762 The range vectors can be directly fed into the calc vector functions
1763 like @samp{vmean} and @samp{vsum}.
1765 @cindex format specifier
1766 @cindex mode, for @file{calc}
1767 A formula can contain an optional mode string after a semicolon.  This
1768 string consists of flags to influence Calc and other modes during
1769 execution.  By default, Org-mode uses the standard calc modes (precision
1770 12, angular units degrees, fraction and symbolic modes off.  The display
1771 format, however, has been changed to @code{(float 5)} to keep tables
1772 compact.  The default settings can be configured using the variable
1773 @code{org-calc-default-modes}.
1775 @example
1776 p20           @r{switch the internal precision to 20 digits}
1777 n3 s3 e2 f4   @r{normal, scientific, engineering, or fixed display format}
1778 D R           @r{angle modes: degrees, radians}
1779 F S           @r{fraction and symbolic modes}
1780 N             @r{interpret all fields as numbers, use 0 for non-numbers}
1781 T             @r{force text interpretation}
1782 E             @r{keep empty fields in ranges}
1783 @end example
1785 @noindent
1786 In addition, you may provide a @code{printf} format specifier to
1787 reformat the final result.  A few examples:
1789 @example
1790 $1+$2                @r{Sum of first and second field}
1791 $1+$2;%.2f           @r{Same, format result to two decimals}
1792 exp($2)+exp($1)      @r{Math functions can be used}
1793 $0;%.1f              @r{Reformat current cell to 1 decimal}
1794 ($3-32)*5/9          @r{Degrees F -> C conversion}
1795 $c/$1/$cm            @r{Hz -> cm conversion, using @file{constants.el}}
1796 tan($1);Dp3s1        @r{Compute in degrees, precision 3, display SCI 1}
1797 sin($1);Dp3%.1e      @r{Same, but use printf specifier for display}
1798 vmean($2..$7)        @r{Compute column range mean, using vector function}
1799 vmean($2..$7);EN     @r{Same, but treat empty fields as 0}
1800 taylor($3,x=7,2)     @r{taylor series of $3, at x=7, second degree}
1801 @end example
1803 Calc also contains a complete set of logical operations.  For example
1805 @example
1806 if($1<20,teen,string(""))  @r{``teen'' if age $1 less than 20, else empty}
1807 @end example
1809 @node Formula syntax for Lisp, Field formulas, Formula syntax for Calc, The spreadsheet
1810 @subsection Emacs Lisp forms as formulas
1811 @cindex Lisp forms, as table formulas
1813 It is also possible to write a formula in Emacs Lisp; this can be useful
1814 for string manipulation and control structures, if the Calc's
1815 functionality is not enough.  If a formula starts with a single quote
1816 followed by an opening parenthesis, then it is evaluated as a lisp form.
1817 The evaluation should return either a string or a number.  Just as with
1818 @file{calc} formulas, you can specify modes and a printf format after a
1819 semicolon.  With Emacs Lisp forms, you need to be concious about the way
1820 field references are interpolated into the form.  By default, a
1821 reference will be interpolated as a Lisp string (in double quotes)
1822 containing the field.  If you provide the @samp{N} mode switch, all
1823 referenced elements will be numbers (non-number fields will be zero) and
1824 interpolated as Lisp numbers, without quotes.  If you provide the
1825 @samp{L} flag, all fields will be interpolated literally, without quotes.
1826 I.e., if you want a reference to be interpreted as a string by the Lisp
1827 form, enclode the reference operator itself in double quotes, like
1828 @code{"$3"}.  Ranges are inserted as space-separated fields, so you can
1829 embed them in list or vector syntax.  A few examples, note how the
1830 @samp{N} mode is used when we do computations in lisp.
1832 @example
1833 @r{Swap the first two characters of the content of column 1}
1834   '(concat (substring $1 1 2) (substring $1 0 1) (substring $1 2))
1835 @r{Add columns 1 and 2, equivalent to the Calc's @code{$1+$2}}
1836   '(+ $1 $2);N
1837 @r{Compute the sum of columns 1-4, like Calc's @code{vsum($1..$4)}}
1838   '(apply '+ '($1..$4));N
1839 @end example
1841 @node Field formulas, Column formulas, Formula syntax for Lisp, The spreadsheet
1842 @subsection Field formulas
1843 @cindex field formula
1844 @cindex formula, for individual table field
1846 To assign a formula to a particular field, type it directly into the
1847 field, preceded by @samp{:=}, for example @samp{:=$1+$2}.  When you
1848 press @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in
1849 the field, the formula will be stored as the formula for this field,
1850 evaluated, and the current field replaced with the result.
1852 Formulas are stored in a special line starting with @samp{#+TBLFM:}
1853 directly below the table.  If you typed the equation in the 4th field of
1854 the 3rd data line in the table, the formula will look like
1855 @samp{@@3$4=$1+$2}.  When inserting/deleting/swapping column and rows
1856 with the appropriate commands, @i{absolute references} (but not relative
1857 ones) in stored formulas are modified in order to still reference the
1858 same field.  Of cause this is not true if you edit the table structure
1859 with normal editing commands - then you must fix the equations yourself.
1861 Instead of typing an equation into the field, you may also use the
1862 following command
1864 @table @kbd
1865 @kindex C-u C-c =
1866 @item C-u C-c =
1867 Install a new formula for the current field.  The command prompts for a
1868 formula, with default taken from the @samp{#+TBLFM:} line, applies
1869 it to the current field and stores it.
1870 @end table
1872 @node Column formulas, Editing and debugging formulas, Field formulas, The spreadsheet
1873 @subsection Column formulas
1874 @cindex column formula
1875 @cindex formula, for table column
1877 Often in a table, the same formula should be used for all fields in a
1878 particular column.  Instead of having to copy the formula to all fields
1879 in that column, org-mode allows to assign a single formula to an entire
1880 column.  If the table contains horizontal separator hlines, everything
1881 before the first such line is considered part of the table @emph{header}
1882 and will not be modified by column formulas.
1884 To assign a formula to a column, type it directly into any field in the
1885 column, preceded by an equal sign, like @samp{=$1+$2}.  When you press
1886 @key{TAB} or @key{RET} or @kbd{C-c C-c} with the cursor still in the
1887 field, the formula will be stored as the formula for the current column,
1888 evaluated and the current field replaced with the result.  If the field
1889 contains only @samp{=}, the previously stored formula for this column is
1890 used.  For each column, Org-mode will only remember the most recently
1891 used formula.  In the @samp{TBLFM:} line, column formulas will look like
1892 @samp{$4=$1+$2}.
1894 Instead of typing an equation into the field, you may also use the
1895 following command:
1897 @table @kbd
1898 @kindex C-c =
1899 @item C-c =
1900 Install a new formula for the current column and replace current field
1901 with the result of the formula.  The command prompts for a formula, with
1902 default taken from the @samp{#+TBLFM} line, applies it to the current
1903 field and stores it.  With a numerical prefix (e.g. @kbd{C-5 C-c =})
1904 will apply it to that many consecutive fields in the current column.
1905 @end table
1908 @node Editing and debugging formulas, Updating the table, Column formulas, The spreadsheet
1909 @subsection Editing and Debugging formulas
1910 @cindex formula editing
1911 @cindex editing, of table formulas
1913 You can edit individual formulas in the minibuffer or directly in the
1914 field.  Org-mode can also prepare a special buffer with all active
1915 formulas of a table.  When offering a formula for editing, Org-mode
1916 converts references to the standard format (like @code{B3} or @code{D&})
1917 if possible.  If you prefer to only work with the internal format (like
1918 @code{@@3$2} or @code{$4}), configure the variable
1919 @code{org-table-use-standard-references}.
1921 @table @kbd
1922 @kindex C-c =
1923 @kindex C-u C-c =
1924 @item C-c =
1925 @itemx C-u C-c =
1926 Edit the formula associated with the current column/field in the
1927 minibuffer.  See @ref{Column formulas} and @ref{Field formulas}.
1928 @kindex C-u C-u C-c =
1929 @item C-u C-u C-c =
1930 Re-insert the active formula (either a
1931 field formula, or a column formula) into the current field, so that you
1932 can edit it directly in the field.  The advantage over editing in the
1933 minibuffer is that you can use the command @kbd{C-c ?}.
1934 @kindex C-c ?
1935 @item C-c ?
1936 While editing a formula in a table field, highlight the field(s)
1937 referenced by the reference at the cursor position in the formula.
1938 @kindex C-c @}
1939 @item C-c @}
1940 Toggle the display of row and column numbers for a table, using
1941 overlays.  These are updated each time the table is aligned, you can
1942 force it with @kbd{C-c C-c}.
1943 @kindex C-c @{
1944 @item C-c @{
1945 Toggle the formula debugger on and off.  See below.
1946 @kindex C-c '
1947 @item C-c '
1948 Edit all formulas for the current table in a special buffer, where the
1949 formulas will be displayed one per line.  If the current field has an
1950 active formula, the cursor in the formula editor will mark it.
1951 While inside the special buffer, Org-mode will automatically highlight
1952 any field or range reference at the cursor position.  You may edit,
1953 remove and add formulas, and use the following commands:
1954 @table @kbd
1955 @kindex C-c C-c
1956 @kindex C-x C-s
1957 @item C-c C-c
1958 @itemx C-x C-s
1959 Exit the formula editor and store the modified formulas.  With @kbd{C-u}
1960 prefix, also apply the new formulas to the entire table.
1961 @kindex C-c C-q
1962 @item C-c C-q
1963 Exit the formula editor without installing changes.
1964 @kindex C-c C-r
1965 @item C-c C-r
1966 Toggle all references in the formula editor between standard (like
1967 @code{B3}) and internal (like @code{@@3$2}).
1968 @kindex @key{TAB}
1969 @item @key{TAB}
1970 Pretty-print or indent lisp formula at point.  When in a line containing
1971 a lisp formula, format the formula according to Emacs Lisp rules.
1972 Another @key{TAB} collapses the formula back again.  In the open
1973 formula, @key{TAB} re-indents just like in Emacs-lisp-mode.
1974 @kindex M-@key{TAB}
1975 @item M-@key{TAB}
1976 Complete Lisp symbols, just like in Emacs-lisp-mode.
1977 @kindex S-@key{up}
1978 @kindex S-@key{down}
1979 @kindex S-@key{left}
1980 @kindex S-@key{right}
1981 @item S-@key{up}/@key{down}/@key{left}/@key{right}
1982 Shift the reference at point.  For example, if the reference is
1983 @code{B3} and you press @kbd{S-@key{right}}, it will become @code{C3}.
1984 This also works for relative references, and for hline references.
1985 @kindex M-S-@key{up}
1986 @kindex M-S-@key{down}
1987 @item M-S-@key{up}/@key{down}
1988 Move the test line for column formulas in the Org-mode buffer up and
1989 down.
1990 @kindex M-@key{up}
1991 @kindex M-@key{down}
1992 @item M-@key{up}/@key{down}
1993 Scroll the window displaying the table.
1994 @kindex C-c @}
1995 @item C-c @}
1996 Turn the coordinate grid in the table on and off.
1997 @end table
1998 @end table
2000 Making a table field blank does not remove the formula associated with
2001 the field, because that is stored in a different line (the @samp{TBLFM}
2002 line) - during the next recalculation the field will be filled again.
2003 To remove a formula from a field, you have to give an empty reply when
2004 prompted for the formula, or to edit the @samp{#+TBLFM} line.
2006 @kindex C-c C-c
2007 You may edit the @samp{#+TBLFM} directly and re-apply the changed
2008 equations with @kbd{C-c C-c} in that line, or with the normal
2009 recalculation commands in the table.
2011 @subsubheading Debugging formulas
2012 @cindex formula debugging
2013 @cindex debugging, of table formulas
2014 When the evaluation of a formula leads to an error, the field content
2015 becomes the string @samp{#ERROR}.  If you would like see what is going
2016 on during variable substitution and calculation in order to find a bug,
2017 turn on formula debugging in the @code{Tbl} menu and repeat the
2018 calculation, for example by pressing @kbd{C-u C-u C-c = @key{RET}} in a
2019 field.  Detailed information will be displayed.
2021 @node Updating the table, Advanced features, Editing and debugging formulas, The spreadsheet
2022 @subsection Updating the Table
2023 @cindex recomputing table fields
2024 @cindex updating, table
2026 Recalculation of a table is normally not automatic, but needs to be
2027 triggered by a command.  See @ref{Advanced features} for a way to make
2028 recalculation at least semi-automatically.
2030 In order to recalculate a line of a table or the entire table, use the
2031 following commands:
2033 @table @kbd
2034 @kindex C-c *
2035 @item C-c *
2036 Recalculate the current row by first applying the stored column formulas
2037 from left to right, and all field formulas in the current row.
2039 @kindex C-u C-c *
2040 @item C-u C-c *
2041 @kindex C-u C-c C-c
2042 @itemx C-u C-c C-c
2043 Recompute the entire table, line by line.  Any lines before the first
2044 hline are left alone, assuming that these are part of the table header.
2046 @kindex C-u C-u C-c *
2047 @kindex C-u C-u C-c C-c
2048 @item C-u C-u C-c *
2049 @itemx C-u C-u C-c C-c
2050 Iterate the table by recomputing it until no further changes occur.
2051 This may be necessary if some computed fields use the value of other
2052 fields that are computed @i{later} in the calculation sequence.
2053 @end table
2055 @node Advanced features,  , Updating the table, The spreadsheet
2056 @subsection Advanced features
2058 If you want the recalculation of fields to happen automatically, or if
2059 you want to be able to assign @i{names} to fields and columns, you need
2060 to reserve the first column of the table for special marking characters.
2061 @table @kbd
2062 @kindex C-#
2063 @item C-#
2064 Rotate the calculation mark in first column through the states @samp{},
2065 @samp{#}, @samp{*}, @samp{!}, @samp{$}.  The meaning of these characters
2066 is discussed below.  When there is an active region, change all marks in
2067 the region.
2068 @end table
2070 Here is an example of a table that collects exam results of students and
2071 makes use of these features:
2073 @example
2074 @group
2075 |---+---------+--------+--------+--------+-------+------|
2076 |   | Student | Prob 1 | Prob 2 | Prob 3 | Total | Note |
2077 |---+---------+--------+--------+--------+-------+------|
2078 | ! |         |     P1 |     P2 |     P3 |   Tot |      |
2079 | # | Maximum |     10 |     15 |     25 |    50 | 10.0 |
2080 | ^ |         |     m1 |     m2 |     m3 |    mt |      |
2081 |---+---------+--------+--------+--------+-------+------|
2082 | # | Peter   |     10 |      8 |     23 |    41 |  8.2 |
2083 | # | Sara    |      6 |     14 |     19 |    39 |  7.8 |
2084 | # | Sam     |      2 |      4 |      3 |     9 |  1.8 |
2085 |---+---------+--------+--------+--------+-------+------|
2086 |   | Average |        |        |        |  29.7 |      |
2087 | ^ |         |        |        |        |    at |      |
2088 | $ | max=50  |        |        |        |       |      |
2089 |---+---------+--------+--------+--------+-------+------|
2090 #+TBLFM: $6=vsum($P1..$P3)::$7=10*$Tot/$max;%.1f::$at=vmean(@@-II..@@-I);%.1f
2091 @end group
2092 @end example
2094 @noindent @b{Important}: Please note that for these special tables,
2095 recalculating the table with @kbd{C-u C-c *} will only affect rows that
2096 are marked @samp{#} or @samp{*}, and fields that have a formula assigned
2097 to the field itself.  The column formulas are not applied in rows with
2098 empty first field.
2100 @cindex marking characters, tables
2101 The marking characters have the following meaning:
2102 @table @samp
2103 @item !
2104 The fields in this line define names for the columns, so that you may
2105 refer to a column as @samp{$Tot} instead of @samp{$6}.
2106 @item ^
2107 This row defines names for the fields @emph{above} the row.  With such
2108 a definition, any formula in the table may use @samp{$m1} to refer to
2109 the value @samp{10}.  Also, if you assign a formula to a names field, it
2110 will be stored as @samp{$name=...}.
2111 @item _
2112 Similar to @samp{^}, but defines names for the fields in the row
2113 @emph{below}.
2114 @item $
2115 Fields in this row can define @emph{parameters} for formulas.  For
2116 example, if a field in a @samp{$} row contains @samp{max=50}, then
2117 formulas in this table can refer to the value 50 using @samp{$max}.
2118 Parameters work exactly like constants, only that they can be defined on
2119 a per-table basis.
2120 @item #
2121 Fields in this row are automatically recalculated when pressing
2122 @key{TAB} or @key{RET} or @kbd{S-@key{TAB}} in this row.  Also, this row
2123 is selected for a global recalculation with @kbd{C-u C-c *}.  Unmarked
2124 lines will be left alone by this command.
2125 @item *
2126 Selects this line for global recalculation with @kbd{C-u C-c *}, but
2127 not for automatic recalculation.  Use this when automatic
2128 recalculation slows down editing too much.
2129 @item
2130 Unmarked lines are exempt from recalculation with @kbd{C-u C-c *}.
2131 All lines that should be recalculated should be marked with @samp{#}
2132 or @samp{*}.
2133 @item /
2134 Do not export this line.  Useful for lines that contain the narrowing
2135 @samp{<N>} markers.
2136 @end table
2138 Finally, just to whet your appetite on what can be done with the
2139 fantastic @file{calc} package, here is a table that computes the Taylor
2140 series of degree @code{n} at location @code{x} for a couple of
2141 functions.
2143 @example
2144 @group
2145 |---+-------------+---+-----+--------------------------------------|
2146 |   | Func        | n | x   | Result                               |
2147 |---+-------------+---+-----+--------------------------------------|
2148 | # | exp(x)      | 1 | x   | 1 + x                                |
2149 | # | exp(x)      | 2 | x   | 1 + x + x^2 / 2                      |
2150 | # | exp(x)      | 3 | x   | 1 + x + x^2 / 2 + x^3 / 6            |
2151 | # | x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
2152 | # | x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2    |
2153 | * | tan(x)      | 3 | x   | 0.0175 x + 1.77e-6 x^3               |
2154 |---+-------------+---+-----+--------------------------------------|
2155 #+TBLFM: $5=taylor($2,$4,$3);n3
2156 @end group
2157 @end example
2159 @node Hyperlinks, TODO items, Tables, Top
2160 @chapter Hyperlinks
2161 @cindex hyperlinks
2163 Like HTML, Org-mode provides links inside a file, external links to
2164 other files, Usenet articles, emails, and much more.
2166 @menu
2167 * Link format::                 How links in Org-mode are formatted
2168 * Internal links::              Links to other places in the current file
2169 * External links::              URL-like links to the world
2170 * Handling links::              Creating, inserting and following
2171 * Using links outside Org-mode::  Linking from my C source code?
2172 * Link abbreviations::          Shortcuts for writing complex links
2173 * Search options::              Linking to a specific location
2174 * Custom searches::             When the default search is not enough
2175 @end menu
2177 @node Link format, Internal links, Hyperlinks, Hyperlinks
2178 @section Link format
2179 @cindex link format
2180 @cindex format, of links
2182 Org-mode will recognize plain URL-like links and activate them as
2183 clickable links.  The general link format, however, looks like this:
2185 @example
2186 [[link][description]]       @r{or alternatively}           [[link]]  
2187 @end example
2189 Once a link in the buffer is complete (all brackets present), Org-mode
2190 will change the display so that @samp{description} is displayed instead
2191 of @samp{[[link][description]]} and @samp{link} is displayed instead of
2192 @samp{[[link]]}.  Links will be highlighted in the face @code{org-link},
2193 which by default is an underlined face.  You can directly edit the
2194 visible part of a link.  Note that this can be either the @samp{link}
2195 part (if there is no description) or the @samp{description} part.  To
2196 edit also the invisible @samp{link} part, use @kbd{C-c C-l} with the
2197 cursor on the link.
2199 If you place the cursor at the beginning or just behind the end of the
2200 displayed text and press @key{BACKSPACE}, you will remove the
2201 (invisible) bracket at that location.  This makes the link incomplete
2202 and the internals are again displayed as plain text.  Inserting the
2203 missing bracket hides the link internals again.  To show the
2204 internal structure of all links, use the menu entry
2205 @code{Org->Hyperlinks->Literal links}.
2207 @node Internal links, External links, Link format, Hyperlinks
2208 @section Internal links
2209 @cindex internal links
2210 @cindex links, internal
2211 @cindex targets, for links
2213 If the link does not look like a URL, it is considered to be internal in
2214 the current file.  Links such as @samp{[[My Target]]} or @samp{[[My
2215 Target][Find my target]]} lead to a text search in the current file.
2216 The link can be followed with @kbd{C-c C-o} when the cursor is on the
2217 link, or with a mouse click (@pxref{Handling links}).  The preferred
2218 match for such a link is a dedicated target: the same string in double
2219 angular brackets.  Targets may be located anywhere; sometimes it is
2220 convenient to put them into a comment line. For example
2222 @example
2223 # <<My Target>>
2224 @end example
2226 @noindent In HTML export (@pxref{HTML export}), such targets will become
2227 named anchors for direct access through @samp{http} links@footnote{Note
2228 that text before the first headline is usually not exported, so the
2229 first such target should be after the first headline.}.
2231 If no dedicated target exists, Org-mode will search for the words in the
2232 link.  In the above example the search would be for @samp{my target}.
2233 Links starting with a star like @samp{*My Target} restrict the search to
2234 headlines.  When searching, Org-mode will first try an exact match, but
2235 then move on to more and more lenient searches.  For example, the link
2236 @samp{[[*My Targets]]} will find any of the following:
2238 @example
2239 ** My targets
2240 ** TODO my targets are bright
2241 ** my 20 targets are
2242 @end example
2244 To insert a link targeting a headline, in-buffer completion can be used.
2245 Just type a star followed by a few optional letters into the buffer and
2246 press @kbd{M-@key{TAB}}.  All headlines in the current buffer will be
2247 offered as completions.  @xref{Handling links}, for more commands
2248 creating links.
2250 Following a link pushes a mark onto Org-mode's own mark ring.  You can
2251 return to the previous position with @kbd{C-c &}.  Using this command
2252 several times in direct succession goes back to positions recorded
2253 earlier.
2255 @menu
2256 * Radio targets::               Make targets trigger links in plain text.
2257 @end menu
2259 @node Radio targets,  , Internal links, Internal links
2260 @subsection Radio targets
2261 @cindex radio targets
2262 @cindex targets, radio
2263 @cindex links, radio targets
2265 Org-mode can automatically turn any occurrences of certain target names
2266 in normal text into a link.  So without explicitly creating a link, the
2267 text connects to the target radioing its position.  Radio targets are
2268 enclosed by triple angular brackets.  For example, a target @samp{<<<My
2269 Target>>>} causes each occurrence of @samp{my target} in normal text to
2270 become activated as a link.  The Org-mode file is scanned automatically
2271 for radio targets only when the file is first loaded into Emacs.  To
2272 update the target list during editing, press @kbd{C-c C-c} with the
2273 cursor on or at a target.
2275 @node External links, Handling links, Internal links, Hyperlinks
2276 @section External links
2277 @cindex links, external
2278 @cindex external links
2279 @cindex links, external
2280 @cindex GNUS links
2281 @cindex BBDB links
2282 @cindex IRC links
2283 @cindex URL links
2284 @cindex file links
2285 @cindex VM links
2286 @cindex RMAIL links
2287 @cindex WANDERLUST links
2288 @cindex MH-E links
2289 @cindex USENET links
2290 @cindex SHELL links
2291 @cindex Info links
2292 @cindex elisp links
2294 Org-mode supports links to files, websites, Usenet and email messages,
2295 BBDB database entries and links to both IRC conversations and their
2296 logs.  External links are URL-like locators.  They start with a short
2297 identifying string followed by a colon.  There can be no space after
2298 the colon.  The following list shows examples for each link type.
2300 @example
2301 http://www.astro.uva.nl/~dominik          @r{on the web}
2302 file:/home/dominik/images/jupiter.jpg     @r{file, absolute path}
2303 file:papers/last.pdf                      @r{file, relative path}
2304 news:comp.emacs                           @r{Usenet link}
2305 mailto:adent@@galaxy.net                  @r{Mail link}
2306 vm:folder                                 @r{VM folder link}
2307 vm:folder#id                              @r{VM message link}
2308 vm://myself@@some.where.org/folder#id     @r{VM on remote machine}
2309 wl:folder                                 @r{WANDERLUST folder link}
2310 wl:folder#id                              @r{WANDERLUST message link}
2311 mhe:folder                                @r{MH-E folder link}
2312 mhe:folder#id                             @r{MH-E message link}
2313 rmail:folder                              @r{RMAIL folder link}
2314 rmail:folder#id                           @r{RMAIL message link}
2315 gnus:group                                @r{GNUS group link}
2316 gnus:group#id                             @r{GNUS article link}
2317 bbdb:Richard Stallman                     @r{BBDB link}
2318 irc:/irc.com/#emacs/bob                   @r{IRC link}
2319 shell:ls *.org                            @r{A shell command}
2320 elisp:(find-file-other-frame "Elisp.org") @r{An elisp form to evaluate}
2321 @end example
2323 A link should be enclosed in double brackets and may contain a
2324 descriptive text to be displayed instead of the url (@pxref{Link
2325 format}), for example:
2327 @example
2328 [[http://www.gnu.org/software/emacs/][GNU Emacs]]
2329 @end example
2331 @noindent
2332 If the description is a file name or URL that points to an image, HTML
2333 export (@pxref{HTML export}) will inline the image as a clickable
2334 button.  If there is no description at all and the link points to an
2335 image,
2336 that image will be inlined into the exported HTML file.
2338 @cindex angular brackets, around links
2339 @cindex plain text external links
2340 Org-mode also finds external links in the normal text and activates them
2341 as links.  If spaces must be part of the link (for example in
2342 @samp{bbdb:Richard Stallman}), or if you need to remove ambiguities
2343 about the end of the link, enclose them in angular brackets.
2345 @node Handling links, Using links outside Org-mode, External links, Hyperlinks
2346 @section Handling links
2347 @cindex links, handling
2349 Org-mode provides methods to create a link in the correct syntax, to
2350 insert it into an org-mode file, and to follow the link.
2352 @table @kbd
2353 @kindex C-c l
2354 @cindex storing links
2355 @item C-c l
2356 Store a link to the current location.  This is a @emph{global} command
2357 which can be used in any buffer to create a link.  The link will be
2358 stored for later insertion into an Org-mode buffer (see below).  For
2359 Org-mode files, if there is a @samp{<<target>>} at the cursor, the
2360 link points to the target.  Otherwise it points to the current
2361 headline.  For VM, RMAIL, WANDERLUST, MH-E, GNUS and BBDB buffers, the
2362 link will indicate the current article/entry.  For W3 and W3M buffers,
2363 the link goes to the current URL.  For IRC links, if you set the
2364 variable @code{org-irc-link-to-logs} to non-nil then @kbd{C-c l} will
2365 store a @samp{file:/} style link to the relevant point in the logs for
2366 the current conversation. Otherwise an @samp{irc:/} style link to the
2367 user/channel/server under the point will be stored.  For any other
2368 files, the link will point to the file, with a search string
2369 (@pxref{Search options}) pointing to the contents of the current line.
2370 If there is an active region, the selected words will form the basis
2371 of the search string.  If the automatically created link is not
2372 working correctly or accurately enough, you can write custom functions
2373 to select the search string and to do the search for particular file
2374 types - see @ref{Custom searches}.  The key binding @kbd{C-c l} is
2375 only a suggestion - see @ref{Installation}.
2377 @kindex C-c C-l
2378 @cindex link completion
2379 @cindex completion, of links
2380 @cindex inserting links
2381 @item C-c C-l
2382 Insert a link.  This prompts for a link to be inserted into the buffer.
2383 You can just type a link, using text for an internal link, or one of the
2384 link type prefixes mentioned in the examples above.  All links stored
2385 during the current session are part of the history for this prompt, so
2386 you can access them with @key{up} and @key{down} (or @kbd{M-p/n}).
2387 Completion, on the other hand, will help you to insert valid link
2388 prefixes like @samp{http:} or @samp{ftp:}, including the prefixes
2389 defined through link abbreviations (@pxref{Link abbreviations}).  The
2390 link will be inserted into the buffer@footnote{After insertion of a
2391 stored link, the link will be removed from the list of stored links.  To
2392 keep it in the list later use, use a triple @kbd{C-u} prefix to @kbd{C-c
2393 C-l}, or configure the option
2394 @code{org-keep-stored-link-after-insertion}.}, along with a descriptive
2395 text.  If some text was selected when this command is called, the
2396 selected text becomes the default description.@* Note that you don't
2397 have to use this command to insert a link.  Links in Org-mode are plain
2398 text, and you can type or paste them straight into the buffer.  By using
2399 this command, the links are automatically enclosed in double brackets,
2400 and you will be asked for the optional descriptive text.
2402 @c  If the link is a @samp{file:} link and
2403 @c the linked file is located in the same directory as the current file or
2404 @c a subdirectory of it, the path of the file will be inserted relative to
2405 @c the current directory.
2407 @kindex C-u C-c C-l
2408 @cindex file name completion
2409 @cindex completion, of file names
2410 @item C-u C-c C-l
2411 When @kbd{C-c C-l} is called with a @kbd{C-u} prefix argument, a link to
2412 a file will be inserted and you may use file name completion to select
2413 the name of the file.  The path to the file is inserted relative to the
2414 directory of the current org file, if the linked file is in the current
2415 directory or in a subdirectory of it, or if the path is written relative
2416 to the current directory using @samp{../}.  Otherwise an absolute path
2417 is used, if possible with @samp{~/} for your home directory.  You can
2418 force an absolute path with two @kbd{C-u} prefixes.
2420 @item C-c C-l @r{(with cursor on existing link)}
2421 When the cursor is on an existing link, @kbd{C-c C-l} allows you to edit the
2422 link and description parts of the link.
2424 @cindex following links
2425 @kindex C-c C-o
2426 @item C-c C-o
2427 Open link at point.  This will launch a web browser for URLs (using
2428 @command{browse-url-at-point}), run vm/mh-e/wanderlust/rmail/gnus/bbdb
2429 for the corresponding links, and execute the command in a shell link.
2430 When the cursor is on an internal link, this commands runs the
2431 corresponding search.  When the cursor is on a TAG list in a headline,
2432 it creates the corresponding TAGS view.  If the cursor is on a time
2433 stamp, it compiles the agenda for that date.  Furthermore, it will visit
2434 text and remote files in @samp{file:} links with Emacs and select a
2435 suitable application for local non-text files.  Classification of files
2436 is based on file extension only.  See option @code{org-file-apps}.  If
2437 you want to override the default application and visit the file with
2438 Emacs, use a @kbd{C-u} prefix.
2440 @kindex mouse-2
2441 @kindex mouse-1
2442 @item mouse-2
2443 @itemx mouse-1
2444 On links, @kbd{mouse-2} will open the link just as @kbd{C-c C-o}
2445 would.  Under Emacs 22, also @kbd{mouse-1} will follow a link.
2447 @kindex mouse-3
2448 @item mouse-3
2449 Like @kbd{mouse-2}, but force file links to be opened with Emacs, and
2450 internal links to be displayed in another window@footnote{See the
2451 variable @code{org-display-internal-link-with-indirect-buffer}}.
2453 @cindex mark ring
2454 @kindex C-c %
2455 @item C-c %
2456 Push the current position onto the mark ring, to be able to return
2457 easily. Commands following an internal link do this automatically.
2459 @cindex links, returning to
2460 @kindex C-c &
2461 @item C-c &
2462 Jump back to a recorded position.  A position is recorded by the
2463 commands following internal links, and by @kbd{C-c %}.  Using this
2464 command several times in direct succession moves through a ring of
2465 previously recorded positions.
2467 @kindex C-c C-x C-n
2468 @kindex C-c C-x C-p
2469 @cindex links, finding next/previous
2470 @item C-c C-x C-n
2471 @itemx C-c C-x C-p
2472 Move forward/backward to the next link in the buffer.  At the limit of
2473 the buffer, the search fails once, and then wraps around.  The key
2474 bindings for this are really too long, you might want to bind this also
2475 to @kbd{C-n} and @kbd{C-p}
2476 @lisp
2477 (add-hook 'org-load-hook
2478   (lambda ()
2479     (define-key 'org-mode-map "\C-n" 'org-next-link)
2480     (define-key 'org-mode-map "\C-p" 'org-previous-link)))
2481 @end lisp
2482 @end table
2484 @node Using links outside Org-mode, Link abbreviations, Handling links, Hyperlinks
2485 @section Using links outside Org-mode
2487 You can insert and follow links that have Org-mode syntax not only in
2488 Org-mode, but in any Emacs buffer.  For this, you should create two
2489 global commands, like this (please select suitable global keys
2490 yourself):
2492 @lisp
2493 (global-set-key "\C-c L" 'org-insert-link-global)
2494 (global-set-key "\C-c o" 'org-open-at-point-global)
2495 @end lisp
2497 @node Link abbreviations, Search options, Using links outside Org-mode, Hyperlinks
2498 @section Link abbreviations
2499 @cindex link abbreviations
2500 @cindex abbreviation, links
2502 Long URLs can be cumbersome to type, and often many similar links are
2503 needed in a document.  For this you can use link abbreviations.  An
2504 abbreviated link looks like this
2506 @example
2507 [[linkword:tag][description]]
2508 @end example
2510 @noindent
2511 where the tag is optional.  Such abbreviations are resolved according to
2512 the information in the variable @code{org-link-abbrev-alist} that
2513 relates the linkwords to replacement text.  Here is an example:
2515 @lisp
2516 @group
2517 (setq org-link-abbrev-alist
2518   '(("bugzilla" . "http://10.1.2.9/bugzilla/show_bug.cgi?id=")
2519     ("google"   . "http://www.google.com/search?q=")
2520     ("ads"      . "http://adsabs.harvard.edu/cgi-bin/
2521                    nph-abs_connect?author=%s&db_key=AST")))
2522 @end group
2523 @end lisp
2525 If the replacement text contains the string @samp{%s}, it will be
2526 replaced with the tag.  Otherwise the tag will be appended to the string
2527 in order to create the link.  You may also specify a function that will
2528 be called with the tag as the only argument to create the link.
2530 With the above setting, you could link to a specific bug with
2531 @code{[[bugzilla:129]]}, search the web for @samp{OrgMode} with
2532 @code{[[google:OrgMode]]} and find out what the Org-mode author is
2533 doing besides Emacs hacking with @code{[[ads:Dominik,C]]}.
2535 If you need special abbreviations just for a single Org-mode buffer, you
2536 can define them in the file with
2538 @example
2539 #+LINK: bugzilla  http://10.1.2.9/bugzilla/show_bug.cgi?id=
2540 #+LINK: google    http://www.google.com/search?q=%s
2541 @end example
2543 @noindent
2544 In-buffer completion @pxref{Completion} can be used after @samp{[} to
2545 complete link abbreviations.
2547 @node Search options, Custom searches, Link abbreviations, Hyperlinks
2548 @section Search options in file links
2549 @cindex search option in file links
2550 @cindex file links, searching
2552 File links can contain additional information to make Emacs jump to a
2553 particular location in the file when following a link.  This can be a
2554 line number or a search option after a double@footnote{For backward
2555 compatibility, line numbers can also follow a single colon.} colon. For
2556 example, when the command @kbd{C-c l} creates a link (@pxref{Handling
2557 links}) to a file, it encodes the words in the current line as a search
2558 string that can be used to find this line back later when following the
2559 link with @kbd{C-c C-o}. 
2561 Here is the syntax of the different ways to attach a search to a file
2562 link, together with an explanation:
2564 @example
2565 [[file:~/code/main.c::255]]
2566 [[file:~/xx.org::My Target]]
2567 [[file:~/xx.org::*My Target]]
2568 [[file:~/xx.org::/regexp/]]
2569 @end example
2571 @table @code
2572 @item 255
2573 Jump to line 255.
2574 @item My Target
2575 Search for a link target @samp{<<My Target>>}, or do a text search for
2576 @samp{my target}, similar to the search in internal links, see
2577 @ref{Internal links}.  In HTML export (@pxref{HTML export}), such a file
2578 link will become an HTML reference to the corresponding named anchor in
2579 the linked file.
2580 @item *My Target
2581 In an Org-mode file, restrict search to headlines.
2582 @item /regexp/
2583 Do a regular expression search for @code{regexp}.  This uses the Emacs
2584 command @code{occur} to list all matches in a separate window.  If the
2585 target file is in Org-mode, @code{org-occur} is used to create a
2586 sparse tree with the matches.
2587 @c If the target file is a directory,
2588 @c @code{grep} will be used to search all files in the directory.
2589 @end table
2591 As a degenerate case, a file link with an empty file name can be used
2592 to search the current file.  For example, @code{[[file:::find me]]} does
2593 a search for @samp{find me} in the current file, just as
2594 @samp{[[find me]]} would.
2596 @node Custom searches,  , Search options, Hyperlinks
2597 @section Custom Searches
2598 @cindex custom search strings
2599 @cindex search strings, custom
2601 The default mechanism for creating search strings and for doing the
2602 actual search related to a file link may not work correctly in all
2603 cases.  For example, BibTeX database files have many entries like
2604 @samp{year="1993"} which would not result in good search strings,
2605 because the only unique identification for a BibTeX entry is the
2606 citation key.
2608 If you come across such a problem, you can write custom functions to set
2609 the right search string for a particular file type, and to do the search
2610 for the string in the file.  Using @code{add-hook}, these functions need
2611 to be added to the hook variables
2612 @code{org-create-file-search-functions} and
2613 @code{org-execute-file-search-functions}.  See the docstring for these
2614 variables for more information.  Org-mode actually uses this mechanism
2615 for Bib@TeX{} database files, and you can use the corresponding code as
2616 an implementation example.  Search for @samp{BibTeX links} in the source
2617 file.
2621 @node TODO items, Tags, Hyperlinks, Top
2622 @chapter TODO items
2623 @cindex TODO items
2625 Org-mode does not maintain TODO lists as separate documents.  Instead,
2626 TODO items are an integral part of the notes file, because TODO items
2627 usually come up while taking notes!  With Org-mode, simply mark any
2628 entry in a tree as being a TODO item.  In this way, information is not
2629 duplicated, and the entire context from which the TODO item emerged is
2630 always present.
2632 Of course, this technique for managing TODO items scatters them
2633 throughout your notes file.  Org-mode compensates for this by providing
2634 methods to give you an overview of all the things that you have to do.
2636 @menu
2637 * TODO basics::                 Marking and displaying TODO entries
2638 * TODO extensions::             Workflow and assignments
2639 * Progress logging::            Dates and notes for progress
2640 * Priorities::                  Some things are more important than others
2641 * Breaking down tasks::         Splitting a task into manageable pieces
2642 * Checkboxes::                  Tick-off lists
2643 @end menu
2645 @node TODO basics, TODO extensions, TODO items, TODO items
2646 @section Basic TODO functionality
2648 Any headline becomes a TODO item when it starts with the word
2649 @samp{TODO}, for example:
2651 @example
2652 *** TODO Write letter to Sam Fortune
2653 @end example
2655 @noindent
2656 The most important commands to work with TODO entries are:
2658 @table @kbd
2659 @kindex C-c C-t
2660 @cindex cycling, of TODO states
2661 @item C-c C-t
2662 Rotate the TODO state of the current item among
2664 @example
2665 ,-> (unmarked) -> TODO -> DONE --.
2666 '--------------------------------'
2667 @end example
2669 The same rotation can also be done ``remotely'' from the timeline and
2670 agenda buffers with the @kbd{t} command key (@pxref{Agenda commands}).
2672 @kindex C-u C-c C-t
2673 @item C-u C-c C-t
2674 Select a specific keyword using completion or (if it has been set up)
2675 the fast selection interface.  For the latter, you need to assign keys
2676 to TODO states, see @ref{Per-file keywords} and @ref{Setting tags} for
2677 more information.
2679 @kindex S-@key{right}
2680 @kindex S-@key{left}
2681 @item S-@key{right}
2682 @itemx S-@key{left}
2683 Select the following/preceding TODO state, similar to cycling.  Useful
2684 mostly if more than two TODO states are possible (@pxref{TODO
2685 extensions}).
2686 @kindex C-c C-v
2687 @kindex C-c / t
2688 @cindex sparse tree, for TODO
2689 @item C-c C-v
2690 @itemx C-c / t
2691 View TODO items in a @emph{sparse tree} (@pxref{Sparse trees}).  Folds
2692 the entire buffer, but shows all TODO items and the headings hierarchy
2693 above them.  With prefix arg, search for a specific TODO.  You will be
2694 prompted for the keyword, and you can also give a list of keywords like
2695 @code{KWD1|KWD2|...}.  With numerical prefix N, show the tree for the
2696 Nth keyword in the variable @code{org-todo-keywords}.  With two prefix
2697 args, find all TODO and DONE entries.
2698 @kindex C-c a t
2699 @item C-c a t
2700 Show the global TODO list.  Collects the TODO items from all agenda
2701 files (@pxref{Agenda views}) into a single buffer.  The new buffer will
2702 be in @code{agenda-mode}, which provides commands to examine and
2703 manipulate the TODO entries from the new buffer (@pxref{Agenda
2704 commands}).  @xref{Global TODO list}, for more information.
2705 @kindex S-M-@key{RET}
2706 @item S-M-@key{RET}
2707 Insert a new TODO entry below the current one.
2708 @end table
2710 @node TODO extensions, Progress logging, TODO basics, TODO items
2711 @section Extended use of TODO keywords
2712 @cindex extended TODO keywords
2714 By default, marked TODO entries have one of only two states: TODO and
2715 DONE.  Org-mode allows you to classify TODO items in more complex ways
2716 with @emph{TODO keywords} (stored in @code{org-todo-keywords}).  With
2717 special setup, the TODO keyword system can work differently in different
2718 files.
2720 Note that @i{tags} are another way to classify headlines in general and
2721 TODO items in particular (@pxref{Tags}).
2723 @menu
2724 * Workflow states::             From TODO to DONE in steps
2725 * TODO types::                  I do this, Fred does the rest
2726 * Multiple sets in one file::   Mixing it all, and still finding your way
2727 * Fast access to TODO states::  Single letter selection of a state
2728 * Per-file keywords::           Different files, different requirements
2729 * Faces for TODO keywords::     Highlighting states
2730 @end menu
2732 @node Workflow states, TODO types, TODO extensions, TODO extensions
2733 @subsection TODO keywords as workflow states
2734 @cindex TODO workflow
2735 @cindex workflow states as TODO keywords
2737 You can use TODO keywords to indicate different @emph{sequential} states
2738 in the process of working on an item, for example@footnote{Changing
2739 this variable only becomes effective after restarting Org-mode in a
2740 buffer.}:
2742 @lisp
2743 (setq org-todo-keywords
2744   '((sequence "TODO" "FEEDBACK" "VERIFY" "|" "DONE" "DELEGATED")))
2745 @end lisp
2747 The vertical bar separates the TODO keywords (states that @emph{need
2748 action}) from the DONE states (which need @emph{no further action}.  If
2749 you don't provide the separator bar, the last state is used as the DONE
2750 state.
2751 @cindex completion, of TODO keywords
2752 With this setup, the command @kbd{C-c C-t} will cycle an entry from TODO
2753 to FEEDBACK, then to VERIFY, and finally to DONE and DELEGATED.  You may
2754 also use a prefix argument to quickly select a specific state.  For
2755 example @kbd{C-3 C-c C-t} will change the state immediately to VERIFY.
2756 Or you can use @kbd{S-left} to go backward through the sequence.  If you
2757 define many keywords, you can use in-buffer completion
2758 (@pxref{Completion}) or even a special one-key selection scheme
2759 (@pxref{Fast access to TODO states}) to insert these words into the
2760 buffer.  Changing a todo state can be logged with a timestamp, see
2761 @ref{Tracking TODO state changes} for more information.
2763 @node TODO types, Multiple sets in one file, Workflow states, TODO extensions
2764 @subsection TODO keywords as types
2765 @cindex TODO types
2766 @cindex names as TODO keywords
2767 @cindex types as TODO keywords
2769 The second possibility is to use TODO keywords to indicate different
2770 @emph{types} of action items.  For example, you might want to indicate
2771 that items are for ``work'' or ``home''.  Or, when you work with several
2772 people on a single project, you might want to assign action items
2773 directly to persons, by using their names as TODO keywords.  This would
2774 be set up like this:
2776 @lisp
2777 (setq org-todo-keywords '((type "Fred" "Sara" "Lucy" "|" "DONE")))
2778 @end lisp
2780 In this case, different keywords do not indicate a sequence, but rather
2781 different types.  So the normal work flow would be to assign a task to a
2782 person, and later to mark it DONE.  Org-mode supports this style by
2783 adapting the workings of the command @kbd{C-c C-t}@footnote{This is also
2784 true for the @kbd{t} command in the timeline and agenda buffers.}.  When
2785 used several times in succession, it will still cycle through all names,
2786 in order to first select the right type for a task.  But when you return
2787 to the item after some time and execute @kbd{C-c C-t} again, it will
2788 switch from any name directly to DONE.  Use prefix arguments or
2789 completion to quickly select a specific name.  You can also review the
2790 items of a specific TODO type in a sparse tree by using a numeric prefix
2791 to @kbd{C-c C-v}.  For example, to see all things Lucy has to do, you
2792 would use @kbd{C-3 C-c C-v}.  To collect Lucy's items from all agenda
2793 files into a single buffer, you would use the prefix arg as well when
2794 creating the global todo list: @kbd{C-3 C-c t}.
2796 @node Multiple sets in one file, Fast access to TODO states, TODO types, TODO extensions
2797 @subsection Multiple keyword sets in one file
2798 @cindex todo keyword sets
2800 Sometimes you may want to use different sets of TODO keywords in
2801 parallel.  For example, you may want to have the basic
2802 @code{TODO}/@code{DONE}, but also a workflow for bug fixing, and a
2803 separate state indicating that an item has been canceled (so it is not
2804 DONE, but also does not require action).  Your setup would then look
2805 like this:
2807 @lisp
2808 (setq org-todo-keywords
2809       '((sequence "TODO" "|" "DONE")
2810         (sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
2811         (sequence "|" "CANCELED")))
2812 @end lisp
2814 The keywords should all be different, this helps Org-mode to keep track
2815 of which subsequence should be used for a given entry.  In this setup,
2816 @kbd{C-c C-t} only operates within a subsequence, so it switches from
2817 @code{DONE} to (nothing) to @code{TODO}, and from @code{FIXED} to
2818 (nothing) to @code{REPORT}.  Therefore you need a mechanism to initially
2819 select the correct sequence.  Besides the obvious ways like typing a
2820 keyword or using completion, you may also apply the following commands:
2822 @table @kbd
2823 @kindex C-S-@key{right}
2824 @kindex C-S-@key{left}
2825 @item C-S-@key{right}
2826 @itemx C-S-@key{left}
2827 These keys jump from one TODO subset to the next.  In the above example,
2828 @kbd{C-S-@key{right}} would jump from @code{TODO} or @code{DONE} to
2829 @code{REPORT}, and any of the words in the second row to @code{CANCELED}.
2830 @kindex S-@key{right}
2831 @kindex S-@key{left}
2832 @item S-@key{right}
2833 @itemx S-@key{left}
2834 @kbd{S-@key{<left>}} and @kbd{S-@key{<right>}} and walk through
2835 @emph{all} keywords from all sets, so for example @kbd{S-@key{<right>}}
2836 would switch from @code{DONE} to @code{REPORT} in the example above.
2837 @end table
2839 @node Fast access to TODO states, Per-file keywords, Multiple sets in one file, TODO extensions
2840 @subsection Fast access to TODO states
2842 If you would like to quickly change an entry to an arbitrary TODO state
2843 instead of cycling through the states, you can set up keys for
2844 single-letter access to the states.  This is done by adding the section
2845 key after each keyword, in parenthesis.  For example:
2847 @lisp
2848 (setq org-todo-keywords
2849       '((sequence "TODO(t)" "|" "DONE(d)")
2850         (sequence "REPORT(r)" "BUG(b)" "KNOWNCAUSE(k)" "|" "FIXED(f)")
2851         (sequence "|" "CANCELED(c)")))
2852 @end lisp
2854 If you then press @code{C-u C-c C-t} followed by the selection key, the
2855 entry will be switched to this state.  @key{SPC} can be used to remove
2856 any TODO keyword from an entry.  Should you like this way of selecting
2857 TODO states a lot, you might want to set the variable
2858 @code{org-use-fast-todo-selection} to @code{t} and make this behavior
2859 the default.  Check also the variable
2860 @code{org-fast-tag-selection-include-todo}, it allows to change the TODO
2861 state through the tags interface (@pxref{Setting tags}), in case you
2862 like to mingle the two concepts.
2864 @node Per-file keywords, Faces for TODO keywords, Fast access to TODO states, TODO extensions
2865 @subsection Setting up keywords for individual files
2866 @cindex keyword options
2867 @cindex per-file keywords
2869 It can be very useful to use different aspects of the TODO mechanism in
2870 different files.  For file-local settings, you need to add special lines
2871 to the file which set the keywords and interpretation for that file
2872 only.  For example, to set one of the two examples discussed above, you
2873 need one of the following lines, starting in column zero anywhere in the
2874 file:
2876 @example
2877 #+SEQ_TODO: TODO FEEDBACK VERIFY | DONE CANCELED
2878 @end example
2880 @example
2881 #+TYP_TODO: Fred Sara Lucy Mike | DONE
2882 @end example
2884 A setup for using several sets in parallel would be:
2886 @example
2887 #+SEQ_TODO: TODO | DONE
2888 #+SEQ_TODO: REPORT BUG KNOWNCAUSE | FIXED
2889 #+SEQ_TODO: | CANCELED
2890 @end example
2892 @cindex completion, of option keywords
2893 @kindex M-@key{TAB}
2894 @noindent To make sure you are using the correct keyword, type
2895 @samp{#+} into the buffer and then use @kbd{M-@key{TAB}} completion.
2897 @cindex DONE, final TODO keyword
2898 Remember that the keywords after the vertical bar (or the last keyword
2899 if no bar is there) must always mean that the item is DONE (although you
2900 may use a different word).  After changing one of these lines, use
2901 @kbd{C-c C-c} with the cursor still in the line to make the changes
2902 known to Org-mode@footnote{Org-mode parses these lines only when
2903 Org-mode is activated after visiting a file.  @kbd{C-c C-c} with the
2904 cursor in a line starting with @samp{#+} is simply restarting Org-mode
2905 for the current buffer.}.
2907 @node Faces for TODO keywords,  , Per-file keywords, TODO extensions
2908 @subsection Faces for TODO keywords
2909 @cindex faces, for TODO keywords
2911 Org-mode highlights TODO keywords with special faces: @code{org-todo}
2912 for keywords indicating that an item still has to be acted upon, and
2913 @code{org-done} for keywords indicating that an item is finished.  If
2914 you are using more than 2 different states, you might want to use
2915 special faces for some of them.  This can be done using the variable
2916 @code{org-todo-keyword-faces}.  For example:
2918 @lisp
2919 (setq org-todo-keyword-faces
2920       '(("TODO"      . org-warning)
2921         ("DEFERRED"  . shadow)
2922         ("CANCELED"  . (:foreground "blue" :weight bold))))
2923 @end lisp
2925 While using a list with face properties as shown for CANCELED
2926 @emph{should} work, this does not aways seem to be the case.  If
2927 necessary, define a special face and use that.
2929 @page
2930 @node Progress logging, Priorities, TODO extensions, TODO items
2931 @section Progress Logging
2932 @cindex progress logging
2933 @cindex logging, of progress
2935 Org-mode can automatically record a time stamp and possibly a note when
2936 you mark a TODO item as DONE, or even each time you change the state of
2937 a TODO item.  This system is highly configurable, settings can be on a
2938 per-keyword basis and can be localized to a file or even a subtree.  For
2939 information on how to clock working time for a task, see @ref{Clocking
2940 work time}.
2942 @menu
2943 * Closing items::               When was this entry marked DONE?
2944 * Tracking TODO state changes::  When did the status change?
2945 @end menu
2947 @node Closing items, Tracking TODO state changes, Progress logging, Progress logging
2948 @subsection Closing items
2950 The most basic logging is to keep track of @emph{when} a certain TODO
2951 item was finished.  This is achieved with@footnote{The corresponding
2952 in-buffer setting is: @code{#+STARTUP: logdone}}.
2954 @lisp
2955 (setq org-log-done 'time)
2956 @end lisp
2958 @noindent
2959 Then each time you turn an entry from a TODO (not-done) state into any
2960 of the DONE states, a line @samp{CLOSED: [timestamp]} will be inserted
2961 just after the headline.  If you turn the entry back into a TODO item
2962 through further state cycling, that line will be removed again.  If you
2963 want to record a note along with the timestamp, use@footnote{The
2964 corresponding in-buffer setting is: @code{#+STARTUP: lognotedone}}
2966 @lisp
2967 (setq org-log-done 'note)
2968 @end lisp
2970 @noindent
2971 You will then be prompted for a note, and that note will be stored below
2972 the entry with a @samp{Closing Note} heading.
2974 In the timeline (@pxref{Timeline}) and in the agenda
2975 (@pxref{Weekly/Daily agenda}), you can then use the @kbd{l} key to
2976 display the TODO items with a @samp{CLOSED} timestamp on each day,
2977 giving you an overview of what has been done.
2979 @node Tracking TODO state changes,  , Closing items, Progress logging
2980 @subsection Tracking TODO state changes
2982 When TODO keywords are used as workflow states (@pxref{Workflow
2983 states}), you might want to keep track of when a state change occurred
2984 and maybe take a note about this change.  Since it is normally too much
2985 to record a note for every state, Org-mode expects configuration on a
2986 per-keyword basis for this.  This is achieved by adding special markers
2987 @samp{!} (for a time stamp) and @samp{@@} (for a note) in parenthesis
2988 after each keyword.  For example, with the setting
2990 @lisp
2991 (setq org-todo-keywords
2992   '((sequence "TODO(t)" "WAIT(w@@/!)" "|" "DONE(d!)" "CANCELED(c@@)")))
2993 @end lisp
2995 @noindent
2996 you not only define global TODO keywords and fast access keys, but also
2997 request that a time is recorded when the entry is turned into
2998 DONE@footnote{It is possible that Org-mode will record two time stamps
2999 when you are using both @code{org-log-done} and state change logging.
3000 However, it will never prompt for two notes - if you have configured
3001 both, the state change recording note will take precedence and cancel
3002 the @samp{Closing Note}.}, and that a note is recorded when switching to
3003 WAIT or CANCELED.  The setting for WAIT is even more special: The
3004 @samp{!} after the slash means that in addition to the note taken when
3005 entering the state, a time stamp should be recorded when @i{leaving} the
3006 WAIT state.  This allows you to get a record when switching from WAIT
3007 back to TODO, without getting one when first turning an entry into a
3008 TODO.
3010 You can use the exact same syntax for setting logging preferences local
3011 to a buffer:
3012 @example
3013 #+SEQ_TODO: TODO(t) WAIT(w@@/!) | DONE(d!) CANCELED(c@@)
3014 @end example
3016 In order to define logging settings that are local to a subtree or a
3017 single item, define a LOGGING property in this entry.  Any non-empty
3018 LOGGING property resets all logging settings to nil.  You may then turn
3019 on logging for this specific tree using STARTUP keywords like
3020 @code{lognotedone} or @code{logrepeat}, as well as adding state specific
3021 settings like @code{TODO(!)}.  For example
3023 @example
3024 * TODO Log each state with only a time
3025   :PROPERTIES:
3026   :LOGGING: TODO(!) WAIT(!) DONE(!) CANCELED(!)
3027   :END:
3028 * TODO Only log when switching to WAIT, and when repeating
3029   :PROPERTIES:
3030   :LOGGING: WAIT(@@) logrepeat
3031   :END:
3032 * TODO No logging at all
3033   :PROPERTIES:
3034   :LOGGING: nil
3035   :END:
3036 @end example
3039 @node Priorities, Breaking down tasks, Progress logging, TODO items
3040 @section Priorities
3041 @cindex priorities
3043 If you use Org-mode extensively, you may end up enough TODO items that
3044 it starts to make sense to prioritize them.  Prioritizing can be done by
3045 placing a @emph{priority cookie} into the headline of a TODO item, like
3046 this
3048 @example
3049 *** TODO [#A] Write letter to Sam Fortune
3050 @end example
3052 @noindent
3053 By default, Org-mode supports three priorities: @samp{A}, @samp{B}, and
3054 @samp{C}.  @samp{A} is the highest priority.  An entry without a cookie
3055 is treated as priority @samp{B}.  Priorities make a difference only in
3056 the agenda (@pxref{Weekly/Daily agenda}); outside the agenda, they have
3057 no inherent meaning to Org-mode.
3059 Priorities can be attached to any outline tree entries; they do not need
3060 to be TODO items.
3062 @table @kbd
3063 @kindex @kbd{C-c ,}
3064 @item @kbd{C-c ,}
3065 Set the priority of the current headline.  The command prompts for a
3066 priority character @samp{A}, @samp{B} or @samp{C}.  When you press
3067 @key{SPC} instead, the priority cookie is removed from the headline.
3068 The priorities can also be changed ``remotely'' from the timeline and
3069 agenda buffer with the @kbd{,} command (@pxref{Agenda commands}).
3071 @kindex S-@key{up}
3072 @kindex S-@key{down}
3073 @item S-@key{up}
3074 @itemx S-@key{down}
3075 Increase/decrease priority of current headline@footnote{See also the
3076 option @code{org-priority-start-cycle-with-default'}.}.  Note that these
3077 keys are also used to modify time stamps (@pxref{Creating timestamps}).
3078 Furthermore, these keys are also used by CUA-mode (@pxref{Conflicts}).
3079 @end table
3081 You can change the range of allowed priorities by setting the variables
3082 @code{org-highest-priority}, @code{org-lowest-priority}, and
3083 @code{org-default-priority}.  For an individual buffer, you may set
3084 these values (highest, lowest, default) like this (please make sure that
3085 the highest priority is earlier in the alphabet than the lowest
3086 priority):
3088 @example
3089 #+PRIORITIES: A C B
3090 @end example
3092 @node Breaking down tasks, Checkboxes, Priorities, TODO items
3093 @section Breaking tasks down into subtasks
3094 @cindex tasks, breaking down
3096 It is often advisable to break down large tasks into smaller, manageable
3097 subtasks.  You can do this by creating an outline tree below a TODO
3098 item, with detailed subtasks on the tree@footnote{To keep subtasks out
3099 of the global TODO list, see the
3100 @code{org-agenda-todo-list-sublevels}.}.  Another possibility is the use
3101 of checkboxes to identify (a hierarchy of) a large number of subtasks
3102 (@pxref{Checkboxes}).
3105 @node Checkboxes,  , Breaking down tasks, TODO items
3106 @section Checkboxes
3107 @cindex checkboxes
3109 Every item in a plain list (@pxref{Plain lists}) can be made into a
3110 checkbox by starting it with the string @samp{[ ]}.  This feature is
3111 similar to TODO items (@pxref{TODO items}), but is more lightweight.
3112 Checkboxes are not included into the global TODO list, so they are often
3113 great to split a task into a number of simple steps.  Or you can use
3114 them in a shopping list.  To toggle a checkbox, use @kbd{C-c C-c}, or
3115 use the mouse (thanks to Piotr Zielinski's @file{org-mouse.el}).
3117 Here is an example of a checkbox list.
3119 @example
3120 * TODO Organize party [2/4]
3121   - [-] call people [1/3]
3122     - [ ] Peter
3123     - [X] Sarah
3124     - [ ] Sam
3125   - [X] order food
3126   - [ ] think about what music to play
3127   - [X] talk to the neighbors
3128 @end example
3130 Checkboxes work hierarchically, so if a checkbox item has children that
3131 are checkboxes, toggling one of the children checkboxes will make the
3132 parent checkbox reflect if none, some, or all of the children are
3133 checked.
3135 @cindex statistics, for checkboxes
3136 @cindex checkbox statistics
3137 The @samp{[2/4]} and @samp{[1/3]} in the first and second line are
3138 cookies indicating how many checkboxes present in this entry have been
3139 checked off, and the total number of checkboxes are present.  This can
3140 give you an idea on how many checkboxes remain, even without opening a
3141 folded entry.  The cookies can be placed into a headline or into (the
3142 first line of) a plain list item. Each cookie covers all checkboxes
3143 structurally below the headline/item on which the cookie appear.  You
3144 have to insert the cookie yourself by typing either @samp{[/]} or
3145 @samp{[%]}.  With @samp{[/]} you get an @samp{n out of m} result, as in
3146 the examples above.  With @samp{[%]} you get information about the
3147 percentage of checkboxes checked (in the above example, this would be
3148 @samp{[50%]} and @samp{[33%]}, respectively).
3150 @noindent The following commands work with checkboxes:
3152 @table @kbd
3153 @kindex C-c C-c
3154 @item C-c C-c
3155 Toggle checkbox at point.  With prefix argument, set it to @samp{[-]},
3156 which is considered to be an intermediate state.
3157 @kindex C-c C-x C-b
3158 @item C-c C-x C-b
3159 Toggle checkbox at point.
3160 @itemize @minus
3161 @item
3162 If there is an active region, toggle the first checkbox in the region
3163 and set all remaining boxes to the same status as the first.  If you
3164 want to toggle all boxes in the region independently, use a prefix
3165 argument.
3166 @item
3167 If the cursor is in a headline, toggle checkboxes in the region between
3168 this headline and the next (so @emph{not} the entire subtree).
3169 @item
3170 If there is no active region, just toggle the checkbox at point.
3171 @end itemize
3172 @kindex M-S-@key{RET}
3173 @item M-S-@key{RET}
3174 Insert a new item with a checkbox.
3175 This works only if the cursor is already in a plain list item
3176 (@pxref{Plain lists}).
3177 @kindex C-c #
3178 @item C-c #
3179 Update the checkbox statistics in the current outline entry.  When
3180 called with a @kbd{C-u} prefix, update the entire file.  Checkbox
3181 statistic cookies are updated automatically if you toggle checkboxes
3182 with @kbd{C-c C-c} and make new ones with @kbd{M-S-@key{RET}}.  If you
3183 delete boxes or add/change them by hand, use this command to get things
3184 back into synch.  Or simply toggle any checkbox twice with @kbd{C-c C-c}.
3185 @end table
3187 @node Tags, Properties and columns, TODO items, Top
3188 @chapter Tags
3189 @cindex tags
3190 @cindex headline tagging
3191 @cindex matching, tags
3192 @cindex sparse tree, tag based
3194 An excellent way to implement labels and contexts for cross-correlating
3195 information is to assign @i{tags} to headlines.  Org-mode has extensive
3196 support for tags.
3198 Every headline can contain a list of tags; they occur at the end of the
3199 headline.  Tags are normal words containing letters, numbers, @samp{_},
3200 and @samp{@@}.  Tags must be preceded and followed by a single colon,
3201 e.g., @samp{:WORK:}.  Several tags can be specified, as in
3202 @samp{:work:URGENT:}.
3204 @menu
3205 * Tag inheritance::             Tags use the tree structure of the outline
3206 * Setting tags::                How to assign tags to a headline
3207 * Tag searches::                Searching for combinations of tags
3208 @end menu
3210 @node Tag inheritance, Setting tags, Tags, Tags
3211 @section Tag inheritance
3212 @cindex tag inheritance
3213 @cindex inheritance, of tags
3214 @cindex sublevels, inclusion into tags match
3216 @i{Tags} make use of the hierarchical structure of outline trees.  If a
3217 heading has a certain tag, all subheadings will inherit the tag as
3218 well.  For example, in the list
3220 @example
3221 * Meeting with the French group      :work:
3222 ** Summary by Frank                  :boss:notes:
3223 *** TODO Prepare slides for him      :action:
3224 @end example
3226 @noindent
3227 the final heading will have the tags @samp{:work:}, @samp{:boss:},
3228 @samp{:notes:}, and @samp{:action:} even though the final heading is not
3229 explicitly marked with those tags.  When executing tag searches and
3230 Org-mode finds that a certain headline matches the search criterion, it
3231 will not check any sublevel headline, assuming that these also match and
3232 that the list of matches could become very long because of that.  If you
3233 do want the subevels be tested and listed as well, you may set the
3234 variable @code{org-tags-match-list-sublevels}.  To turn off tag
3235 inheritance entirely, use the variable @code{org-use-tag-inheritance}.
3237 @node Setting tags, Tag searches, Tag inheritance, Tags
3238 @section Setting tags
3239 @cindex setting tags
3240 @cindex tags, setting
3242 @kindex M-@key{TAB}
3243 Tags can simply be typed into the buffer at the end of a headline.
3244 After a colon, @kbd{M-@key{TAB}} offers completion on tags.  There is
3245 also a special command for inserting tags:
3247 @table @kbd
3248 @kindex C-c C-c
3249 @item C-c C-c
3250 @cindex completion, of tags
3251 Enter new tags for the current headline.  Org-mode will either offer
3252 completion or a special single-key interface for setting tags, see
3253 below.  After pressing @key{RET}, the tags will be inserted and aligned
3254 to @code{org-tags-column}.  When called with a @kbd{C-u} prefix, all
3255 tags in the current buffer will be aligned to that column, just to make
3256 things look nice.  TAGS are automatically realigned after promotion,
3257 demotion, and TODO state changes (@pxref{TODO basics}).
3258 @end table
3260 Org will support tag insertion based on a @emph{list of tags}.  By
3261 default this list is constructed dynamically, containing all tags
3262 currently used in the buffer.  You may also globally specify a hard list
3263 of tags with the variable @code{org-tag-alist}.  Finally you can set
3264 the default tags for a given file with lines like
3266 @example
3267 #+TAGS: @@work @@home @@tennisclub
3268 #+TAGS: laptop car pc sailboat
3269 @end example
3271 If you have globally defined your preferred set of tags using the
3272 variable @code{org-tag-alist}, but would like to use a dynamic tag list
3273 in a specific file, add an empty TAGS option line to that file:
3275 @example
3276 #+TAGS:
3277 @end example
3279 The default support method for entering tags is minibuffer completion.
3280 However, Org-mode also implements a much better method: @emph{fast tag
3281 selection}.  This method allows to select and deselect tags with a
3282 single key per tag.  To function efficiently, you should assign unique
3283 keys to most tags.  This can be done globally with
3285 @lisp
3286 (setq org-tag-alist '(("@@work" . ?w) ("@@home" . ?h) ("laptop" . ?l)))
3287 @end lisp
3289 @noindent or on a per-file basis with
3291 @example
3292 #+TAGS: @@work(w)  @@home(h)  @@tennisclub(t)  laptop(l)  pc(p)
3293 @end example
3295 @noindent
3296 You can also group together tags that are mutually exclusive.  With
3297 curly braces@footnote{In @code{org-mode-alist} use
3298 @code{'(:startgroup)} and @code{'(:endgroup)}, respectively.  Several
3299 groups are allowed.}
3301 @example
3302 #+TAGS: @{ @@work(w)  @@home(h)  @@tennisclub(t) @}  laptop(l)  pc(p)
3303 @end example
3305 @noindent you indicate that at most one of @samp{@@work}, @samp{@@home},
3306 and @samp{@@tennisclub} should be selected.
3308 @noindent Don't forget to press @kbd{C-c C-c} with the cursor in one of
3309 these lines to activate any changes.
3311 If at least one tag has a selection key, pressing @kbd{C-c C-c} will
3312 automatically present you with a special interface, listing inherited
3313 tags, the tags of the current headline, and a list of all valid tags
3314 with corresponding keys@footnote{Keys will automatically be assigned to
3315 tags which have no configured keys.}.  In this interface, you can use
3316 the following keys:
3318 @table @kbd
3319 @item a-z...
3320 Pressing keys assigned to tags will add or remove them from the list of
3321 tags in the current line.  Selecting a tag in a group of mutually
3322 exclusive tags will turn off any other tags from that group.
3323 @kindex @key{TAB}
3324 @item @key{TAB}
3325 Enter a tag in the minibuffer, even if the tag is not in the predefined
3326 list.  You will be able to complete on all tags present in the buffer.
3327 @kindex @key{SPC}
3328 @item @key{SPC}
3329 Clear all tags for this line.
3330 @kindex @key{RET}
3331 @item @key{RET}
3332 Accept the modified set.
3333 @item C-g
3334 Abort without installing changes.
3335 @item q
3336 If @kbd{q} is not assigned to a tag, it aborts like @kbd{C-g}.
3337 @item !
3338 Turn off groups of mutually exclusive tags.  Use this to (as an
3339 exception) assign several tags from such a group.
3340 @item C-c
3341 Toggle auto-exit after the next change (see below).
3342 If you are using expert mode, the first @kbd{C-c} will display the
3343 selection window.
3344 @end table
3346 @noindent
3347 This method lets you assign tags to a headline with very few keys.  With
3348 the above setup, you could clear the current tags and set @samp{@@home},
3349 @samp{laptop} and @samp{pc} tags with just the following keys: @kbd{C-c
3350 C-c @key{SPC} h l p @key{RET}}.  Switching from @samp{@@home} to
3351 @samp{@@work} would be done with @kbd{C-c C-c w @key{RET}} or
3352 alternatively with @kbd{C-c C-c C-c w}.  Adding the non-predefined tag
3353 @samp{Sarah} could be done with @kbd{C-c C-c @key{TAB} S a r a h
3354 @key{RET} @key{RET}}.
3356 If you find that most of the time, you need only a single keypress to
3357 modify your list of tags, set the variable
3358 @code{org-fast-tag-selection-single-key}.  Then you no longer have to
3359 press @key{RET} to exit fast tag selection - it will immediately exit
3360 after the first change.  If you then occasionally need more keys, press
3361 @kbd{C-c} to turn off auto-exit for the current tag selection process
3362 (in effect: start selection with @kbd{C-c C-c C-c} instead of @kbd{C-c
3363 C-c}).  If you set the variable to the value @code{expert}, the special
3364 window is not even shown for single-key tag selection, it comes up only
3365 when you press an extra @kbd{C-c}.
3367 @node Tag searches,  , Setting tags, Tags
3368 @section Tag searches
3369 @cindex tag searches
3370 @cindex searching for tags
3372 Once a system of tags has been set up, it can be used to collect related
3373 information into special lists.
3375 @table @kbd
3376 @kindex C-c \
3377 @kindex C-c / T
3378 @item C-c \
3379 @itemx C-c / T
3380 Create a sparse tree with all headlines matching a tags search.  With a
3381 @kbd{C-u} prefix argument, ignore headlines that are not a TODO line.
3382 @kindex C-c a m
3383 @item C-c a m
3384 Create a global list of tag matches from all agenda files.
3385 @xref{Matching tags and properties}.
3386 @kindex C-c a M
3387 @item C-c a M
3388 Create a global list of tag matches from all agenda files, but check
3389 only TODO items and force checking subitems (see variable
3390 @code{org-tags-match-list-sublevels}).
3391 @end table
3393 @cindex Boolean logic, for tag searches
3394 A @i{tags} search string can use Boolean operators @samp{&} for AND and
3395 @samp{|} for OR.  @samp{&} binds more strongly than @samp{|}.
3396 Parenthesis are currently not implemented.  A tag may also be preceded
3397 by @samp{-}, to select against it, and @samp{+} is syntactic sugar for
3398 positive selection.  The AND operator @samp{&} is optional when @samp{+}
3399 or @samp{-} is present.  Examples:
3401 @table @samp
3402 @item +work-boss
3403 Select headlines tagged @samp{:work:}, but discard those also tagged
3404 @samp{:boss:}.
3405 @item work|laptop
3406 Selects lines tagged @samp{:work:} or @samp{:laptop:}.
3407 @item work|laptop&night
3408 Like before, but require the @samp{:laptop:} lines to be tagged also
3409 @samp{:night:}.
3410 @end table
3412 @cindex TODO keyword matching, with tags search
3413 If you are using multi-state TODO keywords (@pxref{TODO extensions}), it
3414 can be useful to also match on the TODO keyword.  This can be done by
3415 adding a condition after a slash to a tags match.  The syntax is similar
3416 to the tag matches, but should be applied with consideration: For
3417 example, a positive selection on several TODO keywords can not
3418 meaningfully be combined with boolean AND.  However, @emph{negative
3419 selection} combined with AND can be meaningful.  To make sure that only
3420 lines are checked that actually have any TODO keyword, use @kbd{C-c a
3421 M}, or equivalently start the todo part after the slash with @samp{!}.
3422 Examples:
3424 @table @samp
3425 @item work/WAITING
3426 Select @samp{:work:}-tagged TODO lines with the specific TODO
3427 keyword @samp{WAITING}.
3428 @item work/!-WAITING-NEXT
3429 Select @samp{:work:}-tagged TODO lines that are neither @samp{WAITING}
3430 nor @samp{NEXT}
3431 @item work/+WAITING|+NEXT
3432 Select @samp{:work:}-tagged TODO lines that are either @samp{WAITING} or
3433 @samp{NEXT}.
3434 @end table
3436 @cindex regular expressions, with tags search
3437 Any element of the tag/todo match can be a regular expression - in this
3438 case it must be enclosed in curly braces.  For example,
3439 @samp{work+@{^boss.*@}} matches headlines that contain the tag
3440 @samp{:work:} and any tag @i{starting} with @samp{boss}.
3442 @cindex level, require for tags/property match
3443 @cindex category, require for tags/property match
3444 You can also require a headline to be of a certain level or category, by
3445 writing instead of any TAG an expression like @samp{LEVEL=3} or
3446 @samp{CATEGORY="work"}, respectively.  For example, a search
3447 @samp{+LEVEL=3+boss/-DONE} lists all level three headlines that have the
3448 tag @samp{boss} and are @emph{not} marked with the todo keyword DONE.
3450 @node Properties and columns, Dates and times, Tags, Top
3451 @chapter Properties and Columns
3452 @cindex properties
3454 Properties are a set of key-value pairs associated with an entry.  There
3455 are two main applications for properties in Org-mode.  First, properties
3456 are like tags, but with a value.  Second, you can use properties to
3457 implement (very basic) database capabilities in an Org-mode buffer.  For
3458 an example of the first application, imagine maintaining a file where
3459 you document bugs and plan releases of a piece of software.  Instead of
3460 using tags like @code{:release_1:}, @code{:release_2:}, one can use a
3461 property, say @code{:Release:}, that in different subtrees has different
3462 values, such as @code{1.0} or @code{2.0}.  For an example of the second
3463 application of properties, imagine keeping track of one's music CD's,
3464 where properties could be things such as the album artist, date of
3465 release, number of tracks, and so on.
3467 Properties can be conveniently edited and viewed in column view
3468 (@pxref{Column view}).
3470 Properties are like tags, but with a value.  For example, in a file
3471 where you document bugs and plan releases of a piece of software,
3472 instead of using tags like @code{:release_1:}, @code{:release_2:}, it
3473 can be more efficient to use a property @code{:Release:} with a value
3474 @code{1.0} or @code{2.0}.  Second, you can use properties to implement
3475 (very basic) database capabilities in an Org-mode buffer, for example to
3476 create a list of Music CD's you own.  You can edit and view properties
3477 conveniently in column view (@pxref{Column view}).
3479 @menu
3480 * Property syntax::             How properties are spelled out
3481 * Special properties::          Access to other Org-mode features
3482 * Property searches::           Matching property values
3483 * Property inheritance::        Passing values down the tree
3484 * Column view::                 Tabular viewing and editing
3485 * Property API::                Properties for Lisp programmers
3486 @end menu
3488 @node Property syntax, Special properties, Properties and columns, Properties and columns
3489 @section Property Syntax
3490 @cindex property syntax
3491 @cindex drawer, for properties
3493 Properties are key-value pairs.  They need to be inserted into a special
3494 drawer (@pxref{Drawers}) with the name @code{PROPERTIES}.  Each property
3495 is specified on a single line, with the key (surrounded by colons)
3496 first, and the value after it.  Here is an example:
3498 @example
3499 * CD collection
3500 ** Classic
3501 *** Goldberg Variations
3502     :PROPERTIES:
3503     :Title:     Goldberg Variations
3504     :Composer:  J.S. Bach
3505     :Artist:    Glen Gould 
3506     :Publisher: Deutsche Grammphon
3507     :NDisks:    1
3508     :END:       
3509 @end example
3511 You may define the allowed values for a particular property @samp{:Xyz:}
3512 by setting a property @samp{:Xyz_ALL:}.  This special property is
3513 @emph{inherited}, so if you set it in a level 1 entry, it will apply to
3514 the entire tree.  When allowed values are defined, setting the
3515 corresponding property becomes easier and is less prone to typing
3516 errors.  For the example with the CD collection, we can predefine
3517 publishers and the number of disks in a box like this:
3519 @example
3520 * CD collection
3521   :PROPERTIES:
3522   :NDisks_ALL:  1 2 3 4
3523   :Publisher_ALL: "Deutsche Grammophon" Phillips EMI
3524   :END:
3525 @end example
3527 If you want to set properties that can be inherited by any entry in a
3528 file, use a line like
3530 @example
3531 #+PROPERTY: NDisks_ALL 1 2 3 4
3532 @end example
3534 Property values set with the global variable
3535 @code{org-global-properties} can be inherited by all entries in all
3536 Org-mode files.
3538 @noindent
3539 The following commands help to work with properties:
3541 @table @kbd
3542 @kindex M-@key{TAB}
3543 @item M-@key{TAB}
3544 After an initial colon in a line, complete property keys.  All keys used
3545 in the current file will be offered as possible completions.
3546 @kindex C-c C-x p
3547 @item C-c C-x p
3548 Set a property.  This prompts for a property name and a value.  If
3549 necessary, the property drawer is created as well.
3550 @item M-x org-insert-property-drawer
3551 Insert a property drawer into the current entry.  The drawer will be
3552 inserted early in the entry, but after the lines with planning
3553 information like deadlines.
3554 @kindex C-c C-c
3555 @item C-c C-c
3556 With the cursor in a property drawer, this executes property commands.
3557 @item C-c C-c s
3558 Set a property in the current entry.  Both the property and the value
3559 can be inserted using completion.
3560 @kindex S-@key{right}
3561 @kindex S-@key{left}
3562 @item S-@key{left}/@key{right}
3563 Switch property at point to the next/previous allowed value.
3564 @item C-c C-c d
3565 Remove a property from the current entry.
3566 @item C-c C-c D
3567 Globally remove a property, from all entries in the current file.
3568 @item C-c C-c c
3569 Compute the property at point, using the operator and scope from the
3570 nearest column format definition.
3571 @end table
3573 @node Special properties, Property searches, Property syntax, Properties and columns
3574 @section Special Properties
3575 @cindex properties, special
3577 Special properties provide alternative access method to Org-mode
3578 features discussed in the previous chapters, like the TODO state or the
3579 priority of an entry.  This interface exists so that you can include
3580 these states into columns view (@pxref{Column view}), or to use them in
3581 queries.  The following property names are special and should not be
3582 used as keys in the properties drawer:
3584 @example
3585 TODO         @r{The TODO keyword of the entry.}
3586 TAGS         @r{The tags defined directly in the headline.}
3587 ALLTAGS      @r{All tags, including inherited ones.}
3588 PRIORITY     @r{The priority of the entry, a string with a single letter.}
3589 DEADLINE     @r{The deadline time string, without the angular brackets.}
3590 SCHEDULED    @r{The scheduling time stamp, without the angular brackets.}
3591 TIMESTAMP    @r{The first keyword-less time stamp in the entry.}
3592 TIMESTAMP_IA @r{The first inactive time stamp in the entry.}
3593 CLOCKSUM     @r{The sum of CLOCK intervals in the subtree.  @code{org-clock-sum}}
3594              @r{must be run first to compute the values.}
3595 @end example
3597 @node Property searches, Property inheritance, Special properties, Properties and columns
3598 @section Property searches
3599 @cindex properties, searching
3600 @cindex properties, inheritance
3601 @cindex searching, of properties
3602 @cindex inheritance, of properties
3604 To create sparse trees and special lists with selection based on
3605 properties, the same commands are used as for tag searches (@pxref{Tag
3606 searches}), and the same logic applies.  For example, a search string
3608 @example
3609 +work-boss+PRIORITY="A"+Coffee="unlimited"+Effort=""+With=@{Sarah\|Denny@}
3610 @end example
3612 @noindent
3613 finds entries tagged @samp{:work:} but not @samp{:boss:}, which
3614 also have a priority value @samp{A}, a @samp{:Coffee:} property with the
3615 value @samp{unlimited}, an @samp{Effort} property that is undefined or
3616 empty, and a @samp{:With:} property that is matched by
3617 the regular expression @samp{Sarah\|Denny}.
3619 You can configure Org-mode to use property inheritance during a search,
3620 see @ref{Property inheritance} for details.
3622 There is also a special command for creating sparse trees based on a
3623 single property:
3625 @table @kbd
3626 @kindex C-c / p
3627 @item C-c / p
3628 Create a sparse tree based on the value of a property.  This first
3629 prompts for the name of a property, and then for a value.  A sparse tree
3630 is created with all entries that define this property with the given
3631 value.  If you enclose the value into curly braces, it is interpreted as
3632 a regular expression and matched against the property values.
3633 @end table
3635 @node Property inheritance, Column view, Property searches, Properties and columns
3636 @section Property Inheritance
3638 The outline structure of Org-mode documents lends itself for an
3639 inheritance model of properties: If the parent in a tree has a certain
3640 property, the children can inherit this property.  Org-mode does not
3641 turn this on by default, because it can slow down property searches
3642 significantly and is often not needed.  However, if you find inheritance
3643 useful, you can turn it on by setting the variable
3644 @code{org-use-property-inheritance}.  It may be set to @code{t}, to make
3645 all properties inherited from the parent, or to a list of properties
3646 that should be inherited.
3648 Org-mode has a few properties for which inheritance is hard-coded, at
3649 least for the special applications for which they are used:
3651 @table @code
3652 @item COLUMNS
3653 The @code{:COLUMNS:} property defines the format of column view
3654 (@pxref{Column view}).  It is inherited in the sense that the level
3655 where a @code{:COLUMNS:} property is defined is used as the starting
3656 point for a column view table, independently of the location in the
3657 subtree from where columns view is turned on.
3658 @item CATEGORY
3659 For agenda view, a category set through a @code{:CATEGORY:} property
3660 applies to the entire subtree.
3661 @item ARCHIVE
3662 For archiving, the @code{:ARCHIVE:} property may define the archive
3663 location for the entire subtree (@pxref{Moving subtrees}).
3664 @item LOGGING
3665 The LOGGING property may define logging settings for an entry or a
3666 subtree (@pxref{Tracking TODO state changes}).
3667 @end table
3669 @node Column view, Property API, Property inheritance, Properties and columns
3670 @section Column View
3672 A great way to view and edit properties in an outline tree is
3673 @emph{column view}.  In column view, each outline item is turned into a
3674 table row.  Columns in this table provide access to properties of the
3675 entries.  Org-mode implements columns by overlaying a tabular structure
3676 over the headline of each item.  While the headlines have been turned
3677 into a table row, you can still change the visibility of the outline
3678 tree.  For example, you get a compact table by switching to CONTENTS
3679 view (@kbd{S-@key{TAB} S-@key{TAB}}, or simply @kbd{c} while column view
3680 is active), but you can still open, read, and edit the entry below each
3681 headline.  Or, you can switch to column view after executing a sparse
3682 tree command and in this way get a table only for the selected items.
3683 Column view also works in agenda buffers (@pxref{Agenda views}) where
3684 queries have collected selected items, possibly from a number of files.
3686 @menu
3687 * Defining columns::            The COLUMNS format property
3688 * Using column view::           How to create and use column view
3689 * Capturing Column View::       A dynamic block for column view
3690 @end menu
3692 @node Defining columns, Using column view, Column view, Column view
3693 @subsection Defining Columns
3694 @cindex column view, for properties
3695 @cindex properties, column view
3697 Setting up a column view first requires defining the columns.  This is
3698 done by defining a column format line.
3700 @menu
3701 * Scope of column definitions::  Where defined, where valid?
3702 * Column attributes::           Appearance and content of a column
3703 @end menu
3705 @node Scope of column definitions, Column attributes, Defining columns, Defining columns
3706 @subsubsection Scope of column definitions
3708 To define a column format for an entire file, use a line like
3710 @example
3711 #+COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
3712 @end example
3714 To specify a format that only applies to a specific tree, add a
3715 @code{:COLUMNS:} property to the top node of that tree, for example:
3717 @example
3718 ** Top node for columns view
3719    :PROPERTIES:
3720    :COLUMNS: %25ITEM %TAGS %PRIORITY %TODO
3721    :END:
3722 @end example
3724 If a @code{:COLUMNS:} property is present in an entry, it defines columns
3725 for the entry itself, and for the entire subtree below it.  Since the
3726 column definition is part of the hierarchical structure of the document,
3727 you can define columns on level 1 that are general enough for all
3728 sublevels, and more specific columns further down, when you edit a
3729 deeper part of the tree.
3731 @node Column attributes,  , Scope of column definitions, Defining columns
3732 @subsubsection Column attributes
3733 A column definition sets the attributes of a column.  The general
3734 definition looks like this:
3736 @example
3737  %[width]property[(title)][@{summary-type@}]
3738 @end example
3740 @noindent
3741 Except for the percent sign and the property name, all items are
3742 optional.  The individual parts have the following meaning:
3744 @example
3745 width           @r{An integer specifying the width of the column in characters.}
3746                 @r{If omitted, the width will be determined automatically.}
3747 property        @r{The property that should be edited in this column.}
3748 (title)         @r{The header text for the column. If omitted, the}
3749                 @r{property name is used.}
3750 @{summary-type@}  @r{The summary type.  If specified, the column values for}
3751                 @r{parent nodes are computed from the children.}
3752                 @r{Supported summary types are:}
3753                 @{+@}       @r{Sum numbers in this column.}
3754                 @{+;%.1f@}  @r{Like @samp{+}, but format result with @samp{%.1f}.}
3755                 @{$@}       @r{Currency, short for @samp{+;%.2f}.}
3756                 @{:@}       @r{Sum times, HH:MM:SS, plain numbers are hours.}
3757                 @{X@}       @r{Checkbox status, [X] if all children are [X].}
3758                 @{X/@}      @r{Checkbox status, [n/m].}
3759                 @{X%@}      @r{Checkbox status, [n%].}
3760 @end example
3762 @noindent
3763 Here is an example for a complete columns definition, along with allowed
3764 values.
3766 @example
3767 :COLUMNS:  %20ITEM %9Approved(Approved?)@{X@} %Owner %11Status \@footnote{Please note that the COLUMNS definition must be on a single line - it is wrapped here only because of formatting constraints.}
3768                    %10Time_Estimate@{:@} %CLOCKSUM
3769 :Owner_ALL:    Tammy Mark Karl Lisa Don
3770 :Status_ALL:   "In progress" "Not started yet" "Finished" ""
3771 :Approved_ALL: "[ ]" "[X]"
3772 @end example
3774 The first column, @samp{%25ITEM}, means the first 25 characters of the
3775 item itself, i.e. of the headline.  You probably always should start the
3776 column definition with the ITEM specifier.  The other specifiers create
3777 columns @samp{Owner} with a list of names as allowed values, for
3778 @samp{Status} with four different possible values, and for a checkbox
3779 field @samp{Approved}.  When no width is given after the @samp{%}
3780 character, the column will be exactly as wide as it needs to be in order
3781 to fully display all values.  The @samp{Approved} column does have a
3782 modified title (@samp{Approved?}, with a question mark).  Summaries will
3783 be created for the @samp{Time_Estimate} column by adding time duration
3784 expressions like HH:MM, and for the @samp{Approved} column, by providing
3785 an @samp{[X]} status if all children have been checked.  The
3786 @samp{CLOCKSUM} column is special, it lists the sum of CLOCK intervals
3787 in the subtree.
3789 @node Using column view, Capturing Column View, Defining columns, Column view
3790 @subsection Using Column View
3792 @table @kbd
3793 @tsubheading{Turning column view on and off}
3794 @kindex C-c C-x C-c
3795 @item C-c C-x C-c
3796 Create the column view for the local environment.  This command searches
3797 the hierarchy, up from point, for a @code{:COLUMNS:} property that defines
3798 a format.  When one is found, the column view table is established for
3799 the entire tree, starting from the entry that contains the @code{:COLUMNS:}
3800 property.  If none is found, the format is taken from the @code{#+COLUMNS}
3801 line or from the variable @code{org-columns-default-format}, and column
3802 view is established for the current entry and its subtree.
3803 @kindex r
3804 @item r
3805 Recreate the column view, to included hanges happening in the buffer.
3806 @kindex g
3807 @item g
3808 Same as @kbd{r}.
3809 @kindex q
3810 @item q
3811 Exit column view.
3812 @tsubheading{Editing values}
3813 @item @key{left} @key{right} @key{up} @key{down}
3814 Move through the column view from field to field.
3815 @kindex S-@key{left}
3816 @kindex S-@key{right}
3817 @item  S-@key{left}/@key{right}
3818 Switch to the next/previous allowed value of the field.  For this, you
3819 have to have specified allowed values for a property.
3820 @kindex n
3821 @kindex p
3822 @itemx  n / p
3823 Same as @kbd{S-@key{left}/@key{right}}
3824 @kindex e
3825 @item e
3826 Edit the property at point.  For the special properties, this will
3827 invoke the same interface that you normally use to change that
3828 property.  For example, when editing a TAGS property, the tag completion
3829 or fast selection interface will pop up.
3830 @kindex C-c C-c
3831 @item C-c C-c
3832 When there is a checkbox at point, toggle it.
3833 @kindex v
3834 @item v
3835 View the full value of this property.  This is useful if the width of
3836 the column is smaller than that of the value.
3837 @kindex a
3838 @item a
3839 Edit the list of allowed values for this property.  If the list is found
3840 in the hierarchy, the modified values is stored there.  If no list is
3841 found, the new value is stored in the first entry that is part of the
3842 current column view.
3843 @tsubheading{Modifying the table structure}
3844 @kindex <
3845 @kindex >
3846 @item < / >
3847 Make the column narrower/wider by one character.
3848 @kindex S-M-@key{right}
3849 @item S-M-@key{right}
3850 Insert a new column, to the right of the current column.
3851 @kindex S-M-@key{left}
3852 @item S-M-@key{left}
3853 Delete the current column.
3854 @end table
3856 @node Capturing Column View,  , Using column view, Column view
3857 @subsection Capturing Column View
3859 Since column view is just an overlay over a buffer, it cannot be
3860 exported or printed directly.  If you want to capture a column view, use
3861 the dynamic block (@pxref{Dynamic blocks}).  The frame of this block
3862 looks like this:
3864 @example
3865 * The column view
3866 #+BEGIN: columnview :hlines 1 :id "label"
3868 #+END:
3869 @end example
3871 @noindent This dynamic block has the following parameters:
3873 @table @code
3874 @item :id
3875 This is most important parameter.  Column view is a feature that is
3876 often localized to a certain (sub)tree, and the capture block might be
3877 in a different location in the file.  To identify the tree whose view to
3878 capture, you can use 3 values:
3879 @example
3880 local     @r{use the tree in which the capture block is located}
3881 global    @r{make a global view, including all headings in the file}
3882 "label"   @r{call column view in the tree that has and @code{:ID:}}
3883           @r{property with the value @i{label}}
3884 @end example
3885 @item :hlines
3886 When @code{t}, insert a hline after every line.  When a number N, insert
3887 a hline before each headline with level @code{<= N}.
3888 @item :vlines
3889 When set to @code{t}, enforce column groups to get vertical lines.
3890 @end table
3892 @noindent
3893 The following commands insert or update the dynamic block:
3895 @table @kbd
3896 @kindex C-c C-x r
3897 @item C-c C-x r
3898 Insert a dynamic block capturing a column view.  You will be prompted
3899 for the scope or id of the view.
3900 @kindex C-c C-c
3901 @item C-c C-c
3902 @kindex C-c C-x C-u
3903 @itemx C-c C-x C-u
3904 Update dynamical block at point.  The cursor needs to be in the
3905 @code{#+BEGIN} line of the dynamic block.
3906 @kindex C-u C-c C-x C-u
3907 @item C-u C-c C-x C-u
3908 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
3909 you have several clocktable blocks in a buffer.
3910 @end table
3912 @node Property API,  , Column view, Properties and columns
3913 @section The Property API
3914 @cindex properties, API
3915 @cindex API, for properties
3917 There is a full API for accessing and changing properties.  This API can
3918 be used by Emacs Lisp programs to work with properties and to implement
3919 features based on them.  For more information see @ref{Using the
3920 property API}.
3922 @node Dates and times, Remember, Properties and columns, Top
3923 @chapter Dates and Times
3924 @cindex dates
3925 @cindex times
3926 @cindex time stamps
3927 @cindex date stamps
3929 To assist project planning, TODO items can be labeled with a date and/or
3930 a time.  The specially formatted string carrying the date and time
3931 information is called a @emph{timestamp} in Org-mode.  This may be a
3932 little confusing because timestamp is often used as indicating when
3933 something was created or last changed.  However, in Org-mode this term
3934 is used in a much wider sense.
3936 @menu
3937 * Time stamps::                 Assigning a time to a tree entry
3938 * Creating timestamps::         Commands which insert timestamps
3939 * Deadlines and scheduling::    Planning your work
3940 * Clocking work time::          
3941 @end menu
3944 @node Time stamps, Creating timestamps, Dates and times, Dates and times
3945 @section Time stamps, deadlines and scheduling
3946 @cindex time stamps
3947 @cindex ranges, time
3948 @cindex date stamps
3949 @cindex deadlines
3950 @cindex scheduling
3952 A time stamp is a specification of a date (possibly with time or a range
3953 of times) in a special format, either @samp{<2003-09-16 Tue>} or
3954 @samp{<2003-09-16 Tue 09:39>} or @samp{<2003-09-16 Tue
3955 12:00-12:30>}@footnote{This is the standard ISO date/time format.  To
3956 use an alternative format, see @ref{Custom time format}.}.  A time stamp
3957 can appear anywhere in the headline or body of an org-tree entry.  Its
3958 presence causes entries to be shown on specific dates in the agenda
3959 (@pxref{Weekly/Daily agenda}).  We distinguish:
3961 @table @var
3962 @item Plain time stamp; Event; Appointment
3963 @cindex timestamp
3964 A simple time stamp just assigns a date/time to an item.  This is just
3965 like writing down an appointment or event in a paper agenda.  In the
3966 timeline and agenda displays, the headline of an entry associated with a
3967 plain time stamp will be shown exactly on that date.
3969 @example
3970 * Meet Peter at the movies <2006-11-01 Wed 19:15>
3971 * Discussion on climate change <2006-11-02 Thu 20:00-22:00>
3972 @end example
3974 @item Time stamp with repeater interval
3975 @cindex timestamp, with repeater interval
3976 A time stamp may contain a @emph{repeater interval}, indicating that it
3977 applies not only on the given date, but again and again after a certain
3978 interval of N days (d), weeks (w), months(m), or years(y).  The
3979 following will show up in the agenda every Wednesday:
3981 @example
3982 * Pick up Sam at school <2007-05-16 Wed 12:30 +1w>
3983 @end example
3985 @item Diary-style sexp entries
3986 For more complex date specifications, Org-mode supports using the
3987 special sexp diary entries implemented in the Emacs calendar/diary
3988 package.  For example
3990 @example
3991 * The nerd meeting on every 2nd Thursday of the month
3992   <%%(diary-float t 4 2)>
3993 @end example
3995 @item Time/Date range
3996 @cindex timerange
3997 @cindex date range
3998 Two time stamps connected by @samp{--} denote a range.  The headline
3999 will be shown on the first and last day of the range, and on any dates
4000 that are displayed and fall in the range.  Here is an example:
4002 @example
4003 ** Meeting in Amsterdam
4004    <2004-08-23 Mon>--<2004-08-26 Thu>
4005 @end example
4007 @item Inactive time stamp
4008 @cindex timestamp, inactive
4009 @cindex inactive timestamp
4010 Just like a plain time stamp, but with square brackets instead of
4011 angular ones.  These time stamps are inactive in the sense that they do
4012 @emph{not} trigger an entry to show up in the agenda.
4014 @example
4015 * Gillian comes late for the fifth time [2006-11-01 Wed]
4016 @end example
4018 @end table
4020 @node Creating timestamps, Deadlines and scheduling, Time stamps, Dates and times
4021 @section Creating timestamps
4022 @cindex creating timestamps
4023 @cindex timestamps, creating
4025 For Org-mode to recognize time stamps, they need to be in the specific
4026 format.  All commands listed below produce time stamps in the correct
4027 format.
4029 @table @kbd
4030 @kindex C-c .
4031 @item C-c .
4032 Prompt for a date and insert a corresponding time stamp.  When the
4033 cursor is at a previously used time stamp, it is updated to NOW.  When
4034 this command is used twice in succession, a time range is inserted.
4036 @kindex C-u C-c .
4037 @item C-u C-c .
4038 Like @kbd{C-c .}, but use the alternative format which contains date
4039 and time.  The default time can be rounded to multiples of 5 minutes,
4040 see the option @code{org-time-stamp-rounding-minutes}.
4042 @kindex C-c !
4043 @item C-c !
4044 Like @kbd{C-c .}, but insert an inactive time stamp that will not cause
4045 an agenda entry.
4047 @kindex C-c <
4048 @item C-c <
4049 Insert a time stamp corresponding to the cursor date in the Calendar.
4051 @kindex C-c >
4052 @item C-c >
4053 Access the Emacs calendar for the current date.  If there is a
4054 timestamp in the current line, goto the corresponding date
4055 instead.
4057 @kindex C-c C-o
4058 @item C-c C-o
4059 Access the agenda for the date given by the time stamp or -range at
4060 point (@pxref{Weekly/Daily agenda}).
4062 @kindex S-@key{left}
4063 @kindex S-@key{right}
4064 @item S-@key{left}
4065 @itemx S-@key{right}
4066 Change date at cursor by one day.  These key bindings conflict with
4067 CUA-mode (@pxref{Conflicts}).
4069 @kindex S-@key{up}
4070 @kindex S-@key{down}
4071 @item S-@key{up}
4072 @itemx S-@key{down}
4073 Change the item under the cursor in a timestamp.  The cursor can be on a
4074 year, month, day, hour or minute.  Note that if the cursor is in a
4075 headline and not at a time stamp, these same keys modify the priority of
4076 an item.  (@pxref{Priorities}). The key bindings also conflict with
4077 CUA-mode (@pxref{Conflicts}).
4079 @kindex C-c C-y
4080 @cindex evaluate time range
4081 @item C-c C-y
4082 Evaluate a time range by computing the difference between start and
4083 end.  With prefix arg, insert result after the time range (in a table:
4084 into the following column).
4085 @end table
4088 @menu
4089 * The date/time prompt::        How org-mode helps you entering date and time
4090 * Custom time format::          Making dates look differently
4091 @end menu
4093 @node The date/time prompt, Custom time format, Creating timestamps, Creating timestamps
4094 @subsection The date/time prompt
4095 @cindex date, reading in minibuffer
4096 @cindex time, reading in minibuffer
4098 When Org-mode prompts for a date/time, the default is shown as an ISO
4099 date, and the prompt therefore seems to ask for an ISO date.  But it
4100 will in fact accept any string containing some date and/or time
4101 information, and it is really smart about interpreting your input.  You
4102 can, for example, use @kbd{C-y} to paste a (possibly multi-line) string
4103 copied from an email message.  Org-mode will find whatever information
4104 is in there and derive anything you have not specified from the
4105 @emph{default date and time}.  The default is usually the current date
4106 and time, but when modifying an existing time stamp, or when entering
4107 the second stamp of a range, it is taken from the stamp in the buffer.
4108 When filling in information, Org-mode assumes that most of the time you
4109 will want to enter a date in the future: If you omit the month/year and
4110 the given day/month is @i{before} today, it will assume that you mean a
4111 future date@footnote{See the variable
4112 @code{org-read-date-prefer-future}.}.
4114 For example, lets assume that today is @b{June 13, 2006}.  Here is how
4115 various inputs will be interpreted, the items filled in by Org-mode are
4116 in @b{bold}.
4118 @example
4119 3-2-5         --> 2003-02-05
4120 14            --> @b{2006}-@b{06}-14
4121 12            --> @b{2006}-@b{07}-12
4122 Fri           --> nearest Friday (defaultdate or later)
4123 sep 15        --> @b{2006}-11-15
4124 feb 15        --> @b{2007}-02-15
4125 sep 12 9      --> 2009-09-12
4126 12:45         --> @b{2006}-@b{06}-@b{13} 12:45
4127 22 sept 0:34  --> @b{2006}-09-22 0:34
4128 @end example
4130 Furthermore you can specify a relative date by giving, as the
4131 @emph{first} thing in the input: a plus/minus sign, a number and a
4132 letter [dwmy] to indicate change in days weeks, months, years.  With a
4133 single plus or minus, the date is always relative to today.  With a
4134 double plus or minus, it is relative to the default date.  If instead of
4135 a single letter, you use the abbreviation of day name, the date will be
4136 the nth such day.  E.g.
4138 @example
4139 +4d           --> four days from today
4140 +4            --> same as above
4141 +2w           --> two weeks from today
4142 ++5           --> five days from default date
4143 +2tue         --> second tuesday from now.
4144 @end example
4146 The function understands English month and weekday abbreviations.  If
4147 you want to use unabbreviated names and/or other languages, configure
4148 the variables @code{parse-time-months} and @code{parse-time-weekdays}.
4150 @cindex calendar, for selecting date
4151 Parallel to the minibuffer prompt, a calendar is popped up@footnote{If
4152 you don't need/want the calendar, configure the variable
4153 @code{org-popup-calendar-for-date-prompt}.}.  When you exit the date
4154 prompt, either by clicking on a date in the calendar, or by pressing
4155 @key{RET}, the date selected in the calendar will be combined with the
4156 information entered at the prompt.  You can control the calendar fully
4157 from the minibuffer:
4159 @kindex <
4160 @kindex >
4161 @kindex mouse-1
4162 @kindex S-@key{right}
4163 @kindex S-@key{left}
4164 @kindex S-@key{down}
4165 @kindex S-@key{up}
4166 @kindex M-S-@key{right}
4167 @kindex M-S-@key{left}
4168 @kindex @key{RET}
4169 @example
4170 > / <          @r{Scroll calendar forward/backward by one month.}
4171 mouse-1        @r{Select date by clicking on it.}
4172 S-@key{right}/@key{left}     @r{One day forward/backward.}
4173 S-@key{down}/@key{up}     @r{One week forward/backward.}
4174 M-S-@key{right}/@key{left}   @r{One month forward/backward.}
4175 @key{RET}           @r{Choose date in calendar.}
4176 @end example
4178 The actions of the date/time prompt may seem complex, but I asure you
4179 they will grow on you.  To help you understand what is going on, the
4180 current interpretation of your input will be displayed live in the
4181 minibuffer@footnote{If you find this distracting, turn the display of
4182 with @code{org-read-date-display-live}.}.
4184 @node Custom time format,  , The date/time prompt, Creating timestamps
4185 @subsection Custom time format
4186 @cindex custom date/time format
4187 @cindex time format, custom
4188 @cindex date format, custom
4190 Org-mode uses the standard ISO notation for dates and times as it is
4191 defined in ISO 8601.  If you cannot get used to this and require another
4192 representation of date and time to keep you happy, you can get it by
4193 customizing the variables @code{org-display-custom-times} and
4194 @code{org-time-stamp-custom-formats}.
4196 @table @kbd
4197 @kindex C-c C-x C-t
4198 @item C-c C-x C-t
4199 Toggle the display of custom formats for dates and times.
4200 @end table
4202 @noindent
4203 Org-mode needs the default format for scanning, so the custom date/time
4204 format does not @emph{replace} the default format - instead it is put
4205 @emph{over} the default format using text properties.  This has the
4206 following consequences:
4207 @itemize @bullet
4208 @item 
4209 You cannot place the cursor onto a time stamp anymore, only before or
4210 after.
4211 @item
4212 The @kbd{S-@key{up}/@key{down}} keys can no longer be used to adjust
4213 each component of a time stamp.  If the cursor is at the beginning of
4214 the stamp, @kbd{S-@key{up}/@key{down}} will change the stamp by one day,
4215 just like @kbd{S-@key{left}/@key{right}}.  At the end of the stamp, the
4216 time will be changed by one minute.
4217 @item
4218 If the time stamp contains a range of clock times or a repeater, these
4219 will not be overlayed, but remain in the buffer as they were.
4220 @item
4221 When you delete a time stamp character-by-character, it will only
4222 disappear from the buffer after @emph{all} (invisible) characters
4223 belonging to the ISO timestamp have been removed.
4224 @item
4225 If the custom time stamp format is longer than the default and you are
4226 using dates in tables, table alignment will be messed up.  If the custom
4227 format is shorter, things do work as expected.
4228 @end itemize
4231 @node Deadlines and scheduling, Clocking work time, Creating timestamps, Dates and times
4232 @section Deadlines and Scheduling
4234 A time stamp may be preceded by special keywords to facilitate planning:
4236 @table @var
4237 @item DEADLINE
4238 @cindex DEADLINE keyword
4240 Meaning: the task (most likely a TODO item, though not necessarily) is supposed
4241 to be finished on that date.
4243 On the deadline date, the task will be listed in the agenda.  In
4244 addition, the agenda for @emph{today} will carry a warning about the
4245 approaching or missed deadline, starting
4246 @code{org-deadline-warning-days} before the due date, and continuing
4247 until the entry is marked DONE.  An example:
4249 @example
4250 *** TODO write article about the Earth for the Guide
4251     The editor in charge is [[bbdb:Ford Prefect]]
4252     DEADLINE: <2004-02-29 Sun>
4253 @end example
4255 You can specify a different lead time for warnings for a specific
4256 deadlines using the following syntax.  Here is an example with a warning
4257 period of 5 days @code{DEADLINE: <2004-02-29 Sun -5d>}.
4259 @item SCHEDULED
4260 @cindex SCHEDULED keyword
4262 Meaning: you are planning to start working on that task on the given
4263 date.
4265 The headline will be listed under the given date@footnote{It will still
4266 be listed on that date after it has been marked DONE.  If you don't like
4267 this, set the variable @code{org-agenda-skip-scheduled-if-done}.}.  In
4268 addition, a reminder that the scheduled date has passed will be present
4269 in the compilation for @emph{today}, until the entry is marked DONE.
4270 I.e., the task will automatically be forwarded until completed.
4272 @example
4273 *** TODO Call Trillian for a date on New Years Eve.
4274     SCHEDULED: <2004-12-25 Sat>
4275 @end example
4277 @noindent
4278 @b{Important:} Scheduling an item in Org-mode should @i{not} be
4279 understood in the same way that we understand @i{scheduling a meeting}.
4280 Setting a date for a meeting is just a simple appointment, you should
4281 mark this entry with a simple plain time stamp, to get this item shown
4282 on the date where it applies.  This is a frequent mis-understanding from
4283 Org-users.  In Org-mode, @i{scheduling} means setting a date when you
4284 want to start working on an action item.
4285 @end table
4287 You may use time stamps with repeaters in scheduling and deadline
4288 entries.  Org-mode will issue early and late warnings based on the
4289 assumption that the time stamp represents the @i{nearest instance} of
4290 the repeater.  However, the use of diary sexp entries like
4292 @code{<%%(diary-float t 42)>}
4294 in scheduling and deadline timestamps is limited.  Org-mode does not
4295 know enough about the internals of each sexp function to issue early and
4296 late warnings.  However, it will show the item on each day where the
4297 sexp entry matches.
4299 @menu
4300 * Inserting deadline/schedule::  Planning items
4301 * Repeated tasks::              Items that show up again and again
4302 @end menu
4304 @node Inserting deadline/schedule, Repeated tasks, Deadlines and scheduling, Deadlines and scheduling
4305 @subsection Inserting deadline/schedule
4307 The following commands allow to quickly insert a deadline or to schedule
4308 an item:
4310 @table @kbd
4312 @kindex C-c C-d
4313 @item C-c C-d
4314 Insert @samp{DEADLINE} keyword along with a stamp.  The insertion will
4315 happen in the line directly following the headline.  When called with a
4316 prefix arg, an existing deadline will be removed from the entry.
4317 @c FIXME Any CLOSED timestamp will be removed.????????
4319 @kindex C-c / d
4320 @cindex sparse tree, for deadlines
4321 @item C-c / d
4322 Create a sparse tree with all deadlines that are either past-due, or
4323 which will become due within @code{org-deadline-warning-days}.
4324 With @kbd{C-u} prefix, show all deadlines in the file.  With a numeric
4325 prefix, check that many days.  For example, @kbd{C-1 C-c / d} shows
4326 all deadlines due tomorrow.
4328 @kindex C-c C-s
4329 @item C-c C-s
4330 Insert @samp{SCHEDULED} keyword along with a stamp.  The insertion will
4331 happen in the line directly following the headline.  Any CLOSED
4332 timestamp will be removed.  When called with a prefix argument, remove
4333 the scheduling date from the entry.
4334 @end table
4336 @node Repeated tasks,  , Inserting deadline/schedule, Deadlines and scheduling
4337 @subsection Repeated Tasks
4339 Some tasks need to be repeated again and again.  Org-mode helps to
4340 organize such tasks using a so-called repeater in a DEADLINE, SCHEDULED,
4341 or plain time stamp.  In the following example
4342 @example
4343 ** TODO Pay the rent
4344    DEADLINE: <2005-10-01 Sat +1m>
4345 @end example
4346 the @code{+1m} is a repeater; the intended interpretation is that the
4347 task has a deadline on <2005-10-01> and repeats itself every (one) month
4348 starting from that time.
4350 Deadlines and scheduled items produce entries in the agenda when they
4351 are over-due, so it is important to be able to mark such an entry as
4352 completed once you have done so.  When you mark a DEADLINE or a SCHEDULE
4353 with the todo keyword DONE, it will no longer produce entries in the
4354 agenda.  The problem with this is, however, that then also the
4355 @emph{next} instance of the repeated entry will not be active.  Org-mode
4356 deals with this in the following way: When you try to mark such an entry
4357 DONE (using @kbd{C-c C-t}), it will shift the base date of the repeating
4358 time stamp by the repeater interval, and immediately set the entry state
4359 back to TODO.  In the example above, setting the state to DONE would
4360 actually switch the date like this:
4362 @example
4363 ** TODO Pay the rent
4364    DEADLINE: <2005-11-01 Tue +1m>
4365 @end example
4367 You will also be prompted for a note@footnote{You can change this using
4368 the option @code{org-log-repeat}, or the @code{#+STARTUP} options
4369 @code{logrepeat}, @code{lognoterepeat}, and @code{nologrepeat}.} that
4370 will be put under the DEADLINE line to keep a record that you actually
4371 acted on the previous instance of this deadline.
4373 As a consequence of shifting the base date, this entry will no longer be
4374 visible in the agenda when checking past dates, but all future instances
4375 will be visible.
4377 You may have both scheduling and deadline information for a specific
4378 task - just make sure that the repeater intervals on both are the same.
4380 @node Clocking work time,  , Deadlines and scheduling, Dates and times
4381 @section Clocking work time
4383 Org-mode allows you to clock the time you spent on specific tasks in a
4384 project.  When you start working on an item, you can start the clock.
4385 When you stop working on that task, or when you mark the task done, the
4386 clock is stopped and the corresponding time interval is recorded.  It
4387 also computes the total time spent on each subtree of a project.
4389 @table @kbd
4390 @kindex C-c C-x C-i
4391 @item C-c C-x C-i
4392 Start the clock on the current item (clock-in).  This inserts the CLOCK
4393 keyword together with a timestamp.  If this is not the first clocking of
4394 this item, the multiple CLOCK lines will be wrapped into a
4395 @code{:CLOCK:} drawer (see also the variable
4396 @code{org-clock-into-drawer}).
4397 @kindex C-c C-x C-o
4398 @item C-c C-x C-o
4399 Stop the clock (clock-out).  The inserts another timestamp at the same
4400 location where the clock was last started.  It also directly computes
4401 the resulting time in inserts it after the time range as @samp{=>
4402 HH:MM}.  See the variable @code{org-log-note-clock-out} for the
4403 possibility to record an additional note together with the clock-out
4404 time stamp@footnote{The corresponding in-buffer setting is:
4405 @code{#+STARTUP: lognoteclock-out}}.
4406 @kindex C-c C-y
4407 @item C-c C-y
4408 Recompute the time interval after changing one of the time stamps.  This
4409 is only necessary if you edit the time stamps directly.  If you change
4410 them with @kbd{S-@key{cursor}} keys, the update is automatic.
4411 @kindex C-c C-t
4412 @item C-c C-t
4413 Changing the TODO state of an item to DONE automatically stops the clock
4414 if it is running in this same item.
4415 @kindex C-c C-x C-x
4416 @item C-c C-x C-x
4417 Cancel the current clock.  This is useful if a clock was started by
4418 mistake, or if you ended up working on something else.
4419 @kindex C-c C-x C-j
4420 @item C-c C-x C-j
4421 Jump to the entry that contains the currently running clock, an another
4422 window.
4423 @kindex C-c C-x C-d
4424 @item C-c C-x C-d
4425 Display time summaries for each subtree in the current buffer.  This
4426 puts overlays at the end of each headline, showing the total time
4427 recorded under that heading, including the time of any subheadings. You
4428 can use visibility cycling to study the tree, but the overlays disappear
4429 when you change the buffer (see variable
4430 @code{org-remove-highlights-with-change}) or press @kbd{C-c C-c}.
4431 @kindex C-c C-x C-r
4432 @item C-c C-x C-r
4433 Insert a dynamic block (@pxref{Dynamic blocks}) containing a clock
4434 report as an org-mode table into the current file.  When the cursor is
4435 at an existing clock table, just update it.  When called with a prefix
4436 argument, jump to the first clock report in the current document and
4437 update it.
4438 @example
4439 #+BEGIN: clocktable :maxlevel 2 :emphasize nil :scope file
4441 #+END: clocktable
4442 @end example
4443 @noindent
4444 If such a block already exists at point, its content is replaced by the
4445 new table.  The @samp{BEGIN} line can specify options:
4446 @example
4447 :maxlevel    @r{Maximum level depth to which times are listed in the table.}
4448 :emphasize   @r{When @code{t}, emphasize level one and level two items}
4449 :scope       @r{The scope to consider.  This can be any of the following:}
4450              nil        @r{the current buffer or narrowed region}
4451              file       @r{the full current buffer}
4452              subtree    @r{the subtree where the clocktable is located}
4453              treeN      @r{the surrounding level N tree, for example @code{tree3}}
4454              tree       @r{the surrounding level 1 tree}
4455              agenda     @r{all agenda files}
4456              ("file"..) @r{scan these files}
4457 :block       @r{The time block to consider.  This block is specified relative}
4458              @r{to the current time and may be any of these keywords:}
4459              @r{@code{today}, @code{yesterday}, @code{thisweek}, @code{lastweek},}
4460              @r{@code{thismonth}, @code{lastmonth}, @code{thisyear}, or @code{lastyear}}.
4461 :tstart      @r{A time string specifying when to start considering times}
4462 :tend        @r{A time string specifying when to stop considering times}
4463 :step        @r{@code{week} or @code{day}, to split the table into chunks}
4464 @end example
4465 So to get a clock summary of the current level 1 tree, for the current
4466 day, you could write
4467 @example
4468 #+BEGIN: clocktable :maxlevel 2 :block today :scope tree1
4470 #+END: clocktable
4471 @end example
4472 and to use a specific time range you could write@footnote{Note that all
4473 parameters must be specified in a single line - the line is broken here
4474 only to fit it onto the manual.}
4475 @example
4476 #+BEGIN: clocktable :tstart "<2006-08-10 Thu 10:00>" 
4477                     :tend "<2006-08-10 Thu 12:00>"
4479 #+END: clocktable
4480 @end example
4481 @kindex C-c C-c
4482 @item C-c C-c
4483 @kindex C-c C-x C-u
4484 @itemx C-c C-x C-u
4485 Update dynamical block at point.  The cursor needs to be in the
4486 @code{#+BEGIN} line of the dynamic block.
4487 @kindex C-u C-c C-x C-u
4488 @item C-u C-c C-x C-u
4489 Update all dynamic blocks (@pxref{Dynamic blocks}).  This is useful if
4490 you have several clocktable blocks in a buffer.
4491 @end table
4493 The @kbd{l} key may be used in the timeline (@pxref{Timeline}) and in
4494 the agenda (@pxref{Weekly/Daily agenda}) to show which tasks have been
4495 worked on or closed during a day.
4497 @node Remember, Agenda views, Dates and times, Top
4498 @chapter Remember
4499 @cindex @file{remember.el}
4501 The @i{Remember} package by John Wiegley lets you store quick notes with
4502 little interruption of your work flow.  See
4503 @uref{http://www.emacswiki.org/cgi-bin/wiki/RememberMode} for more
4504 information.  It is an excellent way to add new notes and tasks to
4505 Org-mode files.  Org-mode significantly expands the possibilities of
4506 @i{remember}: You may define templates for different note types, and
4507 associate target files and headlines with specific templates.  It also
4508 allows you to select the location where a note should be stored
4509 interactively, on the fly.
4511 @menu
4512 * Setting up remember::         Some code for .emacs to get things going
4513 * Remember templates::          Define the outline of different note types
4514 * Storing notes::               Directly get the note to where it belongs
4515 * Refiling notes::              Moving a note or task to a project
4516 @end menu
4518 @node Setting up remember, Remember templates, Remember, Remember
4519 @section Setting up remember
4521 The following customization will tell @i{remember} to use org files as
4522 target, and to create annotations compatible with Org-mode links.
4524 @example
4525 (org-remember-insinuate)
4526 (setq org-directory "~/path/to/my/orgfiles/")
4527 (setq org-default-notes-file (concat org-directory "/notes.org"))
4528 (define-key global-map "\C-cr" 'org-remember)
4529 @end example
4531 The last line binds the command @code{org-remember} to a global
4532 key@footnote{Please select your own key, @kbd{C-c r} is only a
4533 suggestion.}.  @code{org-remember} basically just calls @code{remember},
4534 but it makes a few things easier: If there is an active region, it will
4535 automatically copy the region into the remember buffer.  It also allows
4536 to jump to the buffer and location where remember notes are being
4537 stored: Just call @code{org-remember} with a prefix argument.  If you
4538 use two prefix arguments, Org-mode jumps to the location where the last
4539 remember note was stored.
4541 @node Remember templates, Storing notes, Setting up remember, Remember
4542 @section Remember templates
4543 @cindex templates, for remember
4545 In combination with Org-mode, you can use templates to generate
4546 different types of @i{remember} notes.  For example, if you would like
4547 to use one template to create general TODO entries, another one for
4548 journal entries, and a third one for collecting random ideas, you could
4549 use:
4551 @example
4552 (setq org-remember-templates
4553  '(("Todo" ?t "* TODO %?\n  %i\n  %a" "~/org/TODO.org" "Tasks")
4554    ("Journal" ?j "* %U %?\n\n  %i\n  %a" "~/org/JOURNAL.org")
4555    ("Idea" ?i "* %^@{Title@}\n  %i\n  %a" "~/org/JOURNAL.org" "New Ideas")))
4556 @end example
4558 @noindent In these entries, the first string is just a name, and the
4559 character specifies how to select the template.  It is useful if the
4560 character is also the first letter of the name.  The next string
4561 specifies the template.  Two more (optional) strings give the file in
4562 which, and the headline under which the new note should be stored.  The
4563 file (if not present or @code{nil}) defaults to
4564 @code{org-default-notes-file}, the heading to
4565 @code{org-remember-default-headline}.
4567 When you call @kbd{M-x remember} (or @kbd{M-x org-remember}) to remember
4568 something, org will prompt for a key to select the template (if you have
4569 more than one template) and then prepare the buffer like
4570 @example
4571 * TODO
4572   [[file:link to where you called remember]]
4573 @end example
4575 @noindent
4576 During expansion of the template, special @kbd{%}-escapes allow dynamic
4577 insertion of content:
4578 @example
4579 %^@{prompt@}  @r{prompt the user for a string and replace this sequence with it.}
4580             @r{You may specify a default value and a completion table with}
4581             @r{%^@{prompt|default|completion2|completion3...@}}
4582             @r{The arrow keys access a prompt-specific history.}
4583 %t          @r{time stamp, date only}
4584 %T          @r{time stamp with date and time}
4585 %u, %U      @r{like the above, but inactive time stamps}
4586 %^t         @r{like @code{%t}, but prompt for date.  Similarly @code{%^T}, @code{%^u}, @code{%^U}}
4587             @r{You may define a prompt like @code{%^@{Birthday@}t}}
4588 %n          @r{user name (taken from @code{user-full-name})}
4589 %a          @r{annotation, normally the link created with @code{org-store-link}}
4590 %A          @r{like @code{%a}, but prompt for the description part}
4591 %i          @r{initial content, the region when remember is called with C-u.}
4592             @r{The entire text will be indented like @code{%i} itself.}
4593 %c          @r{Content of the clipboard, or current kill ring head.}
4594 %^g         @r{prompt for tags, with completion on tags in target file.}
4595 %^G         @r{prompt for tags, with completion all tags in all agenda files.}
4596 %:keyword   @r{specific information for certain link types, see below}
4597 %[pathname] @r{insert the contents of the file given by @code{pathname}}
4598 %(sexp)     @r{evaluate elisp @code{(sexp)} and replace with the result}
4599 %!          @r{immediately store note after completing the template}
4600             @r{(skipping the @kbd{C-c C-c} that normally triggers storing)}
4601 @end example
4603 @noindent
4604 For specific link types, the following keywords will be
4605 defined@footnote{If you define your own link types (@pxref{Adding
4606 hyperlink types}), any property you store with
4607 @code{org-store-link-props} can be accessed in remember templates in a
4608 similar way.}:
4610 @example
4611 Link type          |  Available keywords
4612 -------------------+----------------------------------------------
4613 bbdb               |  %:name %:company
4614 bbdb               |  %::server %:port %:nick
4615 vm, wl, mh, rmail  |  %:type %:subject %:message-id
4616                    |  %:from %:fromname %:fromaddress
4617                    |  %:to   %:toname   %:toaddress
4618                    |  %: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}.}}       
4619 gnus               |  %:group, @r{for messages also all email fields}
4620 w3, w3m            |  %:url
4621 info               |  %:file %:node
4622 calendar           |  %:date"
4623 @end example
4625 @noindent
4626 To place the cursor after template expansion use:
4628 @example
4629 %?          @r{After completing the template, position cursor here.}
4630 @end example
4632 @noindent
4633 If you change your mind about which template to use, call
4634 @code{org-remember} in the remember buffer.  You may then select a new
4635 template that will be filled with the previous context information.
4637 @node Storing notes, Refiling notes, Remember templates, Remember
4638 @section Storing notes
4640 When you are finished preparing a note with @i{remember}, you have to
4641 press @kbd{C-c C-c} to file the note away.  The handler will store the
4642 note in the file and under the headline specified in the template, or it
4643 will use the default file and headlines.  The window configuration will
4644 be restored, sending you back to the working context before the call to
4645 @code{remember}.  To re-use the location found during the last call to
4646 @code{remember}, exit the remember buffer with @kbd{C-u C-u C-c C-c},
4647 i.e. specify a double prefix argument to @kbd{C-c C-c}.
4649 If you want to store the note directly to a different place, use
4650 @kbd{C-u C-c C-c} instead to exit remember@footnote{Configure the
4651 variable @code{org-remember-store-without-prompt} to make this behavior
4652 the default.}.  The handler will then first prompt for a target file -
4653 if you press @key{RET}, the value specified for the template is used.
4654 Then the command offers the headings tree of the selected file, with the
4655 cursor position at the default headline (if you had specified one in the
4656 template).  You can either immediately press @key{RET} to get the note
4657 placed there.  Or you can use the following keys to find a different
4658 location:
4659 @example
4660 @key{TAB}         @r{Cycle visibility.}
4661 @key{down} / @key{up}   @r{Next/previous visible headline.}
4662 n / p        @r{Next/previous visible headline.}
4663 f / b        @r{Next/previous headline same level.}
4664 u            @r{One level up.}
4665 @c 0-9          @r{Digit argument.}
4666 @end example
4667 @noindent
4668 Pressing @key{RET} or @key{left} or @key{right}
4669 then leads to the following result.
4671 @multitable @columnfractions 0.2 0.15 0.65
4672 @item @b{Cursor position} @tab @b{Key} @tab @b{Note gets inserted}
4673 @item on headline     @tab @key{RET}              @tab as sublevel of the heading at cursor, first or last
4674 @item                 @tab                        @tab depending on @code{org-reverse-note-order}.
4675 @item                 @tab @key{left}/@key{right} @tab as same level, before/after current heading
4676 @item buffer-start    @tab @key{RET} @tab as level 2 heading at end of file or level 1 at beginning
4677 @item                 @tab @tab depending on @code{org-reverse-note-order}.
4678 @item not on headline @tab @key{RET}
4679       @tab at cursor position, level taken from context.
4680 @end multitable
4682 Before inserting the text into a tree, the function ensures that the
4683 text has a headline, i.e. a first line that starts with a @samp{*}.  If
4684 not, a headline is constructed from the current date and some additional
4685 data.  If you have indented the text of the note below the headline, the
4686 indentation will be adapted if inserting the note into the tree requires
4687 demotion from level 1.
4689 @node Refiling notes,  , Storing notes, Remember
4690 @section Refiling notes
4691 @cindex refiling notes
4693 Remember is usually used to quickly capture notes and tasks into one or
4694 a few capture lists.  When reviewing the captured data, you may want to
4695 refile some of the entries into a different list, for example into a
4696 project.  Cutting, finding the right location and then pasting the note
4697 is cumbersome.  To simplify this process, you can use the following
4698 special command:
4700 @table @kbd
4701 @kindex C-c C-w
4702 @item C-c C-w
4703 Refile the entry at point.  This command offers possible locations for
4704 refiling the entry and lets you select one with completion.  The item is
4705 filed below the target heading as a subitem.  Depending on
4706 @code{org-reverse-note-order}, it will be either the first of last
4707 subitem.@* By default, all level 1 headlines in the current buffer are
4708 considered to be targets, but you can have more complex definitions
4709 across a number of files.  See the variable @code{org-refile-targets}
4710 for details.
4711 @kindex C-u C-c C-w
4712 @item C-u C-c C-w
4713 Use the refile interface to jump to a heading.
4714 @kindex C-u C-u C-c C-w
4715 @item C- C-u C-c C-w
4716 Jump to the location where @code{org-refile} last moved a tree to.
4717 @end table
4719 @node Agenda views, Embedded LaTeX, Remember, Top
4720 @chapter Agenda Views
4721 @cindex agenda views
4723 Due to the way Org-mode works, TODO items, time-stamped items, and
4724 tagged headlines can be scattered throughout a file or even a number of
4725 files.  To get an overview of open action items, or of events that are
4726 important for a particular date, this information must be collected,
4727 sorted and displayed in an organized way.
4729 Org-mode can select items based on various criteria, and display them
4730 in a separate buffer.  Six different view types are provided:
4732 @itemize @bullet
4733 @item
4734 an @emph{agenda} that is like a calendar and shows information
4735 for specific dates,
4736 @item
4737 a @emph{TODO list} that covers all unfinished
4738 action items,
4739 @item
4740 a @emph{tags view}, showings headlines based on
4741 the tags associated with them,
4742 @item
4743 a @emph{timeline view} that shows all events in a single Org-mode file,
4744 in time-sorted view,
4745 @item
4746 a @emph{stuck projects view} showing projects that currently don't move
4747 along, and
4748 @item
4749 @emph{custom views} that are special tag/keyword searches and
4750 combinations of different views.
4751 @end itemize
4753 @noindent
4754 The extracted information is displayed in a special @emph{agenda
4755 buffer}.  This buffer is read-only, but provides commands to visit the
4756 corresponding locations in the original Org-mode files, and even to
4757 edit these files remotely.  
4759 Two variables control how the agenda buffer is displayed and whether the
4760 window configuration is restored when the agenda exits:
4761 @code{org-agenda-window-setup} and
4762 @code{org-agenda-restore-windows-after-quit}.
4764 @menu
4765 * Agenda files::                Files being searched for agenda information
4766 * Agenda dispatcher::           Keyboard access to agenda views
4767 * Built-in agenda views::       What is available out of the box?
4768 * Presentation and sorting::    How agenda items are prepared for display
4769 * Agenda commands::             Remote editing of org trees
4770 * Custom agenda views::         Defining special searches and views
4771 @end menu
4773 @node Agenda files, Agenda dispatcher, Agenda views, Agenda views
4774 @section Agenda files
4775 @cindex agenda files
4776 @cindex files for agenda
4778 The information to be shown is normally collected from all @emph{agenda
4779 files}, the files listed in the variable
4780 @code{org-agenda-files}@footnote{If the value of that variable is not a
4781 list, but a single file name, then the list of agenda files will be
4782 maintained in that external file.}. If a directory is part of this list,
4783 all files with the extension @file{.org} in this directory will be part
4784 of the list.
4786 Thus even if you only work with a single Org-mode file, this file should
4787 be put into that list@footnote{When using the dispatcher, pressing
4788 @kbd{<} before selecting a command will actually limit the command to
4789 the current file, and ignore @code{org-agenda-files} until the next
4790 dispatcher command.}.  You can customize @code{org-agenda-files}, but
4791 the easiest way to maintain it is through the following commands
4793 @cindex files, adding to agenda list
4794 @table @kbd
4795 @kindex C-c [
4796 @item C-c [
4797 Add current file to the list of agenda files.  The file is added to
4798 the front of the list.  If it was already in the list, it is moved to
4799 the front.  With prefix arg, file is added/moved to the end.
4800 @kindex C-c ]
4801 @item C-c ]
4802 Remove current file from the list of agenda files.
4803 @kindex C-,
4804 @kindex C-'
4805 @item C-,
4806 @itemx C-'
4807 Cycle through agenda file list, visiting one file after the other.
4808 @end table
4810 @noindent
4811 The Org menu contains the current list of files and can be used
4812 to visit any of them.
4814 If you would like to focus the agenda temporarily onto a file not in
4815 this list, or onto just one file in the list or even only a subtree in a
4816 file, this can be done in different ways.  For a single agenda command,
4817 you may press @kbd{<} once or several times in the dispatcher
4818 (@pxref{Agenda dispatcher}).  To restrict the agenda scope for an
4819 extended period, use the following commands:
4821 @table @kbd
4822 @kindex C-c C-x <
4823 @item C-c C-x <
4824 Permanently restrict the agenda to the current subtree.  When with a
4825 prefix argument, or with the cursor before the first headline in a file,
4826 the agenda scope is set to the entire file.  This restriction remains in
4827 effect until removed with @kbd{C-c C-x >}, or by typing either @kbd{<}
4828 or @kbd{>} in the agenda dispatcher.  If there is a window displaying an
4829 agenda view, the new restriction takes effect immediately.
4830 @kindex C-c C-x <
4831 @item C-c C-x <
4832 Remove the permanent restriction created by @kbd{C-c C-x <}.
4833 @end table
4835 @noindent
4836 When working with @file{Speedbar}, you can use the following commands in
4837 the speedbar frame:
4838 @table @kbd
4839 @kindex <
4840 @item < @r{in the speedbar frame}
4841 Permanently restrict the agenda to the item at the cursor in the
4842 speedbar frame, either an Org-mode file or a subtree in such a file.
4843 If there is a window displaying an agenda view, the new restriction takes
4844 effect immediately.
4845 @kindex <
4846 @item > @r{in the speedbar frame}
4847 Lift the restriction again.
4848 @end table
4850 @node Agenda dispatcher, Built-in agenda views, Agenda files, Agenda views
4851 @section The agenda dispatcher
4852 @cindex agenda dispatcher
4853 @cindex dispatching agenda commands
4854 The views are created through a dispatcher that should be bound to a
4855 global key, for example @kbd{C-c a} (@pxref{Installation}).  In the
4856 following we will assume that @kbd{C-c a} is indeed how the dispatcher
4857 is accessed and list keyboard access to commands accordingly.  After
4858 pressing @kbd{C-c a}, an additional letter is required to execute a
4859 command.  The dispatcher offers the following default commands:
4860 @table @kbd
4861 @item a
4862 Create the calendar-like agenda (@pxref{Weekly/Daily agenda}).
4863 @item t @r{/} T
4864 Create a list of all TODO items (@pxref{Global TODO list}).
4865 @item m @r{/} M
4866 Create a list of headlines matching a TAGS expression (@pxref{Matching
4867 tags and properties}).
4868 @item L
4869 Create the timeline view for the current buffer (@pxref{Timeline}).
4870 @item # @r{/} !
4871 Create a list of stuck projects (@pxref{Stuck projects}).
4872 @item /
4873 Search for a regular expression in all agenda files and additionally in
4874 the files listed in @code{org-agenda-multi-occur-extra-files}.  This
4875 uses the Emacs command @code{multi-occur}.  A prefix argument can be
4876 used to specify the number of context lines for each match, default is
4878 @item <
4879 Restrict an agenda command to the current buffer@footnote{For backward
4880 compatibility, you can also press @kbd{1} to restrict to the current
4881 buffer.}.  After pressing @kbd{<}, you still need to press the character
4882 selecting the command.
4883 @item < <
4884 If there is an active region, restrict the following agenda command to
4885 the region.  Otherwise, restrict it to the current subtree@footnote{For
4886 backward compatibility, you can also press @kbd{0} to restrict to the
4887 current buffer.}.  After pressing @kbd{< <}, you still need to press the
4888 character selecting the command.
4889 @end table
4891 You can also define custom commands that will be accessible through the
4892 dispatcher, just like the default commands.  This includes the
4893 possibility to create extended agenda buffers that contain several
4894 blocks together, for example the weekly agenda, the global TODO list and
4895 a number of special tags matches.  @xref{Custom agenda views}.
4897 @node Built-in agenda views, Presentation and sorting, Agenda dispatcher, Agenda views
4898 @section The built-in agenda views
4900 In this section we describe the built-in views.
4902 @menu
4903 * Weekly/Daily agenda::         The calendar page with current tasks
4904 * Global TODO list::            All unfinished action items
4905 * Matching tags and properties::  Structured information with fine-tuned search
4906 * Timeline::                    Time-sorted view for single file
4907 * Stuck projects::              Find projects you need to review
4908 @end menu
4910 @node Weekly/Daily agenda, Global TODO list, Built-in agenda views, Built-in agenda views
4911 @subsection The weekly/daily agenda
4912 @cindex agenda
4913 @cindex weekly agenda
4914 @cindex daily agenda
4916 The purpose of the weekly/daily @emph{agenda} is to act like a page of a
4917 paper agenda, showing all the tasks for the current week or day.
4919 @table @kbd
4920 @cindex org-agenda, command
4921 @kindex C-c a a
4922 @item C-c a a
4923 Compile an agenda for the current week from a list of org files.  The
4924 agenda shows the entries for each day.  With a numeric
4925 prefix@footnote{For backward compatibility, the universal prefix
4926 @kbd{C-u} causes all TODO entries to be listed before the agenda.  This
4927 feature is deprecated, use the dedicated TODO list, or a block agenda
4928 instead.}  (like @kbd{C-u 2 1 C-c a a}) you may set the number of days
4929 to be displayed (see also the variable @code{org-agenda-ndays})
4930 @end table
4932 Remote editing from the agenda buffer means, for example, that you can
4933 change the dates of deadlines and appointments from the agenda buffer.
4934 The commands available in the Agenda buffer are listed in @ref{Agenda
4935 commands}.
4937 @subsubheading Calendar/Diary integration
4938 @cindex calendar integration
4939 @cindex diary integration
4941 Emacs contains the calendar and diary by Edward M. Reingold.  The
4942 calendar displays a three-month calendar with holidays from different
4943 countries and cultures.  The diary allows you to keep track of
4944 anniversaries, lunar phases, sunrise/set, recurrent appointments
4945 (weekly, monthly) and more.  In this way, it is quite complementary to
4946 Org-mode.  It can be very useful to combine output from Org-mode with
4947 the diary.
4949 In order to include entries from the Emacs diary into Org-mode's
4950 agenda, you only need to customize the variable
4952 @lisp
4953 (setq org-agenda-include-diary t)
4954 @end lisp
4956 @noindent After that, everything will happen automatically.  All diary
4957 entries including holidays, anniversaries etc will be included in the
4958 agenda buffer created by Org-mode.  @key{SPC}, @key{TAB}, and
4959 @key{RET} can be used from the agenda buffer to jump to the diary
4960 file in order to edit existing diary entries.  The @kbd{i} command to
4961 insert new entries for the current date works in the agenda buffer, as
4962 well as the commands @kbd{S}, @kbd{M}, and @kbd{C} to display
4963 Sunrise/Sunset times, show lunar phases and to convert to other
4964 calendars, respectively.  @kbd{c} can be used to switch back and forth
4965 between calendar and agenda.
4967 If you are using the diary only for sexp entries and holidays, it is
4968 faster to not use the above setting, but instead to copy or even move
4969 the entries into an Org-mode file. Org-mode evaluates diary-style sexp
4970 entries, and does it faster because there is no overhead for first
4971 creating the diary display.  Note that the sexp entries must start at
4972 the left margin, no white space is allowed before them.  For example,
4973 the following segment of an Org-mode file will be processed and entries
4974 will be made in the agenda:
4976 @example
4977 * Birthdays and similar stuff
4978 #+CATEGORY: Holiday
4979 %%(org-calendar-holiday)   ; special function for holiday names
4980 #+CATEGORY: Ann
4981 %%(diary-anniversary 14  5 1956) Arthur Dent is %d years old
4982 %%(diary-anniversary  2 10 1869) Mahatma Gandhi would be %d years old
4983 @end example
4985 @subsubheading Appointment reminders
4986 @cindex @file{appt.el}
4987 @cindex appointment reminders
4989 Org can interact with Emacs appointments notification facility.
4991 To add all the appointments of your agenda files, use the command
4992 @code{org-agenda-to-appt}.  This commands also lets you filter through
4993 the list of your appointments and add only those belonging to a specific
4994 category or matching a regular expression. See the docstring for
4995 details.
4997 @node Global TODO list, Matching tags and properties, Weekly/Daily agenda, Built-in agenda views
4998 @subsection The global TODO list
4999 @cindex global TODO list
5000 @cindex TODO list, global
5002 The global TODO list contains all unfinished TODO items, formatted and
5003 collected into a single place.
5005 @table @kbd
5006 @kindex C-c a t
5007 @item C-c a t
5008 Show the global TODO list.  This collects the TODO items from all
5009 agenda files (@pxref{Agenda views}) into a single buffer.  The buffer is in
5010 @code{agenda-mode}, so there are commands to examine and manipulate
5011 the TODO entries directly from that buffer (@pxref{Agenda commands}).
5012 @kindex C-c a T
5013 @item C-c a T
5014 @cindex TODO keyword matching
5015 Like the above, but allows selection of a specific TODO keyword.  You
5016 can also do this by specifying a prefix argument to @kbd{C-c a t}.  With
5017 a @kbd{C-u} prefix you are prompted for a keyword, and you may also
5018 specify several keywords by separating them with @samp{|} as boolean OR
5019 operator.  With a numeric prefix, the Nth keyword in
5020 @code{org-todo-keywords} is selected.
5021 @kindex r
5022 The @kbd{r} key in the agenda buffer regenerates it, and you can give
5023 a prefix argument to this command to change the selected TODO keyword,
5024 for example @kbd{3 r}.  If you often need a search for a specific
5025 keyword, define a custom command for it (@pxref{Agenda dispatcher}).@*
5026 Matching specific TODO keywords can also be done as part of a tags
5027 search (@pxref{Tag searches}).
5028 @end table
5030 Remote editing of TODO items means that you can change the state of a
5031 TODO entry with a single key press.  The commands available in the
5032 TODO list are described in @ref{Agenda commands}.
5034 @cindex sublevels, inclusion into todo list
5035 Normally the global todo list simply shows all headlines with TODO
5036 keywords.  This list can become very long.  There are two ways to keep
5037 it more compact:
5038 @itemize @minus
5039 @item
5040 Some people view a TODO item that has been @emph{scheduled} for
5041 execution (@pxref{Time stamps}) as no longer @emph{open}.  Configure the
5042 variable @code{org-agenda-todo-ignore-scheduled} to exclude scheduled
5043 items from the global TODO list.
5044 @item
5045 TODO items may have sublevels to break up the task into subtasks.  In
5046 such cases it may be enough to list only the highest level TODO headline
5047 and omit the sublevels from the global list.  Configure the variable
5048 @code{org-agenda-todo-list-sublevels} to get this behavior.
5049 @end itemize
5051 @node Matching tags and properties, Timeline, Global TODO list, Built-in agenda views
5052 @subsection Matching Tags and Properties
5053 @cindex matching, of tags
5054 @cindex matching, of properties
5055 @cindex tags view
5057 If headlines in the agenda files are marked with @emph{tags}
5058 (@pxref{Tags}), you can select headlines based on the tags that apply
5059 to them and collect them into an agenda buffer.
5061 @table @kbd
5062 @kindex C-c a m
5063 @item C-c a m
5064 Produce a list of all headlines that match a given set of tags.  The
5065 command prompts for a selection criterion, which is a boolean logic
5066 expression with tags, like @samp{+work+urgent-withboss} or
5067 @samp{work|home} (@pxref{Tags}).  If you often need a specific search,
5068 define a custom command for it (@pxref{Agenda dispatcher}).
5069 @kindex C-c a M
5070 @item C-c a M
5071 Like @kbd{C-c a m}, but only select headlines that are also TODO items
5072 and force checking subitems (see variable
5073 @code{org-tags-match-list-sublevels}).  Matching specific todo keywords
5074 together with a tags match is also possible, see @ref{Tag searches}.
5075 @end table
5077 The commands available in the tags list are described in @ref{Agenda
5078 commands}.
5080 @node Timeline, Stuck projects, Matching tags and properties, Built-in agenda views
5081 @subsection Timeline for a single file
5082 @cindex timeline, single file
5083 @cindex time-sorted view
5085 The timeline summarizes all time-stamped items from a single Org-mode
5086 file in a @emph{time-sorted view}.  The main purpose of this command is
5087 to give an overview over events in a project.
5089 @table @kbd
5090 @kindex C-c a L
5091 @item C-c a L
5092 Show a time-sorted view of the org file, with all time-stamped items.
5093 When called with a @kbd{C-u} prefix, all unfinished TODO entries
5094 (scheduled or not) are also listed under the current date.
5095 @end table
5097 @noindent
5098 The commands available in the timeline buffer are listed in
5099 @ref{Agenda commands}.
5102 @node Stuck projects,  , Timeline, Built-in agenda views
5103 @subsection Stuck projects
5105 If you are following a system like David Allen's GTD to organize your
5106 work, one of the ``duties'' you have is a regular review to make sure
5107 that all projects move along.  A @emph{stuck} project is a project that
5108 has no defined next actions, so it will never show up in the TODO lists
5109 Org-mode produces.  During the review, you need to identify such
5110 projects and define next actions for them.
5112 @table @kbd
5113 @kindex C-c a #
5114 @item C-c a #
5115 List projects that are stuck.
5116 @kindex C-c a !
5117 @item C-c a !
5118 Customize the variable @code{org-stuck-projects} to define what a stuck
5119 project is and how to find it.
5120 @end table
5122 You almost certainly will have to configure this view before it will
5123 work for you.  The built-in default assumes that all your projects are
5124 level-2 headlines, and that a project is not stuck if it has at least
5125 one entry marked with a todo keyword TODO or NEXT or NEXTACTION.
5127 Lets assume that you, in your own way of using Org-mode, identify
5128 projects with a tag PROJECT, and that you use a todo keyword MAYBE to
5129 indicate a project that should not be considered yet.  Lets further
5130 assume that the todo keyword DONE marks finished projects, and that NEXT
5131 and TODO indicate next actions.  The tag @@SHOP indicates shopping and
5132 is a next action even without the NEXT tag.  Finally, if the project
5133 contains the special word IGNORE anywhere, it should not be listed
5134 either.  In this case you would start by identifying eligible projects
5135 with a tags/todo match @samp{+PROJECT/-MAYBE-DONE}, and then check for
5136 TODO, NEXT, @@SHOP, and IGNORE in the subtree to identify projects that
5137 are not stuck.  The correct customization for this is
5139 @lisp
5140 (setq org-stuck-projects
5141       '("+PROJECT/-MAYBE-DONE" ("NEXT" "TODO") ("@@SHOP")
5142                                "\\<IGNORE\\>"))
5143 @end lisp
5146 @node Presentation and sorting, Agenda commands, Built-in agenda views, Agenda views
5147 @section Presentation and sorting
5148 @cindex presentation, of agenda items
5150 Before displaying items in an agenda view, Org-mode visually prepares
5151 the items and sorts them.  Each item occupies a single line.  The line
5152 starts with a @emph{prefix} that contains the @emph{category}
5153 (@pxref{Categories}) of the item and other important information.  You can
5154 customize the prefix using the option @code{org-agenda-prefix-format}.
5155 The prefix is followed by a cleaned-up version of the outline headline
5156 associated with the item.
5158 @menu
5159 * Categories::                  Not all tasks are equal
5160 * Time-of-day specifications::  How the agenda knows the time
5161 * Sorting of agenda items::     The order of things
5162 @end menu
5164 @node Categories, Time-of-day specifications, Presentation and sorting, Presentation and sorting
5165 @subsection Categories
5167 @cindex category
5168 The category is a broad label assigned to each agenda item.  By default,
5169 the category is simply derived from the file name, but you can also
5170 specify it with a special line in the buffer, like this@footnote{For
5171 backward compatibility, the following also works: If there are several
5172 such lines in a file, each specifies the category for the text below it.
5173 The first category also applies to any text before the first CATEGORY
5174 line.  However, using this method is @emph{strongly} deprecated as it is
5175 incompatible with the outline structure of the document.  The correct
5176 method for setting multiple categories in a buffer is using a
5177 property.}:
5179 @example
5180 #+CATEGORY: Thesis
5181 @end example
5183 @noindent
5184 If you would like to have a special CATEGORY for a single entry or a
5185 (sub)tree, give the entry a @code{:CATEGORY:} property with the location
5186 as the value (@pxref{Properties and columns}).
5188 @noindent
5189 The display in the agenda buffer looks best if the category is not
5190 longer than 10 characters.
5192 @node Time-of-day specifications, Sorting of agenda items, Categories, Presentation and sorting
5193 @subsection Time-of-Day Specifications
5194 @cindex time-of-day specification
5196 Org-mode checks each agenda item for a time-of-day specification.  The
5197 time can be part of the time stamp that triggered inclusion into the
5198 agenda, for example as in @w{@samp{<2005-05-10 Tue 19:00>}}.  Time
5199 ranges can be specified with two time stamps, like
5201 @w{@samp{<2005-05-10 Tue 20:30>--<2005-05-10 Tue 22:15>}}.
5203 In the headline of the entry itself, a time(range) may also appear as
5204 plain text (like @samp{12:45} or a @samp{8:30-1pm}.  If the agenda
5205 integrates the Emacs diary (@pxref{Weekly/Daily agenda}), time
5206 specifications in diary entries are recognized as well.
5208 For agenda display, Org-mode extracts the time and displays it in a
5209 standard 24 hour format as part of the prefix.  The example times in
5210 the previous paragraphs would end up in the agenda like this:
5212 @example
5213     8:30-13:00 Arthur Dent lies in front of the bulldozer
5214    12:45...... Ford Prefect arrives and takes Arthur to the pub
5215    19:00...... The Vogon reads his poem
5216    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
5217 @end example
5219 @cindex time grid
5220 If the agenda is in single-day mode, or for the display of today, the
5221 timed entries are embedded in a time grid, like
5223 @example
5224     8:00...... ------------------
5225     8:30-13:00 Arthur Dent lies in front of the bulldozer
5226    10:00...... ------------------
5227    12:00...... ------------------
5228    12:45...... Ford Prefect arrives and takes Arthur to the pub
5229    14:00...... ------------------
5230    16:00...... ------------------
5231    18:00...... ------------------
5232    19:00...... The Vogon reads his poem
5233    20:00...... ------------------
5234    20:30-22:15 Marwin escorts the Hitchhikers to the bridge
5235 @end example
5237 The time grid can be turned on and off with the variable
5238 @code{org-agenda-use-time-grid}, and can be configured with
5239 @code{org-agenda-time-grid}.
5241 @node Sorting of agenda items,  , Time-of-day specifications, Presentation and sorting
5242 @subsection Sorting of agenda items
5243 @cindex sorting, of agenda items
5244 @cindex priorities, of agenda items
5245 Before being inserted into a view, the items are sorted.  How this is
5246 done depends on the type of view.
5247 @itemize @bullet
5248 @item
5249 For the daily/weekly agenda, the items for each day are sorted.  The
5250 default order is to first collect all items containing an explicit
5251 time-of-day specification.  These entries will be shown at the beginning
5252 of the list, as a @emph{schedule} for the day.  After that, items remain
5253 grouped in categories, in the sequence given by @code{org-agenda-files}.
5254 Within each category, items are sorted by priority (@pxref{Priorities}),
5255 which is composed of the base priority (2000 for priority @samp{A}, 1000
5256 for @samp{B}, and 0 for @samp{C}), plus additional increments for
5257 overdue scheduled or deadline items.
5258 @item 
5259 For the TODO list, items remain in the order of categories, but within
5260 each category, sorting takes place according to priority
5261 (@pxref{Priorities}).
5262 @item
5263 For tags matches, items are not sorted at all, but just appear in the
5264 sequence in which they are found in the agenda files.
5265 @end itemize
5267 Sorting can be customized using the variable
5268 @code{org-agenda-sorting-strategy}.
5271 @node Agenda commands, Custom agenda views, Presentation and sorting, Agenda views
5272 @section Commands in the agenda buffer
5273 @cindex commands, in agenda buffer
5275 Entries in the agenda buffer are linked back to the org file or diary
5276 file where they originate.  You are not allowed to edit the agenda
5277 buffer itself, but commands are provided to show and jump to the
5278 original entry location, and to edit the org-files ``remotely'' from
5279 the agenda buffer.  In this way, all information is stored only once,
5280 removing the risk that your agenda and note files may diverge.
5282 Some commands can be executed with mouse clicks on agenda lines.  For
5283 the other commands, the cursor needs to be in the desired line.
5285 @table @kbd
5286 @tsubheading{Motion}
5287 @cindex motion commands in agenda
5288 @kindex n
5289 @item n
5290 Next line (same as @key{up} and @kbd{C-p}).
5291 @kindex p
5292 @item p
5293 Previous line (same as @key{down} and @kbd{C-n}).
5294 @tsubheading{View/GoTo org file}
5295 @kindex mouse-3
5296 @kindex @key{SPC}
5297 @item mouse-3
5298 @itemx @key{SPC}
5299 Display the original location of the item in another window.
5301 @kindex L
5302 @item L
5303 Display original location and recenter that window.
5305 @kindex mouse-2
5306 @kindex mouse-1
5307 @kindex @key{TAB}
5308 @item mouse-2
5309 @itemx mouse-1
5310 @itemx @key{TAB}
5311 Go to the original location of the item in another window.  Under Emacs
5312 22, @kbd{mouse-1} will also works for this.
5314 @kindex @key{RET}
5315 @itemx @key{RET}
5316 Go to the original location of the item and delete other windows.
5318 @kindex f
5319 @item f
5320 Toggle Follow mode.  In Follow mode, as you move the cursor through
5321 the agenda buffer, the other window always shows the corresponding
5322 location in the org file.  The initial setting for this mode in new
5323 agenda buffers can be set with the variable
5324 @code{org-agenda-start-with-follow-mode}.
5326 @kindex b
5327 @item b
5328 Display the entire subtree of the current item in an indirect buffer.
5329 With numerical prefix ARG, go up to this level and then take that tree.
5330 If ARG is negative, go up that many levels.  With @kbd{C-u} prefix, do
5331 not remove the previously used indirect buffer.
5333 @kindex l
5334 @item l
5335 Toggle Logbook mode.  In Logbook mode, entries that where marked DONE while
5336 logging was on (variable @code{org-log-done}) are shown in the agenda,
5337 as are entries that have been clocked on that day.
5339 @tsubheading{Change display}
5340 @cindex display changing, in agenda
5341 @kindex o
5342 @item o
5343 Delete other windows.
5345 @kindex d
5346 @kindex w
5347 @kindex m
5348 @kindex y
5349 @item d w m y
5350 Switch to day/week/month/year view.  When switching to day or week view,
5351 this setting becomes the default for subseqent agenda commands.  Since
5352 month and year views are slow to create, the do not become the default.
5354 @kindex D
5355 @item D
5356 Toggle the inclusion of diary entries.  See @ref{Weekly/Daily agenda}.
5358 @kindex G
5359 @item G
5360 Toggle the time grid on and off.  See also the variables
5361 @code{org-agenda-use-time-grid} and @code{org-agenda-time-grid}.
5363 @kindex r
5364 @item r
5365 Recreate the agenda buffer, for example to reflect the changes
5366 after modification of the time stamps of items with S-@key{left} and
5367 S-@key{right}.  When the buffer is the global todo list, a prefix
5368 argument is interpreted to create a selective list for a specific TODO
5369 keyword.
5370 @kindex g
5371 @item g
5372 Same as @kbd{r}.
5374 @kindex s
5375 @kindex C-x C-s
5376 @item s
5377 @itemx C-x C-s
5378 Save all Org-mode buffers in the current Emacs session.
5380 @kindex @key{right}
5381 @item @key{right}
5382 Display the following @code{org-agenda-ndays} days.  For example, if
5383 the display covers a week, switch to the following week.  With prefix
5384 arg, go forward that many times @code{org-agenda-ndays} days.
5386 @kindex @key{left}
5387 @item @key{left}
5388 Display the previous dates.
5390 @kindex .
5391 @item .
5392 Goto today.
5394 @tsubheading{Remote editing}
5395 @cindex remote editing, from agenda
5397 @item 0-9
5398 Digit argument.
5400 @cindex undoing remote-editing events
5401 @cindex remote editing, undo
5402 @kindex C-_
5403 @item C-_
5404 Undo a change due to a remote editing command.  The change is undone
5405 both in the agenda buffer and in the remote buffer.
5407 @kindex t
5408 @item t
5409 Change the TODO state of the item, both in the agenda and in the
5410 original org file.
5412 @kindex C-k
5413 @item C-k
5414 Delete the current agenda item along with the entire subtree belonging
5415 to it in the original Org-mode file.  If the text to be deleted remotely
5416 is longer than one line, the kill needs to be confirmed by the user.  See
5417 variable @code{org-agenda-confirm-kill}.
5419 @kindex $
5420 @item $
5421 Archive the subtree corresponding to the current headline.
5423 @kindex T
5424 @item T
5425 Show all tags associated with the current item.  Because of
5426 inheritance, this may be more than the tags listed in the line itself.
5428 @kindex :
5429 @item :
5430 Set tags for the current headline.  If there is an active region in the
5431 agenda, change a tag for all headings in the region.
5433 @kindex a
5434 @item a
5435 Toggle the ARCHIVE tag for the current headline.
5437 @kindex ,
5438 @item ,
5439 Set the priority for the current item.  Org-mode prompts for the
5440 priority character. If you reply with @key{SPC}, the priority cookie
5441 is removed from the entry.
5443 @kindex P
5444 @item P
5445 Display weighted priority of current item.
5447 @kindex +
5448 @kindex S-@key{up}
5449 @item +
5450 @itemx S-@key{up}
5451 Increase the priority of the current item.  The priority is changed in
5452 the original buffer, but the agenda is not resorted.  Use the @kbd{r}
5453 key for this.
5455 @kindex -
5456 @kindex S-@key{down}
5457 @item -
5458 @itemx S-@key{down}
5459 Decrease the priority of the current item.
5461 @kindex C-c C-s
5462 @item C-c C-s
5463 Schedule this item
5465 @kindex C-c C-d
5466 @item C-c C-d
5467 Set a deadline for this item.
5469 @kindex S-@key{right}
5470 @item S-@key{right}
5471 Change the time stamp associated with the current line by one day into
5472 the future.  With prefix argument, change it by that many days.  For
5473 example, @kbd{3 6 5 S-@key{right}} will change it by a year.  The
5474 stamp is changed in the original org file, but the change is not
5475 directly reflected in the agenda buffer.  Use the
5476 @kbd{r} key to update the buffer.
5478 @kindex S-@key{left}
5479 @item S-@key{left}
5480 Change the time stamp associated with the current line by one day
5481 into the past.
5483 @kindex >
5484 @item >
5485 Change the time stamp associated with the current line to today.
5486 The key @kbd{>} has been chosen, because it is the same as @kbd{S-.}
5487 on my keyboard.
5489 @kindex I
5490 @item I
5491 Start the clock on the current item.  If a clock is running already, it
5492 is stopped first.
5494 @kindex O
5495 @item O
5496 Stop the previously started clock.
5498 @kindex X
5499 @item X
5500 Cancel the currently running clock.
5502 @kindex J
5503 @item J
5504 Jump to the running clock in another window.
5506 @tsubheading{Calendar commands}
5507 @cindex calendar commands, from agenda
5508 @kindex c
5509 @item c
5510 Open the Emacs calendar and move to the date at the agenda cursor.
5512 @item c
5513 When in the calendar, compute and show the Org-mode agenda for the
5514 date at the cursor.
5516 @cindex diary entries, creating from agenda
5517 @kindex i
5518 @item i
5519 Insert a new entry into the diary.  Prompts for the type of entry
5520 (day, weekly, monthly, yearly, anniversary, cyclic) and creates a new
5521 entry in the diary, just as @kbd{i d} etc. would do in the calendar.
5522 The date is taken from the cursor position.
5524 @kindex M
5525 @item M
5526 Show the phases of the moon for the three months around current date.
5528 @kindex S
5529 @item S
5530 Show sunrise and sunset times.  The geographical location must be set
5531 with calendar variables, see documentation of the Emacs calendar.
5533 @kindex C
5534 @item C
5535 Convert the date at cursor into many other cultural and historic
5536 calendars.
5538 @kindex H
5539 @item H
5540 Show holidays for three month around the cursor date.
5542 @c FIXME:  This should be a different key.
5543 @kindex C-c C-x C-c
5544 @item C-c C-x C-c
5545 Export a single iCalendar file containing entries from all agenda files.
5547 @tsubheading{Exporting to a file}
5548 @kindex C-x C-w
5549 @item C-x C-w
5550 @cindex exporting agenda views
5551 @cindex agenda views, exporting
5552 Write the agenda view to a file.  Depending on the extension of the
5553 selected file name, the view will be exported as HTML (extension
5554 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}), or
5555 plain text (any other extension).  Use the variable
5556 @code{org-agenda-exporter-settings} to set options for @file{ps-print}
5557 and for @file{htmlize} to be used during export.
5559 @tsubheading{Quit and Exit}
5560 @kindex q
5561 @item q
5562 Quit agenda, remove the agenda buffer.
5564 @kindex x
5565 @cindex agenda files, removing buffers
5566 @item x
5567 Exit agenda, remove the agenda buffer and all buffers loaded by Emacs
5568 for the compilation of the agenda.  Buffers created by the user to
5569 visit org files will not be removed.
5570 @end table
5573 @node Custom agenda views,  , Agenda commands, Agenda views
5574 @section Custom agenda views
5575 @cindex custom agenda views
5576 @cindex agenda views, custom
5578 Custom agenda commands serve two purposes: to store and quickly access
5579 frequently used TODO and tags searches, and to create special composite
5580 agenda buffers.  Custom agenda commands will be accessible through the
5581 dispatcher (@pxref{Agenda dispatcher}), just like the default commands.
5583 @menu
5584 * Storing searches::            Type once, use often
5585 * Block agenda::                All the stuff you need in a single buffer
5586 * Setting Options::             Changing the rules
5587 * Exporting Agenda Views::      Writing agendas to files.
5588 * Extracting Agenda Information for other programs::  
5589 @end menu
5591 @node Storing searches, Block agenda, Custom agenda views, Custom agenda views
5592 @subsection Storing searches
5594 The first application of custom searches is the definition of keyboard
5595 shortcuts for frequently used searches, either creating an agenda
5596 buffer, or a sparse tree (the latter covering of course only the current
5597 buffer).
5598 @kindex C-c a C
5599 Custom commands are configured in the variable
5600 @code{org-agenda-custom-commands}.  You can customize this variable, for
5601 example by pressing @kbd{C-c a C}.  You can also directly set it with
5602 Emacs Lisp in @file{.emacs}.  The following example contains all valid
5603 search types:
5605 @lisp
5606 @group
5607 (setq org-agenda-custom-commands
5608       '(("w" todo "WAITING")
5609         ("W" todo-tree "WAITING")
5610         ("u" tags "+boss-urgent")
5611         ("v" tags-todo "+boss-urgent")
5612         ("U" tags-tree "+boss-urgent")
5613         ("f" occur-tree "\\<FIXME\\>")
5614         ("h" . "HOME+Name tags searches") ; description for "h" prefix
5615         ("hl" tags "+home+Lisa")
5616         ("hp" tags "+home+Peter")
5617         ("hk" tags "+home+Kim")))
5618 @end group
5619 @end lisp
5621 @noindent
5622 The initial string in each entry defines the keys you have to press
5623 after the dispatcher command @kbd{C-c a} in order to access the command.
5624 Usually this will be just a single character, but if you have many
5625 similar commands, you can also define two-letter combinations where the
5626 first character is the same in several combinations and serves as a
5627 prefix key@footnote{You can provide a description for a prefix key by
5628 inserting a cons cell with the prefix and the description.}.  The second
5629 parameter is the search type, followed by the string or regular
5630 expression to be used for the matching.  The example above will
5631 therefore define:
5633 @table @kbd
5634 @item C-c a w
5635 as a global search for TODO entries with @samp{WAITING} as the TODO
5636 keyword
5637 @item C-c a W
5638 as the same search, but only in the current buffer and displaying the
5639 results as a sparse tree
5640 @item C-c a u
5641 as a global tags search for headlines marked @samp{:boss:} but not
5642 @samp{:urgent:}
5643 @item C-c a v
5644 as the same search as @kbd{C-c a u}, but limiting the search to
5645 headlines that are also TODO items
5646 @item C-c a U
5647 as the same search as @kbd{C-c a u}, but only in the current buffer and
5648 displaying the result as a sparse tree
5649 @item C-c a f
5650 to create a sparse tree (again: current buffer only) with all entries
5651 containing the word @samp{FIXME}
5652 @item C-c a h
5653 as a prefix command for a HOME tags search where you have to press an
5654 additional key (@kbd{l}, @kbd{p} or @kbd{k}) to select a name (Lisa,
5655 Peter, or Kim) as additional tag to match.
5656 @end table
5658 @node Block agenda, Setting Options, Storing searches, Custom agenda views
5659 @subsection Block agenda
5660 @cindex block agenda
5661 @cindex agenda, with block views
5663 Another possibility is the construction of agenda views that comprise
5664 the results of @emph{several} commands, each of which creates a block in
5665 the agenda buffer.  The available commands include @code{agenda} for the
5666 daily or weekly agenda (as created with @kbd{C-c a a}), @code{alltodo}
5667 for the global todo list (as constructed with @kbd{C-c a t}), and the
5668 matching commands discussed above: @code{todo}, @code{tags}, and
5669 @code{tags-todo}.  Here are two examples:
5671 @lisp
5672 @group
5673 (setq org-agenda-custom-commands
5674       '(("h" "Agenda and Home-related tasks"
5675          ((agenda)
5676           (tags-todo "home")
5677           (tags "garden")))
5678         ("o" "Agenda and Office-related tasks"
5679          ((agenda)
5680           (tags-todo "work")
5681           (tags "office")))))
5682 @end group
5683 @end lisp
5685 @noindent
5686 This will define @kbd{C-c a h} to create a multi-block view for stuff
5687 you need to attend to at home.  The resulting agenda buffer will contain
5688 your agenda for the current week, all TODO items that carry the tag
5689 @samp{home}, and also all lines tagged with @samp{garden}.  Finally the
5690 command @kbd{C-c a o} provides a similar view for office tasks.
5693 @node Setting Options, Exporting Agenda Views, Block agenda, Custom agenda views
5694 @subsection Setting Options for custom commands
5695 @cindex options, for custom agenda views
5697 Org-mode contains a number of variables regulating agenda construction
5698 and display.  The global variables define the behavior for all agenda
5699 commands, including the custom commands.  However, if you want to change
5700 some settings just for a single custom view, you can do so.  Setting
5701 options requires inserting a list of variable names and values at the
5702 right spot in @code{org-agenda-custom-commands}.  For example:
5704 @lisp
5705 @group
5706 (setq org-agenda-custom-commands
5707       '(("w" todo "WAITING"
5708          ((org-agenda-sorting-strategy '(priority-down))
5709           (org-agenda-prefix-format "  Mixed: ")))
5710         ("U" tags-tree "+boss-urgent"
5711          ((org-show-following-heading nil)
5712           (org-show-hierarchy-above nil)))))
5713 @end group
5714 @end lisp
5716 @noindent
5717 Now the @kbd{C-c a w} command will sort the collected entries only by
5718 priority, and the prefix format is modified to just say @samp{  Mixed: }
5719 instead of giving the category of the entry.  The sparse tags tree of
5720 @kbd{C-c a U} will now turn out ultra-compact, because neither the
5721 headline hierarchy above the match, nor the headline following the match
5722 will be shown.
5724 For command sets creating a block agenda,
5725 @code{org-agenda-custom-commands} has two separate spots for setting
5726 options.  You can add options that should be valid for just a single
5727 command in the set, and options that should be valid for all commands in
5728 the set.  The former are just added to the command entry, the latter
5729 must come after the list of command entries.  Going back to the block
5730 agenda example (@pxref{Block agenda}), let's change the sorting strategy
5731 for the @kbd{C-c a h} commands to @code{priority-down}, but let's sort
5732 the results for GARDEN tags query in the opposite order,
5733 @code{priority-up}.  This would look like this:
5735 @lisp
5736 @group
5737 (setq org-agenda-custom-commands
5738       '(("h" "Agenda and Home-related tasks"
5739          ((agenda)
5740           (tags-todo "home")
5741           (tags "garden"
5742                 ((org-agenda-sorting-strategy '(priority-up)))))
5743          ((org-agenda-sorting-strategy '(priority-down))))
5744         ("o" "Agenda and Office-related tasks"
5745          ((agenda)
5746           (tags-todo "work")
5747           (tags "office")))))
5748 @end group
5749 @end lisp
5751 As you see, the values and parenthesis setting is a little complex.
5752 When in doubt, use the customize interface to set this variable - it
5753 fully supports its structure.  Just one caveat: When setting options in
5754 this interface, the @emph{values} are just lisp expressions.  So if the
5755 value is a string, you need to add the double quotes around the value
5756 yourself.
5759 @node Exporting Agenda Views, Extracting Agenda Information for other programs, Setting Options, Custom agenda views
5760 @subsection Exporting Agenda Views
5761 @cindex agenda views, exporting
5763 If you are away from your computer, it can be very useful to have a
5764 printed version of some agenda views to carry around.  Org-mode can
5765 export custom agenda views as plain text, HTML@footnote{You need to
5766 install Hrvoje Niksic' @file{htmlize.el}.} and postscript.  If you want
5767 to do this only occasionally, use the command
5769 @table @kbd
5770 @kindex C-x C-w
5771 @item C-x C-w
5772 @cindex exporting agenda views
5773 @cindex agenda views, exporting
5774 Write the agenda view to a file.  Depending on the extension of the
5775 selected file name, the view will be exported as HTML (extension
5776 @file{.html} or @file{.htm}), Postscript (extension @file{.ps}), or
5777 plain text (any other extension).  Use the variable
5778 @code{org-agenda-exporter-settings} to set options for @file{ps-print}
5779 and for @file{htmlize} to be used during export, for example
5780 @lisp
5781 (setq org-agenda-exporter-settings
5782       '((ps-number-of-columns 2)
5783         (ps-landscape-mode t)
5784         (htmlize-output-type 'css)))
5785 @end lisp
5786 @end table
5788 If you need to export certain agenda views frequently, you can associate
5789 any custom agenda command with a list of output file names
5790 @footnote{If you want to store standard views like the weekly agenda
5791 or the global TODO list as well, you need to define custom commands for
5792 them in order to be able to specify filenames.}.  Here is an example
5793 that first does define custom commands for the agenda and the global
5794 todo list, together with a number of files to which to export them.
5795 Then we define two block agenda commands and specify filenames for them
5796 as well.  File names can be relative to the current working directory,
5797 or absolute.
5799 @lisp
5800 @group
5801 (setq org-agenda-custom-commands
5802       '(("X" agenda "" nil ("agenda.html" "agenda.ps"))
5803         ("Y" alltodo "" nil ("todo.html" "todo.txt" "todo.ps"))
5804         ("h" "Agenda and Home-related tasks"
5805          ((agenda)
5806           (tags-todo "home")
5807           (tags "garden"))
5808          nil
5809          ("~/views/home.html"))
5810         ("o" "Agenda and Office-related tasks"
5811          ((agenda)
5812           (tags-todo "work")
5813           (tags "office"))
5814          nil
5815          ("~/views/office.ps"))))
5816 @end group
5817 @end lisp
5819 The extension of the file name determines the type of export.  If it is
5820 @file{.html}, Org-mode will use the @file{htmlize.el} package to convert
5821 the buffer to HTML and save it to this file name.  If the extension is
5822 @file{.ps}, @code{ps-print-buffer-with-faces} is used to produce
5823 postscript output.  Any other extension produces a plain ASCII file.
5825 The export files are @emph{not} created when you use one of those
5826 commands interactively.  Instead, there is a special command to produce
5827 @emph{all} specified files in one step:
5829 @table @kbd
5830 @kindex C-c a e
5831 @item C-c a e
5832 Export all agenda views that have export filenames associated with
5833 them.
5834 @end table
5836 You can use the options section of the custom agenda commands to also
5837 set options for the export commands.  For example:
5839 @lisp
5840 (setq org-agenda-custom-commands
5841       '(("X" agenda ""
5842          ((ps-number-of-columns 2)
5843           (ps-landscape-mode t)
5844           (org-agenda-prefix-format " [ ] ")
5845           (org-agenda-with-colors nil)
5846           (org-agenda-remove-tags t))
5847          ("theagenda.ps"))))
5848 @end lisp
5850 @noindent
5851 This command sets two options for the postscript exporter, to make it
5852 print in two columns in landscape format - the resulting page can be cut
5853 in two and then used in a paper agenda.  The remaining settings modify
5854 the agenda prefix to omit category and scheduling information, and
5855 instead include a checkbox to check off items.  We also remove the tags
5856 to make the lines compact, and we don't want to use colors for the
5857 black-and-white printer.  Settings specified in
5858 @code{org-agenda-exporter-settings} will also apply, but the settings
5859 in @code{org-agenda-custom-commands} take precedence.
5861 @noindent
5862 From the command line you may also use
5863 @example
5864 emacs -f org-batch-store-agenda-views -kill
5865 @end example
5866 @noindent
5867 or, if you need to modify some parameters
5868 @example
5869 emacs -eval '(org-batch-store-agenda-views                      \
5870               org-agenda-ndays 30                               \
5871               org-agenda-start-day "2007-11-01"                 \
5872               org-agenda-include-diary nil                      \
5873               org-agenda-files (quote ("~/org/project.org")))'  \
5874       -kill
5875 @end example
5876 @noindent
5877 which will create the agenda views restricted to the file
5878 @file{~/org/project.org}, without diary entries and with 30 days
5879 extent. 
5881 @node Extracting Agenda Information for other programs,  , Exporting Agenda Views, Custom agenda views
5882 @subsection Extracting Agenda Information for other programs
5883 @cindex agenda, pipe
5884 @cindex Scripts, for agenda processing
5886 Org-mode provides commands to access agenda information for the command
5887 line in emacs batch mode.  This extracted information can be sent
5888 directly to a printer, or it can be read by a program that does further
5889 processing of the data.  The first of these commands is the function
5890 @code{org-batch-agenda}, that produces an agenda view and sends it as
5891 ASCII text to STDOUT.  The command takes a single string as parameter.
5892 If the string has length 1, it is used as a key to one of the commands
5893 you have configured in @code{org-agenda-custom-commands}, basically any
5894 key you can use after @kbd{C-c a}.  For example, to directly print the
5895 current TODO list, you could use
5897 @example
5898 emacs -batch -l ~/.emacs -eval '(org-batch-agenda "t")' | lpr
5899 @end example
5901 If the parameter is a string with 2 or more characters, it is used as a
5902 tags/todo match string.  For example, to print your local shopping list
5903 (all items with the tag @samp{shop}, but excluding the tag
5904 @samp{NewYork}), you could use
5906 @example
5907 emacs -batch -l ~/.emacs                                      \       
5908       -eval '(org-batch-agenda "+shop-NewYork")' | lpr
5909 @end example
5911 @noindent
5912 You may also modify parameters on the fly like this:
5914 @example
5915 emacs -batch -l ~/.emacs                                      \
5916    -eval '(org-batch-agenda "a"                               \
5917             org-agenda-ndays 30                               \
5918             org-agenda-include-diary nil                      \
5919             org-agenda-files (quote ("~/org/project.org")))'  \
5920    | lpr
5921 @end example
5923 @noindent
5924 which will produce a 30 day agenda, fully restricted to the Org file
5925 @file{~/org/projects.org}, not even including the diary.
5927 If you want to process the agenda data in more sophisticated ways, you
5928 can use the command @code{org-batch-agenda-csv} to get a comma-separated
5929 list of values for each agenda item.  Each line in the output will
5930 contain a number of fields separated by commas.  The fields in a line
5931 are:
5933 @example
5934 category     @r{The category of the item}
5935 head         @r{The headline, without TODO kwd, TAGS and PRIORITY}
5936 type         @r{The type of the agenda entry, can be}
5937                 todo               @r{selected in TODO match}
5938                 tagsmatch          @r{selected in tags match}
5939                 diary              @r{imported from diary}
5940                 deadline           @r{a deadline}
5941                 scheduled          @r{scheduled}
5942                 timestamp          @r{appointment, selected by timestamp}
5943                 closed             @r{entry was closed on date}
5944                 upcoming-deadline  @r{warning about nearing deadline}
5945                 past-scheduled     @r{forwarded scheduled item}
5946                 block              @r{entry has date block including date}
5947 todo         @r{The todo keyword, if any}
5948 tags         @r{All tags including inherited ones, separated by colons}
5949 date         @r{The relevant date, like 2007-2-14}
5950 time         @r{The time, like 15:00-16:50}
5951 extra        @r{String with extra planning info}
5952 priority-l   @r{The priority letter if any was given}
5953 priority-n   @r{The computed numerical priority}
5954 @end example
5956 @noindent
5957 Time and date will only be given if a timestamp (or deadline/scheduled)
5958 lead to the selection of the item.
5960 A CSV list like this is very easy to use in a post processing script.
5961 For example, here is a Perl program that gets the TODO list from
5962 Emacs/org-mode and prints all the items, preceded by a checkbox:
5964 @example
5965 @group
5966 #!/usr/bin/perl
5968 # define the Emacs command to run
5969 $cmd = "emacs -batch -l ~/.emacs -eval '(org-batch-agenda-csv \"t\")'";
5971 # run it and capture the output
5972 $agenda = qx@{$cmd 2>/dev/null@};
5974 # loop over all lines
5975 foreach $line (split(/\n/,$agenda)) @{
5977   # get the individual values
5978   ($category,$head,$type,$todo,$tags,$date,$time,$extra,
5979    $priority_l,$priority_n) = split(/,/,$line);
5981   # proccess and print
5982   print "[ ] $head\n";
5984 @end group
5985 @end example
5987 @node Embedded LaTeX, Exporting, Agenda views, Top
5988 @chapter Embedded LaTeX
5989 @cindex @TeX{} interpretation
5990 @cindex La@TeX{} interpretation
5992 Plain ASCII is normally sufficient for almost all note taking.  One
5993 exception, however, are scientific notes which need to be able to
5994 contain mathematical symbols and the occasional formula.
5995 La@TeX{}@footnote{La@TeX{} is a macro system based on Donald E. Knuth's
5996 @TeX{} system.  Many of the features described here as ``La@TeX{}'' are
5997 really from @TeX{}, but for simplicity I am blurring this distinction.}
5998 is widely used to typeset scientific documents. Org-mode supports
5999 embedding La@TeX{} code into its files, because many academics are used
6000 to read La@TeX{} source code, and because it can be readily processed
6001 into images for HTML production.
6003 It is not necessary to mark La@TeX{} macros and code in any special way.
6004 If you observe a few conventions, Org-mode knows how to find it and what
6005 to do with it.
6007 @menu
6008 * Math symbols::                TeX macros for symbols and Greek letters
6009 * Subscripts and Superscripts::  Simple syntax for raising/lowering text
6010 * LaTeX fragments::             Complex formulas made easy
6011 * Processing LaTeX fragments::  Previewing LaTeX processing
6012 * CDLaTeX mode::                Speed up entering of formulas
6013 @end menu
6015 @node Math symbols, Subscripts and Superscripts, Embedded LaTeX, Embedded LaTeX
6016 @section Math symbols
6017 @cindex math symbols
6018 @cindex TeX macros
6020 You can use La@TeX{} macros to insert special symbols like @samp{\alpha}
6021 to indicate the Greek letter, or @samp{\to} to indicate an arrow.
6022 Completion for these macros is available, just type @samp{\} and maybe a
6023 few letters, and press @kbd{M-@key{TAB}} to see possible completions.
6024 Unlike La@TeX{} code, Org-mode allows these macros to be present
6025 without surrounding math delimiters, for example:
6027 @example
6028 Angles are written as Greek letters \alpha, \beta and \gamma.
6029 @end example
6031 During HTML export (@pxref{HTML export}), these symbols are translated
6032 into the proper syntax for HTML, for the above examples this is
6033 @samp{&alpha;} and @samp{&rarr;}, respectively.
6035 @node Subscripts and Superscripts, LaTeX fragments, Math symbols, Embedded LaTeX
6036 @section Subscripts and Superscripts
6037 @cindex subscript
6038 @cindex superscript
6040 Just like in La@TeX{}, @samp{^} and @samp{_} are used to indicate super-
6041 and subscripts.  Again, these can be used without embedding them in
6042 math-mode delimiters.  To increase the readability of ASCII text, it is
6043 not necessary (but OK) to surround multi-character sub- and superscripts
6044 with curly braces.  For example
6046 @example
6047 The mass if the sun is M_sun = 1.989 x 10^30 kg.  The radius of
6048 the sun is R_@{sun@} = 6.96 x 10^8 m.
6049 @end example
6051 To avoid interpretation as raised or lowered text, you can quote
6052 @samp{^} and @samp{_} with a backslash: @samp{\_} and @samp{\^}.
6054 During HTML export (@pxref{HTML export}), subscript and superscripts
6055 are surrounded with @code{<sub>} and @code{<sup>} tags, respectively.
6057 @node LaTeX fragments, Processing LaTeX fragments, Subscripts and Superscripts, Embedded LaTeX
6058 @section LaTeX fragments
6059 @cindex LaTeX fragments
6061 With symbols, sub- and superscripts, HTML is pretty much at its end when
6062 it comes to representing mathematical formulas@footnote{Yes, there is
6063 MathML, but that is not yet fully supported by many browsers, and there
6064 is no decent converter for turning La@TeX{} or ASCII representations of
6065 formulas into MathML. So for the time being, converting formulas into
6066 images seems the way to go.}. More complex expressions need a dedicated
6067 formula processor. To this end, Org-mode can contain arbitrary La@TeX{}
6068 fragments. It provides commands to preview the typeset result of these
6069 fragments, and upon export to HTML, all fragments will be converted to
6070 images and inlined into the HTML document@footnote{The La@TeX{} export
6071 will not use images for displaying La@TeX{} fragments but include these
6072 fragments directly into the La@TeX{} code.}. For this to work you
6073 need to be on a system with a working La@TeX{} installation. You also
6074 need the @file{dvipng} program, available at
6075 @url{http://sourceforge.net/projects/dvipng/}. The La@TeX{} header that
6076 will be used when processing a fragment can be configured with the
6077 variable @code{org-format-latex-header}.
6079 La@TeX{} fragments don't need any special marking at all.  The following
6080 snippets will be identified as La@TeX{} source code:
6081 @itemize @bullet
6082 @item
6083 Environments of any kind.  The only requirement is that the
6084 @code{\begin} statement appears on a new line, preceded by only
6085 whitespace.
6086 @item
6087 Text within the usual La@TeX{} math delimiters.  To avoid conflicts with
6088 currency specifications, single @samp{$} characters are only recognized
6089 as math delimiters if the enclosed text contains at most two line breaks,
6090 is directly attached to the @samp{$} characters with no whitespace in
6091 between, and if the closing @samp{$} is followed by whitespace or
6092 punctuation.  For the other delimiters, there is no such restriction, so
6093 when in doubt, use @samp{\(...\)} as inline math delimiters.
6094 @end itemize
6096 @noindent For example:
6098 @example
6099 \begin@{equation@}                          % arbitrary environments,
6100 x=\sqrt@{b@}                                % even tables, figures
6101 \end@{equation@}                            % etc
6103 If $a^2=b$ and \( b=2 \), then the solution must be
6104 either $$ a=+\sqrt@{2@} $$ or \[ a=-\sqrt@{2@} \].
6105 @end example
6107 @noindent
6108 If you need any of the delimiter ASCII sequences for other purposes, you
6109 can configure the option @code{org-format-latex-options} to deselect the
6110 ones you do not wish to have interpreted by the La@TeX{} converter.
6112 @node Processing LaTeX fragments, CDLaTeX mode, LaTeX fragments, Embedded LaTeX
6113 @section Processing LaTeX fragments
6114 @cindex LaTeX fragments, preview
6116 La@TeX{} fragments can be processed to produce a preview images of the
6117 typeset expressions:
6119 @table @kbd
6120 @kindex C-c C-x C-l
6121 @item C-c C-x C-l
6122 Produce a preview image of the La@TeX{} fragment at point and overlay it
6123 over the source code.  If there is no fragment at point, process all
6124 fragments in the current entry (between two headlines).  When called
6125 with a prefix argument, process the entire subtree.  When called with
6126 two prefix arguments, or when the cursor is before the first headline,
6127 process the entire buffer.
6128 @kindex C-c C-c
6129 @item C-c C-c
6130 Remove the overlay preview images.
6131 @end table
6133 During HTML export (@pxref{HTML export}), all La@TeX{} fragments are
6134 converted into images and inlined into the document if the following
6135 setting is active:
6137 @lisp
6138 (setq org-export-with-LaTeX-fragments t)
6139 @end lisp
6141 @node CDLaTeX mode,  , Processing LaTeX fragments, Embedded LaTeX
6142 @section Using CDLaTeX to enter math
6143 @cindex CDLaTeX
6145 CDLaTeX-mode is a minor mode that is normally used in combination with a
6146 major La@TeX{} mode like AUCTeX in order to speed-up insertion of
6147 environments and math templates.  Inside Org-mode, you can make use of
6148 some of the features of cdlatex-mode.  You need to install
6149 @file{cdlatex.el} and @file{texmathp.el} (the latter comes also with
6150 AUCTeX) from @url{http://www.astro.uva.nl/~dominik/Tools/cdlatex}.
6151 Don't turn cdlatex-mode itself under Org-mode, but use the light
6152 version @code{org-cdlatex-mode} that comes as part of Org-mode.  Turn it
6153 on for the current buffer with @code{M-x org-cdlatex-mode}, or for all
6154 Org-mode files with
6156 @lisp
6157 (add-hook 'org-mode-hook 'turn-on-org-cdlatex)
6158 @end lisp
6160 When this mode is enabled, the following features are present (for more
6161 details see the documentation of cdlatex-mode):
6162 @itemize @bullet
6163 @kindex C-c @{
6164 @item
6165 Environment templates can be inserted with @kbd{C-c @{}.
6166 @item
6167 @kindex @key{TAB}
6168 The @key{TAB} key will do template expansion if the cursor is inside a
6169 La@TeX{} fragment@footnote{Org-mode has a method to test if the cursor is
6170 inside such a fragment, see the documentation of the function
6171 @code{org-inside-LaTeX-fragment-p}.}.  For example, @key{TAB} will
6172 expand @code{fr} to @code{\frac@{@}@{@}} and position the cursor
6173 correctly inside the first brace.  Another @key{TAB} will get you into
6174 the second brace.  Even outside fragments, @key{TAB} will expand
6175 environment abbreviations at the beginning of a line.  For example, if
6176 you write @samp{equ} at the beginning of a line and press @key{TAB},
6177 this abbreviation will be expanded to an @code{equation} environment.
6178 To get a list of all abbreviations, type @kbd{M-x cdlatex-command-help}.
6179 @item
6180 @kindex _
6181 @kindex ^
6182 Pressing @kbd{_} and @kbd{^} inside a La@TeX{} fragment will insert these
6183 characters together with a pair of braces.  If you use @key{TAB} to move
6184 out of the braces, and if the braces surround only a single character or
6185 macro, they are removed again (depending on the variable
6186 @code{cdlatex-simplify-sub-super-scripts}).
6187 @item
6188 @kindex `
6189 Pressing the backquote @kbd{`} followed by a character inserts math
6190 macros, also outside La@TeX{} fragments.  If you wait more than 1.5 seconds
6191 after the backquote, a help window will pop up.
6192 @item
6193 @kindex '
6194 Pressing the normal quote @kbd{'} followed by another character modifies
6195 the symbol before point with an accent or a font.  If you wait more than
6196 1.5 seconds after the backquote, a help window will pop up.  Character
6197 modification will work only inside La@TeX{} fragments, outside the quote
6198 is normal.
6199 @end itemize
6201 @node Exporting, Publishing, Embedded LaTeX, Top
6202 @chapter Exporting
6203 @cindex exporting
6205 Org-mode documents can be exported into a variety of other formats.  For
6206 printing and sharing of notes, ASCII export produces a readable and
6207 simple version of an Org-mode file.  HTML export allows you to publish a
6208 notes file on the web, while the XOXO format provides a solid base for
6209 exchange with a broad range of other applications. La@TeX{} export lets
6210 you use Org-mode and its structured editing functions to easily create
6211 La@TeX{} files.  To incorporate entries with associated times like
6212 deadlines or appointments into a desktop calendar program like iCal,
6213 Org-mode can also produce extracts in the iCalendar format.  Currently
6214 Org-mode only supports export, not import of these different formats.
6216 When exporting, Org-mode uses special conventions to enrich the output
6217 produced.  @xref{Text interpretation}, for more details.
6219 @table @kbd
6220 @kindex C-c C-e
6221 @item C-c C-e
6222 Dispatcher for export and publishing commands.  Displays a help-window
6223 listing the additional key(s) needed to launch an export or publishing
6224 command.
6225 @end table
6227 @menu
6228 * ASCII export::                Exporting to plain ASCII
6229 * HTML export::                 Exporting to HTML
6230 * LaTeX export::                Exporting to LaTeX
6231 * XOXO export::                 Exporting to XOXO
6232 * iCalendar export::            Exporting in iCalendar format
6233 * Text interpretation::         How the exporter looks at the file
6234 @end menu
6236 @node ASCII export, HTML export, Exporting, Exporting
6237 @section ASCII export
6238 @cindex ASCII export
6240 ASCII export produces a simple and very readable version of an Org-mode
6241 file.
6243 @cindex region, active
6244 @cindex active region
6245 @cindex transient-mark-mode
6246 @table @kbd
6247 @kindex C-c C-e a
6248 @item C-c C-e a
6249 Export as ASCII file.  For an org file @file{myfile.org}, the ASCII file
6250 will be @file{myfile.txt}.  The file will be overwritten without
6251 warning.  If there is an active region, only the region will be
6252 exported. If the selected region is a single tree, the tree head will
6253 become the document title.  If the tree head entry has or inherits an
6254 @code{:EXPORT_FILE_NAME:} property, that name will be used for the
6255 export. 
6256 @kindex C-c C-e v a
6257 @item C-c C-e v a
6258 Export only the visible part of the document.
6259 @end table
6261 @cindex headline levels, for exporting
6262 In the exported version, the first 3 outline levels will become
6263 headlines, defining a general document structure.  Additional levels
6264 will be exported as itemized lists.  If you want that transition to occur
6265 at a different level, specify it with a prefix argument.  For example,
6267 @example
6268 @kbd{C-1 C-c C-e a}
6269 @end example
6271 @noindent
6272 creates only top level headlines and does the rest as items.  When
6273 headlines are converted to items, the indentation of the text following
6274 the headline is changed to fit nicely under the item.  This is done with
6275 the assumption that the first bodyline indicates the base indentation of
6276 the body text.  Any indentation larger than this is adjusted to preserve
6277 the layout relative to the first line.  Should there be lines with less
6278 indentation than the first, these are left alone.
6280 @node HTML export, LaTeX export, ASCII export, Exporting
6281 @section HTML export
6282 @cindex HTML export
6284 Org-mode contains an HTML (XHTML 1.0 strict) exporter with extensive
6285 HTML formatting, in ways similar to John Grubers @emph{markdown}
6286 language, but with additional support for tables.
6288 @menu
6289 * HTML Export commands::        How to invoke LaTeX export
6290 * Quoting HTML tags::           Using direct HTML in Org-mode
6291 * Links::                       Transformation of links for HTML
6292 * Images::                      How to include images
6293 * CSS support::                 Changing the appearence of the output
6294 @end menu
6296 @node HTML Export commands, Quoting HTML tags, HTML export, HTML export
6297 @subsection HTML export commands
6299 @cindex region, active
6300 @cindex active region
6301 @cindex transient-mark-mode
6302 @table @kbd
6303 @kindex C-c C-e h
6304 @item C-c C-e h
6305 Export as HTML file @file{myfile.html}.  For an org file
6306 @file{myfile.org}, the ASCII file will be @file{myfile.html}.  The file
6307 will be overwritten without warning.  If there is an active region, only
6308 the region will be exported. If the selected region is a single tree,
6309 the tree head will become the document title.  If the tree head entry
6310 has or inherits an @code{:EXPORT_FILE_NAME:} property, that name will be
6311 used for the export.
6312 @kindex C-c C-e b
6313 @item C-c C-e b
6314 Export as HTML file and immediately open it with a browser.
6315 @kindex C-c C-e H
6316 @item C-c C-e H
6317 Export to a temporary buffer, do not create a file.
6318 @kindex C-c C-e R
6319 @item C-c C-e R
6320 Export the active region to a temporary buffer.  With prefix arg, do not
6321 produce file header and foot, but just the plain HTML section for the
6322 region.  This is good for cut-and-paste operations.
6323 @kindex C-c C-e v h
6324 @kindex C-c C-e v b
6325 @kindex C-c C-e v H
6326 @kindex C-c C-e v R
6327 @item C-c C-e v h
6328 @item C-c C-e v b
6329 @item C-c C-e v H
6330 @item C-c C-e v R
6331 Export only the visible part of the document.
6332 @item M-x org-export-region-as-html
6333 Convert the region to HTML under the assumption that it was org-mode
6334 syntax before.  This is a global command that can be invoked in any
6335 buffer.
6336 @item M-x org-replace-region-by-HTML
6337 Replace the active region (assumed to be in Org-mode syntax) by HTML
6338 code.
6339 @end table
6341 @cindex headline levels, for exporting
6342 In the exported version, the first 3 outline levels will become
6343 headlines, defining a general document structure.  Additional levels
6344 will be exported as itemized lists.  If you want that transition to occur
6345 at a different level, specify it with a prefix argument.  For example,
6347 @example
6348 @kbd{C-2 C-c C-e b}
6349 @end example
6351 @noindent
6352 creates two levels of headings and does the rest as items.
6354 @node Quoting HTML tags, Links, HTML Export commands, HTML export
6355 @subsection Quoting HTML tags
6357 Plain @samp{<} and @samp{>} are always transformed to @samp{&lt;} and
6358 @samp{&gt;} in HTML export.  If you want to include simple HTML tags
6359 which should be interpreted as such, mark them with @samp{@@} as in
6360 @samp{@@<b>bold text@@</b>}.  Note that this really works only for
6361 simple tags.  For more extensive HTML that should be copied verbatim to
6362 the exported file use either
6364 @example
6365 #+HTML: Literal HTML code for export
6366 @end example
6368 @noindent or
6370 @example
6371 #+BEGIN_HTML
6372 All lines between these markers are exported literally
6373 #+END_HTML
6374 @end example
6377 @node Links, Images, Quoting HTML tags, HTML export
6378 @subsection Links
6380 @cindex links, in HTML export
6381 @cindex internal links, in HTML export
6382 @cindex external links, in HTML export
6383 Internal links (@pxref{Internal links}) will continue to work in HTML
6384 files only if they match a dedicated @samp{<<target>>}.  Automatic links
6385 created by radio targets (@pxref{Radio targets}) will also work in the
6386 HTML file.  Links to external files will still work if the HTML file is
6387 in the same directory as the Org-mode file.  Links to other @file{.org}
6388 files will be translated into HTML links under the assumption that an
6389 HTML version also exists of the linked file.  For information related to
6390 linking files while publishing them to a publishing directory see
6391 @ref{Publishing links}.
6393 @node Images, CSS support, Links, HTML export
6394 @subsection Images
6396 @cindex images, inline in HTML
6397 @cindex inlining images in HTML
6398 HTML export can inline images given as links in the Org-mode file, and
6399 it can make an image the clickable part of a link.  By
6400 default@footnote{but see the variable
6401 @code{org-export-html-inline-images}}, images are inlined if a link does
6402 not have a description.  So @samp{[[file:myimg.jpg]]} will be inlined,
6403 while @samp{[[file:myimg.jpg][the image]]} will just produce a link
6404 @samp{the image} that points to the image.  If the description part
6405 itself is a @code{file:} link or a @code{http:} URL pointing to an
6406 image, this image will be inlined and activated so that clicking on the
6407 image will activate the link.  For example, to include a thumbnail that
6408 will link to a high resolution version of the image, you could use:
6410 @example
6411 [[file:highres.jpg][file:thumb.jpg]]
6412 @end example
6414 @noindent
6415 and you could use @code{http} addresses just as well.
6417 @node CSS support,  , Images, HTML export
6418 @subsection CSS support
6420 You can also give style information for the exported file.  The HTML
6421 exporter assigns the following CSS classes to appropriate parts of the
6422 document - your style specifications may change these:
6423 @example
6424 .todo           @r{TODO keywords}
6425 .done           @r{the DONE keyword}
6426 .timestamp      @r{time stamp}
6427 .timestamp-kwd  @r{keyword associated with a time stamp, like SCHEDULED}
6428 .tag            @r{tag in a headline}
6429 .target         @r{target for links}
6430 @end example
6432 The default style specification can be configured through the option
6433 @code{org-export-html-style}.  If you want to use a file-local style,
6434 you may use file variables, best wrapped into a COMMENT section at the
6435 end of the outline tree.  For example@footnote{Under Emacs 21, the
6436 continuation lines for a variable value should have no @samp{#} at the
6437 start of the line.}:
6439 @example
6440 * COMMENT html style specifications
6442 # Local Variables:
6443 # org-export-html-style: "   <style type=\"text/css\">
6444 #       p @{font-weight: normal; color: gray; @}
6445 #       h1 @{color: black; @}
6446 #   </style>"
6447 # End:
6448 @end example
6450 Remember to execute @kbd{M-x normal-mode} after changing this to make
6451 the new style visible to Emacs.  This command restarts org-mode for the
6452 current buffer and forces Emacs to re-evaluate the local variables
6453 section in the buffer.
6455 @c FIXME: More about header and footer styles
6456 @c FIXME: Talk about links and targets.
6458 @node LaTeX export, XOXO export, HTML export, Exporting
6459 @section LaTeX export
6460 @cindex LaTeX export
6462 Org-mode contains a La@TeX{} exporter written by Bastien Guerry.
6464 @menu
6465 * LaTeX export commands::       How to invoke LaTeX export
6466 * Quoting LaTeX code::          Incorporating literal LaTeX code
6467 * Sectioning structure::        
6468 @end menu
6470 @node LaTeX export commands, Quoting LaTeX code, LaTeX export, LaTeX export
6471 @subsection LaTeX export commands
6473 @table @kbd
6474 @kindex C-c C-e l
6475 @item C-c C-e l
6476 Export as La@TeX{} file @file{myfile.tex}.
6477 @kindex C-c C-e L
6478 @item C-c C-e L
6479 Export to a temporary buffer, do not create a file.
6480 @kindex C-c C-e v l
6481 @kindex C-c C-e v L
6482 @item C-c C-e v l
6483 @item C-c C-e v L
6484 Export only the visible part of the document.
6485 @item M-x org-export-region-as-latex
6486 Convert the region to La@TeX{} under the assumption that it was org-mode
6487 syntax before.  This is a global command that can be invoked in any
6488 buffer.
6489 @item M-x org-replace-region-by-latex
6490 Replace the active region (assumed to be in Org-mode syntax) by La@TeX{}
6491 code.
6492 @end table
6494 @cindex headline levels, for exporting
6495 In the exported version, the first 3 outline levels will become
6496 headlines, defining a general document structure.  Additional levels
6497 will be exported as description lists.  The exporter can ignore them or
6498 convert them to a custom string depending on
6499 @code{org-latex-low-levels}.
6501 If you want that transition to occur at a different level, specify it
6502 with a prefix argument. For example,
6504 @example
6505 @kbd{C-2 C-c C-e l}
6506 @end example
6508 @noindent
6509 creates two levels of headings and does the rest as items.
6511 @node Quoting LaTeX code, Sectioning structure, LaTeX export commands, LaTeX export
6512 @subsection Quoting LaTeX code
6514 Embedded La@TeX{} as described in @ref{Embedded LaTeX} will be correctly
6515 inserted into the La@TeX{} file.  Forthermore, you can add special code
6516 that should only be present in La@TeX{} export with the following
6517 constructs:
6519 @example
6520 #+LaTeX: Literal LaTeX code for export
6521 @end example
6523 @noindent or
6525 @example
6526 #+BEGIN_LaTeX
6527 All lines between these markers are exported literally
6528 #+END_LaTeX
6529 @end example
6533 @node   Sectioning structure,  , Quoting LaTeX code, LaTeX export
6534 @subsection Sectioning structure
6535 @cindex LaTeX class
6536 @cindex LaTeX sectioning structure
6538 By default, the La@TeX{} output uses the class @code{article}.
6540 You can change this globally by setting a different value for
6541 @code{org-export-latex-default-class} or locally by adding an option
6542 like @code{#+LaTeX_CLASS: myclass} in your file.  The class should be
6543 listed in @code{org-export-latex-classes}, where you can also define the
6544 sectioning structure for each class.
6547 @node XOXO export, iCalendar export, LaTeX export, Exporting
6548 @section XOXO export
6549 @cindex XOXO export
6551 Org-mode contains an exporter that produces XOXO-style output.
6552 Currently, this exporter only handles the general outline structure and
6553 does not interpret any additional Org-mode features.
6555 @table @kbd
6556 @kindex C-c C-e x
6557 @item C-c C-e x
6558 Export as XOXO file @file{myfile.html}.
6559 @kindex C-c C-e v
6560 @item C-c C-e v x
6561 Export only the visible part of the document.
6562 @end table
6564 @node iCalendar export, Text interpretation, XOXO export, Exporting
6565 @section iCalendar export
6566 @cindex iCalendar export
6568 Some people like to use Org-mode for keeping track of projects, but
6569 still prefer a standard calendar application for anniversaries and
6570 appointments.  In this case it can be useful to have deadlines and
6571 other time-stamped items in Org-mode files show up in the calendar
6572 application.  Org-mode can export calendar information in the standard
6573 iCalendar format.  If you also want to have TODO entries included in the
6574 export, configure the variable @code{org-icalendar-include-todo}.
6576 @table @kbd
6577 @kindex C-c C-e i
6578 @item C-c C-e i
6579 Create iCalendar entries for the current file and store them in the same
6580 directory, using a file extension @file{.ics}.
6581 @kindex C-c C-e I
6582 @item C-c C-e I
6583 Like @kbd{C-c C-e i}, but do this for all files in
6584 @code{org-agenda-files}.  For each of these files, a separate iCalendar
6585 file will be written.
6586 @kindex C-c C-e c
6587 @item C-c C-e c
6588 Create a single large iCalendar file from all files in
6589 @code{org-agenda-files} and write it to the file given by
6590 @code{org-combined-agenda-icalendar-file}.
6591 @end table
6593 The export will honor SUMMARY, DESCRIPTION and LOCATION properties if
6594 the selected entries have them.  If not, the summary will be derived
6595 from the headline, and the description from the body (limited to
6596 @code{org-icalendar-include-body} characters).  
6598 How this calendar is best read and updated, depends on the application
6599 you are using.  The FAQ covers this issue.
6602 @node Text interpretation,  , iCalendar export, Exporting
6603 @section Text interpretation by the exporter
6605 The exporter backends interpret additional structure in the Org-mode file
6606 in order to produce better output.
6608 @menu
6609 * Comment lines::               Some lines will not be exported
6610 * Initial text::                Text before the first headline
6611 * Footnotes::                   Numbers like [1]
6612 * Quoted examples::             Inserting quoted chnuks of text            
6613 * Enhancing text::              Subscripts, symbols and more
6614 * Export options::              How to influence the export settings
6615 @end menu
6617 @node Comment lines, Initial text, Text interpretation, Text interpretation
6618 @subsection Comment lines
6619 @cindex comment lines
6620 @cindex exporting, not
6622 Lines starting with @samp{#} in column zero are treated as comments
6623 and will never be exported.  Also entire subtrees starting with the
6624 word @samp{COMMENT} will never be exported.
6626 @table @kbd
6627 @kindex C-c ;
6628 @item C-c ;
6629 Toggle the COMMENT keyword at the beginning of an entry.
6630 @end table
6632 @node Initial text, Footnotes, Comment lines, Text interpretation
6633 @subsection Text before the first headline
6635 Org-mode normally ignores any text before the first headline when
6636 exporting, leaving this region for internal links to speed up navigation
6637 etc.  However, in publishing-oriented files, you might want to have some
6638 text before the first headline, like a small introduction, special HTML
6639 code with a navigation bar, etc.  You can ask to have this part of the
6640 file exported as well by setting the variable
6641 @code{org-export-skip-text-before-1st-heading} to @code{nil}.  On a
6642 per-file basis, you can get the same effect with
6644 @example
6645 #+OPTIONS: skip:nil
6646 @end example
6648 The text before the first headline will be fully processed
6649 (@pxref{Enhancing text}), and the first non-comment line becomes the
6650 title of the exported document.  If you need to include literal HTML,
6651 use the special constructs described in @ref{Quoting HTML tags}.  The
6652 table of contents is normally inserted directly before the first
6653 headline of the file.  If you would like to get it to a different
6654 location, insert the string @code{[TABLE-OF-CONTENTS]} on a line by
6655 itself at the desired location.
6657 Finally, if you want to use the space before the first headline for
6658 internal purposes, but @emph{still} want to place something before the
6659 first headline when exporting the file, you can use the @code{#+TEXT}
6660 construct:
6662 @example
6663 #+OPTIONS: skip:t
6664 #+TEXT: This text will go before the *first* headline.
6665 #+TEXT: We place the table of contents here:
6666 #+TEXT: [TABLE-OF-CONTENTS]
6667 #+TEXT: This goes between the table of contents and the first headline
6668 @end example
6670 @node Footnotes, Quoted examples, Initial text, Text interpretation
6671 @subsection Footnotes
6672 @cindex footnotes
6673 @cindex @file{footnote.el}
6675 Numbers in square brackets are treated as footnotes, so that you can use
6676 the Emacs package @file{footnote.el} to create footnotes.  For example:
6678 @example
6679 The org-mode homepage[1] clearly needs help from
6680 a good web designer.
6682 [1] The link is: http://orgmode.org
6683 @end example
6685 @noindent
6686 @kindex C-c !
6687 Note that the @file{footnote} package uses @kbd{C-c !} to invoke its
6688 commands.  This binding conflicts with the org-mode command for
6689 inserting inactive time stamps.  You could use the variable
6690 @code{footnote-prefix} to switch footnotes commands to another key.  Or,
6691 if you are too used to this binding, you could use
6692 @code{org-replace-disputed-keys} and @code{org-disputed-keys} to change
6693 the settings in Org-mode.
6695 @node Quoted examples, Enhancing text, Footnotes, Text interpretation
6696 @subsection Quoted examples
6697 @cindex quoted examples
6698 @cindex examples, quoted
6699 @cindex text, fixed width
6700 @cindex fixed width text
6702 When writing technical documents, you often need to insert examples that
6703 are not further interpreted by Org-mode.  For historical reasons, there
6704 are several ways to do this:
6706 @itemize @bullet
6707 @item
6708 If a headline starts with the word @samp{QUOTE}, the text below the
6709 headline will be typeset as fixed-width, to allow quoting of computer
6710 codes etc.
6711 @item
6712 Lines starting with @samp{:} are also typeset in fixed-width font. 
6713 @table @kbd
6714 @kindex C-c :
6715 @item C-c :
6716 Toggle fixed-width for entry (QUOTE) or region, see below.
6717 @end table
6718 @item
6719 Finally, text between
6720 @example
6721 #+BEGIN_EXAMPLE
6722 quoted text
6723 #+END_EXAMPLE
6724 @end example
6725 will also be exported in this way.
6726 @end itemize
6729 @node Enhancing text, Export options, Quoted examples, Text interpretation
6730 @subsection Enhancing text for export
6731 @cindex enhancing text
6732 @cindex richer text
6734 Some of the export backends of Org-mode allow for sophisticated text
6735 formatting, this is true in particular for the HTML and La@TeX{}
6736 backends.  Org-mode has a number of typing conventions that allow to
6737 produce a richly formatted output.
6739 @itemize @bullet
6741 @cindex hand-formatted lists
6742 @cindex lists, hand-formatted
6743 @item
6744 Plain lists @samp{-}, @samp{*} or @samp{+} as bullet, or with @samp{1.}
6745 or @samp{2)} as enumerator will be recognized and transformed if the
6746 backend supports lists.  See @xref{Plain lists}.
6748 @cindex underlined text
6749 @cindex bold text
6750 @cindex italic text
6751 @cindex verbatim text
6752 @item
6753 You can make words @b{*bold*}, @i{/italic/}, _underlined_, @code{=code=}
6754 and @code{~verbatim~}, and, if you must, @samp{+strikethrough+}.  Text
6755 in the code and verbatim string is not processed for org-mode specific
6756 syntax, it is exported verbatim.
6758 @cindex horizontal rules, in exported files
6759 @item
6760 A line consisting of only dashes, and at least 5 of them, will be
6761 exported as a horizontal line (@samp{<hr/>} in HTML).
6763 @cindex LaTeX fragments, export
6764 @cindex TeX macros, export
6765 @item
6766 Many @TeX{} macros and entire La@TeX{} fragments are converted into HTML
6767 entities or images (@pxref{Embedded LaTeX}).
6769 @cindex tables, export
6770 @item
6771 Tables are transformed into native tables under the exporter, if the
6772 export backend supports this. Data fields before the first horizontal
6773 separator line will be formatted as table header fields.
6775 @cindex fixed width
6776 @item
6777 If a headline starts with the word @samp{QUOTE}, the text below the
6778 headline will be typeset as fixed-width, to allow quoting of computer
6779 codes etc.  Lines starting with @samp{:} are also typeset in fixed-width
6780 font. 
6781 @table @kbd
6782 @kindex C-c :
6783 @item C-c :
6784 Toggle fixed-width for entry (QUOTE) or region, see below.
6785 @end table
6786 Finally, text between
6787 @example
6788 #+BEGIN_EXAMPLE
6789 quoted text
6790 #+END_EXAMPLE
6791 @end example
6792 will also be exported in this way.
6794 @cindex linebreak, forced
6795 @item 
6796 A double backslash @emph{at the end of a line} enforces a line break at
6797 this position.
6799 @cindex HTML entities, LaTeX entities
6800 @item
6801 Strings like @code{\alpha} will be exported as @code{&alpha;}, in the
6802 HTML output.  These strings are exported as @code{$\alpha$} in the
6803 La@TeX{} output.  Similarly, @code{\nbsp} will become @code{&nbsp;} in
6804 HTML and in La@TeX{}.  This applies for a long list of entities, see
6805 the variable @code{org-html-entities} for the complete list.
6806 @c FIXME
6807 @end itemize
6809 If these conversions conflict with your habits of typing ASCII text,
6810 they can all be turned off with corresponding variables.  See the
6811 customization group @code{org-export-general}, and the following section
6812 which explains how to set export options with special lines in a
6813 buffer.
6816 @node Export options,  , Enhancing text, Text interpretation
6817 @subsection Export options
6818 @cindex options, for export
6820 @cindex completion, of option keywords
6821 The exporter recognizes special lines in the buffer which provide
6822 additional information.  These lines may be put anywhere in the file.
6823 The whole set of lines can be inserted into the buffer with @kbd{C-c
6824 C-e t}.  For individual lines, a good way to make sure the keyword is
6825 correct is to type @samp{#+} and then use @kbd{M-@key{TAB}} completion
6826 (@pxref{Completion}).
6828 @table @kbd
6829 @kindex C-c C-e t
6830 @item C-c C-e t
6831 Insert template with export options, see example below.
6832 @end table
6834 @example
6835 #+TITLE:     the title to be shown (default is the buffer name)
6836 #+AUTHOR:    the author (default taken from @code{user-full-name})
6837 #+DATE:      A date, fixed, of a format string for @code{format-time-string}
6838 #+EMAIL:     his/her email address (default from @code{user-mail-address})
6839 #+LANGUAGE:  language for HTML, e.g. @samp{en} (@code{org-export-default-language})
6840 #+TEXT:      Some descriptive text to be inserted at the beginning.
6841 #+TEXT:      Several lines may be given.
6842 #+OPTIONS:   H:2 num:t toc:t \n:nil @@:t ::t |:t ^:t f:t TeX:t ...
6843 @end example
6845 @noindent
6846 The OPTIONS line is a compact form to specify export settings.  Here
6847 you can:
6848 @cindex headline levels
6849 @cindex section-numbers
6850 @cindex table of contents
6851 @cindex linebreak preservation
6852 @cindex quoted HTML tags
6853 @cindex fixed-width sections
6854 @cindex tables
6855 @cindex @TeX{}-like syntax for sub- and superscripts
6856 @cindex footnotes
6857 @cindex special strings
6858 @cindex emphasized text
6859 @cindex @TeX{} macros
6860 @cindex La@TeX{} fragments
6861 @cindex author info, in export
6862 @cindex time info, in export
6863 @example
6864 H:         @r{set the number of headline levels for export}
6865 num:       @r{turn on/off section-numbers}
6866 toc:       @r{turn on/off table of contents, or set level limit (integer)}
6867 \n:        @r{turn on/off linebreak-preservation}
6868 @@:         @r{turn on/off quoted HTML tags}
6869 ::         @r{turn on/off fixed-width sections}
6870 |:         @r{turn on/off tables}
6871 ^:         @r{turn on/off @TeX{}-like syntax for sub- and superscripts.  If}
6872            @r{you write "^:@{@}", @code{a_@{b@}} will be interpreted, but}
6873            @r{the simple @code{a_b} will be left as it is.}
6874 -:         @r{turn on/off conversion of special strings.}
6875 f:         @r{turn on/off foototes like this[1].}
6876 *:         @r{turn on/off emphasized text (bold, italic, underlined)}
6877 TeX:       @r{turn on/off simple @TeX{} macros in plain text}
6878 LaTeX:     @r{turn on/off La@TeX{} fragments}
6879 skip:      @r{turn on/off skipping the text before the first heading}
6880 author:    @r{turn on/off inclusion of author name/email into exported file}
6881 timestamp: @r{turn on/off inclusion creation time into exported file}
6882 d:         @r{turn on/off inclusion of drawers}
6883 @end example
6885 These options take effect in both the HTML and La@TeX{} export, except
6886 for @code{TeX} and @code{LaTeX}, which are respectively @code{t} and
6887 @code{nil} for the La@TeX{} export.
6889 @node Publishing, Miscellaneous, Exporting, Top
6890 @chapter Publishing
6891 @cindex publishing
6893 Org-mode includes@footnote{@file{org-publish.el} is not distributed with
6894 Emacs 21, if you are still using Emacs 21, you need you need to download
6895 this file separately.} a publishing management system that allows you to
6896 configure automatic HTML conversion of @emph{projects} composed of
6897 interlinked org files.  This system is called @emph{org-publish}.  You can
6898 also configure org-publish to automatically upload your exported HTML
6899 pages and related attachments, such as images and source code files, to
6900 a web server. Org-publish turns org-mode into a web-site authoring tool.
6902 You can also use Org-publish to convert files into La@TeX{}, or even
6903 combine HTML and La@TeX{} conversion so that files are available in both
6904 formats on the server@footnote{Since La@TeX{} files on a server are not
6905 that helpful, you surely want to perform further conversion on them --
6906 e.g. convert them to @code{PDF} format.}.
6908 Org-publish has been contributed to Org-mode by David O'Toole.
6910 @menu
6911 * Configuration::               Defining projects
6912 * Sample configuration::        Example projects
6913 * Triggering publication::      Publication commands
6914 @end menu
6916 @node Configuration, Sample configuration, Publishing, Publishing
6917 @section Configuration
6919 Publishing needs significant configuration to specify files, destination
6920 and many other properties of a project.
6922 @menu
6923 * Project alist::               The central configuration variable
6924 * Sources and destinations::    From here to there
6925 * Selecting files::             What files are part of the project?
6926 * Publishing action::           Setting the function doing the publishing
6927 * Publishing options::          Tweaking HTML export
6928 * Publishing links::            Which links keep working after publishing?
6929 * Project page index::          Publishing a list of project files
6930 @end menu
6932 @node Project alist, Sources and destinations, Configuration, Configuration
6933 @subsection The variable @code{org-publish-project-alist}
6934 @cindex org-publish-project-alist
6935 @cindex projects, for publishing
6937 Org-publish is configured almost entirely through setting the value of
6938 one variable, called @code{org-publish-project-alist}.
6939 Each element of the list configures one project, and may be in one of
6940 the two following forms:
6942 @lisp
6943 ("project-name" :property value :property value ...)
6945 @r{or} 
6947 ("project-name" :components ("project-name" "project-name" ...))
6949 @end lisp
6951 In both cases, projects are configured by specifying property values.
6952 A project defines the set of files that will be published, as well as
6953 the publishing configuration to use when publishing those files.  When
6954 a project takes the second form listed above, the individual members
6955 of the ``components'' property are taken to be components of the
6956 project, which group together files requiring different publishing
6957 options. When you publish such a ``meta-project'' all the components
6958 will also publish.
6960 @node Sources and destinations, Selecting files, Project alist, Configuration
6961 @subsection Sources and destinations for files
6962 @cindex directories, for publishing
6964 Most properties are optional, but some should always be set. In
6965 particular, org-publish needs to know where to look for source files,
6966 and where to put published files.
6968 @multitable @columnfractions 0.3 0.7
6969 @item @code{:base-directory}
6970 @tab Directory containing publishing source files
6971 @item @code{:publishing-directory}
6972 @tab Directory (possibly remote) where output files will be published.
6973 @item @code{:preparation-function}
6974 @tab Function called before starting publishing process, for example to
6975 run @code{make} for updating files to be published.
6976 @end multitable
6977 @noindent
6979 @node Selecting files, Publishing action, Sources and destinations, Configuration
6980 @subsection Selecting files
6981 @cindex files, selecting for publishing
6983 By default, all files with extension @file{.org} in the base directory
6984 are considered part of the project.  This can be modified by setting the
6985 properties 
6986 @multitable @columnfractions 0.25 0.75
6987 @item @code{:base-extension}
6988 @tab Extension (without the dot!) of source files.  This actually is a
6989 regular expression.
6991 @item @code{:exclude} 
6992 @tab Regular expression to match file names that should not be
6993 published, even though they have been selected on the basis of their
6994 extension.
6996 @item @code{:include}
6997 @tab List of files to be included regardless of @code{:base-extension}
6998 and @code{:exclude}.
6999 @end multitable
7001 @node Publishing action, Publishing options, Selecting files, Configuration
7002 @subsection Publishing Action
7003 @cindex action, for publishing
7005 Publishing means that a file is copied to the destination directory and
7006 possibly transformed in the process.  The default transformation is to
7007 export Org-mode files as HTML files, and this is done by the function
7008 @code{org-publish-org-to-html} which calls the HTML exporter
7009 (@pxref{HTML export}). But you also can publish your files in La@TeX{} by
7010 using the function @code{org-publish-org-to-latex} instead. Other files
7011 like images only need to be copied to the publishing destination. For
7012 non-Org-mode files, you need to specify the publishing function.
7015 @multitable @columnfractions 0.3 0.7
7016 @item @code{:publishing-function}
7017 @tab Function executing the publication of a file.  This may also be a
7018 list of functions, which will all be called in turn.
7019 @end multitable
7021 The function must accept two arguments: a property list containing at
7022 least a @code{:publishing-directory} property, and the name of the file
7023 to be published.  It should take the specified file, make the necessary
7024 transformation (if any) and place the result into the destination folder.
7025 You can write your own publishing function, but @code{org-publish}
7026 provides one for attachments (files that only need to be copied):
7027 @code{org-publish-attachment}.
7029 @node Publishing options, Publishing links, Publishing action, Configuration
7030 @subsection Options for the HTML/LaTeX exporters
7031 @cindex options, for publishing
7033 The property list can be used to set many export options for the HTML
7034 and La@TeX{} exporters.  In most cases, these properties correspond to user
7035 variables in Org-mode.  The table below lists these properties along
7036 with the variable they belong to.  See the documentation string for the
7037 respective variable for details.
7039 @multitable @columnfractions 0.3 0.7
7040 @item @code{:language}              @tab @code{org-export-default-language}
7041 @item @code{:headline-levels}       @tab @code{org-export-headline-levels}
7042 @item @code{:section-numbers}       @tab @code{org-export-with-section-numbers}
7043 @item @code{:table-of-contents}     @tab @code{org-export-with-toc}
7044 @item @code{:archived-trees}        @tab @code{org-export-with-archived-trees}
7045 @item @code{:emphasize}             @tab @code{org-export-with-emphasize}
7046 @item @code{:sub-superscript}       @tab @code{org-export-with-sub-superscripts}
7047 @item @code{:special-strings}       @tab @code{org-export-with-special-strings}
7048 @item @code{:TeX-macros}            @tab @code{org-export-with-TeX-macros}
7049 @item @code{:LaTeX-fragments}       @tab @code{org-export-with-LaTeX-fragments}
7050 @item @code{:fixed-width}           @tab @code{org-export-with-fixed-width}
7051 @item @code{:timestamps}           .@tab @code{org-export-with-timestamps}
7052 @item @code{:tags}                 .@tab @code{org-export-with-tags}
7053 @item @code{:tables}                @tab @code{org-export-with-tables}
7054 @item @code{:table-auto-headline}   @tab @code{org-export-highlight-first-table-line}
7055 @item @code{:style}                 @tab @code{org-export-html-style}
7056 @item @code{:convert-org-links}     @tab @code{org-export-html-link-org-files-as-html}
7057 @item @code{:inline-images}         @tab @code{org-export-html-inline-images}
7058 @item @code{:expand-quoted-html}    @tab @code{org-export-html-expand}
7059 @item @code{:timestamp}             @tab @code{org-export-html-with-timestamp}
7060 @item @code{:publishing-directory}  @tab @code{org-export-publishing-directory}
7061 @item @code{:preamble}              @tab @code{org-export-html-preamble}
7062 @item @code{:postamble}             @tab @code{org-export-html-postamble}
7063 @item @code{:auto-preamble}         @tab @code{org-export-html-auto-preamble}
7064 @item @code{:auto-postamble}        @tab @code{org-export-html-auto-postamble}
7065 @item @code{:author}                @tab @code{user-full-name}
7066 @item @code{:email}                 @tab @code{user-mail-address}
7067 @end multitable
7069 If you use several email addresses, separate them by a semi-column.
7071 Most of the @code{org-export-with-*} variables have the same effect in
7072 both HTML and La@TeX{} exporters, except for @code{:TeX-macros} and
7073 @code{:LaTeX-fragments}, respectively @code{nil} and @code{t} in the
7074 La@TeX{} export.
7076 When a property is given a value in @code{org-publish-project-alist},
7077 its setting overrides the value of the corresponding user variable (if
7078 any) during publishing.  Options set within a file (@pxref{Export
7079 options}), however, override everything.
7081 @node Publishing links, Project page index, Publishing options, Configuration
7082 @subsection Links between published files
7083 @cindex links, publishing
7085 To create a link from one Org-mode file to another, you would use
7086 something like @samp{[[file:foo.org][The foo]]} or simply
7087 @samp{file:foo.org.} (@pxref{Hyperlinks}).  Upon publishing this link
7088 becomes a link to @file{foo.html}.  In this way, you can interlink the
7089 pages of your "org web" project and the links will work as expected when
7090 you publish them to HTML.
7092 You may also link to related files, such as images. Provided you are
7093 careful with relative pathnames, and provided you have also configured
7094 @code{org-publish} to upload the related files, these links will work
7095 too. @ref{Complex example} for an example of this usage.
7097 Sometime an Org-mode file to be published may contain links that are
7098 only valid in your production environment, but not in the publishing
7099 location.  In this case, use the property 
7101 @multitable @columnfractions 0.4 0.6
7102 @item @code{:link-validation-function}
7103 @tab Function to validate links
7104 @end multitable
7106 @noindent
7107 to define a function for checking link validity.  This function must
7108 accept two arguments, the file name and a directory relative to which
7109 the file name is interpreted in the production environment.  If this
7110 function returns @code{nil}, then the HTML generator will only insert a
7111 description into the HTML file, but no link.  One option for this
7112 function is @code{org-publish-validate-link} which checks if the given
7113 file is part of any project in @code{org-publish-project-alist}.
7115 @node Project page index,  , Publishing links, Configuration
7116 @subsection Project page index
7117 @cindex index, of published pages
7119 The following properties may be used to control publishing of an
7120 index of files or summary page for a given project.
7122 @multitable @columnfractions 0.25 0.75
7123 @item @code{:auto-index}
7124 @tab When non-nil, publish an index during org-publish-current-project or
7125 org-publish-all.
7127 @item @code{:index-filename}
7128 @tab Filename for output of index. Defaults to @file{index.org} (which
7129 becomes @file{index.html}).
7131 @item @code{:index-title}
7132 @tab Title of index page. Defaults to name of file.
7134 @item @code{:index-function}
7135 @tab Plugin function to use for generation of index.
7136 Defaults to @code{org-publish-org-index}, which generates a plain list
7137 of links to all files in the project.
7138 @end multitable
7140 @node Sample configuration, Triggering publication, Configuration, Publishing
7141 @section Sample configuration
7143 Below we provide two example configurations.  The first one is a simple
7144 project publishing only a set of Org-mode files.  The second example is
7145 more complex, with a multi-component project.
7147 @menu
7148 * Simple example::              One-component publishing
7149 * Complex example::             A multi-component publishing example
7150 @end menu
7152 @node Simple example, Complex example, Sample configuration, Sample configuration
7153 @subsection Example: simple publishing configuration
7155 This example publishes a set of Org-mode files to the @file{public_html}
7156 directory on the local machine.
7158 @lisp
7159 (setq org-publish-project-alist
7160       '(("org" 
7161          :base-directory "~/org/"
7162          :publishing-directory "~/public_html"
7163          :section-numbers nil
7164          :table-of-contents nil
7165          :style "<link rel=stylesheet 
7166                 href=\"../other/mystyle.css\"
7167                 type=\"text/css\">")))
7168 @end lisp
7170 @node Complex example,  , Simple example, Sample configuration
7171 @subsection Example: complex publishing configuration
7173 This more complicated example publishes an entire website, including
7174 org files converted to HTML, image files, emacs lisp source code, and
7175 stylesheets. The publishing-directory is remote and private files are
7176 excluded.
7178 To ensure that links are preserved, care should be taken to replicate
7179 your directory structure on the web server, and to use relative file
7180 paths. For example, if your org files are kept in @file{~/org} and your
7181 publishable images in @file{~/images}, you'd link to an image with
7183 @example
7184 file:../images/myimage.png
7185 @end example
7187 On the web server, the relative path to the image should be the
7188 same. You can accomplish this by setting up an "images" folder in the
7189 right place on the webserver, and publishing images to it.
7191 @lisp
7192 (setq org-publish-project-alist
7193       '(("orgfiles"
7194           :base-directory "~/org/"
7195           :base-extension "org"
7196           :publishing-directory "/ssh:user@@host:~/html/notebook/"
7197           :publishing-function org-publish-org-to-html
7198           :exclude "PrivatePage.org"   ;; regexp
7199           :headline-levels 3
7200           :section-numbers nil
7201           :table-of-contents nil
7202           :style "<link rel=stylesheet 
7203                   href=\"../other/mystyle.css\" type=\"text/css\">"
7204           :auto-preamble t
7205           :auto-postamble nil)
7206          
7207          ("images"
7208           :base-directory "~/images/"
7209           :base-extension "jpg\\|gif\\|png"
7210           :publishing-directory "/ssh:user@@host:~/html/images/"
7211           :publishing-function org-publish-attachment)
7213          ("other"
7214           :base-directory "~/other/"
7215           :base-extension "css\\|el"
7216           :publishing-directory "/ssh:user@@host:~/html/other/"
7217           :publishing-function org-publish-attachment)
7218          ("website" :components ("orgfiles" "images" "other"))))
7219 @end lisp
7221 @node Triggering publication,  , Sample configuration, Publishing
7222 @section Triggering publication
7224 Once org-publish is properly configured, you can publish with the
7225 following functions: 
7227 @table @kbd
7228 @item C-c C-e C
7229 Prompt for a specific project and publish all files that belong to it.
7230 @item C-c C-e P
7231 Publish the project containing the current file.
7232 @item C-c C-e F
7233 Publish only the current file.
7234 @item C-c C-e A
7235 Publish all projects.
7236 @end table
7238 Org uses timestamps to track when a file has changed. The above
7239 functions normally only publish changed files. You can override this and
7240 force publishing of all files by giving a prefix argument.
7242 @node Miscellaneous, Extensions and Hacking, Publishing, Top
7243 @chapter Miscellaneous
7245 @menu
7246 * Completion::                  M-TAB knows what you need
7247 * Customization::               Adapting Org-mode to your taste
7248 * In-buffer settings::          Overview of the #+KEYWORDS
7249 * The very busy C-c C-c key::   When in doubt, press C-c C-c
7250 * Clean view::                  Getting rid of leading stars in the outline
7251 * TTY keys::                    Using Org-mode on a tty
7252 * Interaction::                 Other Emacs packages
7253 * Bugs::                        Things which do not work perfectly
7254 @end menu
7256 @node Completion, Customization, Miscellaneous, Miscellaneous
7257 @section Completion
7258 @cindex completion, of @TeX{} symbols
7259 @cindex completion, of TODO keywords
7260 @cindex completion, of dictionary words
7261 @cindex completion, of option keywords
7262 @cindex completion, of tags
7263 @cindex completion, of property keys
7264 @cindex completion, of link abbreviations
7265 @cindex @TeX{} symbol completion
7266 @cindex TODO keywords completion
7267 @cindex dictionary word completion
7268 @cindex option keyword completion
7269 @cindex tag completion
7270 @cindex link abbreviations, completion of
7272 Org-mode supports in-buffer completion.  This type of completion does
7273 not make use of the minibuffer.  You simply type a few letters into
7274 the buffer and use the key to complete text right there.
7276 @table @kbd
7277 @kindex M-@key{TAB}
7278 @item M-@key{TAB}
7279 Complete word at point
7280 @itemize @bullet
7281 @item
7282 At the beginning of a headline, complete TODO keywords.
7283 @item
7284 After @samp{\}, complete @TeX{} symbols supported by the exporter.
7285 @item
7286 After @samp{*}, complete headlines in the current buffer so that they
7287 can be used in search links like @samp{[[*find this headline]]}.
7288 @item
7289 After @samp{:} in a headline, complete tags.  The list of tags is taken
7290 from the variable @code{org-tag-alist} (possibly set through the
7291 @samp{#+TAGS} in-buffer option, @pxref{Setting tags}), or it is created
7292 dynamically from all tags used in the current buffer.
7293 @item
7294 After @samp{:} and not in a headline, complete property keys.  The list
7295 of keys is constructed dynamically from all keys used in the current
7296 buffer.
7297 @item
7298 After @samp{[}, complete link abbreviations (@pxref{Link abbreviations}).
7299 @item
7300 After @samp{#+}, complete the special keywords like @samp{TYP_TODO} or
7301 @samp{OPTIONS} which set file-specific options for Org-mode.  When the
7302 option keyword is already complete, pressing @kbd{M-@key{TAB}} again
7303 will insert example settings for this keyword.
7304 @item
7305 In the line after @samp{#+STARTUP: }, complete startup keywords,
7306 i.e. valid keys for this line.
7307 @item
7308 Elsewhere, complete dictionary words using ispell.
7309 @end itemize
7310 @end table
7312 @node Customization, In-buffer settings, Completion, Miscellaneous
7313 @section Customization
7314 @cindex customization
7315 @cindex options, for customization
7316 @cindex variables, for customization
7318 There are more than 180 variables that can be used to customize
7319 Org-mode.  For the sake of compactness of the manual, I am not
7320 describing the variables here.  A structured overview of customization
7321 variables is available with @kbd{M-x org-customize}.  Or select
7322 @code{Browse Org Group} from the @code{Org->Customization} menu.  Many
7323 settings can also be activated on a per-file basis, by putting special
7324 lines into the buffer (@pxref{In-buffer settings}).
7326 @node In-buffer settings, The very busy C-c C-c key, Customization, Miscellaneous
7327 @section Summary of in-buffer settings
7328 @cindex in-buffer settings
7329 @cindex special keywords
7331 Org-mode uses special lines in the buffer to define settings on a
7332 per-file basis.  These lines start with a @samp{#+} followed by a
7333 keyword, a colon, and then individual words defining a setting.  Several
7334 setting words can be in the same line, but you can also have multiple
7335 lines for the keyword.  While these settings are described throughout
7336 the manual, here is a summary.  After changing any of those lines in the
7337 buffer, press @kbd{C-c C-c} with the cursor still in the line to
7338 activate the changes immediately.  Otherwise they become effective only
7339 when the file is visited again in a new Emacs session.
7341 @table @kbd
7342 @item #+ARCHIVE: %s_done::
7343 This line sets the archive location for the agenda file.  It applies for
7344 all subsequent lines until the next @samp{#+ARCHIVE} line, or the end
7345 of the file.  The first such line also applies to any entries before it.
7346 The corresponding variable is @code{org-archive-location}.
7347 @item #+CATEGORY:
7348 This line sets the category for the agenda file.  The category applies
7349 for all subsequent lines until the next @samp{#+CATEGORY} line, or the
7350 end of the file.  The first such line also applies to any entries before it.
7351 @item #+COLUMNS: %25ITEM .....
7352 Set the default format for columns view.  This format applies when
7353 columns view is invoked in location where no @code{COLUMNS} property
7354 applies.
7355 @item #+CONSTANTS: name1=value1 ...
7356 Set file-local values for constants to be used in table formulas.  This
7357 line set the local variable @code{org-table-formula-constants-local}.
7358 The global version of this variable is
7359 @code{org-table-formula-constants}.
7360 @item #+DRAWERS: NAME1 .....
7361 Set the file-local set of drawers.  The corresponding global variable is
7362 @code{org-drawers}.
7363 @item #+LINK:  linkword replace
7364 These lines (several are allowed) specify link abbreviations.
7365 @xref{Link abbreviations}.  The corresponding variable is
7366 @code{org-link-abbrev-alist}.
7367 @item #+PRIORITIES: highest lowest default
7368 This line sets the limits and the default for the priorities.  All three
7369 must be either letters A-Z or numbers 0-9.  The highest priority must
7370 have a lower ASCII number that the lowest priority.
7371 @item #+PROPERTY: Property_Name Value
7372 This line sets a default inheritance value for entries in the current
7373 buffer, most useful for specifying the allowed values of a property.
7374 @item #+STARTUP:
7375 This line sets options to be used at startup of Org-mode, when an
7376 Org-mode file is being visited.  The first set of options deals with the
7377 initial visibility of the outline tree.  The corresponding variable for
7378 global default settings is @code{org-startup-folded}, with a default
7379 value @code{t}, which means @code{overview}.
7380 @cindex @code{overview}, STARTUP keyword
7381 @cindex @code{content}, STARTUP keyword
7382 @cindex @code{showall}, STARTUP keyword
7383 @example
7384 overview   @r{top-level headlines only}
7385 content    @r{all headlines}
7386 showall    @r{no folding at all, show everything}
7387 @end example
7388 Then there are options for aligning tables upon visiting a file.  This
7389 is useful in files containing narrowed table columns.  The corresponding
7390 variable is @code{org-startup-align-all-tables}, with a default value
7391 @code{nil}. 
7392 @cindex @code{align}, STARTUP keyword
7393 @cindex @code{noalign}, STARTUP keyword
7394 @example
7395 align      @r{align all tables}
7396 noalign    @r{don't align tables on startup}
7397 @end example
7398 Logging closing and reinstating TODO items, and clock intervals
7399 (variables @code{org-log-done}, @code{org-log-note-clock-out}, and
7400 @code{org-log-repeat}) can be configured using these options.
7401 @cindex @code{logdone}, STARTUP keyword
7402 @cindex @code{lognotedone}, STARTUP keyword
7403 @cindex @code{nologdone}, STARTUP keyword
7404 @cindex @code{lognoteclock-out}, STARTUP keyword
7405 @cindex @code{nolognoteclock-out}, STARTUP keyword
7406 @cindex @code{logrepeat}, STARTUP keyword
7407 @cindex @code{lognoterepeat}, STARTUP keyword
7408 @cindex @code{nologrepeat}, STARTUP keyword
7409 @example
7410 logdone            @r{record a timestamp when an item is marked DONE}
7411 lognotedone        @r{record timestamp and a note when DONE}
7412 nologdone          @r{don't record when items are marked DONE}
7413 logrepeat          @r{record a time when reinstating a repeating item}
7414 lognoterepeat      @r{record a note when reinstating a repeating item}
7415 nologrepeat        @r{do not record when reinstating repeating item}
7416 lognoteclock-out   @r{record a note when clocking out}
7417 nolognoteclock-out @r{don't record a note when clocking out}
7418 @end example
7419 Here are the options for hiding leading stars in outline headings.  The
7420 corresponding variables are @code{org-hide-leading-stars} and
7421 @code{org-odd-levels-only}, both with a default setting @code{nil}
7422 (meaning @code{showstars} and @code{oddeven}).
7423 @cindex @code{hidestars}, STARTUP keyword
7424 @cindex @code{showstars}, STARTUP keyword
7425 @cindex @code{odd}, STARTUP keyword
7426 @cindex @code{even}, STARTUP keyword
7427 @example
7428 hidestars  @r{make all but one of the stars starting a headline invisible.}
7429 showstars  @r{show all stars starting a headline}
7430 odd        @r{allow only odd outline levels (1,3,...)}
7431 oddeven    @r{allow all outline levels}
7432 @end example
7433 To turn on custom format overlays over time stamps (variables
7434 @code{org-put-time-stamp-overlays} and
7435 @code{org-time-stamp-overlay-formats}), use
7436 @cindex @code{customtime}, STARTUP keyword
7437 @example
7438 customtime @r{overlay custom time format}
7439 @end example
7440 The following options influence the table spreadsheet (variable
7441 @code{constants-unit-system}).
7442 @cindex @code{constcgs}, STARTUP keyword
7443 @cindex @code{constSI}, STARTUP keyword
7444 @example
7445 constcgs   @r{@file{constants.el} should use the c-g-s unit system}
7446 constSI    @r{@file{constants.el} should use the SI unit system}
7447 @end example
7448 @item #+TAGS:  TAG1(c1) TAG2(c2)
7449 These lines (several such lines are allowed) specify the valid tags in
7450 this file, and (potentially) the corresponding @emph{fast tag selection}
7451 keys.  The corresponding variable is @code{org-tag-alist}.
7452 @item #+TBLFM:
7453 This line contains the formulas for the table directly above the line.
7454 @item #+TITLE:, #+AUTHOR:, #+EMAIL:, #+LANGUAGE:, #+TEXT:, #+OPTIONS, #+DATE:
7455 These lines provide settings for exporting files.  For more details see
7456 @ref{Export options}.
7457 @item #+SEQ_TODO:   #+TYP_TODO:
7458 These lines set the TODO keywords and their interpretation in the
7459 current file.  The corresponding variables are @code{org-todo-keywords}
7460 and @code{org-todo-interpretation}.
7461 @end table
7463 @node The very busy C-c C-c key, Clean view, In-buffer settings, Miscellaneous
7464 @section The very busy C-c C-c key
7465 @kindex C-c C-c
7466 @cindex C-c C-c, overview
7468 The key @kbd{C-c C-c} has many purposes in org-mode, which are all
7469 mentioned scattered throughout this manual.  One specific function of
7470 this key is to add @emph{tags} to a headline (@pxref{Tags}).  In many
7471 other circumstances it means something like @emph{Hey Org-mode, look
7472 here and update according to what you see here}.  Here is a summary of
7473 what this means in different contexts.
7475 @itemize @minus
7476 @item
7477 If there are highlights in the buffer from the creation of a sparse
7478 tree, or from clock display, remove these highlights.
7479 @item
7480 If the cursor is in one of the special @code{#+KEYWORD} lines, this
7481 triggers scanning the buffer for these lines and updating the
7482 information. 
7483 @item
7484 If the cursor is inside a table, realign the table.  This command
7485 works even if the automatic table editor has been turned off.
7486 @item
7487 If the cursor is on a @code{#+TBLFM} line, re-apply the formulas to
7488 the entire table.
7489 @item
7490 If the cursor is inside a table created by the @file{table.el} package,
7491 activate that table.
7492 @item
7493 If the current buffer is a remember buffer, close the note and file it.
7494 With a prefix argument, file it, without further interaction, to the
7495 default location.
7496 @item
7497 If the cursor is on a @code{<<<target>>>}, update radio targets and
7498 corresponding links in this buffer.
7499 @item
7500 If the cursor is in a property line or at the start or end of a property
7501 drawer, offer property commands.
7502 @item
7503 If the cursor is in a plain list item with a checkbox, toggle the status
7504 of the checkbox.
7505 @item
7506 If the cursor is on a numbered item in a plain list, renumber the
7507 ordered list.
7508 @item
7509 If the cursor is on the @code{#+BEGIN} line of a dynamical block, the
7510 block is updated.
7511 @end itemize
7513 @node Clean view, TTY keys, The very busy C-c C-c key, Miscellaneous
7514 @section A cleaner outline view
7515 @cindex hiding leading stars
7516 @cindex clean outline view
7518 Some people find it noisy and distracting that the Org-mode headlines
7519 are starting with a potentially large number of stars.  For example
7520 the tree from @ref{Headlines}:
7522 @example
7523 * Top level headline
7524 ** Second level
7525 *** 3rd level
7526     some text
7527 *** 3rd level
7528     more text
7529 * Another top level headline
7530 @end example
7532 @noindent
7533 Unfortunately this is deeply ingrained into the code of Org-mode and
7534 cannot be easily changed.  You can, however, modify the display in such
7535 a way that all leading stars become invisible and the outline more easy
7536 to read.  To do this, customize the variable
7537 @code{org-hide-leading-stars} like this:
7539 @lisp
7540 (setq org-hide-leading-stars t)
7541 @end lisp
7543 @noindent
7544 or change this on a per-file basis with one of the lines (anywhere in
7545 the buffer)
7547 @example
7548 #+STARTUP: showstars
7549 #+STARTUP: hidestars
7550 @end example
7552 @noindent
7553 Press @kbd{C-c C-c} with the cursor in a @samp{STARTUP} line to activate
7554 the modifications.
7556 With stars hidden, the tree becomes:
7558 @example
7559 * Top level headline
7560  * Second level
7561   * 3rd level
7562     some text
7563   * 3rd level
7564     more text
7565 * Another top level headline
7566 @end example
7568 @noindent
7569 Note that the leading stars are not truly replaced by whitespace, they
7570 are only fontified with the face @code{org-hide} that uses the
7571 background color as font color.  If you are not using either white or
7572 black background, you may have to customize this face to get the wanted
7573 effect.  Another possibility is to set this font such that the extra
7574 stars are @i{almost} invisible, for example using the color
7575 @code{grey90} on a white background.
7577 Things become cleaner still if you skip all the even levels and use only
7578 odd levels 1, 3, 5..., effectively adding two stars to go from one
7579 outline level to the next:
7581 @example
7582 * Top level headline
7583   * Second level
7584     * 3rd level
7585       some text
7586     * 3rd level
7587       more text
7588 * Another top level headline
7589 @end example
7591 @noindent
7592 In order to make the structure editing and export commands handle this
7593 convention correctly, use
7595 @lisp
7596 (setq org-odd-levels-only t)
7597 @end lisp
7599 @noindent
7600 or set this on a per-file basis with one of the following lines (don't
7601 forget to press @kbd{C-c C-c} with the cursor in the startup line to
7602 activate changes immediately).
7604 @example
7605 #+STARTUP: odd
7606 #+STARTUP: oddeven
7607 @end example
7609 You can convert an Org-mode file from single-star-per-level to the
7610 double-star-per-level convention with @kbd{M-x org-convert-to-odd-levels
7611 RET} in that file.  The reverse operation is @kbd{M-x
7612 org-convert-to-oddeven-levels}.
7614 @node TTY keys, Interaction, Clean view, Miscellaneous
7615 @section Using org-mode on a tty
7616 @cindex tty keybindings
7618 Because Org-mode contains a large number of commands, by default much of
7619 Org-mode's core commands are bound to keys that are generally not
7620 accessible on a tty, such as the cursor keys (@key{left}, @key{right},
7621 @key{up}, @key{down}), @key{TAB} and @key{RET}, in particular when used
7622 together with modifiers like @key{Meta} and/or @key{Shift}.  To access
7623 these commands on a tty when special keys are unavailable, the following
7624 alternative bindings can be used.  The tty bindings below will likely be
7625 more cumbersome; you may find for some of the bindings below that a
7626 customized work-around suits you better.  For example, changing a time
7627 stamp is really only fun with @kbd{S-@key{cursor}} keys, whereas on a
7628 tty you would rather use @kbd{C-c .} to re-insert the timestamp.
7630 @multitable @columnfractions 0.15 0.2 0.2
7631 @item @b{Default} @tab @b{Alternative 1} @tab @b{Alternative 2}
7632 @item @kbd{S-@key{TAB}}     @tab @kbd{C-u @key{TAB}}       @tab
7633 @item @kbd{M-@key{left}}    @tab @kbd{C-c C-x l}           @tab @kbd{@key{Esc} @key{left}}
7634 @item @kbd{M-S-@key{left}}  @tab @kbd{C-c C-x L}           @tab
7635 @item @kbd{M-@key{right}}   @tab @kbd{C-c C-x r}           @tab @kbd{@key{Esc} @key{right}}
7636 @item @kbd{M-S-@key{right}} @tab @kbd{C-c C-x R}           @tab
7637 @item @kbd{M-@key{up}}      @tab @kbd{C-c C-x u}           @tab @kbd{@key{Esc} @key{up}}
7638 @item @kbd{M-S-@key{up}}    @tab @kbd{C-c C-x U}           @tab
7639 @item @kbd{M-@key{down}}    @tab @kbd{C-c C-x d}           @tab @kbd{@key{Esc} @key{down}}
7640 @item @kbd{M-S-@key{down}}  @tab @kbd{C-c C-x D}           @tab
7641 @item @kbd{S-@key{RET}}     @tab @kbd{C-c C-x c}           @tab
7642 @item @kbd{M-@key{RET}}     @tab @kbd{C-c C-x m}           @tab @kbd{@key{Esc} @key{RET}}
7643 @item @kbd{M-S-@key{RET}}   @tab @kbd{C-c C-x M}           @tab
7644 @item @kbd{S-@key{left}}    @tab @kbd{C-c @key{left}}      @tab
7645 @item @kbd{S-@key{right}}   @tab @kbd{C-c @key{right}}     @tab
7646 @item @kbd{S-@key{up}}      @tab @kbd{C-c @key{up}}        @tab
7647 @item @kbd{S-@key{down}}    @tab @kbd{C-c @key{down}}      @tab
7648 @item @kbd{C-S-@key{left}}  @tab @kbd{C-c C-x @key{left}}  @tab
7649 @item @kbd{C-S-@key{right}} @tab @kbd{C-c C-x @key{right}} @tab
7650 @end multitable
7652 @node Interaction, Bugs, TTY keys, Miscellaneous
7653 @section Interaction with other packages
7654 @cindex packages, interaction with other
7655 Org-mode lives in the world of GNU Emacs and interacts in various ways
7656 with other code out there.
7658 @menu
7659 * Cooperation::                 Packages Org-mode cooperates with
7660 * Conflicts::                   Packages that lead to conflicts
7661 @end menu
7663 @node Cooperation, Conflicts, Interaction, Interaction
7664 @subsection Packages that Org-mode cooperates with
7666 @table @asis
7667 @cindex @file{calc.el}
7668 @item @file{calc.el} by Dave Gillespie
7669 Org-mode uses the calc package for implementing spreadsheet
7670 functionality in its tables (@pxref{The spreadsheet}).  Org-mode
7671 checks for the availability of calc by looking for the function
7672 @code{calc-eval} which should be autoloaded in your setup if calc has
7673 been installed properly.  As of Emacs 22, calc is part of the Emacs
7674 distribution.  Another possibility for interaction between the two
7675 packages is using calc for embedded calculations. @xref{Embedded Mode,
7676 , Embedded Mode, calc, GNU Emacs Calc Manual}.
7677 @cindex @file{constants.el}
7678 @item @file{constants.el} by Carsten Dominik
7679 In a table formula (@pxref{The spreadsheet}), it is possible to use
7680 names for natural constants or units.  Instead of defining your own
7681 constants in the variable @code{org-table-formula-constants}, install
7682 the @file{constants} package which defines a large number of constants
7683 and units, and lets you use unit prefixes like @samp{M} for
7684 @samp{Mega} etc.  You will need version 2.0 of this package, available
7685 at @url{http://www.astro.uva.nl/~dominik/Tools}. Org-mode checks for
7686 the function @code{constants-get}, which has to be autoloaded in your
7687 setup.  See the installation instructions in the file
7688 @file{constants.el}.
7689 @item @file{cdlatex.el} by Carsten Dominik
7690 @cindex @file{cdlatex.el}
7691 Org-mode can make use of the cdlatex package to efficiently enter
7692 La@TeX{} fragments into Org-mode files. See @ref{CDLaTeX mode}.
7693 @item @file{imenu.el} by Ake Stenhoff and Lars Lindberg
7694 @cindex @file{imenu.el}
7695 Imenu allows menu access to an index of items in a file.  Org-mode
7696 supports imenu - all you need to do to get the index is the following:
7697 @lisp
7698 (add-hook 'org-mode-hook 
7699           (lambda () 'imenu-add-to-menubar "Imenu"))
7700 @end lisp
7701 By default the index is two levels deep - you can modify the depth using
7702 the option @code{org-imenu-depth}.
7703 @item @file{remember.el} by John Wiegley
7704 @cindex @file{remember.el}
7705 Org mode cooperates with remember, see @ref{Remember}.
7706 @file{Remember.el} is not part of Emacs, find it on the web.
7707 @item @file{speedbar.el} by Eric M. Ludlam
7708 @cindex @file{speedbar.el}
7709 Speedbar is a package that creates a special frame displaying files and
7710 index items in files.  Org-mode supports speedbar and allows you to
7711 drill into Org-mode files directly from the speedbar.  It also allows to
7712 restrict the scope of agenda commands to a file or a subtree by using
7713 the command @kbd{<} in the speedbar frame.
7714 @cindex @file{table.el}
7715 @item @file{table.el} by Takaaki Ota
7716 @kindex C-c C-c
7717 @cindex table editor, @file{table.el}
7718 @cindex @file{table.el}
7720 Complex ASCII tables with automatic line wrapping, column- and
7721 row-spanning, and alignment can be created using the Emacs table
7722 package by Takaaki Ota (@uref{http://sourceforge.net/projects/table},
7723 and also part of Emacs 22).
7724 When @key{TAB} or @kbd{C-c C-c} is pressed in such a table, Org-mode
7725 will call @command{table-recognize-table} and move the cursor into the
7726 table.  Inside a table, the keymap of Org-mode is inactive.  In order
7727 to execute Org-mode-related commands, leave the table.
7729 @table @kbd
7730 @kindex C-c C-c
7731 @item C-c C-c
7732 Recognize @file{table.el} table.  Works when the cursor is in a
7733 table.el table.
7735 @kindex C-c ~
7736 @item C-c ~
7737 Insert a table.el table.  If there is already a table at point, this
7738 command converts it between the table.el format and the Org-mode
7739 format.  See the documentation string of the command
7740 @code{org-convert-table} for the restrictions under which this is
7741 possible.
7742 @end table
7743 @file{table.el} is part of Emacs 22.
7744 @cindex @file{footnote.el}
7745 @item @file{footnote.el} by Steven L. Baur
7746 Org-mode recognizes numerical footnotes as provided by this package
7747 (@pxref{Footnotes}).
7748 @end table
7750 @node Conflicts,  , Cooperation, Interaction
7751 @subsection Packages that lead to conflicts with Org-mode
7753 @table @asis
7755 @cindex @file{allout.el}
7756 @item @file{allout.el} by Ken Manheimer
7757 Startup of Org-mode may fail with the error message
7758 @code{(wrong-type-argument keymapp nil)} when there is an outdated
7759 version @file{allout.el} on the load path, for example the version
7760 distributed with Emacs 21.x.  Upgrade to Emacs 22 and this problem will
7761 disappear.  If for some reason you cannot do this, make sure that org.el
7762 is loaded @emph{before} @file{allout.el}, for example by putting
7763 @code{(require 'org)} early enough into your @file{.emacs} file.
7765 @cindex @file{CUA.el}
7766 @item @file{CUA.el} by Kim. F. Storm
7767 Keybindings in Org-mode conflict with the @kbd{S-<cursor>} keys used by
7768 CUA-mode (as well as pc-select-mode and s-region-mode) to select and
7769 extend the region.  If you want to use one of these packages along with
7770 Org-mode, configure the variable @code{org-replace-disputed-keys}.  When
7771 set, Org-mode will move the following keybindings in Org-mode files, and
7772 in the agenda buffer (but not during date selection).
7774 @example
7775 S-UP    -> M-p             S-DOWN  -> M-n
7776 S-LEFT  -> M--             S-RIGHT -> M-+
7777 @end example
7779 Yes, these are unfortunately more difficult to remember.  If you want
7780 to have other replacement keys, look at the variable
7781 @code{org-disputed-keys}.
7782 @item @file{windmove.el} by Hovav Shacham
7783 @cindex @file{windmove.el}
7784 Also this package uses the @kbd{S-<cursor>} keys, so everything written
7785 in the paragraph above about CUA mode also applies here.
7787 @cindex @file{footnote.el}
7788 @item @file{footnote.el} by Steven L. Baur
7789 Org-mode supports the syntax of the footnote package, but only the
7790 numerical footnote markers.  Also, the default key for footnote
7791 commands, @kbd{C-c !} is already used by Org-mode.  You could use the
7792 variable @code{footnote-prefix} to switch footnotes commands to another
7793 key.  Or, you could use @code{org-replace-disputed-keys} and
7794 @code{org-disputed-keys} to change the settings in Org-mode.
7796 @end table
7799 @node Bugs,  , Interaction, Miscellaneous
7800 @section Bugs
7801 @cindex bugs
7803 Here is a list of things that should work differently, but which I
7804 have found too hard to fix.
7806 @itemize @bullet
7807 @item
7808 If a table field starts with a link, and if the corresponding table
7809 column is narrowed (@pxref{Narrow columns}) to a width too small to
7810 display the link, the field would look entirely empty even though it is
7811 not.  To prevent this, Org-mode throws an error.  The work-around is to
7812 make the column wide enough to fit the link, or to add some text (at
7813 least 2 characters) before the link in the same field.
7814 @item
7815 Narrowing table columns does not work on XEmacs, because the
7816 @code{format} function does not transport text properties.
7817 @item
7818 Text in an entry protected with the @samp{QUOTE} keyword should not
7819 autowrap.
7820 @item
7821 When the application called by @kbd{C-c C-o} to open a file link fails
7822 (for example because the application does not exist or refuses to open
7823 the file), it does so silently.  No error message is displayed.
7824 @item
7825 Recalculating a table line applies the formulas from left to right.
7826 If a formula uses @emph{calculated} fields further down the row,
7827 multiple recalculation may be needed to get all fields consistent.  You
7828 may use the command @code{org-table-iterate} (@kbd{C-u C-c *}) to
7829 recalculate until convergence.
7830 @item
7831 A single letter cannot be made bold, for example @samp{*a*}.
7832 @item
7833 The exporters work well, but could be made more efficient.
7834 @end itemize
7837 @node Extensions and Hacking, History and Acknowledgments, Miscellaneous, Top
7838 @appendix Extensions, Hooks and Hacking
7840 This appendix lists extensions for Org-mode written by other authors.
7841 It also covers some aspects where users can extend the functionality of
7842 Org-mode.
7844 @menu
7845 * Extensions::                  Existing 3rd-part extensions
7846 * Adding hyperlink types::      New custom link types
7847 * Tables in arbitrary syntax::  Orgtbl for LaTeX and other programs
7848 * Dynamic blocks::              Automatically filled blocks
7849 * Special agenda views::        Customized views
7850 * Using the property API::      Writing programs that use entry properties
7851 @end menu
7853 @node Extensions, Adding hyperlink types, Extensions and Hacking, Extensions and Hacking
7854 @section Third-party extensions for Org-mode
7855 @cindex extension, third-party
7857 The following extensions for Org-mode have been written by other people:
7859 @table @asis
7860 @cindex @file{org-publish.el}
7861 @item @file{org-publish.el} by David O'Toole
7862 This package provides facilities for publishing related sets of Org-mode
7863 files together with linked files like images as webpages.  It is
7864 highly configurable and can be used for other publishing purposes as
7865 well.  As of Org-mode version 4.30, @file{org-publish.el} is part of the
7866 Org-mode distribution.  It is not yet part of Emacs, however, a delay
7867 caused by the preparations for the 22.1 release.  In the mean time,
7868 @file{org-publish.el} can be downloaded from David's site:
7869 @url{http://dto.freeshell.org/e/org-publish.el}.
7870 @cindex @file{org-mouse.el}
7871 @item @file{org-mouse.el} by Piotr Zielinski
7872 This package implements extended mouse functionality for Org-mode.  It
7873 allows you to cycle visibility and to edit the document structure with
7874 the mouse.  Best of all, it provides a context-sensitive menu on
7875 @key{mouse-3} that changes depending on the context of a mouse-click.
7876 As of Org-mode version 4.53, @file{org-mouse.el} is part of the
7877 Org-mode distribution.  It is not yet part of Emacs, however, a delay
7878 caused by the preparations for the 22.1 release.  In the mean time,
7879 @file{org-mouse.el} can be downloaded from Piotr's site:
7880 @url{http://www.cl.cam.ac.uk/~pz215/files/org-mouse.el}.
7881 @cindex @file{org-blog.el}
7882 @item @file{org-blog.el} by David O'Toole
7883 A blogging plug-in for @file{org-publish.el}.@*
7884 @url{http://dto.freeshell.org/notebook/OrgMode.html}.
7885 @cindex @file{blorg.el}
7886 @item @file{blorg.el} by Bastien Guerry
7887 Publish Org-mode files as
7888 blogs. @url{http://www.cognition.ens.fr/~guerry/blorg.html}.
7889 @cindex @file{org2rem.el}
7890 @item @file{org2rem.el} by Bastien Guerry
7891 Translates Org-mode files into something readable by
7892 Remind. @url{http://www.cognition.ens.fr/~guerry/u/org2rem.el}.
7893 @item @file{org-toc.el} by Bastien Guerry
7894 Produces a simple table of contents of an Org-mode file, for easy
7895 navigation. @url{http://www.cognition.ens.fr/~guerry/u/org-registry.el}.
7896 @item @file{org-registry.el} by Bastien Guerry
7897 Find which Org-file link to a certain document.
7898 @url{http://www.cognition.ens.fr/~guerry/u/org2rem.el}.
7899 @end table
7901 @page
7903 @node Adding hyperlink types, Tables in arbitrary syntax, Extensions, Extensions and Hacking
7904 @section Adding hyperlink types
7905 @cindex hyperlinks, adding new types
7907 Org-mode has a large number of hyperlink types built-in
7908 (@pxref{Hyperlinks}).  If you would like to add new link types, it
7909 provides an interface for doing so.  Lets look at an example file
7910 @file{org-man.el} that will add support for creating links like
7911 @samp{[[man:printf][The printf manpage]]} to show unix manual pages inside
7912 emacs:
7914 @lisp
7915 ;;; org-man.el - Support for links to manpages in Org-mode
7917 (require 'org)
7919 (org-add-link-type "man" 'org-man-open)
7920 (add-hook 'org-store-link-functions 'org-man-store-link)
7922 (defcustom org-man-command 'man
7923   "The Emacs command to be used to display a man page."
7924   :group 'org-link
7925   :type '(choice (const man) (const woman)))
7927 (defun org-man-open (path)
7928   "Visit the manpage on PATH.
7929 PATH should be a topic that can be thrown at the man command."
7930   (funcall org-man-command path))
7932 (defun org-man-store-link ()
7933   "Store a link to a manpage."
7934   (when (memq major-mode '(Man-mode woman-mode))
7935     ;; This is a man page, we do make this link
7936     (let* ((page (org-man-get-page-name))
7937            (link (concat "man:" page))
7938            (description (format "Manpage for %s" page)))
7939       (org-store-link-props
7940        :type "man"
7941        :link link
7942        :description description))))
7944 (defun org-man-get-page-name ()
7945   "Extract the page name from the buffer name."
7946   ;; This works for both `Man-mode' and `woman-mode'.
7947   (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
7948       (match-string 1 (buffer-name))
7949     (error "Cannot create link to this man page")))
7951 (provide 'org-man)
7953 ;;; org-man.el ends here
7954 @end lisp
7956 @noindent
7957 You would activate this new link type in @file{.emacs} with
7959 @lisp
7960 (require 'org-man)
7961 @end lisp
7963 @noindent
7964 Lets go through the file and see what it does.
7965 @enumerate
7966 @item 
7967 It does @code{(require 'org)} to make sure that @file{org.el} has been
7968 loaded.
7969 @item
7970 The next line calls @code{org-add-link-type} to define a new link type
7971 with prefix @samp{man}.  The call also contains the name of a function
7972 that will be called to follow such a link.
7973 @item
7974 The next line adds a function to @code{org-store-link-functions}, in
7975 order to allow the command @kbd{C-c l} to record a useful link in a
7976 buffer displaying a man page.
7977 @end enumerate
7979 The rest of the file defines the necessary variables and functions.
7980 First there is a customization variable that determines which emacs
7981 command should be used to display manpages.  There are two options,
7982 @code{man} and @code{woman}.  Then the function to follow a link is
7983 defined.  It gets the link path as an argument - in this case the link
7984 path is just a topic for the manual command.  The function calls the
7985 value of @code{org-man-command} to display the man page.
7987 Finally the function @code{org-man-store-link} is defined.  When you try
7988 to store a link with @kbd{C-c l}, also this function will be called to
7989 try to make a link.  The function must first decide if it is supposed to
7990 create the link for this buffer type, we do this by checking the value
7991 of the variable @code{major-mode}.  If not, the function must exit and
7992 retunr the value @code{nil}.  If yes, the link is created by getting the
7993 manual tpoic from the buffer name and prefixing it with the string
7994 @samp{man:}.  Then it must call the command @code{org-store-link-props}
7995 and set the @code{:type} and @code{:link} properties.  Optionally you
7996 can also set the @code{:description} property to provide a default for
7997 the link description when the link is later inserted into tan Org-mode
7998 buffer with @kbd{C-c C-l}.
8000 @node Tables in arbitrary syntax, Dynamic blocks, Adding hyperlink types, Extensions and Hacking
8001 @section Tables and Lists in arbitrary syntax
8002 @cindex tables, in other modes
8003 @cindex lists, in other modes
8004 @cindex orgtbl-mode
8006 Since Orgtbl-mode can be used as a minor mode in arbitrary buffers, a
8007 frequent feature request has been to make it work with native tables in
8008 specific languages, for example La@TeX{}.  However, this is extremely
8009 hard to do in a general way, would lead to a customization nightmare,
8010 and would take away much of the simplicity of the Orgtbl-mode table
8011 editor.
8014 This appendix describes a different approach.  We keep the Orgtbl-mode
8015 table in its native format (the @i{source table}), and use a custom
8016 function to @i{translate} the table to the correct syntax, and to
8017 @i{install} it in the right location (the @i{target table}).  This puts
8018 the burden of writing conversion functions on the user, but it allows
8019 for a very flexible system.
8021 Bastien added the ability to do the same with lists.  You can use Org's
8022 facilities to edit and structure lists by turning @code{orgstruct-mode}
8023 on, then locally exporting such lists in another format (HTML, La@TeX{}
8024 or TeXInfo.)
8027 @menu
8028 * Radio tables::                Sending and receiving
8029 * A LaTeX example::             Step by step, almost a tutorial
8030 * Translator functions::        Copy and modify
8031 * Radio lists::                 Doing the same for lists.
8032 @end menu
8034 @node Radio tables, A LaTeX example, Tables in arbitrary syntax, Tables in arbitrary syntax
8035 @subsection Radio tables
8036 @cindex radio tables
8038 To define the location of the target table, you first need to create two
8039 lines that are comments in the current mode, but contain magic words for
8040 Orgtbl-mode to find.  Orgtbl-mode will insert the translated table
8041 between these lines, replacing whatever was there before.  For example:
8043 @example
8044 /* BEGIN RECEIVE ORGTBL table_name */
8045 /* END RECEIVE ORGTBL table_name */
8046 @end example
8048 @noindent
8049 Just above the source table, we put a special line that tells
8050 Orgtbl-mode how to translate this table and where to install it.  For
8051 example:
8052 @example
8053 #+ORGTBL: SEND table_name translation_function arguments....
8054 @end example
8056 @noindent
8057 @code{table_name} is the reference name for the table that is also used
8058 in the receiver lines. @code{translation_function} is the Lisp function
8059 that does the translation.  Furthermore, the line can contain a list of
8060 arguments (alternating key and value) at the end.  The arguments will be
8061 passed as a property list to the translation function for
8062 interpretation.  A few standard parameters are already recognized and
8063 acted upon before the translation function is called:
8065 @table @code
8066 @item :skip N
8067 Skip the first N lines of the table. Hlines do count!
8068 @item :skipcols (n1 n2 ...)
8069 List of columns that should be skipped.  If the table has a column with
8070 calculation marks, that column is automatically discarded as well.
8071 Please note that the translator function sees the table @emph{after} the
8072 removal of these columns, the function never knows that there have been
8073 additional columns.
8074 @end table
8076 @noindent
8077 The one problem remaining is how to keep the source table in the buffer
8078 without disturbing the normal workings of the file, for example during
8079 compilation of a C file or processing of a La@TeX{} file.  There are a
8080 number of different solutions:
8082 @itemize @bullet
8083 @item
8084 The table could be placed in a block comment if that is supported by the
8085 language.  For example, in C-mode you could wrap the table between
8086 @samp{/*} and @samp{*/} lines.
8087 @item 
8088 Sometimes it is possible to put the table after some kind of @i{END}
8089 statement, for example @samp{\bye} in TeX and @samp{\end@{document@}}
8090 in La@TeX{}.
8091 @item
8092 You can just comment the table line by line whenever you want to process
8093 the file, and uncomment it whenever you need to edit the table.  This
8094 only sounds tedious - the command @kbd{M-x orgtbl-toggle-comment} does
8095 make this comment-toggling very easy, in particular if you bind it to a
8096 key.
8097 @end itemize
8099 @node A LaTeX example, Translator functions, Radio tables, Tables in arbitrary syntax
8100 @subsection A LaTeX example of radio tables
8101 @cindex LaTeX, and orgtbl-mode
8103 The best way to wrap the source table in La@TeX{} is to use the
8104 @code{comment} environment provided by @file{comment.sty}.  It has to be
8105 activated by placing @code{\usepackage@{comment@}} into the document
8106 header.  Orgtbl-mode can insert a radio table skeleton@footnote{By
8107 default this works only for La@TeX{}, HTML, and TeXInfo.  Configure the
8108 variable @code{orgtbl-radio-tables} to install templates for other
8109 modes.}  with the command @kbd{M-x orgtbl-insert-radio-table}.  You will
8110 be prompted for a table name, lets say we use @samp{salesfigures}.  You
8111 will then get the following template:
8113 @example
8114 % BEGIN RECEIVE ORGTBL salesfigures
8115 % END RECEIVE ORGTBL salesfigures
8116 \begin@{comment@}
8117 #+ORGTBL: SEND salesfigures orgtbl-to-latex
8118 | | |
8119 \end@{comment@}
8120 @end example
8122 @noindent
8123 The @code{#+ORGTBL: SEND} line tells orgtbl-mode to use the function
8124 @code{orgtbl-to-latex} to convert the table into La@TeX{} and to put it
8125 into the receiver location with name @code{salesfigures}.  You may now
8126 fill in the table, feel free to use the spreadsheet features@footnote{If
8127 the @samp{#+TBLFM} line contains an odd number of dollar characters,
8128 this may cause problems with font-lock in latex-mode.  As shown in the
8129 example you can fix this by adding an extra line inside the
8130 @code{comment} environment that is used to balance the dollar
8131 expressions.  If you are using AUCTeX with the font-latex library, a
8132 much better solution is to add the @code{comment} environment to the
8133 variable @code{LaTeX-verbatim-environments}.}:
8135 @example
8136 % BEGIN RECEIVE ORGTBL salesfigures
8137 % END RECEIVE ORGTBL salesfigures
8138 \begin@{comment@}
8139 #+ORGTBL: SEND salesfigures orgtbl-to-latex
8140 | Month | Days | Nr sold | per day |
8141 |-------+------+---------+---------|
8142 | Jan   |   23 |      55 |     2.4 |
8143 | Feb   |   21 |      16 |     0.8 |
8144 | March |   22 |     278 |    12.6 |
8145 #+TBLFM: $4=$3/$2;%.1f
8146 % $ (optional extra dollar to keep font-lock happy, see footnote)
8147 \end@{comment@}
8148 @end example
8150 @noindent
8151 When you are done, press @kbd{C-c C-c} in the table to get the converted
8152 table inserted between the two marker lines.
8154 Now lets assume you want to make the table header by hand, because you
8155 want to control how columns are aligned etc.  In this case we make sure
8156 that the table translator does skip the first 2 lines of the source
8157 table, and tell the command to work as a @i{splice}, i.e. to not produce
8158 header and footer commands of the target table:
8160 @example
8161 \begin@{tabular@}@{lrrr@}
8162 Month & \multicolumn@{1@}@{c@}@{Days@} & Nr.\ sold & per day\\
8163 % BEGIN RECEIVE ORGTBL salesfigures
8164 % END RECEIVE ORGTBL salesfigures
8165 \end@{tabular@}
8167 \begin@{comment@}
8168 #+ORGTBL: SEND salesfigures orgtbl-to-latex :splice t :skip 2
8169 | Month | Days | Nr sold | per day |
8170 |-------+------+---------+---------|
8171 | Jan   |   23 |      55 |     2.4 |
8172 | Feb   |   21 |      16 |     0.8 |
8173 | March |   22 |     278 |    12.6 |
8174 #+TBLFM: $4=$3/$2;%.1f
8175 \end@{comment@}
8176 @end example
8178 The La@TeX{} translator function @code{orgtbl-to-latex} is already part of
8179 Orgtbl-mode.  It uses a @code{tabular} environment to typeset the table
8180 and marks horizontal lines with @code{\hline}.  Furthermore, it
8181 interprets the following parameters:
8183 @table @code
8184 @item :splice nil/t
8185 When set to t, return only table body lines, don't wrap them into a
8186 tabular environment.  Default is nil.
8188 @item :fmt fmt
8189 A format to be used to wrap each field, should contain @code{%s} for the
8190 original field value.  For example, to wrap each field value in dollars,
8191 you could use @code{:fmt "$%s$"}.  This may also be a property list with
8192 column numbers and formats. for example @code{:fmt (2 "$%s$" 4 "%s\\%%")}.
8194 @item :efmt efmt
8195 Use this format to print numbers with exponentials.  The format should
8196 have @code{%s} twice for inserting mantissa and exponent, for example
8197 @code{"%s\\times10^@{%s@}"}.  The default is @code{"%s\\,(%s)"}.  This
8198 may also be a property list with column numbers and formats, for example
8199 @code{:efmt (2 "$%s\\times10^@{%s@}$" 4 "$%s\\cdot10^@{%s@}$")}.  After
8200 @code{efmt} has been applied to a value, @code{fmt} will also be
8201 applied.
8202 @end table
8204 @node Translator functions, Radio lists, A LaTeX example, Tables in arbitrary syntax
8205 @subsection Translator functions
8206 @cindex HTML, and orgtbl-mode
8207 @cindex translator function
8209 Orgtbl-mode has several translator functions built-in:
8210 @code{orgtbl-to-latex}, @code{orgtbl-to-html}, and
8211 @code{orgtbl-to-texinfo}.  Except for @code{orgtbl-to-html}@footnote{The
8212 HTML translator uses the same code that produces tables during HTML
8213 export.}, these all use a generic translator, @code{orgtbl-to-generic}.
8214 For example, @code{orgtbl-to-latex} itself is a very short function that
8215 computes the column definitions for the @code{tabular} environment,
8216 defines a few field and line separators and then hands over to the
8217 generic translator.  Here is the entire code:
8219 @lisp
8220 @group
8221 (defun orgtbl-to-latex (table params)
8222   "Convert the orgtbl-mode TABLE to LaTeX."
8223   (let* ((alignment (mapconcat (lambda (x) (if x "r" "l"))
8224                                org-table-last-alignment ""))
8225          (params2
8226           (list
8227            :tstart (concat "\\begin@{tabular@}@{" alignment "@}")
8228            :tend "\\end@{tabular@}"
8229            :lstart "" :lend " \\\\" :sep " & "
8230            :efmt "%s\\,(%s)" :hline "\\hline")))
8231     (orgtbl-to-generic table (org-combine-plists params2 params))))
8232 @end group
8233 @end lisp
8235 As you can see, the properties passed into the function (variable
8236 @var{PARAMS}) are combined with the ones newly defined in the function
8237 (variable @var{PARAMS2}).  The ones passed into the function (i.e. the
8238 ones set by the @samp{ORGTBL SEND} line) take precedence.  So if you
8239 would like to use the La@TeX{} translator, but wanted the line endings to
8240 be @samp{\\[2mm]} instead of the default @samp{\\}, you could just
8241 overrule the default with
8243 @example
8244 #+ORGTBL: SEND test orgtbl-to-latex :lend " \\\\[2mm]"
8245 @end example
8247 For a new language, you can either write your own converter function in
8248 analogy with the La@TeX{} translator, or you can use the generic function
8249 directly.  For example, if you have a language where a table is started
8250 with @samp{!BTBL!}, ended with @samp{!ETBL!}, and where table lines are
8251 started with @samp{!BL!}, ended with @samp{!EL!} and where the field
8252 separator is a TAB, you could call the generic translator like this (on
8253 a single line!):
8255 @example
8256 #+ORGTBL: SEND test orgtbl-to-generic :tstart "!BTBL!" :tend "!ETBL!"
8257                               :lstart "!BL! " :lend " !EL!" :sep "\t"
8258 @end example
8260 @noindent
8261 Please check the documentation string of the function
8262 @code{orgtbl-to-generic} for a full list of parameters understood by
8263 that function and remember that you can pass each of them into
8264 @code{orgtbl-to-latex}, @code{orgtbl-to-texinfo}, and any other function
8265 using the generic function.
8267 Of course you can also write a completely new function doing complicated
8268 things the generic translator cannot do.  A translator function takes
8269 two arguments.  The first argument is the table, a list of lines, each
8270 line either the symbol @code{hline} or a list of fields.  The second
8271 argument is the property list containing all parameters specified in the
8272 @samp{#+ORGTBL: SEND} line.  The function must return a single string
8273 containing the formatted table.  If you write a generally useful
8274 translator, please post it on @code{emacs-orgmode@@gnu.org} so that
8275 others can benefit from your work.
8277 @node  Radio lists,  , Translator functions, Tables in arbitrary syntax
8278 @subsection Radio lists
8279 @cindex radio lists
8280 @cindex org-list-insert-radio-list
8282 Sending and receiving radio lists works exactly the same way than
8283 sending and receiving radio tables (@pxref{Radio tables}) @footnote{You
8284 need to load the @code{org-export-latex.el} package to use radio lists
8285 since the relevant code is there for now.}.  As for radio tables, you
8286 can insert radio lists templates in HTML, La@TeX{} and TeXInfo modes by
8287 calling @code{org-list-insert-radio-list}.
8289 Here are the differences with radio tables:
8291 @itemize @minus
8292 @item
8293 Use @code{ORGLST} instead of @code{ORGTBL}.
8294 @item
8295 The available translation functions for radio lists don't take
8296 parameters.
8297 @item 
8298 `C-c C-c' will work when pressed on the first item of the list.
8299 @end itemize
8301 Here is a La@TeX{} example.  Let's say that you have this in your
8302 La@TeX{} file:
8304 @example
8305 % BEGIN RECEIVE ORGLST to-buy
8306 % END RECEIVE ORGLST to-buy
8307 \begin@{comment@}
8308 #+ORGLIST: SEND to-buy orgtbl-to-latex
8309 - a new house
8310 - a new computer
8311   + a new keyboard
8312   + a new mouse
8313 - a new life
8314 \end@{comment@}
8315 @end example
8317 Pressing `C-c C-c' on @code{a new house} and will insert the converted
8318 La@TeX{} list between the two marker lines.
8320 @node Dynamic blocks, Special agenda views, Tables in arbitrary syntax, Extensions and Hacking
8321 @section Dynamic blocks
8322 @cindex dynamic blocks
8324 Org-mode documents can contain @emph{dynamic blocks}.  These are
8325 specially marked regions that are updated by some user-written function.
8326 A good example for such a block is the clock table inserted by the
8327 command @kbd{C-c C-x C-r} (@pxref{Clocking work time}).
8329 Dynamic block are enclosed by a BEGIN-END structure that assigns a name
8330 to the block and can also specify parameters for the function producing
8331 the content of the block.
8333 @example
8334 #+BEGIN: myblock :parameter1 value1 :parameter2 value2 ...
8336 #+END:
8337 @end example
8339 Dynamic blocks are updated with the following commands
8341 @table @kbd
8342 @kindex C-c C-x C-u
8343 @item C-c C-x C-u
8344 Update dynamic block at point.
8345 @kindex C-u C-c C-x C-u
8346 @item C-u C-c C-x C-u
8347 Update all dynamic blocks in the current file.
8348 @end table
8350 Updating a dynamic block means to remove all the text between BEGIN and
8351 END, parse the BEGIN line for parameters and then call the specific
8352 writer function for this block to insert the new content.  For a block
8353 with name @code{myblock}, the writer function is
8354 @code{org-dblock-write:myblock} with as only parameter a property list
8355 with the parameters given in the begin line.  Here is a trivial example
8356 of a block that keeps track of when the block update function was last
8357 run:
8359 @example
8360 #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M"
8362 #+END:
8363 @end example
8365 @noindent
8366 The corresponding block writer function could look like this:
8368 @lisp
8369 (defun org-dblock-write:block-update-time (params)
8370    (let ((fmt (or (plist-get params :format) "%d. %m. %Y")))
8371      (insert "Last block update at: "
8372              (format-time-string fmt (current-time)))))
8373 @end lisp
8375 If you want to make sure that all dynamic blocks are always up-to-date,
8376 you could add the function @code{org-update-all-dblocks} to a hook, for
8377 example @code{before-save-hook}.  @code{org-update-all-dblocks} is
8378 written in a way that is does nothing in buffers that are not in Org-mode.
8380 @node Special agenda views, Using the property API, Dynamic blocks, Extensions and Hacking
8381 @section Special Agenda Views
8382 @cindex agenda views, user-defined
8384 Org-mode provides a special hook that can be used to narrow down the
8385 selection made by any of the agenda views.  You may specify a function
8386 that is used at each match to verify if the match should indeed be part
8387 of the agenda view, and if not, how much should be skipped.
8389 Let's say you want to produce a list of projects that contain a WAITING
8390 tag anywhere in the project tree.  Let's further assume that you have
8391 marked all tree headings that define a project with the todo keyword
8392 PROJECT.  In this case you would run a todo search for the keyword
8393 PROJECT, but skip the match unless there is a WAITING tag anywhere in
8394 the subtree belonging to the project line.
8396 To achieve this, you must write a function that searches the subtree for
8397 the tag.  If the tag is found, the function must return @code{nil} to
8398 indicate that this match should not be skipped.  If there is no such
8399 tag, return the location of the end of the subtree, to indicate that
8400 search should continue from there.
8402 @lisp
8403 (defun my-skip-unless-waiting ()
8404   "Skip trees that are not waiting"
8405   (let ((subtree-end (save-excursion (org-end-of-subtree t))))
8406     (if (re-search-forward ":waiting:" subtree-end t)
8407         nil          ; tag found, do not skip
8408       subtree-end))) ; tag not found, continue after end of subtree
8409 @end lisp
8411 Now you may use this function in an agenda custom command, for example
8412 like this:
8414 @lisp
8415 (org-add-agenda-custom-command
8416  '("b" todo "PROJECT"
8417    ((org-agenda-skip-function 'my-org-waiting-projects)
8418     (org-agenda-overriding-header "Projects waiting for something: "))))
8419 @end lisp
8421 Note that this also binds @code{org-agenda-overriding-header} to get a
8422 meaningful header in the agenda view.
8424 You may also put a Lisp form into @code{org-agenda-skip-function}.  In
8425 particular, you may use the functions @code{org-agenda-skip-entry-if}
8426 and @code{org-agenda-skip-subtree-if} in this form, for example:
8428 @table @code
8429 @item '(org-agenda-skip-entry-if 'scheduled)
8430 Skip current entry if it has been scheduled.
8431 @item '(org-agenda-skip-entry-if 'notscheduled)
8432 Skip current entry if it has not been scheduled.
8433 @item '(org-agenda-skip-entry-if 'deadline)
8434 Skip current entry if it has a deadline.
8435 @item '(org-agenda-skip-entry-if 'scheduled 'deadline)
8436 Skip current entry if it has a deadline, or if it is scheduled.
8437 @item '(org-agenda-skip-entry 'regexp "regular expression")
8438 Skip current entry if the regular expression matches in the entry.
8439 @item '(org-agenda-skip-entry 'notregexp "regular expression")
8440 Skip current entry unless the regular expression matches.
8441 @item '(org-agenda-skip-subtree-if 'regexp "regular expression")
8442 Same as above, but check and skip the entire subtree.
8443 @end table
8445 Therefore we could also have written the search for WAITING projects
8446 like this, even without defining a special function:
8448 @lisp
8449 (org-add-agenda-custom-command
8450  '("b" todo "PROJECT"
8451    ((org-agenda-skip-function '(org-agenda-skip-subtree-if
8452                                 'regexp ":waiting:"))
8453     (org-agenda-overriding-header "Projects waiting for something: "))))
8454 @end lisp
8457 @node Using the property API,  , Special agenda views, Extensions and Hacking
8458 @section Using the property API
8459 @cindex API, for properties
8460 @cindex properties, API
8462 Here is a description of the functions that can be used to work with
8463 properties.
8465 @defun org-entry-properties &optional pom which
8466 Get all properties of the entry at point-or-marker POM.
8467 This includes the TODO keyword, the tags, time strings for deadline,
8468 scheduled, and clocking, and any additional properties defined in the
8469 entry.  The return value is an alist, keys may occur multiple times
8470 if the property key was used several times.
8471 POM may also be nil, in which case the current entry is used.
8472 If WHICH is nil or `all', get all properties.  If WHICH is
8473 `special' or `standard', only get that subclass.
8474 @end defun
8475 @defun org-entry-get pom property &optional inherit
8476 Get value of PROPERTY for entry at point-or-marker POM.
8477 If INHERIT is non-nil and the entry does not have the property,
8478 then also check higher levels of the hierarchy.  This function ignores
8479 the value of @code{org-use-property-inheritance} and requires the
8480 explicit INHERIT flag.
8481 @end defun
8483 @defun org-entry-delete pom property
8484 Delete the property PROPERTY from entry at point-or-marker POM.
8485 @end defun
8487 @defun org-entry-put pom property value
8488 Set PROPERTY to VALUE for entry at point-or-marker POM.
8489 @end defun
8491 @defun org-buffer-property-keys &optional include-specials
8492 Get all property keys in the current buffer.
8493 @end defun
8495 @defun org-insert-property-drawer
8496 Insert a property drawer at point.
8497 @end defun
8499 @node History and Acknowledgments, Main Index, Extensions and Hacking, Top
8500 @appendix History and Acknowledgments
8501 @cindex acknowledgments
8502 @cindex history
8503 @cindex thanks
8505 Org-mode was borne in 2003, out of frustration over the user interface
8506 of the Emacs outline-mode.  I was trying to organize my notes and
8507 projects, and using Emacs seemed to be the natural way to go.  However,
8508 having to remember eleven different commands with two or three keys per
8509 command, only to hide and unhide parts of the outline tree, that seemed
8510 entirely unacceptable to me.  Also, when using outlines to take notes, I
8511 constantly want to restructure the tree, organizing it parallel to my
8512 thoughts and plans.  @emph{Visibility cycling} and @emph{structure
8513 editing} were originally implemented in the package
8514 @file{outline-magic.el}, but quickly moved to the more general
8515 @file{org.el}.  As this environment became comfortable for project
8516 planning, the next step was adding @emph{TODO entries}, basic @emph{time
8517 stamps}, and @emph{table support}.  These areas highlight the two main
8518 goals that Org-mode still has today: To create a new, outline-based,
8519 plain text mode with innovative and intuitive editing features, and to
8520 incorporate project planning functionality directly into a notes file.
8522 Since the first release, literally thousands of emails to me or on
8523 @code{emacs-orgmode@@gnu.org} have provided a constant stream of bug
8524 reports, feedback, new ideas, and sometimes patches and add-on code.
8525 Many thanks to everyone who has helped to improve this package.  I am
8526 trying to keep here a list of the people who had significant influence
8527 in shaping one or more aspects of Org-mode.  The list may not be
8528 complete, if I have forgotten someone, please accept my apologies and
8529 let me know.
8531 @itemize @bullet
8533 @item
8534 @i{Russel Adams} came up with the idea for drawers.
8535 @item
8536 @i{Thomas Baumann} contributed the code for links to the MH-E email
8537 system.
8538 @item
8539 @i{Alex Bochannek} provided a patch for rounding time stamps.
8540 @item
8541 @i{Charles Cave}'s suggestion sparked the implementation of templates
8542 for Remember.
8543 @item
8544 @i{Pavel Chalmoviansky} influenced the agenda treatment of items with
8545 specified time.
8546 @item
8547 @i{Gregory Chernov} patched support for lisp forms into table
8548 calculations and improved XEmacs compatibility, in particular by porting
8549 @file{nouline.el} to XEmacs.
8550 @item
8551 @i{Sacha Chua} suggested to copy some linking code from Planner.
8552 @item
8553 @i{Eddward DeVilla} proposed and tested checkbox statistics.  He also
8554 came up with the idea of properties, and that there should be an API for
8555 them.
8556 @item
8557 @i{Kees Dullemond} used to edit projects lists directly in HTML and so
8558 inspired some of the early development, including HTML export.  He also
8559 asked for a way to narrow wide table columns.
8560 @item
8561 @i{Christian Egli} converted the documentation into TeXInfo format,
8562 patched CSS formatting into the HTML exporter, and inspired the agenda.
8563 @item
8564 @i{David Emery} provided a patch for custom CSS support in exported
8565 HTML agendas.
8566 @item
8567 @i{Nic Ferrier} contributed mailcap and XOXO support.
8568 @item
8569 @i{Miguel A. Figueroa-Villanueva} implemented hierarchical checkboxes.
8570 @item
8571 @i{John Foerch} figured out how to make incremental search show context
8572 around a match in a hidden outline tree.
8573 @item
8574 @i{Niels Giesen} had the idea to automatically archive DONE trees.
8575 @item
8576 @i{Bastien Guerry} wrote the La@TeX{} exporter and has been prolific
8577 with patches, ideas, and bug reports.
8578 @item
8579 @i{Kai Grossjohann} pointed out key-binding conflicts with other packages.
8580 @item
8581 @i{Scott Jaderholm} proposed footnotes, control over whitespace between
8582 folded entries, and column view for properties.
8583 @item
8584 @i{Shidai Liu} ("Leo") asked for embedded La@TeX{} and tested it.  He also
8585 provided frequent feedback and some patches.
8586 @item
8587 @i{Jason F. McBrayer} suggested agenda export to CSV format.
8588 @item
8589 @i{Max Mikhanosha} came up with the idea of refiling.
8590 @item
8591 @i{Dmitri Minaev} sent a patch to set priority limits on a per-file
8592 basis.
8593 @item
8594 @i{Stefan Monnier} provided a patch to keep the Emacs-Lisp compiler
8595 happy.
8596 @item
8597 @i{Rick Moynihan} proposed to allow multiple TODO sequences in a file
8598 and to be able to quickly restrict the agenda to a subtree.
8599 @item
8600 @i{Todd Neal} provided patches for links to Info files and elisp forms.
8601 @item
8602 @i{Tim O'Callaghan} suggested in-file links, search options for general
8603 file links, and TAGS.
8604 @item
8605 @i{Takeshi Okano} translated the manual and David O'Toole's tutorial
8606 into Japanese.
8607 @item
8608 @i{Oliver Oppitz} suggested multi-state TODO items.
8609 @item
8610 @i{Scott Otterson} sparked the introduction of descriptive text for
8611 links, among other things.
8612 @item
8613 @i{Pete Phillips} helped during the development of the TAGS feature, and
8614 provided frequent feedback.
8615 @item
8616 @i{T.V. Raman} reported bugs and suggested improvements.
8617 @item
8618 @i{Matthias Rempe} (Oelde) provided ideas, Windows support, and quality
8619 control.
8620 @item
8621 @i{Kevin Rogers} contributed code to access VM files on remote hosts.
8622 @item
8623 @i{Frank Ruell} solved the mystery of the @code{keymapp nil} bug, a
8624 conflict with @file{allout.el}.
8625 @item
8626 @i{Jason Riedy} sent a patch to fix a bug with export of TODO keywords.
8627 @item
8628 @i{Philip Rooke} created the Org-mode reference card and provided lots
8629 of feedback.
8630 @item
8631 @i{Christian Schlauer} proposed angular brackets around links, among
8632 other things.
8633 @item
8634 Linking to VM/BBDB/GNUS was inspired by @i{Tom Shannon}'s
8635 @file{organizer-mode.el}.
8636 @item
8637 @i{Daniel Sinder} came up with the idea of internal archiving by locking
8638 subtrees.
8639 @item
8640 @i{Dale Smith} proposed link abbreviations.
8641 @item
8642 @i{Adam Spiers} asked for global linking commands and inspired the link
8643 extension system.  support mairix.
8644 @item
8645 @i{David O'Toole} wrote @file{org-publish.el} and drafted the manual
8646 chapter about publishing.
8647 @item
8648 @i{J@"urgen Vollmer} contributed code generating the table of contents
8649 in HTML output.
8650 @item
8651 @i{Chris Wallace} provided a patch implementing the @samp{QUOTE}
8652 keyword.
8653 @item
8654 @i{David Wainberg} suggested archiving, and improvements to the linking
8655 system.
8656 @item
8657 @i{John Wiegley} wrote @file{emacs-wiki.el} and @file{planner.el}.  The
8658 development of Org-mode was fully independent, and both systems are
8659 really different beasts in their basic ideas and implementation details.
8660 I later looked at John's code, however, and learned from his
8661 implementation of (i) links where the link itself is hidden and only a
8662 description is shown, and (ii) popping up a calendar to select a date.
8663 John has also contributed a number of great ideas directly to Org-mode.
8664 @item
8665 @i{Carsten Wimmer} suggested some changes and helped fix a bug in
8666 linking to GNUS.
8667 @item
8668 @i{Roland Winkler} requested additional keybindings to make Org-mode
8669 work on a tty.
8670 @item
8671 @i{Piotr Zielinski} wrote @file{org-mouse.el}, proposed agenda blocks
8672 and contributed various ideas and code snippets.
8673 @end itemize
8676 @node Main Index, Key Index, History and Acknowledgments, Top
8677 @unnumbered The Main Index
8679 @printindex cp
8681 @node Key Index,  , Main Index, Top
8682 @unnumbered Key Index
8684 @printindex ky
8686 @bye
8688 @ignore
8689    arch-tag: 7893d1fe-cc57-4d13-b5e5-f494a1bcc7ac
8690 @end ignore